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 | from __future__ import print_function
|
---|
7 | import sys
|
---|
8 |
|
---|
9 | import apiutil
|
---|
10 |
|
---|
11 |
|
---|
12 | apiutil.CopyrightC()
|
---|
13 |
|
---|
14 | print("""
|
---|
15 | /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_retval.py SCRIPT */
|
---|
16 | #include "chromium.h"
|
---|
17 | #include "cr_mem.h"
|
---|
18 | #include "cr_net.h"
|
---|
19 | #include "server_dispatch.h"
|
---|
20 | #include "server.h"
|
---|
21 |
|
---|
22 | void crServerReturnValue( const void *payload, unsigned int payload_len )
|
---|
23 | {
|
---|
24 | if (!cr_server.fProcessingPendedCommands)
|
---|
25 | {
|
---|
26 | CRMessageReadback *rb;
|
---|
27 | int msg_len;
|
---|
28 |
|
---|
29 | /* Don't reply to client if we're loading VM snapshot*/
|
---|
30 | if (cr_server.bIsInLoadingState)
|
---|
31 | return;
|
---|
32 |
|
---|
33 | if (cr_server.curClient->conn->type == CR_FILE)
|
---|
34 | {
|
---|
35 | return;
|
---|
36 | }
|
---|
37 |
|
---|
38 | if (payload_len >= INT32_MAX - sizeof( *rb ))
|
---|
39 | {
|
---|
40 | return;
|
---|
41 | }
|
---|
42 |
|
---|
43 | msg_len = sizeof( *rb ) + payload_len;
|
---|
44 | rb = (CRMessageReadback *) crAlloc( msg_len );
|
---|
45 |
|
---|
46 | rb->header.type = CR_MESSAGE_READBACK;
|
---|
47 | CRDBGPTR_PRINTRB(cr_server.curClient->conn->u32ClientID, &cr_server.writeback_ptr);
|
---|
48 | CRDBGPTR_CHECKNZ(&cr_server.writeback_ptr);
|
---|
49 | CRDBGPTR_CHECKNZ(&cr_server.return_ptr);
|
---|
50 | crMemcpy( &(rb->writeback_ptr), &(cr_server.writeback_ptr), sizeof( rb->writeback_ptr ) );
|
---|
51 | crMemcpy( &(rb->readback_ptr), &(cr_server.return_ptr), sizeof( rb->readback_ptr ) );
|
---|
52 | crMemcpy( rb+1, payload, payload_len );
|
---|
53 | crNetSend( cr_server.curClient->conn, NULL, rb, msg_len );
|
---|
54 | CRDBGPTR_SETZ(&cr_server.writeback_ptr);
|
---|
55 | CRDBGPTR_SETZ(&cr_server.return_ptr);
|
---|
56 | crFree( rb );
|
---|
57 | return;
|
---|
58 | }
|
---|
59 | #ifdef DEBUG_misha
|
---|
60 | WARN(("Pending command returns value"));
|
---|
61 | #endif
|
---|
62 | CRDBGPTR_SETZ(&cr_server.writeback_ptr);
|
---|
63 | CRDBGPTR_SETZ(&cr_server.return_ptr);
|
---|
64 | }
|
---|
65 | """)
|
---|
66 |
|
---|
67 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
68 |
|
---|
69 | for func_name in keys:
|
---|
70 | params = apiutil.Parameters(func_name)
|
---|
71 | return_type = apiutil.ReturnType(func_name)
|
---|
72 | if apiutil.FindSpecial( "server", func_name ):
|
---|
73 | continue
|
---|
74 | if "VBox" == apiutil.Category(func_name):
|
---|
75 | continue
|
---|
76 | if return_type != 'void':
|
---|
77 | print('%s SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( return_type, func_name, apiutil.MakeDeclarationString(params)))
|
---|
78 | print('{')
|
---|
79 | print('\t%s retval;' % return_type)
|
---|
80 | print('\tretval = cr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallString(params) ))
|
---|
81 | print('\tcrServerReturnValue( &retval, sizeof(retval) );')
|
---|
82 | print('\treturn retval; /* WILL PROBABLY BE IGNORED */')
|
---|
83 | print('}')
|
---|