Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: src/shared/srpc/nacl_srpc.c

Issue 5622003: Restructure the structs/unions involved in SRPC argument passing. This will... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2008 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * NaCl service library. a primitive rpc library 8 * NaCl service library. a primitive rpc library
9 */ 9 */
10 10
(...skipping 17 matching lines...) Expand all
28 NaClSrpcArg out_carray; 28 NaClSrpcArg out_carray;
29 NaClSrpcArg* outs[2]; 29 NaClSrpcArg* outs[2];
30 NaClSrpcService* tmp_service = NULL; 30 NaClSrpcService* tmp_service = NULL;
31 NaClSrpcService* service = NULL; 31 NaClSrpcService* service = NULL;
32 NaClSrpcHandlerDesc basic_services[] = { { NULL, NULL } }; 32 NaClSrpcHandlerDesc basic_services[] = { { NULL, NULL } };
33 33
34 /* Set up the output parameters for service discovery. */ 34 /* Set up the output parameters for service discovery. */
35 outs[0] = &out_carray; 35 outs[0] = &out_carray;
36 outs[1] = NULL; 36 outs[1] = NULL;
37 out_carray.tag = NACL_SRPC_ARG_TYPE_CHAR_ARRAY; 37 out_carray.tag = NACL_SRPC_ARG_TYPE_CHAR_ARRAY;
38 out_carray.u.caval.carr = NULL; 38 out_carray.arrays.carr = NULL;
39 /* Set up the basic service descriptor to make the service discovery call. */ 39 /* Set up the basic service descriptor to make the service discovery call. */
40 tmp_service = (NaClSrpcService*) malloc(sizeof(*tmp_service)); 40 tmp_service = (NaClSrpcService*) malloc(sizeof(*tmp_service));
41 if (NULL == tmp_service) { 41 if (NULL == tmp_service) {
42 goto cleanup; 42 goto cleanup;
43 } 43 }
44 if (!NaClSrpcServiceHandlerCtor(tmp_service, basic_services)) { 44 if (!NaClSrpcServiceHandlerCtor(tmp_service, basic_services)) {
45 goto cleanup; 45 goto cleanup;
46 } 46 }
47 channel->client = tmp_service; 47 channel->client = tmp_service;
48 /* Build the argument values for invoking service discovery */ 48 /* Build the argument values for invoking service discovery */
49 outs[0] = &out_carray; 49 outs[0] = &out_carray;
50 outs[1] = NULL; 50 outs[1] = NULL;
51 out_carray.tag = NACL_SRPC_ARG_TYPE_CHAR_ARRAY; 51 out_carray.tag = NACL_SRPC_ARG_TYPE_CHAR_ARRAY;
52 out_carray.u.caval.count = NACL_SRPC_MAX_SERVICE_DISCOVERY_CHARS; 52 out_carray.u.count = NACL_SRPC_MAX_SERVICE_DISCOVERY_CHARS;
53 out_carray.u.caval.carr = calloc(NACL_SRPC_MAX_SERVICE_DISCOVERY_CHARS, 1); 53 out_carray.arrays.carr = calloc(NACL_SRPC_MAX_SERVICE_DISCOVERY_CHARS, 1);
54 if (NULL == out_carray.u.caval.carr) { 54 if (NULL == out_carray.arrays.carr) {
55 goto cleanup; 55 goto cleanup;
56 } 56 }
57 /* Invoke service discovery, getting description string */ 57 /* Invoke service discovery, getting description string */
58 if (NACL_SRPC_RESULT_OK != NaClSrpcInvokeV(channel, 0, ins, outs)) { 58 if (NACL_SRPC_RESULT_OK != NaClSrpcInvokeV(channel, 0, ins, outs)) {
59 goto cleanup; 59 goto cleanup;
60 } 60 }
61 /* Clean up the temporary service. */ 61 /* Clean up the temporary service. */
62 NaClSrpcServiceDtor(tmp_service); 62 NaClSrpcServiceDtor(tmp_service);
63 free(tmp_service); 63 free(tmp_service);
64 tmp_service = NULL; 64 tmp_service = NULL;
65 /* Allocate the real service. */ 65 /* Allocate the real service. */
66 service = (NaClSrpcService*) malloc(sizeof(*service)); 66 service = (NaClSrpcService*) malloc(sizeof(*service));
67 if (NULL == service) { 67 if (NULL == service) {
68 goto cleanup; 68 goto cleanup;
69 } 69 }
70 /* Build the real service from the resulting string. */ 70 /* Build the real service from the resulting string. */
71 if (!NaClSrpcServiceStringCtor(service, out_carray.u.caval.carr)) { 71 if (!NaClSrpcServiceStringCtor(service, out_carray.arrays.carr)) {
72 goto cleanup; 72 goto cleanup;
73 } 73 }
74 channel->client = service; 74 channel->client = service;
75 /* Free the service string */ 75 /* Free the service string */
76 free(out_carray.u.caval.carr); 76 free(out_carray.arrays.carr);
77 /* Return success */ 77 /* Return success */
78 return 1; 78 return 1;
79 79
80 cleanup: 80 cleanup:
81 free(service); 81 free(service);
82 free(out_carray.u.caval.carr); 82 free(out_carray.arrays.carr);
83 NaClSrpcServiceDtor(tmp_service); 83 NaClSrpcServiceDtor(tmp_service);
84 free(tmp_service); 84 free(tmp_service);
85 return 0; 85 return 0;
86 } 86 }
87 87
88 /* 88 /*
89 * The constructors and destructor. 89 * The constructors and destructor.
90 */ 90 */
91 91
92 /* 92 /*
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 /* 166 /*
167 * A standalone SRPC server is not a subprocess of the browser or 167 * A standalone SRPC server is not a subprocess of the browser or
168 * sel_universal. As this is a mode used for testing, the parent environment 168 * sel_universal. As this is a mode used for testing, the parent environment
169 * must set the following variable to indicate that fact. 169 * must set the following variable to indicate that fact.
170 */ 170 */
171 const char kSrpcStandalone[] = "NACL_SRPC_STANDALONE"; 171 const char kSrpcStandalone[] = "NACL_SRPC_STANDALONE";
172 172
173 int NaClSrpcIsStandalone() { 173 int NaClSrpcIsStandalone() {
174 return (NULL != getenv(kSrpcStandalone)); 174 return (NULL != getenv(kSrpcStandalone));
175 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698