server.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
  3. #ifdef _MSC_VER
  4. #define _CRT_SECURE_NO_WARNINGS //disable fopen deprication warning in msvs
  5. #endif
  6. #ifdef UA_NO_AMALGAMATION
  7. # include <time.h>
  8. # include "ua_types.h"
  9. # include "ua_server.h"
  10. # include "ua_config_standard.h"
  11. # include "ua_network_tcp.h"
  12. # include "ua_log_stdout.h"
  13. #else
  14. # include "open62541.h"
  15. #endif
  16. #include <signal.h>
  17. #include <errno.h> // errno, EINTR
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. UA_Boolean running = true;
  22. UA_Logger logger = UA_Log_Stdout;
  23. static UA_ByteString loadCertificate(void) {
  24. UA_ByteString certificate = UA_STRING_NULL;
  25. FILE *fp = NULL;
  26. //FIXME: a potiential bug of locating the certificate, we need to get the path from the server's config
  27. fp=fopen("server_cert.der", "rb");
  28. if(!fp) {
  29. errno = 0; // we read errno also from the tcp layer...
  30. return certificate;
  31. }
  32. fseek(fp, 0, SEEK_END);
  33. certificate.length = (size_t)ftell(fp);
  34. certificate.data = (UA_Byte*)malloc(certificate.length*sizeof(UA_Byte));
  35. if(!certificate.data)
  36. return certificate;
  37. fseek(fp, 0, SEEK_SET);
  38. if(fread(certificate.data, sizeof(UA_Byte), certificate.length, fp) < (size_t)certificate.length)
  39. UA_ByteString_deleteMembers(&certificate); // error reading the cert
  40. fclose(fp);
  41. return certificate;
  42. }
  43. static void stopHandler(int sign) {
  44. UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "Received Ctrl-C");
  45. running = 0;
  46. }
  47. /* Datasource Example */
  48. static UA_StatusCode
  49. readTimeData(void *handle, const UA_NodeId nodeId, UA_Boolean sourceTimeStamp,
  50. const UA_NumericRange *range, UA_DataValue *value) {
  51. if(range) {
  52. value->hasStatus = true;
  53. value->status = UA_STATUSCODE_BADINDEXRANGEINVALID;
  54. return UA_STATUSCODE_GOOD;
  55. }
  56. UA_DateTime currentTime = UA_DateTime_now();
  57. UA_Variant_setScalarCopy(&value->value, &currentTime, &UA_TYPES[UA_TYPES_DATETIME]);
  58. value->hasValue = true;
  59. if(sourceTimeStamp) {
  60. value->hasSourceTimestamp = true;
  61. value->sourceTimestamp = currentTime;
  62. }
  63. return UA_STATUSCODE_GOOD;
  64. }
  65. /* Method Node Example */
  66. #ifdef UA_ENABLE_METHODCALLS
  67. static UA_StatusCode
  68. helloWorld(void *methodHandle, const UA_NodeId *objectId,
  69. const UA_NodeId *sessionId, void *sessionHandle,
  70. size_t inputSize, const UA_Variant *input,
  71. size_t outputSize, UA_Variant *output) {
  72. /* input is a scalar string (checked by the server) */
  73. UA_String *name = (UA_String*)input[0].data;
  74. UA_String hello = UA_STRING("Hello ");
  75. UA_String greet;
  76. greet.length = hello.length + name->length;
  77. greet.data = (UA_Byte*)malloc(greet.length);
  78. memcpy(greet.data, hello.data, hello.length);
  79. memcpy(greet.data + hello.length, name->data, name->length);
  80. UA_Variant_setScalarCopy(output, &greet, &UA_TYPES[UA_TYPES_STRING]);
  81. UA_String_deleteMembers(&greet);
  82. return UA_STATUSCODE_GOOD;
  83. }
  84. static UA_StatusCode
  85. noargMethod(void *methodHandle, const UA_NodeId *objectId,
  86. const UA_NodeId *sessionId, void *sessionHandle,
  87. size_t inputSize, const UA_Variant *input,
  88. size_t outputSize, UA_Variant *output) {
  89. return UA_STATUSCODE_GOOD;
  90. }
  91. static UA_StatusCode
  92. outargMethod(void *methodHandle, const UA_NodeId *objectId,
  93. const UA_NodeId *sessionId, void *sessionHandle,
  94. size_t inputSize, const UA_Variant *input,
  95. size_t outputSize, UA_Variant *output) {
  96. UA_Int32 out = 42;
  97. UA_Variant_setScalarCopy(output, &out, &UA_TYPES[UA_TYPES_INT32]);
  98. return UA_STATUSCODE_GOOD;
  99. }
  100. #endif
  101. int main(int argc, char** argv) {
  102. signal(SIGINT, stopHandler); /* catches ctrl-c */
  103. UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
  104. UA_ServerConfig config = UA_ServerConfig_standard;
  105. config.networkLayers = &nl;
  106. config.networkLayersSize = 1;
  107. /* load certificate */
  108. config.serverCertificate = loadCertificate();
  109. UA_Server *server = UA_Server_new(config);
  110. /* add a static variable node to the server */
  111. UA_VariableAttributes myVar;
  112. UA_VariableAttributes_init(&myVar);
  113. myVar.description = UA_LOCALIZEDTEXT("en_US", "the answer");
  114. myVar.displayName = UA_LOCALIZEDTEXT("en_US", "the answer");
  115. myVar.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
  116. UA_Int32 myInteger = 42;
  117. UA_Variant_setScalarCopy(&myVar.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  118. const UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  119. const UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  120. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  121. UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  122. UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId, parentReferenceNodeId,
  123. myIntegerName, UA_NODEID_NULL, myVar, NULL, NULL);
  124. UA_Variant_deleteMembers(&myVar.value);
  125. /* add a variable with the datetime data source */
  126. UA_DataSource dateDataSource;
  127. dateDataSource.handle = NULL;
  128. dateDataSource.read = readTimeData;
  129. dateDataSource.write = NULL;
  130. UA_VariableAttributes v_attr;
  131. UA_VariableAttributes_init(&v_attr);
  132. v_attr.description = UA_LOCALIZEDTEXT("en_US","current time");
  133. v_attr.displayName = UA_LOCALIZEDTEXT("en_US","current time");
  134. v_attr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
  135. const UA_QualifiedName dateName = UA_QUALIFIEDNAME(1, "current time");
  136. UA_NodeId dataSourceId;
  137. UA_Server_addDataSourceVariableNode(server, UA_NODEID_NULL, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  138. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), dateName,
  139. UA_NODEID_NULL, v_attr, dateDataSource, &dataSourceId);
  140. /* Add HelloWorld method to the server */
  141. #ifdef UA_ENABLE_METHODCALLS
  142. /* Method with IO Arguments */
  143. UA_Argument inputArguments;
  144. UA_Argument_init(&inputArguments);
  145. inputArguments.dataType = UA_TYPES[UA_TYPES_STRING].typeId;
  146. inputArguments.description = UA_LOCALIZEDTEXT("en_US", "Say your name");
  147. inputArguments.name = UA_STRING("Name");
  148. inputArguments.valueRank = -1; /* scalar argument */
  149. UA_Argument outputArguments;
  150. UA_Argument_init(&outputArguments);
  151. outputArguments.arrayDimensionsSize = 0;
  152. outputArguments.arrayDimensions = NULL;
  153. outputArguments.dataType = UA_TYPES[UA_TYPES_STRING].typeId;
  154. outputArguments.description = UA_LOCALIZEDTEXT("en_US", "Receive a greeting");
  155. outputArguments.name = UA_STRING("greeting");
  156. outputArguments.valueRank = -1;
  157. UA_MethodAttributes addmethodattributes;
  158. UA_MethodAttributes_init(&addmethodattributes);
  159. addmethodattributes.displayName = UA_LOCALIZEDTEXT("en_US", "Hello World");
  160. addmethodattributes.executable = true;
  161. addmethodattributes.userExecutable = true;
  162. UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(1, 62541),
  163. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  164. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  165. UA_QUALIFIEDNAME(1, "hello_world"), addmethodattributes,
  166. &helloWorld, /* callback of the method node */
  167. NULL, /* handle passed with the callback */
  168. 1, &inputArguments, 1, &outputArguments, NULL);
  169. #endif
  170. /* Add folders for demo information model */
  171. #define DEMOID 50000
  172. #define SCALARID 50001
  173. #define ARRAYID 50002
  174. #define MATRIXID 50003
  175. #define DEPTHID 50004
  176. UA_ObjectAttributes object_attr;
  177. UA_ObjectAttributes_init(&object_attr);
  178. object_attr.description = UA_LOCALIZEDTEXT("en_US", "Demo");
  179. object_attr.displayName = UA_LOCALIZEDTEXT("en_US", "Demo");
  180. UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, DEMOID),
  181. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  182. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), UA_QUALIFIEDNAME(1, "Demo"),
  183. UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);
  184. object_attr.description = UA_LOCALIZEDTEXT("en_US", "Scalar");
  185. object_attr.displayName = UA_LOCALIZEDTEXT("en_US", "Scalar");
  186. UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, SCALARID),
  187. UA_NODEID_NUMERIC(1, DEMOID), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  188. UA_QUALIFIEDNAME(1, "Scalar"),
  189. UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);
  190. object_attr.description = UA_LOCALIZEDTEXT("en_US", "Array");
  191. object_attr.displayName = UA_LOCALIZEDTEXT("en_US", "Array");
  192. UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, ARRAYID),
  193. UA_NODEID_NUMERIC(1, DEMOID), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  194. UA_QUALIFIEDNAME(1, "Array"),
  195. UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);
  196. object_attr.description = UA_LOCALIZEDTEXT("en_US", "Matrix");
  197. object_attr.displayName = UA_LOCALIZEDTEXT("en_US", "Matrix");
  198. UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, MATRIXID), UA_NODEID_NUMERIC(1, DEMOID),
  199. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), UA_QUALIFIEDNAME(1, "Matrix"),
  200. UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);
  201. /* Fill demo nodes for each type*/
  202. UA_UInt32 id = 51000; // running id in namespace 0
  203. for(UA_UInt32 type = 0; type < UA_TYPES_DIAGNOSTICINFO; type++) {
  204. if(type == UA_TYPES_VARIANT || type == UA_TYPES_DIAGNOSTICINFO)
  205. continue;
  206. UA_VariableAttributes attr;
  207. UA_VariableAttributes_init(&attr);
  208. attr.valueRank = -2;
  209. attr.dataType = UA_TYPES[type].typeId;
  210. #ifndef UA_ENABLE_TYPENAMES
  211. char name[15];
  212. #if defined(_WIN32) && !defined(__MINGW32__)
  213. sprintf_s(name, 15, "%02d", type);
  214. #else
  215. sprintf(name, "%02d", type);
  216. #endif
  217. attr.displayName = UA_LOCALIZEDTEXT("en_US", name);
  218. UA_QualifiedName qualifiedName = UA_QUALIFIEDNAME(1, name);
  219. #else
  220. attr.displayName = UA_LOCALIZEDTEXT_ALLOC("en_US", UA_TYPES[type].typeName);
  221. UA_QualifiedName qualifiedName = UA_QUALIFIEDNAME_ALLOC(1, UA_TYPES[type].typeName);
  222. #endif
  223. attr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
  224. attr.writeMask = UA_WRITEMASK_DISPLAYNAME | UA_WRITEMASK_DESCRIPTION;
  225. attr.userWriteMask = UA_WRITEMASK_DISPLAYNAME | UA_WRITEMASK_DESCRIPTION;
  226. /* add a scalar node for every built-in type */
  227. void *value = UA_new(&UA_TYPES[type]);
  228. UA_Variant_setScalar(&attr.value, value, &UA_TYPES[type]);
  229. UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, ++id),
  230. UA_NODEID_NUMERIC(1, SCALARID), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  231. qualifiedName, UA_NODEID_NULL, attr, NULL, NULL);
  232. UA_Variant_deleteMembers(&attr.value);
  233. /* add an array node for every built-in type */
  234. UA_Variant_setArray(&attr.value, UA_Array_new(10, &UA_TYPES[type]), 10, &UA_TYPES[type]);
  235. UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, ++id), UA_NODEID_NUMERIC(1, ARRAYID),
  236. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), qualifiedName,
  237. UA_NODEID_NULL, attr, NULL, NULL);
  238. UA_Variant_deleteMembers(&attr.value);
  239. /* add an matrix node for every built-in type */
  240. void* myMultiArray = UA_Array_new(9, &UA_TYPES[type]);
  241. attr.value.arrayDimensions = (UA_UInt32*)UA_Array_new(2, &UA_TYPES[UA_TYPES_INT32]);
  242. attr.value.arrayDimensions[0] = 3;
  243. attr.value.arrayDimensions[1] = 3;
  244. attr.value.arrayDimensionsSize = 2;
  245. attr.value.arrayLength = 9;
  246. attr.value.data = myMultiArray;
  247. attr.value.type = &UA_TYPES[type];
  248. UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, ++id), UA_NODEID_NUMERIC(1, MATRIXID),
  249. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), qualifiedName,
  250. UA_NODEID_NULL, attr, NULL, NULL);
  251. UA_Variant_deleteMembers(&attr.value);
  252. #ifdef UA_ENABLE_TYPENAMES
  253. UA_LocalizedText_deleteMembers(&attr.displayName);
  254. UA_QualifiedName_deleteMembers(&qualifiedName);
  255. #endif
  256. }
  257. /* Hierarchy of depth 10 for CTT testing with forward and inverse references */
  258. /* Enter node "depth 9" in CTT configuration - Project->Settings->Server
  259. Test->NodeIds->Paths->Starting Node 1 */
  260. object_attr.description = UA_LOCALIZEDTEXT("en_US","DepthDemo");
  261. object_attr.displayName = UA_LOCALIZEDTEXT("en_US","DepthDemo");
  262. UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, DEPTHID),
  263. UA_NODEID_NUMERIC(1, DEMOID),
  264. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), UA_QUALIFIEDNAME(1, "DepthDemo"),
  265. UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);
  266. id = DEPTHID; // running id in namespace 0 - Start with Matrix NODE
  267. for(UA_UInt32 i = 1; i <= 20; i++) {
  268. char name[15];
  269. #if defined(_WIN32) && !defined(__MINGW32__)
  270. sprintf_s(name, 15, "depth%i", i);
  271. #else
  272. sprintf(name, "depth%i", i);
  273. #endif
  274. object_attr.description = UA_LOCALIZEDTEXT("en_US",name);
  275. object_attr.displayName = UA_LOCALIZEDTEXT("en_US",name);
  276. UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, id+i),
  277. UA_NODEID_NUMERIC(1, i==1 ? DEPTHID : id+i-1), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  278. UA_QUALIFIEDNAME(1, name),
  279. UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE), object_attr, NULL, NULL);
  280. }
  281. /* Add the variable to some more places to get a node with three inverse references for the CTT */
  282. UA_ExpandedNodeId answer_nodeid = UA_EXPANDEDNODEID_STRING(1, "the.answer");
  283. UA_Server_addReference(server, UA_NODEID_NUMERIC(1, DEMOID),
  284. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), answer_nodeid, true);
  285. UA_Server_addReference(server, UA_NODEID_NUMERIC(1, SCALARID),
  286. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), answer_nodeid, true);
  287. /* Example for manually setting an attribute within the server */
  288. UA_LocalizedText objectsName = UA_LOCALIZEDTEXT("en_US", "Objects");
  289. UA_Server_writeDisplayName(server, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER), objectsName);
  290. #define NOARGID 60000
  291. #define INARGID 60001
  292. #define OUTARGID 60002
  293. #define INOUTARGID 60003
  294. #ifdef UA_ENABLE_METHODCALLS
  295. /* adding some more method nodes to pass CTT */
  296. /* Method without arguments */
  297. UA_MethodAttributes_init(&addmethodattributes);
  298. addmethodattributes.displayName = UA_LOCALIZEDTEXT("en_US", "noarg");
  299. addmethodattributes.executable = true;
  300. addmethodattributes.userExecutable = true;
  301. UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(1, NOARGID),
  302. UA_NODEID_NUMERIC(1, DEMOID),
  303. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  304. UA_QUALIFIEDNAME(1, "noarg"), addmethodattributes,
  305. &noargMethod, /* callback of the method node */
  306. NULL, /* handle passed with the callback */
  307. 0, NULL, 0, NULL, NULL);
  308. /* Method with in arguments */
  309. UA_MethodAttributes_init(&addmethodattributes);
  310. addmethodattributes.displayName = UA_LOCALIZEDTEXT("en_US", "inarg");
  311. addmethodattributes.executable = true;
  312. addmethodattributes.userExecutable = true;
  313. UA_Argument_init(&inputArguments);
  314. inputArguments.dataType = UA_TYPES[UA_TYPES_INT32].typeId;
  315. inputArguments.description = UA_LOCALIZEDTEXT("en_US", "Input");
  316. inputArguments.name = UA_STRING("Input");
  317. inputArguments.valueRank = -1; //uaexpert will crash if set to 0 ;)
  318. UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(1, INARGID),
  319. UA_NODEID_NUMERIC(1, DEMOID),
  320. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  321. UA_QUALIFIEDNAME(1, "noarg"), addmethodattributes,
  322. &noargMethod, /* callback of the method node */
  323. NULL, /* handle passed with the callback */
  324. 1, &inputArguments, 0, NULL, NULL);
  325. /* Method with out arguments */
  326. UA_MethodAttributes_init(&addmethodattributes);
  327. addmethodattributes.displayName = UA_LOCALIZEDTEXT("en_US", "outarg");
  328. addmethodattributes.executable = true;
  329. addmethodattributes.userExecutable = true;
  330. UA_Argument_init(&outputArguments);
  331. outputArguments.dataType = UA_TYPES[UA_TYPES_INT32].typeId;
  332. outputArguments.description = UA_LOCALIZEDTEXT("en_US", "Output");
  333. outputArguments.name = UA_STRING("Output");
  334. outputArguments.valueRank = -1;
  335. UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(1, OUTARGID),
  336. UA_NODEID_NUMERIC(1, DEMOID),
  337. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  338. UA_QUALIFIEDNAME(1, "outarg"), addmethodattributes,
  339. &outargMethod, /* callback of the method node */
  340. NULL, /* handle passed with the callback */
  341. 0, NULL, 1, &outputArguments, NULL);
  342. /* Method with inout arguments */
  343. UA_MethodAttributes_init(&addmethodattributes);
  344. addmethodattributes.displayName = UA_LOCALIZEDTEXT("en_US", "inoutarg");
  345. addmethodattributes.executable = true;
  346. addmethodattributes.userExecutable = true;
  347. UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(1, INOUTARGID),
  348. UA_NODEID_NUMERIC(1, DEMOID),
  349. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  350. UA_QUALIFIEDNAME(1, "inoutarg"), addmethodattributes,
  351. &outargMethod, /* callback of the method node */
  352. NULL, /* handle passed with the callback */
  353. 1, &inputArguments, 1, &outputArguments, NULL);
  354. #endif
  355. /* run server */
  356. UA_StatusCode retval = UA_Server_run(server, &running); /* run until ctrl-c is received */
  357. /* deallocate certificate's memory */
  358. UA_ByteString_deleteMembers(&config.serverCertificate);
  359. UA_Server_delete(server);
  360. nl.deleteMembers(&nl);
  361. return (int)retval;
  362. }