1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 | import sys
|
---|
7 |
|
---|
8 | import apiutil
|
---|
9 |
|
---|
10 |
|
---|
11 | apiutil.CopyrightC()
|
---|
12 |
|
---|
13 | print """
|
---|
14 | /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_retval.py SCRIPT */
|
---|
15 | #include "chromium.h"
|
---|
16 | #include "cr_mem.h"
|
---|
17 | #include "cr_net.h"
|
---|
18 | #include "server_dispatch.h"
|
---|
19 | #include "server.h"
|
---|
20 |
|
---|
21 | void crServerReturnValue( const void *payload, unsigned int payload_len )
|
---|
22 | {
|
---|
23 | CRMessageReadback *rb;
|
---|
24 | int msg_len = sizeof( *rb ) + payload_len;
|
---|
25 |
|
---|
26 | /* Don't reply to client if we're loading VM snapshot*/
|
---|
27 | if (cr_server.bIsInLoadingState)
|
---|
28 | return;
|
---|
29 |
|
---|
30 | if (cr_server.curClient->conn->type == CR_FILE)
|
---|
31 | {
|
---|
32 | return;
|
---|
33 | }
|
---|
34 |
|
---|
35 | rb = (CRMessageReadback *) crAlloc( msg_len );
|
---|
36 |
|
---|
37 | rb->header.type = CR_MESSAGE_READBACK;
|
---|
38 | CRDBGPTR_PRINTRB(cr_server.curClient->conn->u32ClientID, &cr_server.writeback_ptr);
|
---|
39 | CRDBGPTR_CHECKNZ(&cr_server.writeback_ptr);
|
---|
40 | CRDBGPTR_CHECKNZ(&cr_server.return_ptr);
|
---|
41 | crMemcpy( &(rb->writeback_ptr), &(cr_server.writeback_ptr), sizeof( rb->writeback_ptr ) );
|
---|
42 | crMemcpy( &(rb->readback_ptr), &(cr_server.return_ptr), sizeof( rb->readback_ptr ) );
|
---|
43 | crMemcpy( rb+1, payload, payload_len );
|
---|
44 | crNetSend( cr_server.curClient->conn, NULL, rb, msg_len );
|
---|
45 | CRDBGPTR_SETZ(&cr_server.writeback_ptr);
|
---|
46 | CRDBGPTR_SETZ(&cr_server.return_ptr);
|
---|
47 | crFree( rb );
|
---|
48 | }
|
---|
49 | """
|
---|
50 |
|
---|
51 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
52 |
|
---|
53 | for func_name in keys:
|
---|
54 | params = apiutil.Parameters(func_name)
|
---|
55 | return_type = apiutil.ReturnType(func_name)
|
---|
56 | if apiutil.FindSpecial( "server", func_name ):
|
---|
57 | continue
|
---|
58 | if "VBox" == apiutil.Category(func_name):
|
---|
59 | continue
|
---|
60 | if return_type != 'void':
|
---|
61 | print '%s SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString(params))
|
---|
62 | print '{'
|
---|
63 | print '\t%s retval;' % return_type
|
---|
64 | print '\tretval = cr_server.head_spu->dispatch_table.%s( %s );' % (func_name, apiutil.MakeCallString(params) );
|
---|
65 | print '\tcrServerReturnValue( &retval, sizeof(retval) );'
|
---|
66 | print '\treturn retval; /* WILL PROBABLY BE IGNORED */'
|
---|
67 | print '}'
|
---|