OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * Simple test for simple rpc. | 8 * Simple test for simple rpc. |
9 */ | 9 */ |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 /* | 27 /* |
28 * Return a clever string. | 28 * Return a clever string. |
29 */ | 29 */ |
30 void HelloWorld(NaClSrpcRpc *rpc, | 30 void HelloWorld(NaClSrpcRpc *rpc, |
31 NaClSrpcArg **in_args, | 31 NaClSrpcArg **in_args, |
32 NaClSrpcArg **out_args, | 32 NaClSrpcArg **out_args, |
33 NaClSrpcClosure *done) { | 33 NaClSrpcClosure *done) { |
34 /* | 34 /* |
35 * Strdup must be used because the SRPC layer frees the string passed to it. | 35 * Strdup must be used because the SRPC layer frees the string passed to it. |
36 */ | 36 */ |
37 out_args[0]->u.sval.str = strdup("hello, world."); | 37 out_args[0]->arrays.str = strdup("hello, world."); |
38 rpc->result = NACL_SRPC_RESULT_OK; | 38 rpc->result = NACL_SRPC_RESULT_OK; |
39 done->Run(done); | 39 done->Run(done); |
40 } | 40 } |
41 | 41 |
42 const struct NaClSrpcHandlerDesc srpc_methods[] = { | 42 const struct NaClSrpcHandlerDesc srpc_methods[] = { |
43 /* Export the method as taking no arguments and returning one integer. */ | 43 /* Export the method as taking no arguments and returning one integer. */ |
44 { "fortytwo::i", FortyTwo }, | 44 { "fortytwo::i", FortyTwo }, |
45 /* Export the method as taking no arguments and returning one string. */ | 45 /* Export the method as taking no arguments and returning one string. */ |
46 { "helloworld::s", HelloWorld }, | 46 { "helloworld::s", HelloWorld }, |
47 { NULL, NULL }, | 47 { NULL, NULL }, |
48 }; | 48 }; |
49 | 49 |
50 int main() { | 50 int main() { |
51 if (!NaClSrpcModuleInit()) { | 51 if (!NaClSrpcModuleInit()) { |
52 return 1; | 52 return 1; |
53 } | 53 } |
54 if (!NaClSrpcAcceptClientConnection(srpc_methods)) { | 54 if (!NaClSrpcAcceptClientConnection(srpc_methods)) { |
55 return 1; | 55 return 1; |
56 } | 56 } |
57 NaClSrpcModuleFini(); | 57 NaClSrpcModuleFini(); |
58 return 0; | 58 return 0; |
59 } | 59 } |
OLD | NEW |