You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5028 lines
123 KiB

  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP version 4.0 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.02 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available at through the world-wide-web at |
  10. | http://www.php.net/license/2_02.txt. |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Uwe Steinmann |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #include <stdlib.h>
  20. #include <errno.h>
  21. extern "C"
  22. {
  23. #include "php.h"
  24. #include "php_globals.h"
  25. //#include "ext/standard/php_standard.h"
  26. #include "ext/standard/head.h"
  27. #include "ext/standard/info.h"
  28. //#include "fopen-wrappers.h"
  29. #include "SAPI.h"
  30. }
  31. #ifdef PHP_WIN32
  32. #include <winsock.h>
  33. #else
  34. #include "build-defs.h"
  35. #endif
  36. #ifdef HAVE_MMAP
  37. #include <sys/mman.h>
  38. #endif
  39. #if HAVE_HWAPI
  40. static int le_hwapip;
  41. static int le_hwapi_objectp;
  42. static int le_hwapi_attributep;
  43. static int le_hwapi_errorp;
  44. static int le_hwapi_contentp;
  45. static int le_hwapi_reasonp;
  46. static zend_class_entry *hw_api_class_entry_ptr;
  47. static zend_class_entry *hw_api_object_class_entry_ptr;
  48. static zend_class_entry *hw_api_attribute_class_entry_ptr;
  49. static zend_class_entry *hw_api_error_class_entry_ptr;
  50. static zend_class_entry *hw_api_content_class_entry_ptr;
  51. static zend_class_entry *hw_api_reason_class_entry_ptr;
  52. #include "php_ini.h"
  53. #include "php_hwapi.h"
  54. //#ifdef __cplusplus
  55. //extern "C" {
  56. #include <sdk/api/api.h>
  57. #include <sdk/hgcsp/apihgcsp.h>
  58. //}
  59. //#endif
  60. function_entry hwapi_functions[] = {
  61. PHP_FE(hwapi_dummy, NULL)
  62. PHP_FE(hwapi_init, NULL)
  63. PHP_FE(hwapi_hgcsp, NULL)
  64. PHP_FE(hwapi_object, NULL)
  65. PHP_FE(hwapi_children, NULL)
  66. PHP_FE(hwapi_parents, NULL)
  67. PHP_FE(hwapi_find, NULL)
  68. PHP_FE(hwapi_identify, NULL)
  69. PHP_FE(hwapi_remove, NULL)
  70. PHP_FE(hwapi_content, NULL)
  71. PHP_FE(hwapi_copy, NULL)
  72. PHP_FE(hwapi_link, NULL)
  73. PHP_FE(hwapi_move, NULL)
  74. PHP_FE(hwapi_lock, NULL)
  75. PHP_FE(hwapi_unlock, NULL)
  76. PHP_FE(hwapi_replace, NULL)
  77. PHP_FE(hwapi_object_new, NULL)
  78. PHP_FE(hwapi_object_count, NULL)
  79. PHP_FE(hwapi_object_title, NULL)
  80. PHP_FE(hwapi_object_attreditable, NULL)
  81. PHP_FE(hwapi_object_assign, NULL)
  82. PHP_FE(hwapi_object_attribute, NULL)
  83. PHP_FE(hwapi_object_insert, NULL)
  84. PHP_FE(hwapi_object_remove, NULL)
  85. PHP_FE(hwapi_object_value, NULL)
  86. PHP_FE(hwapi_attribute_new, NULL)
  87. PHP_FE(hwapi_attribute_key, NULL)
  88. PHP_FE(hwapi_attribute_value, NULL)
  89. PHP_FE(hwapi_attribute_values, NULL)
  90. PHP_FE(hwapi_attribute_langdepvalue, NULL)
  91. PHP_FE(hwapi_content_new, NULL)
  92. {NULL, NULL, NULL}
  93. };
  94. static function_entry php_hw_api_functions[] = {
  95. {"hgcsp", PHP_FN(hwapi_hgcsp), NULL},
  96. {"object", PHP_FN(hwapi_object), NULL},
  97. {"children", PHP_FN(hwapi_children), NULL},
  98. {"mychildren", PHP_FN(hwapi_mychildren), NULL},
  99. {"parents", PHP_FN(hwapi_parents), NULL},
  100. {"find", PHP_FN(hwapi_find), NULL},
  101. {"identify", PHP_FN(hwapi_identify), NULL},
  102. {"remove", PHP_FN(hwapi_remove), NULL},
  103. {"content", PHP_FN(hwapi_content), NULL},
  104. {"copy", PHP_FN(hwapi_copy), NULL},
  105. {"link", PHP_FN(hwapi_link), NULL},
  106. {"move", PHP_FN(hwapi_move), NULL},
  107. {"lock", PHP_FN(hwapi_lock), NULL},
  108. {"unlock", PHP_FN(hwapi_unlock), NULL},
  109. {"replace", PHP_FN(hwapi_replace), NULL},
  110. {"insert", PHP_FN(hwapi_insert), NULL},
  111. {"insertdocument", PHP_FN(hwapi_insertdocument), NULL},
  112. {"insertcollection", PHP_FN(hwapi_insertcollection), NULL},
  113. {"srcanchors", PHP_FN(hwapi_srcanchors), NULL},
  114. {"dstanchors", PHP_FN(hwapi_dstanchors), NULL},
  115. {"objectbyanchor", PHP_FN(hwapi_objectbyanchor), NULL},
  116. {"dstofsrcanchor", PHP_FN(hwapi_dstofsrcanchor), NULL},
  117. {"srcsofdst", PHP_FN(hwapi_srcsofdst), NULL},
  118. {"checkin", PHP_FN(hwapi_checkin), NULL},
  119. {"checkout", PHP_FN(hwapi_checkout), NULL},
  120. {"setcommittedversion", PHP_FN(hwapi_setcommittedversion), NULL},
  121. {"revert", PHP_FN(hwapi_revert), NULL},
  122. {"history", PHP_FN(hwapi_history), NULL},
  123. {"removeversion", PHP_FN(hwapi_removeversion), NULL},
  124. {"freeversion", PHP_FN(hwapi_freeversion), NULL},
  125. {"configurationhistory", PHP_FN(hwapi_configurationhistory), NULL},
  126. {"saveconfiguration", PHP_FN(hwapi_saveconfiguration), NULL},
  127. {"restoreconfiguration", PHP_FN(hwapi_restoreconfiguration), NULL},
  128. {"removeconfiguration", PHP_FN(hwapi_removeconfiguration), NULL},
  129. {"mergeconfiguration", PHP_FN(hwapi_mergeconfiguration), NULL},
  130. {"user", PHP_FN(hwapi_user), NULL},
  131. {"userlist", PHP_FN(hwapi_userlist), NULL},
  132. {"hwstat", PHP_FN(hwapi_hwstat), NULL},
  133. {"dcstat", PHP_FN(hwapi_dcstat), NULL},
  134. {"dbstat", PHP_FN(hwapi_dbstat), NULL},
  135. {"ftstat", PHP_FN(hwapi_ftstat), NULL},
  136. {"info", PHP_FN(hwapi_info), NULL},
  137. {NULL, NULL, NULL}
  138. };
  139. static function_entry php_hw_api_object_functions[] = {
  140. {"hw_api_object", PHP_FN(hwapi_object_new), NULL},
  141. {"count", PHP_FN(hwapi_object_count), NULL},
  142. {"title", PHP_FN(hwapi_object_title), NULL},
  143. {"attributeeditable", PHP_FN(hwapi_object_attreditable), NULL},
  144. {"assign", PHP_FN(hwapi_object_assign), NULL},
  145. {"attribute", PHP_FN(hwapi_object_attribute), NULL},
  146. {"insert", PHP_FN(hwapi_object_insert), NULL},
  147. {"remove", PHP_FN(hwapi_object_remove), NULL},
  148. {"value", PHP_FN(hwapi_object_value), NULL},
  149. {NULL, NULL, NULL}
  150. };
  151. static function_entry php_hw_api_attribute_functions[] = {
  152. {"hw_api_attribute", PHP_FN(hwapi_attribute_new), NULL},
  153. {"key", PHP_FN(hwapi_attribute_key), NULL},
  154. {"value", PHP_FN(hwapi_attribute_value), NULL},
  155. {"values", PHP_FN(hwapi_attribute_values), NULL},
  156. {"langdepvalue", PHP_FN(hwapi_attribute_langdepvalue), NULL},
  157. {NULL, NULL, NULL}
  158. };
  159. static function_entry php_hw_api_error_functions[] = {
  160. {"count", PHP_FN(hwapi_error_count), NULL},
  161. {"reason", PHP_FN(hwapi_error_reason), NULL},
  162. {NULL, NULL, NULL}
  163. };
  164. static function_entry php_hw_api_content_functions[] = {
  165. {"hw_api_content", PHP_FN(hwapi_content_new), NULL},
  166. {"read", PHP_FN(hwapi_content_read), NULL},
  167. {"mimetype", PHP_FN(hwapi_content_mimetype), NULL},
  168. {NULL, NULL, NULL}
  169. };
  170. static function_entry php_hw_api_reason_functions[] = {
  171. {"type", PHP_FN(hwapi_reason_type), NULL},
  172. {"description", PHP_FN(hwapi_reason_description), NULL},
  173. {NULL, NULL, NULL}
  174. };
  175. void hw_api_class_startup();
  176. void hw_api_object_class_startup();
  177. void hw_api_attribute_class_startup();
  178. void hw_api_error_class_startup();
  179. void hw_api_content_class_startup();
  180. void hw_api_reason_class_startup();
  181. static zval *php_hwapi_object_new(void *obj, int rsrc_type);
  182. zend_module_entry hwapi_module_entry = {
  183. STANDARD_MODULE_HEADER,
  184. "hwapi",
  185. hwapi_functions,
  186. PHP_MINIT(hwapi),
  187. PHP_MSHUTDOWN(hwapi),
  188. PHP_RINIT(hwapi),
  189. NULL,
  190. PHP_MINFO(hwapi),
  191. NO_VERSION_YET,
  192. STANDARD_MODULE_PROPERTIES
  193. };
  194. #ifdef ZTS
  195. int hwapi_globals_id;
  196. #else
  197. PHP_HWAPI_API zend_hwapi_globals hwapi_globals;
  198. #endif
  199. #ifdef COMPILE_DL_HWAPI
  200. ZEND_GET_MODULE(hwapi)
  201. #endif
  202. static void print_reason(const HW_API_Reason& reason) {
  203. HW_API_String str_type;
  204. switch(reason.type()) {
  205. case HW_API_Reason::HW_API_ERROR:
  206. str_type = "Error";
  207. break;
  208. case HW_API_Reason::HW_API_WARNING:
  209. str_type = "Warning";
  210. break;
  211. case HW_API_Reason::HW_API_MESSAGE:
  212. str_type = "Message";
  213. break;
  214. }
  215. fprintf(stderr, "%s: %s\n", str_type.string(), reason.description("en").string());
  216. }
  217. static void print_error(const HW_API_Error& error) {
  218. for (int i=0; i < error.count(); i++) {
  219. HW_API_Reason reason;
  220. error.reason(i, reason);
  221. print_reason(reason);
  222. }
  223. }
  224. static void print_object(const HW_API_Object& object) {
  225. fprintf(stderr, "%s\n", object.title("en").string());
  226. for (int i=0; i < object.count(); i++) {
  227. HW_API_Attribute attrib;
  228. object.attribute(i, attrib);
  229. fprintf(stderr, "%s=%s\n", attrib.key().string(), attrib.value().string());
  230. }
  231. }
  232. static void php_hwapi_init_globals(zend_hwapi_globals *hwapi_globals) {
  233. }
  234. static void php_free_hwapi(zend_rsrc_list_entry *rsrc) {
  235. HW_API *obj;
  236. obj = (HW_API *) (rsrc->ptr);
  237. delete obj;
  238. }
  239. static void php_free_hwapi_object(zend_rsrc_list_entry *rsrc) {
  240. HW_API_Object *obj;
  241. obj = (HW_API_Object *) (rsrc->ptr);
  242. delete obj;
  243. }
  244. static void php_free_hwapi_attribute(zend_rsrc_list_entry *rsrc) {
  245. HW_API_Attribute *obj;
  246. obj = (HW_API_Attribute *) (rsrc->ptr);
  247. if(obj)
  248. delete obj;
  249. }
  250. static void php_free_hwapi_error(zend_rsrc_list_entry *rsrc) {
  251. HW_API_Error *obj;
  252. obj = (HW_API_Error *) (rsrc->ptr);
  253. if(obj)
  254. delete obj;
  255. }
  256. static void php_free_hwapi_content(zend_rsrc_list_entry *rsrc) {
  257. HW_API_Content *obj;
  258. obj = (HW_API_Content *) (rsrc->ptr);
  259. if(obj)
  260. delete obj;
  261. }
  262. static void php_free_hwapi_reason(zend_rsrc_list_entry *rsrc) {
  263. HW_API_Reason *obj;
  264. obj = (HW_API_Reason *) (rsrc->ptr);
  265. if(obj)
  266. delete obj;
  267. }
  268. static void print_hwapi_stringarray(const HW_API_StringArray& strings) {
  269. for(int i=0; i<strings.count(); i++) {
  270. HW_API_String str;
  271. strings.string(i, str);
  272. fprintf(stderr, "%s\n", str.string());
  273. }
  274. }
  275. static int stringArray2indexArray(pval **return_value, HW_API_StringArray *values) {
  276. if (array_init(*return_value) == FAILURE) {
  277. return 0;
  278. }
  279. for (int i=0; i<values->count(); i++) {
  280. HW_API_String str;
  281. values->string(i, str);
  282. str.string();
  283. add_next_index_string(*return_value, (char *) str.string(), 1);
  284. }
  285. return 1;
  286. }
  287. static int objectArray2indexArray(pval **return_value, HW_API_ObjectArray *objarr) {
  288. if (array_init(*return_value) == FAILURE) {
  289. return 0;
  290. }
  291. for(int i=0; i<objarr->count(); i++) {
  292. zval *child;
  293. HW_API_Object obj, *objp;
  294. objarr->object(i, obj);
  295. objp = new HW_API_Object(obj);
  296. child = php_hwapi_object_new(objp, le_hwapi_objectp);
  297. add_next_index_zval(*return_value, child);
  298. }
  299. return 1;
  300. }
  301. static void *php_hwapi_get_object(zval *wrapper, int rsrc_type1) {
  302. void *obj;
  303. zval **handle;
  304. int type;
  305. if (Z_TYPE_P(wrapper) != IS_OBJECT) {
  306. php_error(E_ERROR, "Wrapper is not an object");
  307. }
  308. if (zend_hash_find(Z_OBJPROP_P(wrapper), "this", sizeof("this"), (void **)&handle) == FAILURE) {
  309. php_error(E_ERROR, "Underlying object missing");
  310. }
  311. obj = zend_list_find(Z_LVAL_PP(handle), &type);
  312. if (!obj || (type != rsrc_type1)) {
  313. php_error(E_ERROR, "Underlying object missing or of invalid type");
  314. }
  315. return obj;
  316. }
  317. static zval *php_hwapi_object_new(void *obj, int rsrc_type) {
  318. zval *wrapper, *handle;
  319. int ret;
  320. MAKE_STD_ZVAL(wrapper);
  321. if (!obj) {
  322. ZVAL_NULL(wrapper);
  323. return wrapper;
  324. }
  325. /* construct an object with some methods */
  326. if(rsrc_type == le_hwapi_attributep)
  327. object_init_ex(wrapper, hw_api_attribute_class_entry_ptr);
  328. else if(rsrc_type == le_hwapi_objectp)
  329. object_init_ex(wrapper, hw_api_object_class_entry_ptr);
  330. else if(rsrc_type == le_hwapip)
  331. object_init_ex(wrapper, hw_api_class_entry_ptr);
  332. else if(rsrc_type == le_hwapi_errorp)
  333. object_init_ex(wrapper, hw_api_error_class_entry_ptr);
  334. else if(rsrc_type == le_hwapi_contentp)
  335. object_init_ex(wrapper, hw_api_content_class_entry_ptr);
  336. else if(rsrc_type == le_hwapi_reasonp)
  337. object_init_ex(wrapper, hw_api_reason_class_entry_ptr);
  338. MAKE_STD_ZVAL(handle);
  339. ZEND_REGISTER_RESOURCE(handle, obj, rsrc_type);
  340. zend_hash_update(Z_OBJPROP_P(wrapper), "this", sizeof("this"), &handle, sizeof(zval *), NULL);
  341. return(wrapper);
  342. }
  343. static HW_API_StringArray *make_HW_API_StringArray(HashTable *lht) {
  344. int count, j;
  345. HW_API_StringArray *sarr;
  346. sarr = new HW_API_StringArray();
  347. count = zend_hash_num_elements(lht);
  348. zend_hash_internal_pointer_reset(lht);
  349. for(j=0; j<count; j++) {
  350. zval **keydata;
  351. zend_hash_get_current_data(lht, (void **) &keydata);
  352. switch((*keydata)->type) {
  353. case IS_STRING:
  354. sarr->insert((HW_API_String) (*keydata)->value.str.val);
  355. break;
  356. }
  357. zend_hash_move_forward(lht);
  358. }
  359. return sarr;
  360. }
  361. static HW_API_object_In *make_HW_API_object_In(zval *arg1) {
  362. int count, i;
  363. HashTable *lht;
  364. HW_API_object_In *in;
  365. lht = arg1->value.ht;
  366. if(0 == (count = zend_hash_num_elements(lht))) {
  367. return NULL;
  368. }
  369. in = new HW_API_object_In();
  370. zend_hash_internal_pointer_reset(lht);
  371. for(i=0; i<count; i++) {
  372. ulong ind;
  373. char *key;
  374. zval **keydata;
  375. zend_hash_get_current_data(lht, (void **) &keydata);
  376. zend_hash_get_current_key(lht, &key, &ind, 0);
  377. switch((*keydata)->type) {
  378. case IS_STRING:
  379. if(!strcmp(key, "objectIdentifier"))
  380. in->setObjectIdentifier((*keydata)->value.str.val);
  381. else if(!strcmp(key, "version"))
  382. in->setVersion((*keydata)->value.str.val);
  383. break;
  384. case IS_ARRAY: {
  385. HW_API_StringArray *sarr;
  386. if(!strcmp(key, "attributeSelector")) {
  387. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  388. in->setAttributeSelector(*sarr);
  389. /* FIXME: sarr can be propperly by freed now */
  390. }
  391. break;
  392. }
  393. }
  394. zend_hash_move_forward(lht);
  395. }
  396. return(in);
  397. }
  398. static HW_API_children_In *make_HW_API_children_In(zval *arg1) {
  399. int count, i;
  400. HashTable *lht;
  401. HW_API_children_In *in;
  402. lht = arg1->value.ht;
  403. if(0 == (count = zend_hash_num_elements(lht))) {
  404. return NULL;
  405. }
  406. in = new HW_API_children_In();
  407. zend_hash_internal_pointer_reset(lht);
  408. for(i=0; i<count; i++) {
  409. ulong ind;
  410. char *key;
  411. zval **keydata;
  412. zend_hash_get_current_data(lht, (void **) &keydata);
  413. zend_hash_get_current_key(lht, &key, &ind, 0);
  414. switch((*keydata)->type) {
  415. case IS_STRING:
  416. if(!strcmp(key, "objectIdentifier"))
  417. in->setObjectIdentifier((*keydata)->value.str.val);
  418. else if(!strcmp(key, "objectQuery"))
  419. in->setObjectQuery((*keydata)->value.str.val);
  420. break;
  421. case IS_ARRAY: {
  422. HW_API_StringArray *sarr;
  423. if(!strcmp(key, "attributeSelector")) {
  424. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  425. in->setAttributeSelector(*sarr);
  426. /* FIXME: sarr can be propperly by freed now */
  427. }
  428. break;
  429. }
  430. }
  431. zend_hash_move_forward(lht);
  432. }
  433. return(in);
  434. }
  435. static HW_API_parents_In *make_HW_API_parents_In(zval *arg1) {
  436. int count, i;
  437. HashTable *lht;
  438. HW_API_parents_In *in;
  439. lht = arg1->value.ht;
  440. if(0 == (count = zend_hash_num_elements(lht))) {
  441. return NULL;
  442. }
  443. in = new HW_API_parents_In();
  444. zend_hash_internal_pointer_reset(lht);
  445. for(i=0; i<count; i++) {
  446. ulong ind;
  447. char *key;
  448. zval **keydata;
  449. zend_hash_get_current_data(lht, (void **) &keydata);
  450. zend_hash_get_current_key(lht, &key, &ind, 0);
  451. switch((*keydata)->type) {
  452. case IS_STRING:
  453. if(!strcmp(key, "objectIdentifier"))
  454. in->setObjectIdentifier((*keydata)->value.str.val);
  455. else if(!strcmp(key, "objectQuery"))
  456. in->setObjectQuery((*keydata)->value.str.val);
  457. break;
  458. case IS_ARRAY: {
  459. HW_API_StringArray *sarr;
  460. if(!strcmp(key, "attributeSelector")) {
  461. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  462. in->setAttributeSelector(*sarr);
  463. /* FIXME: sarr can be propperly by freed now */
  464. }
  465. break;
  466. }
  467. }
  468. zend_hash_move_forward(lht);
  469. }
  470. return(in);
  471. }
  472. static HW_API_find_In *make_HW_API_find_In(zval *arg1) {
  473. int count, i;
  474. HashTable *lht;
  475. HW_API_find_In *in;
  476. lht = arg1->value.ht;
  477. if(0 == (count = zend_hash_num_elements(lht))) {
  478. return NULL;
  479. }
  480. in = new HW_API_find_In();
  481. zend_hash_internal_pointer_reset(lht);
  482. for(i=0; i<count; i++) {
  483. ulong ind;
  484. char *key;
  485. zval **keydata;
  486. zend_hash_get_current_data(lht, (void **) &keydata);
  487. zend_hash_get_current_key(lht, &key, &ind, 0);
  488. switch((*keydata)->type) {
  489. case IS_STRING:
  490. if(!strcmp(key, "keyQuery"))
  491. in->setKeyQuery((*keydata)->value.str.val);
  492. else if(!strcmp(key, "objectQuery"))
  493. in->setObjectQuery((*keydata)->value.str.val);
  494. else if(!strcmp(key, "fullTextQuery"))
  495. in->setFullTextQuery((*keydata)->value.str.val);
  496. break;
  497. case IS_LONG:
  498. if(!strcmp(key, "startIndex"))
  499. in->setStartIndex((*keydata)->value.lval);
  500. else if(!strcmp(key, "numberOfObjectsToGet"))
  501. in->setNumberOfObjectsToGet((*keydata)->value.lval);
  502. else if(!strcmp(key, "exactMatchLimit"))
  503. in->setExactMatchLimit((*keydata)->value.lval);
  504. break;
  505. case IS_ARRAY: {
  506. HW_API_StringArray *sarr;
  507. if(!strcmp(key, "attributeSelector")) {
  508. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  509. in->setAttributeSelector(*sarr);
  510. /* FIXME: sarr can be propperly by freed now */
  511. } else if(!strcmp(key, "languages")) {
  512. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  513. in->setLanguages(*sarr);
  514. /* FIXME: sarr can be propperly by freed now */
  515. } else if(!strcmp(key, "scope")) {
  516. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  517. in->setScope(*sarr);
  518. /* FIXME: sarr can be propperly by freed now */
  519. }
  520. break;
  521. }
  522. }
  523. zend_hash_move_forward(lht);
  524. }
  525. return(in);
  526. }
  527. static HW_API_identify_In *make_HW_API_identify_In(zval *arg1) {
  528. int count, i;
  529. HashTable *lht;
  530. HW_API_identify_In *in;
  531. lht = arg1->value.ht;
  532. if(0 == (count = zend_hash_num_elements(lht))) {
  533. return NULL;
  534. }
  535. in = new HW_API_identify_In();
  536. zend_hash_internal_pointer_reset(lht);
  537. for(i=0; i<count; i++) {
  538. ulong ind;
  539. char *key;
  540. zval **keydata;
  541. zend_hash_get_current_data(lht, (void **) &keydata);
  542. zend_hash_get_current_key(lht, &key, &ind, 0);
  543. switch((*keydata)->type) {
  544. case IS_STRING:
  545. if(!strcmp(key, "username"))
  546. in->setUsername((*keydata)->value.str.val);
  547. else if(!strcmp(key, "password"))
  548. in->setPassword((*keydata)->value.str.val);
  549. break;
  550. }
  551. zend_hash_move_forward(lht);
  552. }
  553. return(in);
  554. }
  555. static HW_API_remove_In *make_HW_API_remove_In(zval *arg1) {
  556. int count, i;
  557. HashTable *lht;
  558. HW_API_remove_In *in;
  559. lht = arg1->value.ht;
  560. if(0 == (count = zend_hash_num_elements(lht))) {
  561. return NULL;
  562. }
  563. in = new HW_API_remove_In();
  564. zend_hash_internal_pointer_reset(lht);
  565. for(i=0; i<count; i++) {
  566. ulong ind;
  567. char *key;
  568. zval **keydata;
  569. zend_hash_get_current_data(lht, (void **) &keydata);
  570. zend_hash_get_current_key(lht, &key, &ind, 0);
  571. switch((*keydata)->type) {
  572. case IS_STRING:
  573. if(!strcmp(key, "parentIdentifier"))
  574. in->setParentIdentifier((*keydata)->value.str.val);
  575. else if(!strcmp(key, "objectIdentifier"))
  576. in->setObjectIdentifier((*keydata)->value.str.val);
  577. else if(!strcmp(key, "objectQuery"))
  578. in->setObjectQuery((*keydata)->value.str.val);
  579. break;
  580. case IS_LONG:
  581. if(!strcmp(key, "mode"))
  582. in->setMode((*keydata)->value.lval);
  583. break;
  584. }
  585. zend_hash_move_forward(lht);
  586. }
  587. return(in);
  588. }
  589. static HW_API_content_In *make_HW_API_content_In(zval *arg1) {
  590. int count, i;
  591. HashTable *lht;
  592. HW_API_content_In *in;
  593. lht = arg1->value.ht;
  594. if(0 == (count = zend_hash_num_elements(lht))) {
  595. return NULL;
  596. }
  597. in = new HW_API_content_In();
  598. zend_hash_internal_pointer_reset(lht);
  599. for(i=0; i<count; i++) {
  600. ulong ind;
  601. char *key;
  602. zval **keydata;
  603. zend_hash_get_current_data(lht, (void **) &keydata);
  604. zend_hash_get_current_key(lht, &key, &ind, 0);
  605. switch((*keydata)->type) {
  606. case IS_STRING:
  607. if(!strcmp(key, "objectIdentifier"))
  608. in->setObjectIdentifier((*keydata)->value.str.val);
  609. break;
  610. case IS_LONG:
  611. if(!strcmp(key, "mode"))
  612. in->setMode((*keydata)->value.lval);
  613. break;
  614. }
  615. zend_hash_move_forward(lht);
  616. }
  617. return(in);
  618. }
  619. static HW_API_copy_In *make_HW_API_copy_In(zval *arg1) {
  620. int count, i;
  621. HashTable *lht;
  622. HW_API_copy_In *in;
  623. lht = arg1->value.ht;
  624. if(0 == (count = zend_hash_num_elements(lht))) {
  625. return NULL;
  626. }
  627. in = new HW_API_copy_In();
  628. zend_hash_internal_pointer_reset(lht);
  629. for(i=0; i<count; i++) {
  630. ulong ind;
  631. char *key;
  632. zval **keydata;
  633. zend_hash_get_current_data(lht, (void **) &keydata);
  634. zend_hash_get_current_key(lht, &key, &ind, 0);
  635. switch((*keydata)->type) {
  636. case IS_STRING:
  637. if(!strcmp(key, "destinationParentIdentifier"))
  638. in->setDestinationParentIdentifier((*keydata)->value.str.val);
  639. else if(!strcmp(key, "objectIdentifier"))
  640. in->setObjectIdentifier((*keydata)->value.str.val);
  641. break;
  642. case IS_ARRAY: {
  643. HW_API_StringArray *sarr;
  644. if(!strcmp(key, "attributeSelector")) {
  645. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  646. in->setAttributeSelector(*sarr);
  647. /* FIXME: sarr can be propperly by freed now */
  648. }
  649. break;
  650. }
  651. }
  652. zend_hash_move_forward(lht);
  653. }
  654. return(in);
  655. }
  656. static HW_API_link_In *make_HW_API_link_In(zval *arg1) {
  657. int count, i;
  658. HashTable *lht;
  659. HW_API_link_In *in;
  660. lht = arg1->value.ht;
  661. if(0 == (count = zend_hash_num_elements(lht))) {
  662. return NULL;
  663. }
  664. in = new HW_API_link_In();
  665. zend_hash_internal_pointer_reset(lht);
  666. for(i=0; i<count; i++) {
  667. ulong ind;
  668. char *key;
  669. zval **keydata;
  670. zend_hash_get_current_data(lht, (void **) &keydata);
  671. zend_hash_get_current_key(lht, &key, &ind, 0);
  672. switch((*keydata)->type) {
  673. case IS_STRING:
  674. if(!strcmp(key, "destinationParentIdentifier"))
  675. in->setDestinationParentIdentifier((*keydata)->value.str.val);
  676. else if(!strcmp(key, "objectIdentifier"))
  677. in->setObjectIdentifier((*keydata)->value.str.val);
  678. break;
  679. }
  680. zend_hash_move_forward(lht);
  681. }
  682. return(in);
  683. }
  684. static HW_API_move_In *make_HW_API_move_In(zval *arg1) {
  685. int count, i;
  686. HashTable *lht;
  687. HW_API_move_In *in;
  688. lht = arg1->value.ht;
  689. if(0 == (count = zend_hash_num_elements(lht))) {
  690. return NULL;
  691. }
  692. in = new HW_API_move_In();
  693. zend_hash_internal_pointer_reset(lht);
  694. for(i=0; i<count; i++) {
  695. ulong ind;
  696. char *key;
  697. zval **keydata;
  698. zend_hash_get_current_data(lht, (void **) &keydata);
  699. zend_hash_get_current_key(lht, &key, &ind, 0);
  700. switch((*keydata)->type) {
  701. case IS_STRING:
  702. if(!strcmp(key, "destinationParentIdentifier"))
  703. in->setDestinationParentIdentifier((*keydata)->value.str.val);
  704. else if(!strcmp(key, "sourceParentIdentifier"))
  705. in->setSourceParentIdentifier((*keydata)->value.str.val);
  706. else if(!strcmp(key, "objectIdentifier"))
  707. in->setObjectIdentifier((*keydata)->value.str.val);
  708. break;
  709. }
  710. zend_hash_move_forward(lht);
  711. }
  712. return(in);
  713. }
  714. static HW_API_lock_In *make_HW_API_lock_In(zval *arg1) {
  715. int count, i;
  716. HashTable *lht;
  717. HW_API_lock_In *in;
  718. lht = arg1->value.ht;
  719. if(0 == (count = zend_hash_num_elements(lht))) {
  720. return NULL;
  721. }
  722. in = new HW_API_lock_In();
  723. zend_hash_internal_pointer_reset(lht);
  724. for(i=0; i<count; i++) {
  725. ulong ind;
  726. char *key;
  727. zval **keydata;
  728. zend_hash_get_current_data(lht, (void **) &keydata);
  729. zend_hash_get_current_key(lht, &key, &ind, 0);
  730. switch((*keydata)->type) {
  731. case IS_STRING:
  732. if(!strcmp(key, "objectQuery"))
  733. in->setObjectQuery((*keydata)->value.str.val);
  734. else if(!strcmp(key, "objectIdentifier"))
  735. in->setObjectIdentifier((*keydata)->value.str.val);
  736. break;
  737. case IS_LONG:
  738. if(!strcmp(key, "mode"))
  739. in->setMode((*keydata)->value.lval);
  740. break;
  741. }
  742. zend_hash_move_forward(lht);
  743. }
  744. return(in);
  745. }
  746. static HW_API_unlock_In *make_HW_API_unlock_In(zval *arg1) {
  747. int count, i;
  748. HashTable *lht;
  749. HW_API_unlock_In *in;
  750. lht = arg1->value.ht;
  751. if(0 == (count = zend_hash_num_elements(lht))) {
  752. return NULL;
  753. }
  754. in = new HW_API_unlock_In();
  755. zend_hash_internal_pointer_reset(lht);
  756. for(i=0; i<count; i++) {
  757. ulong ind;
  758. char *key;
  759. zval **keydata;
  760. zend_hash_get_current_data(lht, (void **) &keydata);
  761. zend_hash_get_current_key(lht, &key, &ind, 0);
  762. switch((*keydata)->type) {
  763. case IS_STRING:
  764. if(!strcmp(key, "objectQuery"))
  765. in->setObjectQuery((*keydata)->value.str.val);
  766. else if(!strcmp(key, "objectIdentifier"))
  767. in->setObjectIdentifier((*keydata)->value.str.val);
  768. break;
  769. case IS_LONG:
  770. if(!strcmp(key, "mode"))
  771. in->setMode((*keydata)->value.lval);
  772. break;
  773. }
  774. zend_hash_move_forward(lht);
  775. }
  776. return(in);
  777. }
  778. static HW_API_replace_In *make_HW_API_replace_In(zval *arg1) {
  779. int count, i;
  780. HashTable *lht;
  781. HW_API_replace_In *in;
  782. lht = arg1->value.ht;
  783. if(0 == (count = zend_hash_num_elements(lht))) {
  784. return NULL;
  785. }
  786. in = new HW_API_replace_In();
  787. zend_hash_internal_pointer_reset(lht);
  788. for(i=0; i<count; i++) {
  789. ulong ind;
  790. char *key;
  791. zval **keydata;
  792. zend_hash_get_current_data(lht, (void **) &keydata);
  793. zend_hash_get_current_key(lht, &key, &ind, 0);
  794. switch((*keydata)->type) {
  795. case IS_STRING:
  796. if(!strcmp(key, "objectIdentifier"))
  797. in->setObjectIdentifier((*keydata)->value.str.val);
  798. break;
  799. case IS_OBJECT:
  800. if(!strcmp(key, "object")) {
  801. if(!((*keydata)->value.obj.ce->name, "hw_api_object")) {
  802. HW_API_Object *obj;
  803. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  804. in->setObject(*obj);
  805. }
  806. } else if(!strcmp(key, "parameters")) {
  807. if(!((*keydata)->value.obj.ce->name, "hw_api_object")) {
  808. HW_API_Object *obj;
  809. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  810. in->setParameters(*obj);
  811. }
  812. } else if(!strcmp(key, "content")) {
  813. if(!((*keydata)->value.obj.ce->name, "hw_api_content")) {
  814. HW_API_Content *obj;
  815. obj = (HW_API_Content *) php_hwapi_get_object(*keydata, le_hwapi_contentp);
  816. in->setContent(*obj);
  817. }
  818. }
  819. /* FIXME: HW_API_Object and HW_API_Content needs to be handelt */
  820. break;
  821. case IS_ARRAY: {
  822. HW_API_StringArray *sarr;
  823. if(!strcmp(key, "attributeSelector")) {
  824. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  825. in->setAttributeSelector(*sarr);
  826. /* FIXME: sarr can be propperly by freed now */
  827. }
  828. break;
  829. }
  830. case IS_LONG:
  831. if(!strcmp(key, "mode"))
  832. in->setMode((*keydata)->value.lval);
  833. break;
  834. }
  835. zend_hash_move_forward(lht);
  836. }
  837. return(in);
  838. }
  839. static HW_API_insert_In *make_HW_API_insert_In(zval *arg1) {
  840. int count, i;
  841. HashTable *lht;
  842. HW_API_insert_In *in;
  843. lht = arg1->value.ht;
  844. if(0 == (count = zend_hash_num_elements(lht))) {
  845. return NULL;
  846. }
  847. in = new HW_API_insert_In();
  848. zend_hash_internal_pointer_reset(lht);
  849. for(i=0; i<count; i++) {
  850. ulong ind;
  851. char *key;
  852. zval **keydata;
  853. zend_hash_get_current_data(lht, (void **) &keydata);
  854. zend_hash_get_current_key(lht, &key, &ind, 0);
  855. switch((*keydata)->type) {
  856. case IS_OBJECT:
  857. if(!strcmp(key, "object")) {
  858. if(!strcmp((*keydata)->value.obj.ce->name, "hw_api_object")) {
  859. HW_API_Object *obj;
  860. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  861. in->setObject(*obj);
  862. }
  863. } else if(!strcmp(key, "parameters")) {
  864. if(!strcmp((*keydata)->value.obj.ce->name, "hw_api_object")) {
  865. HW_API_Object *obj;
  866. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  867. in->setParameters(*obj);
  868. }
  869. } else if(!strcmp(key, "content")) {
  870. if(!strcmp((*keydata)->value.obj.ce->name, "hw_api_content")) {
  871. HW_API_Content *obj;
  872. obj = (HW_API_Content *) php_hwapi_get_object(*keydata, le_hwapi_contentp);
  873. in->setContent(*obj);
  874. }
  875. }
  876. /* FIXME: HW_API_Object and HW_API_Content needs to be handelt */
  877. break;
  878. case IS_ARRAY: {
  879. HW_API_StringArray *sarr;
  880. if(!strcmp(key, "attributeSelector")) {
  881. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  882. in->setAttributeSelector(*sarr);
  883. /* FIXME: sarr can be propperly by freed now */
  884. }
  885. break;
  886. }
  887. case IS_LONG:
  888. if(!strcmp(key, "mode"))
  889. in->setMode((*keydata)->value.lval);
  890. break;
  891. }
  892. zend_hash_move_forward(lht);
  893. }
  894. return(in);
  895. }
  896. static HW_API_insertDocument_In *make_HW_API_insertDocument_In(zval *arg1) {
  897. int count, i;
  898. HashTable *lht;
  899. HW_API_insertDocument_In *in;
  900. lht = arg1->value.ht;
  901. if(0 == (count = zend_hash_num_elements(lht))) {
  902. return NULL;
  903. }
  904. in = new HW_API_insertDocument_In();
  905. zend_hash_internal_pointer_reset(lht);
  906. for(i=0; i<count; i++) {
  907. ulong ind;
  908. char *key;
  909. zval **keydata;
  910. zend_hash_get_current_data(lht, (void **) &keydata);
  911. zend_hash_get_current_key(lht, &key, &ind, 0);
  912. switch((*keydata)->type) {
  913. case IS_OBJECT:
  914. if(!strcmp(key, "object")) {
  915. if(!((*keydata)->value.obj.ce->name, "HW_API_Object")) {
  916. HW_API_Object *obj;
  917. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  918. in->setObject(*obj);
  919. }
  920. } else if(!strcmp(key, "parameters")) {
  921. if(!((*keydata)->value.obj.ce->name, "HW_API_Object")) {
  922. HW_API_Object *obj;
  923. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  924. in->setParameters(*obj);
  925. }
  926. } else if(!strcmp(key, "content")) {
  927. if(!((*keydata)->value.obj.ce->name, "HW_API_Content")) {
  928. HW_API_Content *obj;
  929. obj = (HW_API_Content *) php_hwapi_get_object(*keydata, le_hwapi_contentp);
  930. in->setContent(*obj);
  931. }
  932. }
  933. /* FIXME: HW_API_Object and HW_API_Content needs to be handelt */
  934. break;
  935. case IS_ARRAY: {
  936. HW_API_StringArray *sarr;
  937. if(!strcmp(key, "attributeSelector")) {
  938. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  939. in->setAttributeSelector(*sarr);
  940. /* FIXME: sarr can be propperly by freed now */
  941. }
  942. break;
  943. }
  944. case IS_LONG:
  945. if(!strcmp(key, "mode"))
  946. in->setMode((*keydata)->value.lval);
  947. break;
  948. case IS_STRING:
  949. if(!strcmp(key, "parentIdentifier"))
  950. in->setParentIdentifier((*keydata)->value.str.val);
  951. break;
  952. }
  953. zend_hash_move_forward(lht);
  954. }
  955. return(in);
  956. }
  957. static HW_API_insertCollection_In *make_HW_API_insertCollection_In(zval *arg1) {
  958. int count, i;
  959. HashTable *lht;
  960. HW_API_insertCollection_In *in;
  961. lht = arg1->value.ht;
  962. if(0 == (count = zend_hash_num_elements(lht))) {
  963. return NULL;
  964. }
  965. in = new HW_API_insertCollection_In();
  966. zend_hash_internal_pointer_reset(lht);
  967. for(i=0; i<count; i++) {
  968. ulong ind;
  969. char *key;
  970. zval **keydata;
  971. zend_hash_get_current_data(lht, (void **) &keydata);
  972. zend_hash_get_current_key(lht, &key, &ind, 0);
  973. switch((*keydata)->type) {
  974. case IS_STRING:
  975. if(!strcmp(key, "parentIdentifier"))
  976. in->setParentIdentifier((*keydata)->value.str.val);
  977. break;
  978. case IS_OBJECT:
  979. if(!strcmp(key, "object")) {
  980. if(!((*keydata)->value.obj.ce->name, "HW_API_Object")) {
  981. HW_API_Object *obj;
  982. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  983. in->setObject(*obj);
  984. }
  985. } else if(!strcmp(key, "parameters")) {
  986. if(!((*keydata)->value.obj.ce->name, "HW_API_Object")) {
  987. HW_API_Object *obj;
  988. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  989. in->setParameters(*obj);
  990. }
  991. }
  992. /* FIXME: HW_API_Object and HW_API_Content needs to be handelt */
  993. break;
  994. case IS_ARRAY: {
  995. HW_API_StringArray *sarr;
  996. if(!strcmp(key, "attributeSelector")) {
  997. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  998. in->setAttributeSelector(*sarr);
  999. /* FIXME: sarr can be propperly by freed now */
  1000. }
  1001. break;
  1002. }
  1003. }
  1004. zend_hash_move_forward(lht);
  1005. }
  1006. return(in);
  1007. }
  1008. static HW_API_insertAnchor_In *make_HW_API_insertAnchor_In(zval *arg1) {
  1009. int count, i;
  1010. HashTable *lht;
  1011. HW_API_insertAnchor_In *in;
  1012. lht = arg1->value.ht;
  1013. if(0 == (count = zend_hash_num_elements(lht))) {
  1014. return NULL;
  1015. }
  1016. in = new HW_API_insertAnchor_In();
  1017. zend_hash_internal_pointer_reset(lht);
  1018. for(i=0; i<count; i++) {
  1019. ulong ind;
  1020. char *key;
  1021. zval **keydata;
  1022. zend_hash_get_current_data(lht, (void **) &keydata);
  1023. zend_hash_get_current_key(lht, &key, &ind, 0);
  1024. switch((*keydata)->type) {
  1025. case IS_STRING:
  1026. if(!strcmp(key, "documentIdentifier"))
  1027. in->setDocumentIdentifier((*keydata)->value.str.val);
  1028. else if(!strcmp(key, "destinationIdentifier"))
  1029. in->setDestinationIdentifier((*keydata)->value.str.val);
  1030. else if(!strcmp(key, "hint"))
  1031. in->setHint((*keydata)->value.str.val);
  1032. break;
  1033. case IS_OBJECT:
  1034. if(!strcmp(key, "object")) {
  1035. if(!((*keydata)->value.obj.ce->name, "HW_API_Object")) {
  1036. HW_API_Object *obj;
  1037. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  1038. in->setObject(*obj);
  1039. }
  1040. } else if(!strcmp(key, "parameters")) {
  1041. if(!((*keydata)->value.obj.ce->name, "HW_API_Object")) {
  1042. HW_API_Object *obj;
  1043. obj = (HW_API_Object *) php_hwapi_get_object(*keydata, le_hwapi_objectp);
  1044. in->setParameters(*obj);
  1045. }
  1046. }
  1047. /* FIXME: HW_API_Object and HW_API_Content needs to be handelt */
  1048. break;
  1049. case IS_ARRAY: {
  1050. HW_API_StringArray *sarr;
  1051. if(!strcmp(key, "attributeSelector")) {
  1052. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1053. in->setAttributeSelector(*sarr);
  1054. /* FIXME: sarr can be propperly by freed now */
  1055. }
  1056. break;
  1057. }
  1058. }
  1059. zend_hash_move_forward(lht);
  1060. }
  1061. return(in);
  1062. }
  1063. static HW_API_srcAnchors_In *make_HW_API_srcAnchors_In(zval *arg1) {
  1064. int count, i;
  1065. HashTable *lht;
  1066. HW_API_srcAnchors_In *in;
  1067. lht = arg1->value.ht;
  1068. if(0 == (count = zend_hash_num_elements(lht))) {
  1069. return NULL;
  1070. }
  1071. in = new HW_API_srcAnchors_In();
  1072. zend_hash_internal_pointer_reset(lht);
  1073. for(i=0; i<count; i++) {
  1074. ulong ind;
  1075. char *key;
  1076. zval **keydata;
  1077. zend_hash_get_current_data(lht, (void **) &keydata);
  1078. zend_hash_get_current_key(lht, &key, &ind, 0);
  1079. switch((*keydata)->type) {
  1080. case IS_STRING:
  1081. if(!strcmp(key, "objectIdentifier"))
  1082. in->setObjectIdentifier((*keydata)->value.str.val);
  1083. else if(!strcmp(key, "objectQuery"))
  1084. in->setObjectQuery((*keydata)->value.str.val);
  1085. break;
  1086. case IS_ARRAY: {
  1087. HW_API_StringArray *sarr;
  1088. if(!strcmp(key, "attributeSelector")) {
  1089. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1090. in->setAttributeSelector(*sarr);
  1091. /* FIXME: sarr can be propperly by freed now */
  1092. }
  1093. break;
  1094. }
  1095. }
  1096. zend_hash_move_forward(lht);
  1097. }
  1098. return(in);
  1099. }
  1100. static HW_API_dstAnchors_In *make_HW_API_dstAnchors_In(zval *arg1) {
  1101. int count, i;
  1102. HashTable *lht;
  1103. HW_API_dstAnchors_In *in;
  1104. lht = arg1->value.ht;
  1105. if(0 == (count = zend_hash_num_elements(lht))) {
  1106. return NULL;
  1107. }
  1108. in = new HW_API_dstAnchors_In();
  1109. zend_hash_internal_pointer_reset(lht);
  1110. for(i=0; i<count; i++) {
  1111. ulong ind;
  1112. char *key;
  1113. zval **keydata;
  1114. zend_hash_get_current_data(lht, (void **) &keydata);
  1115. zend_hash_get_current_key(lht, &key, &ind, 0);
  1116. switch((*keydata)->type) {
  1117. case IS_STRING:
  1118. if(!strcmp(key, "objectIdentifier"))
  1119. in->setObjectIdentifier((*keydata)->value.str.val);
  1120. else if(!strcmp(key, "objectQuery"))
  1121. in->setObjectQuery((*keydata)->value.str.val);
  1122. break;
  1123. case IS_ARRAY: {
  1124. HW_API_StringArray *sarr;
  1125. if(!strcmp(key, "attributeSelector")) {
  1126. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1127. in->setAttributeSelector(*sarr);
  1128. /* FIXME: sarr can be propperly by freed now */
  1129. }
  1130. break;
  1131. }
  1132. }
  1133. zend_hash_move_forward(lht);
  1134. }
  1135. return(in);
  1136. }
  1137. static HW_API_dstOfSrcAnchor_In *make_HW_API_dstOfSrcAnchor_In(zval *arg1) {
  1138. int count, i;
  1139. HashTable *lht;
  1140. HW_API_dstOfSrcAnchor_In *in;
  1141. lht = arg1->value.ht;
  1142. if(0 == (count = zend_hash_num_elements(lht))) {
  1143. return NULL;
  1144. }
  1145. in = new HW_API_dstOfSrcAnchor_In();
  1146. zend_hash_internal_pointer_reset(lht);
  1147. for(i=0; i<count; i++) {
  1148. ulong ind;
  1149. char *key;
  1150. zval **keydata;
  1151. zend_hash_get_current_data(lht, (void **) &keydata);
  1152. zend_hash_get_current_key(lht, &key, &ind, 0);
  1153. switch((*keydata)->type) {
  1154. case IS_STRING:
  1155. if(!strcmp(key, "objectIdentifier"))
  1156. in->setObjectIdentifier((*keydata)->value.str.val);
  1157. break;
  1158. case IS_ARRAY: {
  1159. HW_API_StringArray *sarr;
  1160. if(!strcmp(key, "attributeSelector")) {
  1161. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1162. in->setAttributeSelector(*sarr);
  1163. /* FIXME: sarr can be propperly by freed now */
  1164. }
  1165. break;
  1166. }
  1167. }
  1168. zend_hash_move_forward(lht);
  1169. }
  1170. return(in);
  1171. }
  1172. static HW_API_objectByAnchor_In *make_HW_API_objectByAnchor_In(zval *arg1) {
  1173. int count, i;
  1174. HashTable *lht;
  1175. HW_API_objectByAnchor_In *in;
  1176. lht = arg1->value.ht;
  1177. if(0 == (count = zend_hash_num_elements(lht))) {
  1178. return NULL;
  1179. }
  1180. in = new HW_API_objectByAnchor_In();
  1181. zend_hash_internal_pointer_reset(lht);
  1182. for(i=0; i<count; i++) {
  1183. ulong ind;
  1184. char *key;
  1185. zval **keydata;
  1186. zend_hash_get_current_data(lht, (void **) &keydata);
  1187. zend_hash_get_current_key(lht, &key, &ind, 0);
  1188. switch((*keydata)->type) {
  1189. case IS_STRING:
  1190. if(!strcmp(key, "objectIdentifier"))
  1191. in->setObjectIdentifier((*keydata)->value.str.val);
  1192. break;
  1193. case IS_ARRAY: {
  1194. HW_API_StringArray *sarr;
  1195. if(!strcmp(key, "attributeSelector")) {
  1196. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1197. in->setAttributeSelector(*sarr);
  1198. /* FIXME: sarr can be propperly by freed now */
  1199. }
  1200. break;
  1201. }
  1202. }
  1203. zend_hash_move_forward(lht);
  1204. }
  1205. return(in);
  1206. }
  1207. static HW_API_srcsOfDst_In *make_HW_API_srcsOfDst_In(zval *arg1) {
  1208. int count, i;
  1209. HashTable *lht;
  1210. HW_API_srcsOfDst_In *in;
  1211. lht = arg1->value.ht;
  1212. if(0 == (count = zend_hash_num_elements(lht))) {
  1213. return NULL;
  1214. }
  1215. in = new HW_API_srcsOfDst_In();
  1216. zend_hash_internal_pointer_reset(lht);
  1217. for(i=0; i<count; i++) {
  1218. ulong ind;
  1219. char *key;
  1220. zval **keydata;
  1221. zend_hash_get_current_data(lht, (void **) &keydata);
  1222. zend_hash_get_current_key(lht, &key, &ind, 0);
  1223. switch((*keydata)->type) {
  1224. case IS_STRING:
  1225. if(!strcmp(key, "objectIdentifier"))
  1226. in->setObjectIdentifier((*keydata)->value.str.val);
  1227. else if(!strcmp(key, "objectQuery"))
  1228. in->setObjectQuery((*keydata)->value.str.val);
  1229. break;
  1230. case IS_ARRAY: {
  1231. HW_API_StringArray *sarr;
  1232. if(!strcmp(key, "attributeSelector")) {
  1233. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1234. in->setAttributeSelector(*sarr);
  1235. /* FIXME: sarr can be propperly by freed now */
  1236. }
  1237. break;
  1238. }
  1239. }
  1240. zend_hash_move_forward(lht);
  1241. }
  1242. return(in);
  1243. }
  1244. static HW_API_checkIn_In *make_HW_API_checkIn_In(zval *arg1) {
  1245. int count, i;
  1246. HashTable *lht;
  1247. HW_API_checkIn_In *in;
  1248. lht = arg1->value.ht;
  1249. if(0 == (count = zend_hash_num_elements(lht))) {
  1250. return NULL;
  1251. }
  1252. in = new HW_API_checkIn_In();
  1253. zend_hash_internal_pointer_reset(lht);
  1254. for(i=0; i<count; i++) {
  1255. ulong ind;
  1256. char *key;
  1257. zval **keydata;
  1258. zend_hash_get_current_data(lht, (void **) &keydata);
  1259. zend_hash_get_current_key(lht, &key, &ind, 0);
  1260. switch((*keydata)->type) {
  1261. case IS_STRING:
  1262. if(!strcmp(key, "objectIdentifier"))
  1263. in->setObjectIdentifier((*keydata)->value.str.val);
  1264. else if(!strcmp(key, "objectQuery"))
  1265. in->setObjectQuery((*keydata)->value.str.val);
  1266. else if(!strcmp(key, "version"))
  1267. in->setVersion((*keydata)->value.str.val);
  1268. else if(!strcmp(key, "comment"))
  1269. in->setComment((*keydata)->value.str.val);
  1270. break;
  1271. case IS_LONG:
  1272. if(!strcmp(key, "mode"))
  1273. in->setMode((*keydata)->value.lval);
  1274. break;
  1275. }
  1276. zend_hash_move_forward(lht);
  1277. }
  1278. return(in);
  1279. }
  1280. static HW_API_checkOut_In *make_HW_API_checkOut_In(zval *arg1) {
  1281. int count, i;
  1282. HashTable *lht;
  1283. HW_API_checkOut_In *in;
  1284. lht = arg1->value.ht;
  1285. if(0 == (count = zend_hash_num_elements(lht))) {
  1286. return NULL;
  1287. }
  1288. in = new HW_API_checkOut_In();
  1289. zend_hash_internal_pointer_reset(lht);
  1290. for(i=0; i<count; i++) {
  1291. ulong ind;
  1292. char *key;
  1293. zval **keydata;
  1294. zend_hash_get_current_data(lht, (void **) &keydata);
  1295. zend_hash_get_current_key(lht, &key, &ind, 0);
  1296. switch((*keydata)->type) {
  1297. case IS_STRING:
  1298. if(!strcmp(key, "objectIdentifier"))
  1299. in->setObjectIdentifier((*keydata)->value.str.val);
  1300. else if(!strcmp(key, "objectQuery"))
  1301. in->setObjectQuery((*keydata)->value.str.val);
  1302. else if(!strcmp(key, "version"))
  1303. in->setVersion((*keydata)->value.str.val);
  1304. break;
  1305. case IS_LONG:
  1306. if(!strcmp(key, "mode"))
  1307. in->setMode((*keydata)->value.lval);
  1308. break;
  1309. }
  1310. zend_hash_move_forward(lht);
  1311. }
  1312. return(in);
  1313. }
  1314. static HW_API_setCommittedVersion_In *make_HW_API_setCommittedVersion_In(zval *arg1) {
  1315. int count, i;
  1316. HashTable *lht;
  1317. HW_API_setCommittedVersion_In *in;
  1318. lht = arg1->value.ht;
  1319. if(0 == (count = zend_hash_num_elements(lht))) {
  1320. return NULL;
  1321. }
  1322. in = new HW_API_setCommittedVersion_In();
  1323. zend_hash_internal_pointer_reset(lht);
  1324. for(i=0; i<count; i++) {
  1325. ulong ind;
  1326. char *key;
  1327. zval **keydata;
  1328. zend_hash_get_current_data(lht, (void **) &keydata);
  1329. zend_hash_get_current_key(lht, &key, &ind, 0);
  1330. switch((*keydata)->type) {
  1331. case IS_STRING:
  1332. if(!strcmp(key, "objectIdentifier"))
  1333. in->setObjectIdentifier((*keydata)->value.str.val);
  1334. else if(!strcmp(key, "version"))
  1335. in->setVersion((*keydata)->value.str.val);
  1336. break;
  1337. case IS_ARRAY: {
  1338. HW_API_StringArray *sarr;
  1339. if(!strcmp(key, "attributeSelector")) {
  1340. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1341. in->setAttributeSelector(*sarr);
  1342. /* FIXME: sarr can be propperly be freed now */
  1343. }
  1344. break;
  1345. }
  1346. }
  1347. zend_hash_move_forward(lht);
  1348. }
  1349. return(in);
  1350. }
  1351. static HW_API_revert_In *make_HW_API_revert_In(zval *arg1) {
  1352. int count, i;
  1353. HashTable *lht;
  1354. HW_API_revert_In *in;
  1355. lht = arg1->value.ht;
  1356. if(0 == (count = zend_hash_num_elements(lht))) {
  1357. return NULL;
  1358. }
  1359. in = new HW_API_revert_In();
  1360. zend_hash_internal_pointer_reset(lht);
  1361. for(i=0; i<count; i++) {
  1362. ulong ind;
  1363. char *key;
  1364. zval **keydata;
  1365. zend_hash_get_current_data(lht, (void **) &keydata);
  1366. zend_hash_get_current_key(lht, &key, &ind, 0);
  1367. switch((*keydata)->type) {
  1368. case IS_STRING:
  1369. if(!strcmp(key, "objectIdentifier"))
  1370. in->setObjectIdentifier((*keydata)->value.str.val);
  1371. else if(!strcmp(key, "objectQuery"))
  1372. in->setObjectQuery((*keydata)->value.str.val);
  1373. else if(!strcmp(key, "version"))
  1374. in->setVersion((*keydata)->value.str.val);
  1375. break;
  1376. case IS_LONG:
  1377. if(!strcmp(key, "mode"))
  1378. in->setMode((*keydata)->value.lval);
  1379. break;
  1380. }
  1381. zend_hash_move_forward(lht);
  1382. }
  1383. return(in);
  1384. }
  1385. static HW_API_history_In *make_HW_API_history(zval *arg1) {
  1386. int count, i;
  1387. HashTable *lht;
  1388. HW_API_history_In *in;
  1389. lht = arg1->value.ht;
  1390. if(0 == (count = zend_hash_num_elements(lht))) {
  1391. return NULL;
  1392. }
  1393. in = new HW_API_history_In();
  1394. zend_hash_internal_pointer_reset(lht);
  1395. for(i=0; i<count; i++) {
  1396. ulong ind;
  1397. char *key;
  1398. zval **keydata;
  1399. zend_hash_get_current_data(lht, (void **) &keydata);
  1400. zend_hash_get_current_key(lht, &key, &ind, 0);
  1401. switch((*keydata)->type) {
  1402. case IS_STRING:
  1403. if(!strcmp(key, "objectIdentifier"))
  1404. in->setObjectIdentifier((*keydata)->value.str.val);
  1405. /* else if(!strcmp(key, "objectQuery"))
  1406. in->objectQuery((*keydata)->value.str.val);*/
  1407. break;
  1408. case IS_ARRAY: {
  1409. HW_API_StringArray *sarr;
  1410. if(!strcmp(key, "attributeSelector")) {
  1411. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1412. in->setAttributeSelector(*sarr);
  1413. /* FIXME: sarr can be propperly be freed now */
  1414. }
  1415. break;
  1416. }
  1417. }
  1418. zend_hash_move_forward(lht);
  1419. }
  1420. return(in);
  1421. }
  1422. static HW_API_removeVersion_In *make_HW_API_removeVersion_In(zval *arg1) {
  1423. int count, i;
  1424. HashTable *lht;
  1425. HW_API_removeVersion_In *in;
  1426. lht = arg1->value.ht;
  1427. if(0 == (count = zend_hash_num_elements(lht))) {
  1428. return NULL;
  1429. }
  1430. in = new HW_API_removeVersion_In();
  1431. zend_hash_internal_pointer_reset(lht);
  1432. for(i=0; i<count; i++) {
  1433. ulong ind;
  1434. char *key;
  1435. zval **keydata;
  1436. zend_hash_get_current_data(lht, (void **) &keydata);
  1437. zend_hash_get_current_key(lht, &key, &ind, 0);
  1438. switch((*keydata)->type) {
  1439. case IS_STRING:
  1440. if(!strcmp(key, "objectIdentifier"))
  1441. in->setObjectIdentifier((*keydata)->value.str.val);
  1442. else if(!strcmp(key, "version"))
  1443. in->setVersion((*keydata)->value.str.val);
  1444. break;
  1445. case IS_LONG:
  1446. if(!strcmp(key, "mode"))
  1447. in->setMode((*keydata)->value.lval);
  1448. break;
  1449. }
  1450. zend_hash_move_forward(lht);
  1451. }
  1452. return(in);
  1453. }
  1454. static HW_API_freeVersion_In *make_HW_API_freeVersion_In(zval *arg1) {
  1455. int count, i;
  1456. HashTable *lht;
  1457. HW_API_freeVersion_In *in;
  1458. lht = arg1->value.ht;
  1459. if(0 == (count = zend_hash_num_elements(lht))) {
  1460. return NULL;
  1461. }
  1462. in = new HW_API_freeVersion_In();
  1463. zend_hash_internal_pointer_reset(lht);
  1464. for(i=0; i<count; i++) {
  1465. ulong ind;
  1466. char *key;
  1467. zval **keydata;
  1468. zend_hash_get_current_data(lht, (void **) &keydata);
  1469. zend_hash_get_current_key(lht, &key, &ind, 0);
  1470. switch((*keydata)->type) {
  1471. case IS_STRING:
  1472. if(!strcmp(key, "objectIdentifier"))
  1473. in->setObjectIdentifier((*keydata)->value.str.val);
  1474. else if(!strcmp(key, "version"))
  1475. in->setVersion((*keydata)->value.str.val);
  1476. break;
  1477. case IS_ARRAY: {
  1478. HW_API_StringArray *sarr;
  1479. if(!strcmp(key, "attributeSelector")) {
  1480. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1481. in->setAttributeSelector(*sarr);
  1482. /* FIXME: sarr can be propperly be freed now */
  1483. }
  1484. break;
  1485. }
  1486. }
  1487. zend_hash_move_forward(lht);
  1488. }
  1489. return(in);
  1490. }
  1491. static HW_API_configurationHistory_In *make_HW_API_configurationHistory_In(zval *arg1) {
  1492. int count, i;
  1493. HashTable *lht;
  1494. HW_API_configurationHistory_In *in;
  1495. lht = arg1->value.ht;
  1496. if(0 == (count = zend_hash_num_elements(lht))) {
  1497. return NULL;
  1498. }
  1499. in = new HW_API_configurationHistory_In();
  1500. zend_hash_internal_pointer_reset(lht);
  1501. for(i=0; i<count; i++) {
  1502. ulong ind;
  1503. char *key;
  1504. zval **keydata;
  1505. zend_hash_get_current_data(lht, (void **) &keydata);
  1506. zend_hash_get_current_key(lht, &key, &ind, 0);
  1507. switch((*keydata)->type) {
  1508. case IS_STRING:
  1509. if(!strcmp(key, "objectIdentifier"))
  1510. in->setObjectIdentifier((*keydata)->value.str.val);
  1511. break;
  1512. }
  1513. zend_hash_move_forward(lht);
  1514. }
  1515. return(in);
  1516. }
  1517. static HW_API_saveConfiguration_In *make_HW_API_saveConfiguration_In(zval *arg1) {
  1518. int count, i;
  1519. HashTable *lht;
  1520. HW_API_saveConfiguration_In *in;
  1521. lht = arg1->value.ht;
  1522. if(0 == (count = zend_hash_num_elements(lht))) {
  1523. return NULL;
  1524. }
  1525. in = new HW_API_saveConfiguration_In();
  1526. zend_hash_internal_pointer_reset(lht);
  1527. for(i=0; i<count; i++) {
  1528. ulong ind;
  1529. char *key;
  1530. zval **keydata;
  1531. zend_hash_get_current_data(lht, (void **) &keydata);
  1532. zend_hash_get_current_key(lht, &key, &ind, 0);
  1533. switch((*keydata)->type) {
  1534. case IS_STRING:
  1535. if(!strcmp(key, "objectIdentifier"))
  1536. in->setObjectIdentifier((*keydata)->value.str.val);
  1537. else if(!strcmp(key, "version"))
  1538. in->setVersion((*keydata)->value.str.val);
  1539. else if(!strcmp(key, "comment"))
  1540. in->setComment((*keydata)->value.str.val);
  1541. break;
  1542. case IS_LONG:
  1543. if(!strcmp(key, "mode"))
  1544. in->setMode((*keydata)->value.lval);
  1545. break;
  1546. case IS_ARRAY: {
  1547. HW_API_StringArray *sarr;
  1548. if(!strcmp(key, "attributeSelector")) {
  1549. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1550. in->setAttributeSelector(*sarr);
  1551. /* FIXME: sarr can be propperly be freed now */
  1552. }
  1553. break;
  1554. }
  1555. }
  1556. zend_hash_move_forward(lht);
  1557. }
  1558. return(in);
  1559. }
  1560. static HW_API_restoreConfiguration_In *make_HW_API_restoreConfiguration_In(zval *arg1) {
  1561. int count, i;
  1562. HashTable *lht;
  1563. HW_API_restoreConfiguration_In *in;
  1564. lht = arg1->value.ht;
  1565. if(0 == (count = zend_hash_num_elements(lht))) {
  1566. return NULL;
  1567. }
  1568. in = new HW_API_restoreConfiguration_In();
  1569. zend_hash_internal_pointer_reset(lht);
  1570. for(i=0; i<count; i++) {
  1571. ulong ind;
  1572. char *key;
  1573. zval **keydata;
  1574. zend_hash_get_current_data(lht, (void **) &keydata);
  1575. zend_hash_get_current_key(lht, &key, &ind, 0);
  1576. switch((*keydata)->type) {
  1577. case IS_STRING:
  1578. if(!strcmp(key, "objectIdentifier"))
  1579. in->setObjectIdentifier((*keydata)->value.str.val);
  1580. else if(!strcmp(key, "version"))
  1581. in->setVersion((*keydata)->value.str.val);
  1582. break;
  1583. case IS_LONG:
  1584. if(!strcmp(key, "mode"))
  1585. in->setMode((*keydata)->value.lval);
  1586. break;
  1587. }
  1588. zend_hash_move_forward(lht);
  1589. }
  1590. return(in);
  1591. }
  1592. static HW_API_removeConfiguration_In *make_HW_API_removeConfiguration_In(zval *arg1) {
  1593. int count, i;
  1594. HashTable *lht;
  1595. HW_API_removeConfiguration_In *in;
  1596. lht = arg1->value.ht;
  1597. if(0 == (count = zend_hash_num_elements(lht))) {
  1598. return NULL;
  1599. }
  1600. in = new HW_API_removeConfiguration_In();
  1601. zend_hash_internal_pointer_reset(lht);
  1602. for(i=0; i<count; i++) {
  1603. ulong ind;
  1604. char *key;
  1605. zval **keydata;
  1606. zend_hash_get_current_data(lht, (void **) &keydata);
  1607. zend_hash_get_current_key(lht, &key, &ind, 0);
  1608. switch((*keydata)->type) {
  1609. case IS_STRING:
  1610. if(!strcmp(key, "objectIdentifier"))
  1611. in->setObjectIdentifier((*keydata)->value.str.val);
  1612. else if(!strcmp(key, "version"))
  1613. in->setVersion((*keydata)->value.str.val);
  1614. break;
  1615. }
  1616. zend_hash_move_forward(lht);
  1617. }
  1618. return(in);
  1619. }
  1620. static HW_API_mergeConfiguration_In *make_HW_API_mergeConfiguration_In(zval *arg1) {
  1621. int count, i;
  1622. HashTable *lht;
  1623. HW_API_mergeConfiguration_In *in;
  1624. lht = arg1->value.ht;
  1625. if(0 == (count = zend_hash_num_elements(lht))) {
  1626. return NULL;
  1627. }
  1628. in = new HW_API_mergeConfiguration_In();
  1629. zend_hash_internal_pointer_reset(lht);
  1630. for(i=0; i<count; i++) {
  1631. ulong ind;
  1632. char *key;
  1633. zval **keydata;
  1634. zend_hash_get_current_data(lht, (void **) &keydata);
  1635. zend_hash_get_current_key(lht, &key, &ind, 0);
  1636. switch((*keydata)->type) {
  1637. case IS_STRING:
  1638. if(!strcmp(key, "objectIdentifier"))
  1639. in->setObjectIdentifier((*keydata)->value.str.val);
  1640. else if(!strcmp(key, "version"))
  1641. in->setVersion((*keydata)->value.str.val);
  1642. break;
  1643. case IS_LONG:
  1644. if(!strcmp(key, "mode"))
  1645. in->setMode((*keydata)->value.lval);
  1646. break;
  1647. }
  1648. zend_hash_move_forward(lht);
  1649. }
  1650. return(in);
  1651. }
  1652. static HW_API_user_In *make_HW_API_user_In(zval *arg1) {
  1653. int count, i;
  1654. HashTable *lht;
  1655. HW_API_user_In *in;
  1656. lht = arg1->value.ht;
  1657. if(0 == (count = zend_hash_num_elements(lht))) {
  1658. return NULL;
  1659. }
  1660. in = new HW_API_user_In();
  1661. zend_hash_internal_pointer_reset(lht);
  1662. for(i=0; i<count; i++) {
  1663. ulong ind;
  1664. char *key;
  1665. zval **keydata;
  1666. zend_hash_get_current_data(lht, (void **) &keydata);
  1667. zend_hash_get_current_key(lht, &key, &ind, 0);
  1668. switch((*keydata)->type) {
  1669. case IS_ARRAY: {
  1670. HW_API_StringArray *sarr;
  1671. if(!strcmp(key, "attributeSelector")) {
  1672. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1673. in->setAttributeSelector(*sarr);
  1674. /* FIXME: sarr can be propperly be freed now */
  1675. }
  1676. break;
  1677. }
  1678. }
  1679. zend_hash_move_forward(lht);
  1680. }
  1681. return(in);
  1682. }
  1683. static HW_API_userlist_In *make_HW_API_userlist_In(zval *arg1) {
  1684. int count, i;
  1685. HashTable *lht;
  1686. HW_API_userlist_In *in;
  1687. lht = arg1->value.ht;
  1688. if(0 == (count = zend_hash_num_elements(lht))) {
  1689. return NULL;
  1690. }
  1691. in = new HW_API_userlist_In();
  1692. zend_hash_internal_pointer_reset(lht);
  1693. for(i=0; i<count; i++) {
  1694. ulong ind;
  1695. char *key;
  1696. zval **keydata;
  1697. zend_hash_get_current_data(lht, (void **) &keydata);
  1698. zend_hash_get_current_key(lht, &key, &ind, 0);
  1699. switch((*keydata)->type) {
  1700. case IS_ARRAY: {
  1701. HW_API_StringArray *sarr;
  1702. if(!strcmp(key, "attributeSelector")) {
  1703. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1704. in->setAttributeSelector(*sarr);
  1705. /* FIXME: sarr can be propperly be freed now */
  1706. }
  1707. break;
  1708. }
  1709. }
  1710. zend_hash_move_forward(lht);
  1711. }
  1712. return(in);
  1713. }
  1714. static HW_API_hwStat_In *make_HW_API_hwStat_In(zval *arg1) {
  1715. int count, i;
  1716. HashTable *lht;
  1717. HW_API_hwStat_In *in;
  1718. lht = arg1->value.ht;
  1719. if(0 == (count = zend_hash_num_elements(lht))) {
  1720. return NULL;
  1721. }
  1722. in = new HW_API_hwStat_In();
  1723. zend_hash_internal_pointer_reset(lht);
  1724. for(i=0; i<count; i++) {
  1725. ulong ind;
  1726. char *key;
  1727. zval **keydata;
  1728. zend_hash_get_current_data(lht, (void **) &keydata);
  1729. zend_hash_get_current_key(lht, &key, &ind, 0);
  1730. switch((*keydata)->type) {
  1731. case IS_ARRAY: {
  1732. HW_API_StringArray *sarr;
  1733. if(!strcmp(key, "attributeSelector")) {
  1734. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1735. in->setAttributeSelector(*sarr);
  1736. /* FIXME: sarr can be propperly be freed now */
  1737. }
  1738. break;
  1739. }
  1740. }
  1741. zend_hash_move_forward(lht);
  1742. }
  1743. return(in);
  1744. }
  1745. static HW_API_dcStat_In *make_HW_API_dcStat_In(zval *arg1) {
  1746. int count, i;
  1747. HashTable *lht;
  1748. HW_API_dcStat_In *in;
  1749. lht = arg1->value.ht;
  1750. if(0 == (count = zend_hash_num_elements(lht))) {
  1751. return NULL;
  1752. }
  1753. in = new HW_API_dcStat_In();
  1754. zend_hash_internal_pointer_reset(lht);
  1755. for(i=0; i<count; i++) {
  1756. ulong ind;
  1757. char *key;
  1758. zval **keydata;
  1759. zend_hash_get_current_data(lht, (void **) &keydata);
  1760. zend_hash_get_current_key(lht, &key, &ind, 0);
  1761. switch((*keydata)->type) {
  1762. case IS_ARRAY: {
  1763. HW_API_StringArray *sarr;
  1764. if(!strcmp(key, "attributeSelector")) {
  1765. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1766. in->setAttributeSelector(*sarr);
  1767. /* FIXME: sarr can be propperly be freed now */
  1768. }
  1769. break;
  1770. }
  1771. }
  1772. zend_hash_move_forward(lht);
  1773. }
  1774. return(in);
  1775. }
  1776. static HW_API_dbStat_In *make_HW_API_dbStat_In(zval *arg1) {
  1777. int count, i;
  1778. HashTable *lht;
  1779. HW_API_dbStat_In *in;
  1780. lht = arg1->value.ht;
  1781. if(0 == (count = zend_hash_num_elements(lht))) {
  1782. return NULL;
  1783. }
  1784. in = new HW_API_dbStat_In();
  1785. zend_hash_internal_pointer_reset(lht);
  1786. for(i=0; i<count; i++) {
  1787. ulong ind;
  1788. char *key;
  1789. zval **keydata;
  1790. zend_hash_get_current_data(lht, (void **) &keydata);
  1791. zend_hash_get_current_key(lht, &key, &ind, 0);
  1792. switch((*keydata)->type) {
  1793. case IS_ARRAY: {
  1794. HW_API_StringArray *sarr;
  1795. if(!strcmp(key, "attributeSelector")) {
  1796. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1797. in->setAttributeSelector(*sarr);
  1798. /* FIXME: sarr can be propperly be freed now */
  1799. }
  1800. break;
  1801. }
  1802. }
  1803. zend_hash_move_forward(lht);
  1804. }
  1805. return(in);
  1806. }
  1807. static HW_API_ftStat_In *make_HW_API_ftStat_In(zval *arg1) {
  1808. int count, i;
  1809. HashTable *lht;
  1810. HW_API_ftStat_In *in;
  1811. lht = arg1->value.ht;
  1812. if(0 == (count = zend_hash_num_elements(lht))) {
  1813. return NULL;
  1814. }
  1815. in = new HW_API_ftStat_In();
  1816. zend_hash_internal_pointer_reset(lht);
  1817. for(i=0; i<count; i++) {
  1818. ulong ind;
  1819. char *key;
  1820. zval **keydata;
  1821. zend_hash_get_current_data(lht, (void **) &keydata);
  1822. zend_hash_get_current_key(lht, &key, &ind, 0);
  1823. switch((*keydata)->type) {
  1824. case IS_ARRAY: {
  1825. HW_API_StringArray *sarr;
  1826. if(!strcmp(key, "attributeSelector")) {
  1827. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1828. in->setAttributeSelector(*sarr);
  1829. /* FIXME: sarr can be propperly be freed now */
  1830. }
  1831. break;
  1832. }
  1833. }
  1834. zend_hash_move_forward(lht);
  1835. }
  1836. return(in);
  1837. }
  1838. static HW_API_info_In *make_HW_API_info_In(zval *arg1) {
  1839. int count, i;
  1840. HashTable *lht;
  1841. HW_API_info_In *in;
  1842. lht = arg1->value.ht;
  1843. if(0 == (count = zend_hash_num_elements(lht))) {
  1844. return NULL;
  1845. }
  1846. in = new HW_API_info_In();
  1847. zend_hash_internal_pointer_reset(lht);
  1848. for(i=0; i<count; i++) {
  1849. ulong ind;
  1850. char *key;
  1851. zval **keydata;
  1852. zend_hash_get_current_data(lht, (void **) &keydata);
  1853. zend_hash_get_current_key(lht, &key, &ind, 0);
  1854. switch((*keydata)->type) {
  1855. case IS_ARRAY: {
  1856. HW_API_StringArray *sarr;
  1857. if(!strcmp(key, "attributeSelector")) {
  1858. sarr = make_HW_API_StringArray((*keydata)->value.ht);
  1859. in->setAttributeSelector(*sarr);
  1860. /* FIXME: sarr can be propperly be freed now */
  1861. }
  1862. break;
  1863. }
  1864. }
  1865. zend_hash_move_forward(lht);
  1866. }
  1867. return(in);
  1868. }
  1869. PHP_INI_BEGIN()
  1870. // STD_PHP_INI_ENTRY("hwapi.allow_persistent", "0", PHP_INI_SYSTEM, OnUpdateInt, allow_persistent, zend_hwapi_globals, hwapi_globals)
  1871. PHP_INI_END()
  1872. PHP_MINIT_FUNCTION(hwapi) {
  1873. ZEND_INIT_MODULE_GLOBALS(hwapi, php_hwapi_init_globals, NULL);
  1874. le_hwapip = zend_register_list_destructors_ex(php_free_hwapi, NULL, "hw_api", module_number);
  1875. le_hwapi_attributep = zend_register_list_destructors_ex(php_free_hwapi_attribute, NULL, "hw_api_attribute", module_number);
  1876. le_hwapi_objectp = zend_register_list_destructors_ex(php_free_hwapi_object, NULL, "hw_api_object", module_number);
  1877. le_hwapi_errorp = zend_register_list_destructors_ex(php_free_hwapi_error, NULL, "hw_api_error", module_number);
  1878. le_hwapi_contentp = zend_register_list_destructors_ex(php_free_hwapi_content, NULL, "hw_api_content", module_number);
  1879. le_hwapi_reasonp = zend_register_list_destructors_ex(php_free_hwapi_reason, NULL, "hw_api_reason", module_number);
  1880. hw_api_class_startup();
  1881. hw_api_object_class_startup();
  1882. hw_api_attribute_class_startup();
  1883. hw_api_error_class_startup();
  1884. hw_api_content_class_startup();
  1885. hw_api_reason_class_startup();
  1886. REGISTER_LONG_CONSTANT("HW_API_REMOVE_NORMAL", HW_API_remove_In::NORMAL, CONST_CS | CONST_PERSISTENT);
  1887. REGISTER_LONG_CONSTANT("HW_API_REMOVE_PHYSICAL", HW_API_remove_In::PHYSICAL, CONST_CS | CONST_PERSISTENT);
  1888. REGISTER_LONG_CONSTANT("HW_API_REMOVE_REMOVELINKS", HW_API_remove_In::REMOVELINKS, CONST_CS | CONST_PERSISTENT);
  1889. REGISTER_LONG_CONSTANT("HW_API_REMOVE_NONRECURSIVE", HW_API_remove_In::NONRECURSIVE, CONST_CS | CONST_PERSISTENT);
  1890. REGISTER_LONG_CONSTANT("HW_API_REPLACE_NORMAL", HW_API_replace_In::NORMAL, CONST_CS | CONST_PERSISTENT);
  1891. REGISTER_LONG_CONSTANT("HW_API_REPLACE_FORCE_VERSION_CONTROL", HW_API_replace_In::FORCE_VERSION_CONTROL, CONST_CS | CONST_PERSISTENT);
  1892. REGISTER_LONG_CONSTANT("HW_API_REPLACE_AUTOMATIC_CHECKOUT", HW_API_replace_In::AUTOMATIC_CHECKOUT, CONST_CS | CONST_PERSISTENT);
  1893. REGISTER_LONG_CONSTANT("HW_API_REPLACE_AUTOMATIC_CHECKIN", HW_API_replace_In::AUTOMATIC_CHECKIN, CONST_CS | CONST_PERSISTENT);
  1894. REGISTER_LONG_CONSTANT("HW_API_REPLACE_PLAIN", HW_API_replace_In::PLAIN, CONST_CS | CONST_PERSISTENT);
  1895. REGISTER_LONG_CONSTANT("HW_API_REPLACE_REVERT_IF_NOT_CHANGED", HW_API_replace_In::REVERT_IF_NOT_CHANGED, CONST_CS | CONST_PERSISTENT);
  1896. REGISTER_LONG_CONSTANT("HW_API_REPLACE_KEEP_TIME_MODIFIED", HW_API_replace_In::KEEP_TIME_MODIFIED, CONST_CS | CONST_PERSISTENT);
  1897. REGISTER_LONG_CONSTANT("HW_API_INSERT_NORMAL", HW_API_insert_In::NORMAL, CONST_CS | CONST_PERSISTENT);
  1898. REGISTER_LONG_CONSTANT("HW_API_INSERT_FORCE_VERSION_CONTROL", HW_API_insert_In::FORCE_VERSION_CONTROL, CONST_CS | CONST_PERSISTENT);
  1899. REGISTER_LONG_CONSTANT("HW_API_INSERT_AUTOMATIC_CHECKOUT", HW_API_insert_In::AUTOMATIC_CHECKOUT, CONST_CS | CONST_PERSISTENT);
  1900. REGISTER_LONG_CONSTANT("HW_API_INSERT_PLAIN", HW_API_insert_In::PLAIN, CONST_CS | CONST_PERSISTENT);
  1901. REGISTER_LONG_CONSTANT("HW_API_INSERT_KEEP_TIME_MODIFIED", HW_API_insert_In::KEEP_TIME_MODIFIED, CONST_CS | CONST_PERSISTENT);
  1902. REGISTER_LONG_CONSTANT("HW_API_INSERT_DELAY_INDEXING", HW_API_insert_In::DELAY_INDEXING, CONST_CS | CONST_PERSISTENT);
  1903. REGISTER_LONG_CONSTANT("HW_API_LOCK_NORMAL", HW_API_lock_In::NORMAL, CONST_CS | CONST_PERSISTENT);
  1904. REGISTER_LONG_CONSTANT("HW_API_LOCK_RECURSIVE", HW_API_lock_In::RECURSIVE, CONST_CS | CONST_PERSISTENT);
  1905. REGISTER_LONG_CONSTANT("HW_API_LOCK_SESSION", HW_API_lock_In::SESSION, CONST_CS | CONST_PERSISTENT);
  1906. REGISTER_LONG_CONSTANT("HW_API_CONTENT_ALLLINKS", HW_API_content_In::ALLLINKS, CONST_CS | CONST_PERSISTENT);
  1907. REGISTER_LONG_CONSTANT("HW_API_CONTENT_REACHABLELINKS", HW_API_content_In::REACHABLELINKS, CONST_CS | CONST_PERSISTENT);
  1908. REGISTER_LONG_CONSTANT("HW_API_CONTENT_PLAIN", HW_API_content_In::PLAIN, CONST_CS | CONST_PERSISTENT);
  1909. REGISTER_LONG_CONSTANT("HW_API_REASON_ERROR", HW_API_Reason::HW_API_ERROR, CONST_CS | CONST_PERSISTENT);
  1910. REGISTER_LONG_CONSTANT("HW_API_REASON_WARNING", HW_API_Reason::HW_API_WARNING, CONST_CS | CONST_PERSISTENT);
  1911. REGISTER_LONG_CONSTANT("HW_API_REASON_MESSAGE", HW_API_Reason::HW_API_MESSAGE, CONST_CS | CONST_PERSISTENT);
  1912. /* Make sure there are at least default values, though the MessageFilePath
  1913. * is bogus. If it isn't set at all the web server dies.
  1914. */
  1915. HW_API_init_In initargs;
  1916. initargs.setArgv0("PHP HWAPI");
  1917. initargs.setMessageFilePath("");
  1918. HW_API::init(initargs);
  1919. return SUCCESS;
  1920. }
  1921. PHP_MSHUTDOWN_FUNCTION(hwapi) {
  1922. return SUCCESS;
  1923. }
  1924. PHP_RINIT_FUNCTION(hwapi) {
  1925. return SUCCESS;
  1926. }
  1927. PHP_MINFO_FUNCTION(hwapi) {
  1928. php_info_print_table_start();
  1929. php_info_print_table_row(2, "Hyperwave API Support", "enabled");
  1930. php_info_print_table_end();
  1931. }
  1932. /* {{{ proto string hwapi_dummy(int link, int id, int msgid)
  1933. Hyperwave dummy function */
  1934. PHP_FUNCTION(hwapi_dummy) {
  1935. pval **arg1, **arg2, **arg3;
  1936. int link, id, type, msgid;
  1937. RETURN_TRUE;
  1938. }
  1939. /* }}} */
  1940. /* {{{ proto void hwapi_init(string hostname, int port)
  1941. Hyperwave initialisation */
  1942. PHP_FUNCTION(hwapi_init) {
  1943. zval **argv[2], *id;
  1944. HW_API_init_In initargs;
  1945. HW_API_init_Out out;
  1946. int ret;
  1947. HW_API_HGCSP *db;
  1948. zval *rv;
  1949. int argc = ZEND_NUM_ARGS();
  1950. if (((argc < 1) || (argc > 2)) || zend_get_parameters_array_ex(argc, argv) == FAILURE) {
  1951. WRONG_PARAM_COUNT;
  1952. }
  1953. id = getThis();
  1954. convert_to_string_ex(argv[0]);
  1955. initargs.setArgv0("PHP HWAPI");
  1956. initargs.setMessageFilePath(Z_STRVAL_PP(argv[0]));
  1957. if(argc == 2) {
  1958. convert_to_string_ex(argv[1]);
  1959. initargs.setWhatString(Z_STRVAL_PP(argv[1])) ;
  1960. }
  1961. if(id) {
  1962. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  1963. if(!db) {
  1964. RETURN_FALSE;
  1965. }
  1966. out = db->init(initargs);
  1967. } else {
  1968. out = HW_API::init(initargs);
  1969. }
  1970. if (out.error().error()) {
  1971. HW_API_Error *err = new HW_API_Error(out.error());
  1972. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  1973. SEPARATE_ZVAL(&rv);
  1974. *return_value = *rv;
  1975. FREE_ZVAL(rv);
  1976. return;
  1977. }
  1978. RETURN_TRUE;
  1979. }
  1980. /* }}} */
  1981. /* {{{ proto string hwapi_hgcsp(string hostname, int port)
  1982. Hyperwave dummy function */
  1983. PHP_FUNCTION(hwapi_hgcsp) {
  1984. zval **argv[2];
  1985. HW_API_HGCSP *db;
  1986. zval *rv;
  1987. int argc = ZEND_NUM_ARGS();
  1988. if (((argc < 1) || (argc > 2)) || zend_get_parameters_array_ex(argc, argv) == FAILURE) {
  1989. WRONG_PARAM_COUNT;
  1990. }
  1991. convert_to_string_ex(argv[0]);
  1992. if(argc == 2) {
  1993. convert_to_long_ex(argv[1]);
  1994. db = new HW_API_HGCSP(Z_STRVAL_PP(argv[0]), Z_LVAL_PP(argv[1]));
  1995. } else {
  1996. db = new HW_API_HGCSP(Z_STRVAL_PP(argv[0]));
  1997. }
  1998. rv = php_hwapi_object_new((HW_API_HGCSP *) db, le_hwapip);
  1999. SEPARATE_ZVAL(&rv);
  2000. *return_value = *rv;
  2001. FREE_ZVAL(rv);
  2002. // ret = zend_list_insert(db, le_hwapip);
  2003. /* construct an object with some methods */
  2004. // object_init_ex(return_value, hw_api_class_entry_ptr);
  2005. // add_property_resource(return_value, "this", ret);
  2006. }
  2007. /* }}} */
  2008. /* {{{ proto object hwapi_object(array object_in)
  2009. Hyperwave dummy function */
  2010. PHP_FUNCTION(hwapi_object) {
  2011. pval **arg1, *rv, *id;
  2012. HW_API_Object *newobj;
  2013. HW_API_object_In *in;
  2014. HW_API_object_Out out;
  2015. HW_API_HGCSP *db;
  2016. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2017. WRONG_PARAM_COUNT;
  2018. }
  2019. convert_to_array_ex(arg1);
  2020. id = getThis();
  2021. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2022. if(!db) {
  2023. RETURN_FALSE;
  2024. }
  2025. in = make_HW_API_object_In(*arg1);
  2026. out = db->object(*in);
  2027. delete in;
  2028. if (out.error().error()) {
  2029. HW_API_Error *err = new HW_API_Error(out.error());
  2030. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  2031. SEPARATE_ZVAL(&rv);
  2032. *return_value = *rv;
  2033. FREE_ZVAL(rv);
  2034. return;
  2035. }
  2036. //Frage: Diese Zeile erzeugt erst mit dem Konstruktor von HW_API_Object
  2037. //eine Kopie und danach durch das assign. Wie kann man das verhindern.
  2038. newobj = new HW_API_Object();
  2039. *newobj = out.object();
  2040. // newobj = new HW_API_Object(out.object());
  2041. rv = php_hwapi_object_new(newobj, le_hwapi_objectp);
  2042. SEPARATE_ZVAL(&rv);
  2043. *return_value = *rv;
  2044. FREE_ZVAL(rv);
  2045. }
  2046. /* }}} */
  2047. /* {{{ proto string hwapi_mychildren(array parameters)
  2048. Hyperwave dummy function */
  2049. PHP_FUNCTION(hwapi_mychildren) {
  2050. zval **arg1, *id, *rv;
  2051. HW_API_ObjectArray objarr;
  2052. HW_API_children_In *in;
  2053. HW_API_children_Out out;
  2054. HW_API_HGCSP *db;
  2055. int i;
  2056. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2057. WRONG_PARAM_COUNT;
  2058. }
  2059. convert_to_string_ex(arg1);
  2060. id = getThis();
  2061. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2062. if(!db) {
  2063. RETURN_FALSE;
  2064. }
  2065. in = new HW_API_children_In();
  2066. in->setObjectIdentifier(Z_STRVAL_PP(arg1));
  2067. out = db->children(*in);
  2068. delete in;
  2069. if (out.error().error()) {
  2070. HW_API_Error *err = new HW_API_Error(out.error());
  2071. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  2072. SEPARATE_ZVAL(&rv);
  2073. *return_value = *rv;
  2074. FREE_ZVAL(rv);
  2075. return;
  2076. } else {
  2077. objarr = (HW_API_ObjectArray) out.objects();
  2078. }
  2079. if (array_init(return_value) == FAILURE) {
  2080. RETURN_FALSE;
  2081. }
  2082. for(i=0; i<objarr.count(); i++) {
  2083. zval *child;
  2084. HW_API_Object obj, *objp;
  2085. objarr.object(i, obj);
  2086. objp = new HW_API_Object(obj);
  2087. child = php_hwapi_object_new(objp, le_hwapi_objectp);
  2088. add_next_index_zval(return_value, child);
  2089. }
  2090. return;
  2091. for(i=0; i<objarr.count(); i++) {
  2092. HW_API_Object obj;
  2093. HW_API_Attribute attr;
  2094. objarr.object(i, obj);
  2095. obj.attribute("GOid", attr);
  2096. add_next_index_string(return_value, (char *) attr.value().string(), 1);
  2097. }
  2098. }
  2099. /* }}} */
  2100. /* {{{ proto string hwapi_children(array parameters)
  2101. Hyperwave dummy function */
  2102. PHP_FUNCTION(hwapi_children) {
  2103. zval **arg1, *id, *rv;
  2104. HW_API_ObjectArray objarr;
  2105. HW_API_children_In *in;
  2106. HW_API_children_Out out;
  2107. HW_API_HGCSP *db;
  2108. int i;
  2109. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2110. WRONG_PARAM_COUNT;
  2111. }
  2112. convert_to_array_ex(arg1);
  2113. id = getThis();
  2114. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2115. if(!db) {
  2116. RETURN_FALSE;
  2117. }
  2118. in = make_HW_API_children_In(*arg1);
  2119. out = db->children(*in);
  2120. delete in;
  2121. if (out.error().error()) {
  2122. HW_API_Error *err = new HW_API_Error(out.error());
  2123. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  2124. SEPARATE_ZVAL(&rv);
  2125. *return_value = *rv;
  2126. FREE_ZVAL(rv);
  2127. return;
  2128. } else {
  2129. objarr = (HW_API_ObjectArray) out.objects();
  2130. }
  2131. objectArray2indexArray(&return_value, &objarr);
  2132. }
  2133. /* }}} */
  2134. /* {{{ proto string hwapi_parents(string hostname, int port)
  2135. Hyperwave dummy function */
  2136. PHP_FUNCTION(hwapi_parents) {
  2137. zval **arg1, *id, *rv;
  2138. HW_API_ObjectArray objarr;
  2139. HW_API_parents_In *in;
  2140. HW_API_parents_Out out;
  2141. HW_API_HGCSP *db;
  2142. int i;
  2143. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2144. WRONG_PARAM_COUNT;
  2145. }
  2146. convert_to_array_ex(arg1);
  2147. id = getThis();
  2148. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2149. if(!db) {
  2150. RETURN_FALSE;
  2151. }
  2152. in = make_HW_API_parents_In(*arg1);
  2153. out = db->parents(*in);
  2154. delete in;
  2155. if (out.error().error()) {
  2156. HW_API_Error *err = new HW_API_Error(out.error());
  2157. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  2158. SEPARATE_ZVAL(&rv);
  2159. *return_value = *rv;
  2160. FREE_ZVAL(rv);
  2161. return;
  2162. } else {
  2163. objarr = (HW_API_ObjectArray) out.objects();
  2164. }
  2165. objectArray2indexArray(&return_value, &objarr);
  2166. }
  2167. /* }}} */
  2168. /* {{{ proto string hwapi_find(array parameters)
  2169. Finds objects */
  2170. PHP_FUNCTION(hwapi_find) {
  2171. zval **arg1, *id, *rv;
  2172. HW_API_ObjectArray objarr;
  2173. HW_API_find_In *in;
  2174. HW_API_find_Out out;
  2175. HW_API_HGCSP *db;
  2176. int i;
  2177. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2178. WRONG_PARAM_COUNT;
  2179. }
  2180. convert_to_array_ex(arg1);
  2181. id = getThis();
  2182. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2183. if(!db) {
  2184. RETURN_FALSE;
  2185. }
  2186. in = make_HW_API_find_In(*arg1);
  2187. out = db->find(*in);
  2188. delete in;
  2189. if (out.error().error()) {
  2190. HW_API_Error *err = new HW_API_Error(out.error());
  2191. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  2192. SEPARATE_ZVAL(&rv);
  2193. *return_value = *rv;
  2194. FREE_ZVAL(rv);
  2195. return;
  2196. }
  2197. objarr = (HW_API_ObjectArray) out.objects();
  2198. /* FIXME: No a good idea to return just the objects. There is actually
  2199. * more to return. Changing this to an object of type hw_api_find_out would
  2200. * mean to change hw_api_parents() and hw_api_children() as well. */
  2201. if (array_init(return_value) == FAILURE) {
  2202. RETURN_FALSE;
  2203. }
  2204. /* FIXME: More than just the list of objects is returned by find() */
  2205. if(0 == objectArray2indexArray(&rv, &objarr)) {
  2206. RETURN_FALSE;
  2207. }
  2208. zend_hash_add(return_value->value.ht, "objects", 8, &rv, sizeof(zval *), NULL);
  2209. add_assoc_long(return_value, "endIndex", out.endIndex());
  2210. add_assoc_bool(return_value, "haveMore", out.haveMore() ? true : false);
  2211. add_assoc_long(return_value, "numberOfThingsFound", out.numberOfThingsFound());
  2212. }
  2213. /* }}} */
  2214. /* {{{ proto string hwapi_identify(string hostname, int port)
  2215. Hyperwave dummy function */
  2216. PHP_FUNCTION(hwapi_identify) {
  2217. pval **arg1, *id, *rv;
  2218. HW_API_identify_In *in;
  2219. HW_API_identify_Out out;
  2220. HW_API_HGCSP *db;
  2221. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2222. WRONG_PARAM_COUNT;
  2223. }
  2224. convert_to_array_ex(arg1);
  2225. id = getThis();
  2226. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2227. if(!db) {
  2228. RETURN_FALSE;
  2229. }
  2230. in = make_HW_API_identify_In(*arg1);
  2231. out = db->identify(*in);
  2232. delete in;
  2233. if (out.error().error()) {
  2234. HW_API_Error *err = new HW_API_Error(out.error());
  2235. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  2236. SEPARATE_ZVAL(&rv);
  2237. *return_value = *rv;
  2238. FREE_ZVAL(rv);
  2239. return;
  2240. }
  2241. printf("hwapi_identify\n");
  2242. RETURN_TRUE;
  2243. }
  2244. /* }}} */
  2245. /* {{{ proto string hwapi_remove(array parameters)
  2246. Remove an object */
  2247. PHP_FUNCTION(hwapi_remove) {
  2248. pval **arg1, *id, *rv;
  2249. HW_API_remove_In *in;
  2250. HW_API_remove_Out out;
  2251. HW_API_HGCSP *db;
  2252. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2253. WRONG_PARAM_COUNT;
  2254. }
  2255. convert_to_array_ex(arg1);
  2256. id = getThis();
  2257. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2258. if(!db) {
  2259. RETURN_FALSE;
  2260. }
  2261. in = make_HW_API_remove_In(*arg1);
  2262. out = db->remove(*in);
  2263. delete in;
  2264. if (out.error().error()) {
  2265. HW_API_Error *err = new HW_API_Error(out.error());
  2266. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2267. SEPARATE_ZVAL(&rv);
  2268. *return_value = *rv;
  2269. FREE_ZVAL(rv);
  2270. return;
  2271. }
  2272. printf("hwapi_remove\n");
  2273. RETURN_TRUE;
  2274. }
  2275. /* }}} */
  2276. /* {{{ proto string hwapi_content(string hostname, int port)
  2277. Retrieve content of object */
  2278. PHP_FUNCTION(hwapi_content) {
  2279. pval **arg1, *id, *rv;
  2280. HW_API_content_In *in;
  2281. HW_API_content_Out out;
  2282. HW_API_HGCSP *db;
  2283. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2284. WRONG_PARAM_COUNT;
  2285. }
  2286. convert_to_array_ex(arg1);
  2287. id = getThis();
  2288. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2289. if(!db) {
  2290. RETURN_FALSE;
  2291. }
  2292. in = make_HW_API_content_In(*arg1);
  2293. out = db->content(*in);
  2294. delete in;
  2295. if (!out.error().error()) {
  2296. HW_API_Content *content = new HW_API_Content(out.content());
  2297. rv = php_hwapi_object_new(content, le_hwapi_contentp);
  2298. } else {
  2299. HW_API_Error *err = new HW_API_Error(out.error());
  2300. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2301. }
  2302. SEPARATE_ZVAL(&rv);
  2303. *return_value = *rv;
  2304. FREE_ZVAL(rv);
  2305. }
  2306. /* }}} */
  2307. /* {{{ proto string hwapi_copy(array parameters)
  2308. Hyperwave dummy function */
  2309. PHP_FUNCTION(hwapi_copy) {
  2310. pval **arg1, *id, *rv;
  2311. HW_API_copy_In *in;
  2312. HW_API_copy_Out out;
  2313. HW_API_HGCSP *db;
  2314. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2315. WRONG_PARAM_COUNT;
  2316. }
  2317. convert_to_array_ex(arg1);
  2318. id = getThis();
  2319. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2320. if(!db) {
  2321. RETURN_FALSE;
  2322. }
  2323. in = make_HW_API_copy_In(*arg1);
  2324. out = db->copy(*in);
  2325. delete in;
  2326. if (!out.error().error()) {
  2327. HW_API_Object *object = new HW_API_Object(out.object());
  2328. rv = php_hwapi_object_new((HW_API_Object*) object, le_hwapi_objectp);
  2329. } else {
  2330. HW_API_Error *err = new HW_API_Error(out.error());
  2331. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  2332. }
  2333. SEPARATE_ZVAL(&rv);
  2334. *return_value = *rv;
  2335. FREE_ZVAL(rv);
  2336. printf("hwapi_copy\n");
  2337. }
  2338. /* }}} */
  2339. /* {{{ proto string hwapi_link(array parameters)
  2340. Hyperwave dummy function */
  2341. PHP_FUNCTION(hwapi_link) {
  2342. pval **arg1, *id, *rv;
  2343. HW_API_link_In *in;
  2344. HW_API_link_Out out;
  2345. HW_API_HGCSP *db;
  2346. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2347. WRONG_PARAM_COUNT;
  2348. }
  2349. convert_to_array_ex(arg1);
  2350. id = getThis();
  2351. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2352. if(!db) {
  2353. RETURN_FALSE;
  2354. }
  2355. in = make_HW_API_link_In(*arg1);
  2356. out = db->link(*in);
  2357. delete in;
  2358. if (out.error().error()) {
  2359. HW_API_Error *err = new HW_API_Error(out.error());
  2360. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2361. SEPARATE_ZVAL(&rv);
  2362. *return_value = *rv;
  2363. FREE_ZVAL(rv);
  2364. return;
  2365. }
  2366. printf("hwapi_link\n");
  2367. RETURN_TRUE;
  2368. }
  2369. /* }}} */
  2370. /* {{{ proto string hwapi_move(array parameters)
  2371. Hyperwave dummy function */
  2372. PHP_FUNCTION(hwapi_move) {
  2373. pval **arg1, *id, *rv;
  2374. HW_API_move_In *in;
  2375. HW_API_move_Out out;
  2376. HW_API_HGCSP *db;
  2377. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2378. WRONG_PARAM_COUNT;
  2379. }
  2380. convert_to_array_ex(arg1);
  2381. id = getThis();
  2382. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2383. if(!db) {
  2384. RETURN_FALSE;
  2385. }
  2386. in = make_HW_API_move_In(*arg1);
  2387. out = db->move(*in);
  2388. delete in;
  2389. if (out.error().error()) {
  2390. HW_API_Error *err = new HW_API_Error(out.error());
  2391. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2392. SEPARATE_ZVAL(&rv);
  2393. *return_value = *rv;
  2394. FREE_ZVAL(rv);
  2395. return;
  2396. }
  2397. printf("hwapi_move\n");
  2398. RETURN_TRUE;
  2399. }
  2400. /* }}} */
  2401. /* {{{ proto string hwapi_lock(array parameters)
  2402. Hyperwave dummy function */
  2403. PHP_FUNCTION(hwapi_lock) {
  2404. pval **arg1, *id, *rv;
  2405. HW_API_lock_In *in;
  2406. HW_API_lock_Out out;
  2407. HW_API_HGCSP *db;
  2408. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2409. WRONG_PARAM_COUNT;
  2410. }
  2411. convert_to_array_ex(arg1);
  2412. id = getThis();
  2413. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2414. if(!db) {
  2415. RETURN_FALSE;
  2416. }
  2417. in = make_HW_API_lock_In(*arg1);
  2418. out = db->lock(*in);
  2419. delete in;
  2420. if (out.error().error()) {
  2421. HW_API_Error *err = new HW_API_Error(out.error());
  2422. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2423. SEPARATE_ZVAL(&rv);
  2424. *return_value = *rv;
  2425. FREE_ZVAL(rv);
  2426. return;
  2427. }
  2428. printf("hwapi_lock\n");
  2429. RETURN_TRUE;
  2430. }
  2431. /* }}} */
  2432. /* {{{ proto string hwapi_unlock(array parameters)
  2433. Hyperwave dummy function */
  2434. PHP_FUNCTION(hwapi_unlock) {
  2435. pval **arg1, *id, *rv;
  2436. HW_API_unlock_In *in;
  2437. HW_API_unlock_Out out;
  2438. HW_API_HGCSP *db;
  2439. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2440. WRONG_PARAM_COUNT;
  2441. }
  2442. convert_to_array_ex(arg1);
  2443. id = getThis();
  2444. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2445. if(!db) {
  2446. RETURN_FALSE;
  2447. }
  2448. in = make_HW_API_unlock_In(*arg1);
  2449. out = db->unlock(*in);
  2450. delete in;
  2451. if (out.error().error()) {
  2452. HW_API_Error *err = new HW_API_Error(out.error());
  2453. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2454. SEPARATE_ZVAL(&rv);
  2455. *return_value = *rv;
  2456. FREE_ZVAL(rv);
  2457. return;
  2458. }
  2459. printf("hwapi_unlock\n");
  2460. RETURN_TRUE;
  2461. }
  2462. /* }}} */
  2463. /* {{{ proto string hwapi_replace(array parameters)
  2464. Hyperwave dummy function */
  2465. PHP_FUNCTION(hwapi_replace) {
  2466. pval **arg1, *id, *rv;
  2467. HW_API_replace_In *in;
  2468. HW_API_replace_Out out;
  2469. HW_API_HGCSP *db;
  2470. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2471. WRONG_PARAM_COUNT;
  2472. }
  2473. convert_to_array_ex(arg1);
  2474. id = getThis();
  2475. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2476. if(!db) {
  2477. RETURN_FALSE;
  2478. }
  2479. in = make_HW_API_replace_In(*arg1);
  2480. out = db->replace(*in);
  2481. delete in;
  2482. if (!out.error().error()) {
  2483. HW_API_Object *object = new HW_API_Object(out.object());
  2484. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  2485. } else {
  2486. HW_API_Error *err = new HW_API_Error(out.error());
  2487. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2488. }
  2489. SEPARATE_ZVAL(&rv);
  2490. *return_value = *rv;
  2491. FREE_ZVAL(rv);
  2492. }
  2493. /* }}} */
  2494. /* {{{ proto string hwapi_insert(array parameters)
  2495. Hyperwave dummy function */
  2496. PHP_FUNCTION(hwapi_insert) {
  2497. pval **arg1, *id, *rv;
  2498. HW_API_insert_In *in;
  2499. HW_API_insert_Out out;
  2500. HW_API_HGCSP *db;
  2501. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2502. WRONG_PARAM_COUNT;
  2503. }
  2504. convert_to_array_ex(arg1);
  2505. id = getThis();
  2506. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2507. if(!db) {
  2508. RETURN_FALSE;
  2509. }
  2510. in = make_HW_API_insert_In(*arg1);
  2511. out = db->insert(*in);
  2512. delete in;
  2513. if (!out.error().error()) {
  2514. HW_API_Object *object = new HW_API_Object(out.object());
  2515. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  2516. } else {
  2517. HW_API_Error *err = new HW_API_Error(out.error());
  2518. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2519. }
  2520. SEPARATE_ZVAL(&rv);
  2521. *return_value = *rv;
  2522. FREE_ZVAL(rv);
  2523. }
  2524. /* }}} */
  2525. /* {{{ proto string hwapi_insertdocument(array parameters)
  2526. Hyperwave dummy function */
  2527. PHP_FUNCTION(hwapi_insertdocument) {
  2528. pval **arg1, *id, *rv;
  2529. HW_API_insertDocument_In *in;
  2530. HW_API_insertDocument_Out out;
  2531. HW_API_HGCSP *db;
  2532. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2533. WRONG_PARAM_COUNT;
  2534. }
  2535. convert_to_array_ex(arg1);
  2536. id = getThis();
  2537. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2538. if(!db) {
  2539. RETURN_FALSE;
  2540. }
  2541. in = make_HW_API_insertDocument_In(*arg1);
  2542. out = db->insertDocument(*in);
  2543. delete in;
  2544. if (!out.error().error()) {
  2545. HW_API_Object *object = new HW_API_Object(out.object());
  2546. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  2547. } else {
  2548. HW_API_Error *err = new HW_API_Error(out.error());
  2549. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2550. }
  2551. SEPARATE_ZVAL(&rv);
  2552. *return_value = *rv;
  2553. FREE_ZVAL(rv);
  2554. printf("hwapi_insertdocument\n");
  2555. }
  2556. /* }}} */
  2557. /* {{{ proto string hwapi_insertcollection(array parameters)
  2558. Hyperwave dummy function */
  2559. PHP_FUNCTION(hwapi_insertcollection) {
  2560. pval **arg1, *id, *rv;
  2561. HW_API_insertCollection_In *in;
  2562. HW_API_insertCollection_Out out;
  2563. HW_API_HGCSP *db;
  2564. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2565. WRONG_PARAM_COUNT;
  2566. }
  2567. convert_to_array_ex(arg1);
  2568. id = getThis();
  2569. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2570. if(!db) {
  2571. RETURN_FALSE;
  2572. }
  2573. in = make_HW_API_insertCollection_In(*arg1);
  2574. out = db->insertCollection(*in);
  2575. delete in;
  2576. if (!out.error().error()) {
  2577. HW_API_Object *object = new HW_API_Object(out.object());
  2578. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  2579. } else {
  2580. HW_API_Error *err = new HW_API_Error(out.error());
  2581. rv = php_hwapi_object_new((HW_API_Error *) &err, le_hwapi_errorp);
  2582. }
  2583. SEPARATE_ZVAL(&rv);
  2584. *return_value = *rv;
  2585. FREE_ZVAL(rv);
  2586. printf("hwapi_insertcollection\n");
  2587. }
  2588. /* }}} */
  2589. /* {{{ proto string hwapi_insertanchor(array parameters)
  2590. Hyperwave dummy function */
  2591. PHP_FUNCTION(hwapi_insertanchor) {
  2592. pval **arg1, *id, *rv;
  2593. HW_API_insertAnchor_In *in;
  2594. HW_API_insertAnchor_Out out;
  2595. HW_API_HGCSP *db;
  2596. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2597. WRONG_PARAM_COUNT;
  2598. }
  2599. convert_to_array_ex(arg1);
  2600. id = getThis();
  2601. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2602. if(!db) {
  2603. RETURN_FALSE;
  2604. }
  2605. in = make_HW_API_insertAnchor_In(*arg1);
  2606. out = db->insertAnchor(*in);
  2607. delete in;
  2608. if (!out.error().error()) {
  2609. HW_API_Object *object = new HW_API_Object(out.object());
  2610. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  2611. } else {
  2612. HW_API_Error *err = new HW_API_Error(out.error());
  2613. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2614. }
  2615. SEPARATE_ZVAL(&rv);
  2616. *return_value = *rv;
  2617. FREE_ZVAL(rv);
  2618. printf("hwapi_insertanchor\n");
  2619. }
  2620. /* }}} */
  2621. /* {{{ proto string hwapi_srcanchors(array parameters)
  2622. Hyperwave dummy function */
  2623. PHP_FUNCTION(hwapi_srcanchors) {
  2624. pval **arg1, *id, *rv;
  2625. HW_API_ObjectArray objarr;
  2626. HW_API_srcAnchors_In *in;
  2627. HW_API_srcAnchors_Out out;
  2628. HW_API_HGCSP *db;
  2629. int i;
  2630. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2631. WRONG_PARAM_COUNT;
  2632. }
  2633. convert_to_array_ex(arg1);
  2634. id = getThis();
  2635. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2636. if(!db) {
  2637. RETURN_FALSE;
  2638. }
  2639. in = make_HW_API_srcAnchors_In(*arg1);
  2640. out = db->srcAnchors(*in);
  2641. delete in;
  2642. if (out.error().error()) {
  2643. HW_API_Error *err = new HW_API_Error(out.error());
  2644. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2645. SEPARATE_ZVAL(&rv);
  2646. *return_value = *rv;
  2647. FREE_ZVAL(rv);
  2648. return;
  2649. } else {
  2650. objarr = (HW_API_ObjectArray) out.objects();
  2651. }
  2652. objectArray2indexArray(&return_value, &objarr);
  2653. }
  2654. /* }}} */
  2655. /* {{{ proto string hwapi_dstanchors(array parameters)
  2656. Hyperwave dummy function */
  2657. PHP_FUNCTION(hwapi_dstanchors) {
  2658. pval **arg1, *id, *rv;
  2659. HW_API_ObjectArray objarr;
  2660. HW_API_dstAnchors_In *in;
  2661. HW_API_dstAnchors_Out out;
  2662. HW_API_HGCSP *db;
  2663. int i;
  2664. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2665. WRONG_PARAM_COUNT;
  2666. }
  2667. convert_to_array_ex(arg1);
  2668. id = getThis();
  2669. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2670. if(!db) {
  2671. RETURN_FALSE;
  2672. }
  2673. in = make_HW_API_dstAnchors_In(*arg1);
  2674. out = db->dstAnchors(*in);
  2675. delete in;
  2676. if (out.error().error()) {
  2677. HW_API_Error *err = new HW_API_Error(out.error());
  2678. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2679. SEPARATE_ZVAL(&rv);
  2680. *return_value = *rv;
  2681. FREE_ZVAL(rv);
  2682. return;
  2683. } else {
  2684. objarr = (HW_API_ObjectArray) out.objects();
  2685. }
  2686. objectArray2indexArray(&return_value, &objarr);
  2687. }
  2688. /* }}} */
  2689. /* {{{ proto string hwapi_objectbyanchor(array parameters)
  2690. Hyperwave dummy function */
  2691. PHP_FUNCTION(hwapi_objectbyanchor) {
  2692. pval **arg1, *id, *rv;
  2693. HW_API_objectByAnchor_In *in;
  2694. HW_API_objectByAnchor_Out out;
  2695. HW_API_HGCSP *db;
  2696. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2697. WRONG_PARAM_COUNT;
  2698. }
  2699. convert_to_array_ex(arg1);
  2700. id = getThis();
  2701. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2702. if(!db) {
  2703. RETURN_FALSE;
  2704. }
  2705. in = make_HW_API_objectByAnchor_In(*arg1);
  2706. /* FIXME: return value of any make_HW_API_xxx function should be checked
  2707. * for NULL
  2708. */
  2709. out = db->objectByAnchor(*in);
  2710. delete in;
  2711. if (!out.error().error()) {
  2712. HW_API_Object *object = new HW_API_Object(out.object());
  2713. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  2714. } else {
  2715. HW_API_Error *err = new HW_API_Error(out.error());
  2716. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2717. }
  2718. SEPARATE_ZVAL(&rv);
  2719. *return_value = *rv;
  2720. FREE_ZVAL(rv);
  2721. printf("hwapi_objectbyanchor\n");
  2722. }
  2723. /* }}} */
  2724. /* {{{ proto string hwapi_dstofsrcanchor(array parameters)
  2725. Hyperwave dummy function */
  2726. PHP_FUNCTION(hwapi_dstofsrcanchor) {
  2727. pval **arg1, *id, *rv;
  2728. HW_API_dstOfSrcAnchor_In *in;
  2729. HW_API_dstOfSrcAnchor_Out out;
  2730. HW_API_HGCSP *db;
  2731. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2732. WRONG_PARAM_COUNT;
  2733. }
  2734. convert_to_array_ex(arg1);
  2735. id = getThis();
  2736. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2737. if(!db) {
  2738. RETURN_FALSE;
  2739. }
  2740. in = make_HW_API_dstOfSrcAnchor_In(*arg1);
  2741. out = db->dstOfSrcAnchor(*in);
  2742. delete in;
  2743. if (!out.error().error()) {
  2744. HW_API_Object *object = new HW_API_Object(out.object());
  2745. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  2746. } else {
  2747. HW_API_Error *err = new HW_API_Error(out.error());
  2748. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2749. }
  2750. SEPARATE_ZVAL(&rv);
  2751. *return_value = *rv;
  2752. FREE_ZVAL(rv);
  2753. printf("hwapi_dstofsrcanchor\n");
  2754. }
  2755. /* }}} */
  2756. /* {{{ proto string hwapi_srcsofdst(array parameters)
  2757. Hyperwave dummy function */
  2758. PHP_FUNCTION(hwapi_srcsofdst) {
  2759. pval **arg1, *id, *rv;
  2760. HW_API_ObjectArray objarr;
  2761. HW_API_srcsOfDst_In *in;
  2762. HW_API_srcsOfDst_Out out;
  2763. HW_API_HGCSP *db;
  2764. int i;
  2765. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2766. WRONG_PARAM_COUNT;
  2767. }
  2768. convert_to_array_ex(arg1);
  2769. id = getThis();
  2770. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2771. if(!db) {
  2772. RETURN_FALSE;
  2773. }
  2774. in = make_HW_API_srcsOfDst_In(*arg1);
  2775. out = db->srcsOfDst(*in);
  2776. delete in;
  2777. if (out.error().error()) {
  2778. HW_API_Error *err = new HW_API_Error(out.error());
  2779. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2780. SEPARATE_ZVAL(&rv);
  2781. *return_value = *rv;
  2782. FREE_ZVAL(rv);
  2783. return;
  2784. } else {
  2785. objarr = (HW_API_ObjectArray) out.objects();
  2786. }
  2787. objectArray2indexArray(&return_value, &objarr);
  2788. }
  2789. /* }}} */
  2790. /* {{{ proto string hwapi_checkin(array parameters)
  2791. Checking in a document */
  2792. PHP_FUNCTION(hwapi_checkin) {
  2793. pval **arg1, *id, *rv;
  2794. HW_API_ObjectArray objarr;
  2795. HW_API_checkIn_In *in;
  2796. HW_API_checkIn_Out out;
  2797. HW_API_HGCSP *db;
  2798. int i;
  2799. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2800. WRONG_PARAM_COUNT;
  2801. }
  2802. convert_to_array_ex(arg1);
  2803. id = getThis();
  2804. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2805. if(!db) {
  2806. RETURN_FALSE;
  2807. }
  2808. in = make_HW_API_checkIn_In(*arg1);
  2809. out = db->checkIn(*in);
  2810. delete in;
  2811. if (out.error().error()) {
  2812. HW_API_Error *err = new HW_API_Error(out.error());
  2813. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2814. SEPARATE_ZVAL(&rv);
  2815. *return_value = *rv;
  2816. FREE_ZVAL(rv);
  2817. return;
  2818. } else {
  2819. RETURN_TRUE;
  2820. }
  2821. printf("hwapi_checkin\n");
  2822. }
  2823. /* }}} */
  2824. /* {{{ proto string hwapi_checkout(array parameters)
  2825. Checking out a document */
  2826. PHP_FUNCTION(hwapi_checkout) {
  2827. pval **arg1, *id, *rv;
  2828. HW_API_ObjectArray objarr;
  2829. HW_API_checkOut_In *in;
  2830. HW_API_checkOut_Out out;
  2831. HW_API_HGCSP *db;
  2832. int i;
  2833. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2834. WRONG_PARAM_COUNT;
  2835. }
  2836. convert_to_array_ex(arg1);
  2837. id = getThis();
  2838. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2839. if(!db) {
  2840. RETURN_FALSE;
  2841. }
  2842. in = make_HW_API_checkOut_In(*arg1);
  2843. out = db->checkOut(*in);
  2844. delete in;
  2845. if (out.error().error()) {
  2846. HW_API_Error *err = new HW_API_Error(out.error());
  2847. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2848. SEPARATE_ZVAL(&rv);
  2849. *return_value = *rv;
  2850. FREE_ZVAL(rv);
  2851. return;
  2852. } else {
  2853. RETURN_TRUE;
  2854. }
  2855. printf("hwapi_checkout\n");
  2856. }
  2857. /* }}} */
  2858. /* {{{ proto string hwapi_setcommittedversion(array parameters)
  2859. setcommittedversion */
  2860. PHP_FUNCTION(hwapi_setcommittedversion) {
  2861. pval **arg1, *id, *rv;
  2862. HW_API_ObjectArray objarr;
  2863. HW_API_setCommittedVersion_In *in;
  2864. HW_API_setCommittedVersion_Out out;
  2865. HW_API_HGCSP *db;
  2866. int i;
  2867. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2868. WRONG_PARAM_COUNT;
  2869. }
  2870. convert_to_array_ex(arg1);
  2871. id = getThis();
  2872. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2873. if(!db) {
  2874. RETURN_FALSE;
  2875. }
  2876. in = make_HW_API_setCommittedVersion_In(*arg1);
  2877. out = db->setCommittedVersion(*in);
  2878. delete in;
  2879. if (!out.error().error()) {
  2880. HW_API_Object *object = new HW_API_Object(out.object());
  2881. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  2882. } else {
  2883. HW_API_Error *err = new HW_API_Error(out.error());
  2884. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2885. }
  2886. SEPARATE_ZVAL(&rv);
  2887. *return_value = *rv;
  2888. FREE_ZVAL(rv);
  2889. printf("hwapi_setcommittedversion\n");
  2890. }
  2891. /* }}} */
  2892. /* {{{ proto string hwapi_revert(array parameters)
  2893. Reverting to a former document */
  2894. PHP_FUNCTION(hwapi_revert) {
  2895. pval **arg1, *id, *rv;
  2896. HW_API_ObjectArray objarr;
  2897. HW_API_revert_In *in;
  2898. HW_API_revert_Out out;
  2899. HW_API_HGCSP *db;
  2900. int i;
  2901. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2902. WRONG_PARAM_COUNT;
  2903. }
  2904. convert_to_array_ex(arg1);
  2905. id = getThis();
  2906. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2907. if(!db) {
  2908. RETURN_FALSE;
  2909. }
  2910. in = make_HW_API_revert_In(*arg1);
  2911. out = db->revert(*in);
  2912. delete in;
  2913. if (out.error().error()) {
  2914. HW_API_Error *err = new HW_API_Error(out.error());
  2915. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2916. SEPARATE_ZVAL(&rv);
  2917. *return_value = *rv;
  2918. FREE_ZVAL(rv);
  2919. return;
  2920. } else {
  2921. RETURN_TRUE;
  2922. }
  2923. printf("hwapi_revert\n");
  2924. }
  2925. /* }}} */
  2926. /* {{{ proto string hwapi_history(array parameters)
  2927. history */
  2928. PHP_FUNCTION(hwapi_history) {
  2929. pval **arg1, *id, *rv;
  2930. HW_API_ObjectArray objarr;
  2931. HW_API_history_In *in;
  2932. HW_API_history_Out out;
  2933. HW_API_HGCSP *db;
  2934. int i;
  2935. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2936. WRONG_PARAM_COUNT;
  2937. }
  2938. convert_to_array_ex(arg1);
  2939. id = getThis();
  2940. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2941. if(!db) {
  2942. RETURN_FALSE;
  2943. }
  2944. in = make_HW_API_history(*arg1);
  2945. out = db->history(*in);
  2946. delete in;
  2947. if (out.error().error()) {
  2948. HW_API_Error *err = new HW_API_Error(out.error());
  2949. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  2950. SEPARATE_ZVAL(&rv);
  2951. *return_value = *rv;
  2952. FREE_ZVAL(rv);
  2953. return;
  2954. } else {
  2955. objarr = (HW_API_ObjectArray) out.objects();
  2956. }
  2957. objectArray2indexArray(&return_value, &objarr);
  2958. }
  2959. /* }}} */
  2960. /* {{{ proto string hwapi_removeversion(array parameters)
  2961. Reverting to a former document */
  2962. PHP_FUNCTION(hwapi_removeversion) {
  2963. pval **arg1, *id, *rv;
  2964. HW_API_ObjectArray objarr;
  2965. HW_API_removeVersion_In *in;
  2966. HW_API_removeVersion_Out out;
  2967. HW_API_HGCSP *db;
  2968. int i;
  2969. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  2970. WRONG_PARAM_COUNT;
  2971. }
  2972. convert_to_array_ex(arg1);
  2973. id = getThis();
  2974. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  2975. if(!db) {
  2976. RETURN_FALSE;
  2977. }
  2978. in = make_HW_API_removeVersion_In(*arg1);
  2979. out = db->removeVersion(*in);
  2980. delete in;
  2981. if (out.error().error()) {
  2982. HW_API_Error *err = new HW_API_Error(out.error());
  2983. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  2984. SEPARATE_ZVAL(&rv);
  2985. *return_value = *rv;
  2986. FREE_ZVAL(rv);
  2987. return;
  2988. } else {
  2989. RETURN_TRUE;
  2990. }
  2991. printf("hwapi_removeversion\n");
  2992. }
  2993. /* }}} */
  2994. /* {{{ proto object hwapi_freeversion(array parameters)
  2995. freeversion */
  2996. PHP_FUNCTION(hwapi_freeversion) {
  2997. pval **arg1, *id, *rv;
  2998. HW_API_ObjectArray objarr;
  2999. HW_API_freeVersion_In *in;
  3000. HW_API_freeVersion_Out out;
  3001. HW_API_HGCSP *db;
  3002. int i;
  3003. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3004. WRONG_PARAM_COUNT;
  3005. }
  3006. convert_to_array_ex(arg1);
  3007. id = getThis();
  3008. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3009. if(!db) {
  3010. RETURN_FALSE;
  3011. }
  3012. in = make_HW_API_freeVersion_In(*arg1);
  3013. out = db->freeVersion(*in);
  3014. delete in;
  3015. if (!out.error().error()) {
  3016. HW_API_Object *object = new HW_API_Object(out.object());
  3017. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  3018. } else {
  3019. HW_API_Error *err = new HW_API_Error(out.error());
  3020. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3021. }
  3022. SEPARATE_ZVAL(&rv);
  3023. *return_value = *rv;
  3024. FREE_ZVAL(rv);
  3025. printf("hwapi_freeversion\n");
  3026. }
  3027. /* }}} */
  3028. /* {{{ proto array hwapi_configurationhistory(array parameters)
  3029. Returns configuration history of object */
  3030. PHP_FUNCTION(hwapi_configurationhistory) {
  3031. zval **arg1, *id, *rv;
  3032. HW_API_ObjectArray objarr;
  3033. HW_API_configurationHistory_In *in;
  3034. HW_API_configurationHistory_Out out;
  3035. HW_API_HGCSP *db;
  3036. int i;
  3037. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3038. WRONG_PARAM_COUNT;
  3039. }
  3040. convert_to_array_ex(arg1);
  3041. id = getThis();
  3042. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3043. if(!db) {
  3044. RETURN_FALSE;
  3045. }
  3046. in = make_HW_API_configurationHistory_In(*arg1);
  3047. out = db->configurationHistory(*in);
  3048. delete in;
  3049. if (out.error().error()) {
  3050. HW_API_Error *err = new HW_API_Error(out.error());
  3051. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  3052. SEPARATE_ZVAL(&rv);
  3053. *return_value = *rv;
  3054. FREE_ZVAL(rv);
  3055. return;
  3056. } else {
  3057. objarr = (HW_API_ObjectArray) out.objects();
  3058. }
  3059. objectArray2indexArray(&return_value, &objarr);
  3060. }
  3061. /* }}} */
  3062. /* {{{ proto object hwapi_saveconfiguration(array parameters)
  3063. Save configuration for an object */
  3064. PHP_FUNCTION(hwapi_saveconfiguration) {
  3065. pval **arg1, *id, *rv;
  3066. HW_API_ObjectArray objarr;
  3067. HW_API_saveConfiguration_In *in;
  3068. HW_API_saveConfiguration_Out out;
  3069. HW_API_HGCSP *db;
  3070. int i;
  3071. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3072. WRONG_PARAM_COUNT;
  3073. }
  3074. convert_to_array_ex(arg1);
  3075. id = getThis();
  3076. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3077. if(!db) {
  3078. RETURN_FALSE;
  3079. }
  3080. in = make_HW_API_saveConfiguration_In(*arg1);
  3081. out = db->saveConfiguration(*in);
  3082. delete in;
  3083. if (!out.error().error()) {
  3084. HW_API_Object *object = new HW_API_Object(out.object());
  3085. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  3086. } else {
  3087. HW_API_Error *err = new HW_API_Error(out.error());
  3088. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3089. }
  3090. SEPARATE_ZVAL(&rv);
  3091. *return_value = *rv;
  3092. FREE_ZVAL(rv);
  3093. printf("hwapi_saveconfiguration\n");
  3094. }
  3095. /* }}} */
  3096. /* {{{ proto object hwapi_restoreconfiguration(array parameters)
  3097. Restore configuration for an object */
  3098. PHP_FUNCTION(hwapi_restoreconfiguration) {
  3099. pval **arg1, *id, *rv;
  3100. HW_API_ObjectArray objarr;
  3101. HW_API_restoreConfiguration_In *in;
  3102. HW_API_restoreConfiguration_Out out;
  3103. HW_API_HGCSP *db;
  3104. int i;
  3105. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3106. WRONG_PARAM_COUNT;
  3107. }
  3108. convert_to_array_ex(arg1);
  3109. id = getThis();
  3110. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3111. if(!db) {
  3112. RETURN_FALSE;
  3113. }
  3114. in = make_HW_API_restoreConfiguration_In(*arg1);
  3115. out = db->restoreConfiguration(*in);
  3116. delete in;
  3117. if (!out.error().error()) {
  3118. RETURN_STRING((char *) (out.progressIdentifier().string()), 1);
  3119. } else {
  3120. HW_API_Error *err = new HW_API_Error(out.error());
  3121. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3122. }
  3123. SEPARATE_ZVAL(&rv);
  3124. *return_value = *rv;
  3125. FREE_ZVAL(rv);
  3126. printf("hwapi_restoreconfiguration\n");
  3127. }
  3128. /* }}} */
  3129. /* {{{ proto object hwapi_mergeconfiguration(array parameters)
  3130. Merge configuration for an object */
  3131. PHP_FUNCTION(hwapi_mergeconfiguration) {
  3132. pval **arg1, *id, *rv;
  3133. HW_API_ObjectArray objarr;
  3134. HW_API_mergeConfiguration_In *in;
  3135. HW_API_mergeConfiguration_Out out;
  3136. HW_API_HGCSP *db;
  3137. int i;
  3138. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3139. WRONG_PARAM_COUNT;
  3140. }
  3141. convert_to_array_ex(arg1);
  3142. id = getThis();
  3143. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3144. if(!db) {
  3145. RETURN_FALSE;
  3146. }
  3147. in = make_HW_API_mergeConfiguration_In(*arg1);
  3148. out = db->mergeConfiguration(*in);
  3149. delete in;
  3150. if (!out.error().error()) {
  3151. RETURN_STRING((char *) (out.progressIdentifier().string()), 1);
  3152. } else {
  3153. HW_API_Error *err = new HW_API_Error(out.error());
  3154. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3155. }
  3156. SEPARATE_ZVAL(&rv);
  3157. *return_value = *rv;
  3158. FREE_ZVAL(rv);
  3159. printf("hwapi_mergeconfiguration\n");
  3160. }
  3161. /* }}} */
  3162. /* {{{ proto object hwapi_removeconfiguration(array parameters)
  3163. Removes configuration */
  3164. PHP_FUNCTION(hwapi_removeconfiguration) {
  3165. pval **arg1, *id, *rv;
  3166. HW_API_ObjectArray objarr;
  3167. HW_API_removeConfiguration_In *in;
  3168. HW_API_removeConfiguration_Out out;
  3169. HW_API_HGCSP *db;
  3170. int i;
  3171. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3172. WRONG_PARAM_COUNT;
  3173. }
  3174. convert_to_array_ex(arg1);
  3175. id = getThis();
  3176. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3177. if(!db) {
  3178. RETURN_FALSE;
  3179. }
  3180. in = make_HW_API_removeConfiguration_In(*arg1);
  3181. out = db->removeConfiguration(*in);
  3182. delete in;
  3183. if (out.error().error()) {
  3184. HW_API_Error *err = new HW_API_Error(out.error());
  3185. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3186. SEPARATE_ZVAL(&rv);
  3187. *return_value = *rv;
  3188. FREE_ZVAL(rv);
  3189. return;
  3190. } else {
  3191. RETURN_TRUE;
  3192. }
  3193. printf("hwapi_removeconfiguration\n");
  3194. }
  3195. /* }}} */
  3196. /* {{{ proto string hwapi_user(array parameters)
  3197. Returns information about user */
  3198. PHP_FUNCTION(hwapi_user) {
  3199. pval **arg1, *id, *rv;
  3200. HW_API_user_In *in;
  3201. HW_API_user_Out out;
  3202. HW_API_HGCSP *db;
  3203. int argc;
  3204. id = getThis();
  3205. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3206. if(!db) {
  3207. RETURN_FALSE;
  3208. }
  3209. argc = ZEND_NUM_ARGS();
  3210. switch(argc) {
  3211. case 0:
  3212. out = db->user(HW_API_user_In());
  3213. break;
  3214. case 1:
  3215. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3216. WRONG_PARAM_COUNT;
  3217. }
  3218. convert_to_array_ex(arg1);
  3219. in = make_HW_API_user_In(*arg1);
  3220. if(NULL == in)
  3221. out = db->user(HW_API_user_In());
  3222. else
  3223. out = db->user(*in);
  3224. delete in;
  3225. break;
  3226. default:
  3227. WRONG_PARAM_COUNT;
  3228. }
  3229. if (!out.error().error()) {
  3230. HW_API_Object *object = new HW_API_Object(out.object());
  3231. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  3232. } else {
  3233. HW_API_Error *err = new HW_API_Error(out.error());
  3234. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3235. }
  3236. SEPARATE_ZVAL(&rv);
  3237. *return_value = *rv;
  3238. FREE_ZVAL(rv);
  3239. }
  3240. /* }}} */
  3241. /* {{{ proto string hwapi_userlist(array parameters)
  3242. Returns list of login in users */
  3243. PHP_FUNCTION(hwapi_userlist) {
  3244. zval **arg1, *id, *rv;
  3245. HW_API_userlist_In *in;
  3246. HW_API_userlist_Out out;
  3247. HW_API_ObjectArray objarr;
  3248. HW_API_HGCSP *db;
  3249. int i;
  3250. int argc;
  3251. id = getThis();
  3252. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3253. if(!db) {
  3254. RETURN_FALSE;
  3255. }
  3256. argc = ZEND_NUM_ARGS();
  3257. switch(argc) {
  3258. case 0:
  3259. out = db->userlist(HW_API_userlist_In());
  3260. break;
  3261. case 1:
  3262. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3263. WRONG_PARAM_COUNT;
  3264. }
  3265. convert_to_array_ex(arg1);
  3266. in = make_HW_API_userlist_In(*arg1);
  3267. if(NULL == in)
  3268. out = db->userlist(HW_API_userlist_In());
  3269. else
  3270. out = db->userlist(*in);
  3271. delete in;
  3272. break;
  3273. default:
  3274. WRONG_PARAM_COUNT;
  3275. }
  3276. if (out.error().error()) {
  3277. HW_API_Error *err = new HW_API_Error(out.error());
  3278. rv = php_hwapi_object_new((HW_API_Error *) err, le_hwapi_errorp);
  3279. SEPARATE_ZVAL(&rv);
  3280. *return_value = *rv;
  3281. FREE_ZVAL(rv);
  3282. return;
  3283. } else {
  3284. objarr = (HW_API_ObjectArray) out.objects();
  3285. }
  3286. objectArray2indexArray(&return_value, &objarr);
  3287. }
  3288. /* }}} */
  3289. /* {{{ proto string hwapi_hwstat(array parameters)
  3290. Returns information about hgserver */
  3291. PHP_FUNCTION(hwapi_hwstat) {
  3292. pval **arg1, *id, *rv;
  3293. HW_API_hwStat_In *in;
  3294. HW_API_hwStat_Out out;
  3295. HW_API_HGCSP *db;
  3296. int argc;
  3297. id = getThis();
  3298. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3299. if(!db) {
  3300. RETURN_FALSE;
  3301. }
  3302. argc = ZEND_NUM_ARGS();
  3303. switch(argc) {
  3304. case 0:
  3305. out = db->hwStat(HW_API_hwStat_In());
  3306. break;
  3307. case 1:
  3308. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3309. WRONG_PARAM_COUNT;
  3310. }
  3311. convert_to_array_ex(arg1);
  3312. in = make_HW_API_hwStat_In(*arg1);
  3313. if(NULL == in)
  3314. out = db->hwStat(HW_API_hwStat_In());
  3315. else
  3316. out = db->hwStat(*in);
  3317. delete in;
  3318. break;
  3319. default:
  3320. WRONG_PARAM_COUNT;
  3321. }
  3322. if (!out.error().error()) {
  3323. HW_API_Object *object = new HW_API_Object(out.object());
  3324. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  3325. } else {
  3326. HW_API_Error *err = new HW_API_Error(out.error());
  3327. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3328. }
  3329. SEPARATE_ZVAL(&rv);
  3330. *return_value = *rv;
  3331. FREE_ZVAL(rv);
  3332. }
  3333. /* }}} */
  3334. /* {{{ proto string hwapi_dcstat(array parameters)
  3335. Returns information about hgserver */
  3336. PHP_FUNCTION(hwapi_dcstat) {
  3337. pval **arg1, *id, *rv;
  3338. HW_API_dcStat_In *in;
  3339. HW_API_dcStat_Out out;
  3340. HW_API_HGCSP *db;
  3341. int argc;
  3342. id = getThis();
  3343. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3344. if(!db) {
  3345. RETURN_FALSE;
  3346. }
  3347. argc = ZEND_NUM_ARGS();
  3348. switch(argc) {
  3349. case 0:
  3350. out = db->dcStat(HW_API_dcStat_In());
  3351. break;
  3352. case 1:
  3353. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3354. WRONG_PARAM_COUNT;
  3355. }
  3356. convert_to_array_ex(arg1);
  3357. in = make_HW_API_dcStat_In(*arg1);
  3358. if(NULL == in)
  3359. out = db->dcStat(HW_API_dcStat_In());
  3360. else
  3361. out = db->dcStat(*in);
  3362. delete in;
  3363. break;
  3364. default:
  3365. WRONG_PARAM_COUNT;
  3366. }
  3367. if (!out.error().error()) {
  3368. HW_API_Object *object = new HW_API_Object(out.object());
  3369. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  3370. } else {
  3371. HW_API_Error *err = new HW_API_Error(out.error());
  3372. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3373. }
  3374. SEPARATE_ZVAL(&rv);
  3375. *return_value = *rv;
  3376. FREE_ZVAL(rv);
  3377. }
  3378. /* }}} */
  3379. /* {{{ proto string hwapi_dbstat(array parameters)
  3380. Returns information about hgserver */
  3381. PHP_FUNCTION(hwapi_dbstat) {
  3382. pval **arg1, *id, *rv;
  3383. HW_API_dbStat_In *in;
  3384. HW_API_dbStat_Out out;
  3385. HW_API_HGCSP *db;
  3386. int argc;
  3387. id = getThis();
  3388. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3389. if(!db) {
  3390. RETURN_FALSE;
  3391. }
  3392. argc = ZEND_NUM_ARGS();
  3393. switch(argc) {
  3394. case 0:
  3395. out = db->dbStat(HW_API_dbStat_In());
  3396. break;
  3397. case 1:
  3398. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3399. WRONG_PARAM_COUNT;
  3400. }
  3401. convert_to_array_ex(arg1);
  3402. in = make_HW_API_dbStat_In(*arg1);
  3403. if(NULL == in)
  3404. out = db->dbStat(HW_API_dbStat_In());
  3405. else
  3406. out = db->dbStat(*in);
  3407. delete in;
  3408. break;
  3409. default:
  3410. WRONG_PARAM_COUNT;
  3411. }
  3412. if (!out.error().error()) {
  3413. HW_API_Object *object = new HW_API_Object(out.object());
  3414. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  3415. } else {
  3416. HW_API_Error *err = new HW_API_Error(out.error());
  3417. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3418. }
  3419. SEPARATE_ZVAL(&rv);
  3420. *return_value = *rv;
  3421. FREE_ZVAL(rv);
  3422. }
  3423. /* }}} */
  3424. /* {{{ proto string hwapi_ftstat(array parameters)
  3425. Returns information about ftserver */
  3426. PHP_FUNCTION(hwapi_ftstat) {
  3427. pval **arg1, *id, *rv;
  3428. HW_API_ftStat_In *in;
  3429. HW_API_ftStat_Out out;
  3430. HW_API_HGCSP *db;
  3431. int argc;
  3432. id = getThis();
  3433. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3434. if(!db) {
  3435. RETURN_FALSE;
  3436. }
  3437. argc = ZEND_NUM_ARGS();
  3438. switch(argc) {
  3439. case 0:
  3440. out = db->ftStat(HW_API_ftStat_In());
  3441. break;
  3442. case 1:
  3443. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3444. WRONG_PARAM_COUNT;
  3445. }
  3446. convert_to_array_ex(arg1);
  3447. in = make_HW_API_ftStat_In(*arg1);
  3448. if(NULL == in)
  3449. out = db->ftStat(HW_API_ftStat_In());
  3450. else
  3451. out = db->ftStat(*in);
  3452. delete in;
  3453. break;
  3454. default:
  3455. WRONG_PARAM_COUNT;
  3456. }
  3457. if (!out.error().error()) {
  3458. HW_API_Object *object = new HW_API_Object(out.object());
  3459. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  3460. } else {
  3461. HW_API_Error *err = new HW_API_Error(out.error());
  3462. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3463. }
  3464. SEPARATE_ZVAL(&rv);
  3465. *return_value = *rv;
  3466. FREE_ZVAL(rv);
  3467. }
  3468. /* }}} */
  3469. /* {{{ proto string hwapi_info(array parameters)
  3470. Returns information about server */
  3471. PHP_FUNCTION(hwapi_info) {
  3472. pval **arg1, *id, *rv, *rv1, *rv2, *rv3;
  3473. HW_API_info_In *in;
  3474. HW_API_info_Out out;
  3475. HW_API_HGCSP *db;
  3476. int argc;
  3477. id = getThis();
  3478. db = (HW_API_HGCSP *) php_hwapi_get_object(id, le_hwapip);
  3479. if(!db) {
  3480. RETURN_FALSE;
  3481. }
  3482. argc = ZEND_NUM_ARGS();
  3483. switch(argc) {
  3484. case 0:
  3485. out = db->info(HW_API_info_In());
  3486. break;
  3487. case 1:
  3488. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3489. WRONG_PARAM_COUNT;
  3490. }
  3491. convert_to_array_ex(arg1);
  3492. in = make_HW_API_info_In(*arg1);
  3493. if(NULL == in)
  3494. out = db->info(HW_API_info_In());
  3495. else
  3496. out = db->info(*in);
  3497. delete in;
  3498. break;
  3499. default:
  3500. WRONG_PARAM_COUNT;
  3501. }
  3502. if (!out.error().error()) {
  3503. HW_API_StringArray languages, customidx, systemidx;
  3504. if (array_init(return_value) == FAILURE) {
  3505. RETURN_FALSE;
  3506. }
  3507. HW_API_Object *object = new HW_API_Object(out.typeInfo());
  3508. rv = php_hwapi_object_new(object, le_hwapi_objectp);
  3509. zend_hash_add(return_value->value.ht, "typeInfo", 9, &rv, sizeof(zval *), NULL);
  3510. languages = out.languages();
  3511. MAKE_STD_ZVAL(rv1);
  3512. if(0 == stringArray2indexArray(&rv1, &languages))
  3513. RETURN_FALSE;
  3514. zend_hash_add(return_value->value.ht, "languages", 10, &rv1, sizeof(zval *), NULL);
  3515. customidx = out.customIdx();
  3516. MAKE_STD_ZVAL(rv2);
  3517. if(0 == stringArray2indexArray(&rv2, &customidx))
  3518. RETURN_FALSE;
  3519. zend_hash_add(return_value->value.ht, "customIdx", 10, &rv2, sizeof(zval *), NULL);
  3520. systemidx = out.systemIdx();
  3521. MAKE_STD_ZVAL(rv3);
  3522. if(0 == stringArray2indexArray(&rv3, &systemidx))
  3523. RETURN_FALSE;
  3524. zend_hash_add(return_value->value.ht, "systemIdx", 10, &rv3, sizeof(zval *), NULL);
  3525. } else {
  3526. HW_API_Error *err = new HW_API_Error(out.error());
  3527. rv = php_hwapi_object_new(err, le_hwapi_errorp);
  3528. SEPARATE_ZVAL(&rv);
  3529. *return_value = *rv;
  3530. FREE_ZVAL(rv);
  3531. }
  3532. }
  3533. /* }}} */
  3534. /* {{{ proto string hwapi_object_new()
  3535. Creates new HW_API_Object */
  3536. PHP_FUNCTION(hwapi_object_new) {
  3537. pval **arg1, **arg2, *rv;
  3538. HW_API_Object *obj;
  3539. const HW_API_Object *srcobj;
  3540. int ret;
  3541. switch(ZEND_NUM_ARGS()) {
  3542. case 0:
  3543. obj = new HW_API_Object();
  3544. break;
  3545. case 1:
  3546. if (zend_get_parameters_ex(1, &arg1) == FAILURE)
  3547. WRONG_PARAM_COUNT;
  3548. srcobj = (const HW_API_Object *) php_hwapi_get_object(*arg1, le_hwapi_objectp);
  3549. obj = new HW_API_Object(*srcobj);
  3550. break;
  3551. default:
  3552. WRONG_PARAM_COUNT;
  3553. }
  3554. rv = php_hwapi_object_new(obj, le_hwapi_objectp);
  3555. //zend_print_pval_r(rv, 0);
  3556. SEPARATE_ZVAL(&rv);
  3557. *return_value = *rv;
  3558. FREE_ZVAL(rv);
  3559. }
  3560. /* }}} */
  3561. /* {{{ proto string hwapi_object_count()
  3562. Counts number of attributes of an HW_API_Object */
  3563. PHP_FUNCTION(hwapi_object_count) {
  3564. zval *id, **tmp;
  3565. HW_API_Object *objp;
  3566. int value;
  3567. id = getThis();
  3568. objp = (HW_API_Object *) php_hwapi_get_object(id, le_hwapi_objectp);
  3569. if(!objp) {
  3570. RETURN_FALSE;
  3571. }
  3572. value = objp->count();
  3573. RETURN_LONG(value);
  3574. }
  3575. /* }}} */
  3576. /* {{{ proto string hwapi_object_title(string language)
  3577. Returns title of HW_API_Object for given language */
  3578. PHP_FUNCTION(hwapi_object_title) {
  3579. zval **arg1, *id, **tmp;
  3580. HW_API_Object *objp;
  3581. char *value;
  3582. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3583. WRONG_PARAM_COUNT;
  3584. }
  3585. id = getThis();
  3586. objp = (HW_API_Object *) php_hwapi_get_object(id, le_hwapi_objectp);
  3587. convert_to_string_ex(arg1);
  3588. // Warning: It is import to duplicate the string before RETURN.
  3589. // If that is not done the HW_API_String destructor will be called
  3590. // before RETURN_STRING can duplicate the string.
  3591. value = (char *) estrdup(objp->title(Z_STRVAL_PP(arg1)).string());
  3592. RETURN_STRING(value, 0);
  3593. }
  3594. /* }}} */
  3595. /* {{{ proto string hwapi_object_attreditable(int attr, string username, bool is_system)
  3596. Hyperwave object_attreditable function */
  3597. PHP_FUNCTION(hwapi_object_attreditable) {
  3598. zval *id, **arg1, **arg2, **arg3;
  3599. HW_API_Object *objp;
  3600. HW_API_Attribute *attrp;
  3601. bool value;
  3602. if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
  3603. WRONG_PARAM_COUNT;
  3604. }
  3605. id = getThis();
  3606. objp = (HW_API_Object *) php_hwapi_get_object(id, le_hwapi_objectp);
  3607. convert_to_string_ex(arg2);
  3608. convert_to_long_ex(arg3);
  3609. switch(Z_TYPE_PP(arg1)) {
  3610. case IS_STRING:
  3611. convert_to_string_ex(arg1);
  3612. value = objp->attributeEditable((char *) Z_STRVAL_PP(arg1), (char *) Z_STRVAL_PP(arg2), (bool) Z_LVAL_PP(arg3));
  3613. break;
  3614. case IS_OBJECT:
  3615. attrp = (HW_API_Attribute *) php_hwapi_get_object(*arg1, le_hwapi_attributep);
  3616. value = objp->attributeEditable(*attrp, (char *) Z_STRVAL_PP(arg2), (bool) Z_LVAL_PP(arg3));
  3617. break;
  3618. }
  3619. if(value) {
  3620. RETURN_TRUE;
  3621. } else {
  3622. RETURN_FALSE;
  3623. }
  3624. }
  3625. /* }}} */
  3626. /* {{{ proto object hwapi_object_assign(int object)
  3627. Hyperwave object_assign function */
  3628. PHP_FUNCTION(hwapi_object_assign) {
  3629. zval *id, **arg1, **arg2;
  3630. printf("hwapi_object_assign\n");
  3631. RETURN_TRUE;
  3632. }
  3633. /* }}} */
  3634. /* {{{ proto string hwapi_object_attribute(int index, object &attribute)
  3635. Hyperwave object_attribute function */
  3636. PHP_FUNCTION(hwapi_object_attribute) {
  3637. zval **arg1, *id, *rv;
  3638. HW_API_Attribute *attrp, attr;
  3639. HW_API_Object *objp;
  3640. int error;
  3641. if ((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3642. WRONG_PARAM_COUNT;
  3643. }
  3644. id = getThis();
  3645. objp = (HW_API_Object *) php_hwapi_get_object(id, le_hwapi_objectp);
  3646. if(!objp) {
  3647. RETURN_FALSE;
  3648. }
  3649. switch(Z_TYPE_PP(arg1)) {
  3650. case IS_LONG:
  3651. error = objp->attribute(Z_LVAL_PP(arg1), attr);
  3652. break;
  3653. case IS_STRING:
  3654. error = objp->attribute(HW_API_String(Z_STRVAL_PP(arg1)), attr);
  3655. break;
  3656. default:
  3657. php_error(E_WARNING, "HW_API_Object::attribute() needs string or long as parameter");
  3658. RETURN_FALSE;
  3659. }
  3660. if(error) {
  3661. attrp = new HW_API_Attribute(attr);
  3662. rv = php_hwapi_object_new(attrp, le_hwapi_attributep);
  3663. SEPARATE_ZVAL(&rv);
  3664. *return_value = *rv;
  3665. FREE_ZVAL(rv);
  3666. return;
  3667. } else {
  3668. RETURN_FALSE;
  3669. }
  3670. }
  3671. /* }}} */
  3672. /* {{{ proto string hwapi_object_insert(object attr)
  3673. Inserts new HW_API_Attribute into HW_API_Object */
  3674. PHP_FUNCTION(hwapi_object_insert) {
  3675. zval *arg1, *id;
  3676. HW_API_Object *objp;
  3677. HW_API_Attribute *attrp;
  3678. char *value;
  3679. if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &arg1) == FAILURE) {
  3680. WRONG_PARAM_COUNT;
  3681. }
  3682. id = getThis();
  3683. objp = (HW_API_Object *) php_hwapi_get_object(id, le_hwapi_objectp);
  3684. if(!objp) {
  3685. RETURN_FALSE;
  3686. }
  3687. attrp = (HW_API_Attribute *) php_hwapi_get_object(arg1, le_hwapi_attributep);
  3688. objp->insert(*attrp);
  3689. RETURN_TRUE;
  3690. }
  3691. /* }}} */
  3692. /* {{{ proto string hwapi_object_remove(string name)
  3693. Removes HW_API_Attribute with given name from HW_API_Object */
  3694. PHP_FUNCTION(hwapi_object_remove) {
  3695. zval **arg1, *id, **tmp;
  3696. HW_API_Object *objp;
  3697. int error;
  3698. if ((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3699. WRONG_PARAM_COUNT;
  3700. }
  3701. convert_to_string_ex(arg1);
  3702. id = getThis();
  3703. objp = (HW_API_Object *) php_hwapi_get_object(id, le_hwapi_objectp);
  3704. if(!objp) {
  3705. RETURN_FALSE;
  3706. }
  3707. error = objp->remove(Z_STRVAL_PP(arg1));
  3708. if(!error) {
  3709. RETURN_TRUE;
  3710. } else {
  3711. RETURN_FALSE;
  3712. }
  3713. }
  3714. /* }}} */
  3715. /* {{{ proto string hwapi_object_value(string name)
  3716. Returns attribute value of given attribute */
  3717. PHP_FUNCTION(hwapi_object_value) {
  3718. zval **arg1, *id;
  3719. HW_API_Object *objp;
  3720. HW_API_Attribute *attrp;
  3721. HW_API_String value;
  3722. int error;
  3723. if ((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3724. WRONG_PARAM_COUNT;
  3725. }
  3726. convert_to_string_ex(arg1);
  3727. id = getThis();
  3728. objp = (HW_API_Object *) php_hwapi_get_object(id, le_hwapi_objectp);
  3729. if(!objp) {
  3730. RETURN_FALSE;
  3731. }
  3732. error = objp->value((HW_API_String) Z_STRVAL_PP(arg1), value);
  3733. printf("hwapi_object_value\n");
  3734. if(error) {
  3735. char *str = (char *) estrdup(value.string());
  3736. RETURN_STRING(str, 0);
  3737. } else {
  3738. RETURN_FALSE;
  3739. }
  3740. }
  3741. /* }}} */
  3742. /* {{{ proto string hwapi_attribute_new([string name][, string value])
  3743. Creates new HW_API_Attribute */
  3744. PHP_FUNCTION(hwapi_attribute_new) {
  3745. zval *rv, **arg1, **arg2;
  3746. HW_API_Attribute *attrp;
  3747. int ret;
  3748. /* FIXME: I'm not sure if the constructor of HW_API_Attribute takes normal C-Strings
  3749. * or if it has to be HW_API_String. Currently C-Strings are passed.
  3750. */
  3751. switch(ZEND_NUM_ARGS()) {
  3752. case 0:
  3753. break;
  3754. attrp = new HW_API_Attribute();
  3755. case 1:
  3756. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3757. WRONG_PARAM_COUNT;
  3758. }
  3759. convert_to_string_ex(arg1);
  3760. attrp = new HW_API_Attribute(Z_STRVAL_PP(arg1));
  3761. break;
  3762. case 2: //* FIXME: Second Parameter can be string or array of strings
  3763. if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
  3764. WRONG_PARAM_COUNT;
  3765. }
  3766. convert_to_string_ex(arg1);
  3767. switch((*arg2)->type) {
  3768. case IS_ARRAY: {
  3769. HashTable *lht = (*arg2)->value.ht;
  3770. int i, count;
  3771. HW_API_StringArray values;
  3772. if(NULL == lht)
  3773. RETURN_FALSE;
  3774. if(0 == (count = zend_hash_num_elements(lht))) {
  3775. attrp = new HW_API_Attribute(Z_STRVAL_PP(arg1));
  3776. break;
  3777. }
  3778. zend_hash_internal_pointer_reset(lht);
  3779. for(i=0; i<count; i++) {
  3780. zval *keydata, **keydataptr;
  3781. zend_hash_get_current_data(lht, (void **) &keydataptr);
  3782. /* FIXME: just hope this doesn't do any harm. Maybe convert_to_string
  3783. * changes the type of the array element */
  3784. convert_to_string_ex(keydataptr);
  3785. keydata = *keydataptr;
  3786. values.insert(keydata->value.str.val);
  3787. zend_hash_move_forward(lht);
  3788. }
  3789. attrp = new HW_API_Attribute(Z_STRVAL_PP(arg1), values);
  3790. break;
  3791. }
  3792. default:
  3793. convert_to_string_ex(arg2);
  3794. attrp = new HW_API_Attribute(Z_STRVAL_PP(arg1), Z_STRVAL_PP(arg2));
  3795. }
  3796. break;
  3797. default:
  3798. WRONG_PARAM_COUNT;
  3799. }
  3800. rv = php_hwapi_object_new(attrp, le_hwapi_attributep);
  3801. SEPARATE_ZVAL(&rv);
  3802. *return_value = *rv;
  3803. FREE_ZVAL(rv);
  3804. printf("hwapi_attribute_new\n");
  3805. }
  3806. /* }}} */
  3807. /* {{{ proto string hwapi_attribute_key()
  3808. Returns key of an hwapi_attribute */
  3809. PHP_FUNCTION(hwapi_attribute_key) {
  3810. zval *id;
  3811. HW_API_Attribute *attrp;
  3812. char *value;
  3813. id = getThis();
  3814. attrp = (HW_API_Attribute *) php_hwapi_get_object(id, le_hwapi_attributep);
  3815. // Warning: It is import to duplicate the string before RETURN.
  3816. // If that is not done the HW_API_String destructor will be called
  3817. // before RETURN_STRING can duplicate the string.
  3818. value = (char *) estrdup((attrp->key()).string());
  3819. RETURN_STRING(value, 0);
  3820. }
  3821. /* }}} */
  3822. /* {{{ proto string hwapi_attribute_value()
  3823. Returns value of hw_api_attribute */
  3824. PHP_FUNCTION(hwapi_attribute_value) {
  3825. zval *id;
  3826. HW_API_Attribute *attrp;
  3827. char *value;
  3828. id = getThis();
  3829. attrp = (HW_API_Attribute *) php_hwapi_get_object(id, le_hwapi_attributep);
  3830. // Warning: It is import to duplicate the string before RETURN.
  3831. // If that is not done the HW_API_String destructor will be called
  3832. // before RETURN_STRING can duplicate the string.
  3833. value = (char *) estrdup(attrp->value().string());
  3834. RETURN_STRING(value, 0);
  3835. }
  3836. /* }}} */
  3837. /* {{{ proto string hwapi_attribute_values()
  3838. Returns all values of an attribute as an array */
  3839. PHP_FUNCTION(hwapi_attribute_values) {
  3840. zval *id, **tmp;
  3841. HW_API_Attribute *attrp;
  3842. HW_API_StringArray values;
  3843. id = getThis();
  3844. attrp = (HW_API_Attribute *) php_hwapi_get_object(id, le_hwapi_attributep);
  3845. values = attrp->values();
  3846. if(0 == stringArray2indexArray(&return_value, &values))
  3847. RETURN_FALSE;
  3848. }
  3849. /* }}} */
  3850. /* {{{ proto string hwapi_attribute_langdepvalue(string language)
  3851. Returns value of attribute with givenn language */
  3852. PHP_FUNCTION(hwapi_attribute_langdepvalue) {
  3853. zval **arg1, *id, **tmp;
  3854. HW_API_Attribute *attrp;
  3855. char *value;
  3856. if((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &arg1) == FAILURE)) {
  3857. WRONG_PARAM_COUNT;
  3858. }
  3859. convert_to_string_ex(arg1);
  3860. id = getThis();
  3861. attrp = (HW_API_Attribute *) php_hwapi_get_object(id, le_hwapi_attributep);
  3862. value = (char *) attrp->langDepValue((*arg1)->value.str.val).string();
  3863. printf("hwapi_attribute_langdepvalue\n");
  3864. RETURN_STRING(value, 1);
  3865. }
  3866. /* }}} */
  3867. /* {{{ proto string hwapi_content_new([string name][, string value])
  3868. Creates new HW_API_Content */
  3869. PHP_FUNCTION(hwapi_content_new) {
  3870. zval *rv, **arg1, **arg2, **arg3;
  3871. HW_API_Content *contp;
  3872. int ret;
  3873. switch(ZEND_NUM_ARGS()) {
  3874. case 0:
  3875. contp = new HW_API_Content();
  3876. break;
  3877. case 1:
  3878. if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
  3879. WRONG_PARAM_COUNT;
  3880. }
  3881. switch((*arg1)->type) {
  3882. case IS_OBJECT:
  3883. break;
  3884. default:
  3885. convert_to_string_ex(arg1);
  3886. contp = new HW_API_Content(Z_STRVAL_PP(arg1));
  3887. }
  3888. break;
  3889. case 2: //First Parameter is long, second the file name
  3890. if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
  3891. WRONG_PARAM_COUNT;
  3892. }
  3893. convert_to_long_ex(arg1);
  3894. convert_to_string_ex(arg2);
  3895. contp = new HW_API_Content(HW_API_Content::File, Z_STRVAL_PP(arg2));
  3896. break;
  3897. case 3: //First Parameter is long or string, second and third is string
  3898. if (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
  3899. WRONG_PARAM_COUNT;
  3900. }
  3901. switch((*arg1)->type) {
  3902. case IS_LONG:
  3903. convert_to_string_ex(arg2);
  3904. convert_to_string_ex(arg3);
  3905. contp = new HW_API_Content(HW_API_Content::File, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
  3906. break;
  3907. default:
  3908. convert_to_string_ex(arg1);
  3909. convert_to_string_ex(arg2);
  3910. convert_to_string_ex(arg3);
  3911. contp = new HW_API_Content(Z_STRVAL_PP(arg1), Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3));
  3912. }
  3913. break;
  3914. default:
  3915. WRONG_PARAM_COUNT;
  3916. }
  3917. rv = php_hwapi_object_new(contp, le_hwapi_contentp);
  3918. SEPARATE_ZVAL(&rv);
  3919. *return_value = *rv;
  3920. FREE_ZVAL(rv);
  3921. }
  3922. /* }}} */
  3923. /* {{{ proto string hwapi_content_read(string buffer, int length)
  3924. Reads length bytes from content */
  3925. PHP_FUNCTION(hwapi_content_read) {
  3926. zval **arg1, **arg2, *id, **tmp;
  3927. HW_API_Content *contentp;
  3928. char *value;
  3929. int len;
  3930. if((ZEND_NUM_ARGS() != 2) || (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE)) {
  3931. WRONG_PARAM_COUNT;
  3932. }
  3933. convert_to_long_ex(arg2);
  3934. id = getThis();
  3935. contentp = (HW_API_Content *) php_hwapi_get_object(id, le_hwapi_contentp);
  3936. zval_dtor(*arg1);
  3937. Z_TYPE_PP(arg1) = IS_STRING;
  3938. /* FIXME: Need to finish the new zval */
  3939. value = (char *) emalloc(Z_LVAL_PP(arg2)+1);
  3940. if(value) {
  3941. Z_STRVAL_PP(arg1) = value;
  3942. len = contentp->read(value, Z_LVAL_PP(arg2));
  3943. value[len] = '\0';
  3944. Z_STRLEN_PP(arg1) = len;
  3945. RETURN_LONG(len);
  3946. } else {
  3947. RETURN_FALSE;
  3948. }
  3949. }
  3950. /* }}} */
  3951. /* {{{ proto string hwapi_content_mimetype()
  3952. Returns MimeType of document */
  3953. PHP_FUNCTION(hwapi_content_mimetype) {
  3954. zval *id;
  3955. HW_API_Content *contentp;
  3956. HW_API_String hwstr;
  3957. id = getThis();
  3958. contentp = (HW_API_Content *) php_hwapi_get_object(id, le_hwapi_contentp);
  3959. hwstr = contentp->mimetype();
  3960. RETURN_STRING((char *) hwstr.string(), 1);
  3961. }
  3962. /* }}} */
  3963. /* {{{ proto string hwapi_error_count()
  3964. Counts number of reasons of an HW_API_Error */
  3965. PHP_FUNCTION(hwapi_error_count) {
  3966. zval *id, **tmp;
  3967. HW_API_Error *objp;
  3968. int value;
  3969. id = getThis();
  3970. objp = (HW_API_Error *) php_hwapi_get_object(id, le_hwapi_errorp);
  3971. if(!objp) {
  3972. RETURN_FALSE;
  3973. }
  3974. value = objp->count();
  3975. RETURN_LONG(value);
  3976. }
  3977. /* }}} */
  3978. /* {{{ proto string hwapi_error_reason(int index)
  3979. Returns a reason of an HW_API_Error */
  3980. PHP_FUNCTION(hwapi_error_reason) {
  3981. zval **arg1, *id, **tmp;
  3982. HW_API_Error *objp;
  3983. HW_API_Reason reason;
  3984. bool error;
  3985. if((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &arg1) == FAILURE)) {
  3986. WRONG_PARAM_COUNT;
  3987. }
  3988. convert_to_long_ex(arg1);
  3989. id = getThis();
  3990. objp = (HW_API_Error *) php_hwapi_get_object(id, le_hwapi_errorp);
  3991. if(!objp) {
  3992. RETURN_FALSE;
  3993. }
  3994. if(!objp->error())
  3995. php_error(E_WARNING, "This is not an error");
  3996. error = objp->reason(Z_LVAL_PP(arg1), reason);
  3997. if(error) {
  3998. zval *rv;
  3999. HW_API_Reason *reasonp = new HW_API_Reason(reason);
  4000. rv = php_hwapi_object_new(reasonp, le_hwapi_reasonp);
  4001. SEPARATE_ZVAL(&rv);
  4002. *return_value = *rv;
  4003. FREE_ZVAL(rv);
  4004. return;
  4005. } else {
  4006. RETURN_FALSE;
  4007. }
  4008. }
  4009. /* }}} */
  4010. /* {{{ proto string hwapi_reason_type()
  4011. Returns the type of HW_API_Reason */
  4012. PHP_FUNCTION(hwapi_reason_type) {
  4013. zval **arg1, *id, **tmp;
  4014. HW_API_Reason *objp;
  4015. id = getThis();
  4016. objp = (HW_API_Reason *) php_hwapi_get_object(id, le_hwapi_reasonp);
  4017. if(!objp) {
  4018. RETURN_FALSE;
  4019. }
  4020. RETURN_LONG((long) (objp->type()));
  4021. }
  4022. /* }}} */
  4023. /* {{{ proto string hwapi_reason_description(string language)
  4024. Returns description of HW_API_Reason */
  4025. PHP_FUNCTION(hwapi_reason_description) {
  4026. zval **arg1, *id, **tmp;
  4027. HW_API_Reason *objp;
  4028. HW_API_String desc;
  4029. if((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &arg1) == FAILURE)) {
  4030. WRONG_PARAM_COUNT;
  4031. }
  4032. convert_to_string_ex(arg1);
  4033. id = getThis();
  4034. objp = (HW_API_Reason *) php_hwapi_get_object(id, le_hwapi_reasonp);
  4035. if(!objp) {
  4036. RETURN_FALSE;
  4037. }
  4038. desc = objp->description((HW_API_String) (Z_STRVAL_PP(arg1)));
  4039. RETURN_STRING((char *) desc.string(), 1);
  4040. }
  4041. /* }}} */
  4042. /* hw_api_class_get_property(zend_property_reference *property_reference) {{{
  4043. *
  4044. */
  4045. pval hw_api_class_get_property(zend_property_reference *property_reference) {
  4046. pval result;
  4047. zend_overloaded_element *overloaded_property;
  4048. zend_llist_element *element;
  4049. printf("Reading a property from a HW_API object:\n");
  4050. for (element=property_reference->elements_list->head; element; element=element->next) {
  4051. overloaded_property = (zend_overloaded_element *) element->data;
  4052. switch (Z_TYPE_P(overloaded_property)) {
  4053. case OE_IS_ARRAY:
  4054. printf("Array offset: ");
  4055. break;
  4056. case OE_IS_OBJECT:
  4057. printf("Object property: ");
  4058. break;
  4059. }
  4060. switch (Z_TYPE(overloaded_property->element)) {
  4061. case IS_LONG:
  4062. printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
  4063. break;
  4064. case IS_STRING:
  4065. printf("'%s'\n", Z_STRVAL(overloaded_property->element));
  4066. break;
  4067. }
  4068. pval_destructor(&overloaded_property->element);
  4069. }
  4070. Z_STRVAL(result) = estrndup("testing", 7);
  4071. Z_STRLEN(result) = 7;
  4072. Z_TYPE(result) = IS_STRING;
  4073. return result;
  4074. }
  4075. /* }}} */
  4076. /* hw_api_class_set_property(zend_property_reference *property_reference, pval *value) {{{
  4077. */
  4078. int hw_api_class_set_property(zend_property_reference *property_reference, pval *value) {
  4079. zend_overloaded_element *overloaded_property;
  4080. zend_llist_element *element;
  4081. printf("Writing to a property from a HW_API object:\n");
  4082. printf("Writing '");
  4083. zend_print_variable(value);
  4084. printf("'\n");
  4085. for (element=property_reference->elements_list->head; element; element=element->next) {
  4086. overloaded_property = (zend_overloaded_element *) element->data;
  4087. switch (Z_TYPE_P(overloaded_property)) {
  4088. case OE_IS_ARRAY:
  4089. printf("Array offset: ");
  4090. break;
  4091. case OE_IS_OBJECT:
  4092. printf("Object property: ");
  4093. break;
  4094. }
  4095. switch (Z_TYPE(overloaded_property->element)) {
  4096. case IS_LONG:
  4097. printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
  4098. break;
  4099. case IS_STRING:
  4100. printf("'%s'\n", Z_STRVAL(overloaded_property->element));
  4101. break;
  4102. }
  4103. pval_destructor(&overloaded_property->element);
  4104. }
  4105. return 0;
  4106. }
  4107. /* }}} */
  4108. /* hw_api_class_startup() {{{
  4109. */
  4110. void hw_api_class_startup() {
  4111. zend_class_entry ce;
  4112. INIT_OVERLOADED_CLASS_ENTRY(ce, "HW_API", php_hw_api_functions,
  4113. NULL,
  4114. NULL,
  4115. NULL);
  4116. hw_api_class_entry_ptr = zend_register_internal_class_ex(&ce, NULL, NULL);
  4117. }
  4118. /* }}} */
  4119. /* hw_api_object_class_get_property(zend_property_reference *property_reference) {{{
  4120. */
  4121. pval hw_api_object_class_get_property(zend_property_reference *property_reference) {
  4122. pval result;
  4123. zend_overloaded_element *overloaded_property;
  4124. zend_llist_element *element;
  4125. printf("Reading a property from a HW_API_Object object:\n");
  4126. for (element=property_reference->elements_list->head; element; element=element->next) {
  4127. overloaded_property = (zend_overloaded_element *) element->data;
  4128. switch (Z_TYPE_P(overloaded_property)) {
  4129. case OE_IS_ARRAY:
  4130. printf("Array offset: ");
  4131. break;
  4132. case OE_IS_OBJECT:
  4133. printf("Object property: ");
  4134. break;
  4135. }
  4136. switch (Z_TYPE(overloaded_property->element)) {
  4137. case IS_LONG:
  4138. printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
  4139. break;
  4140. case IS_STRING:
  4141. printf("'%s'\n", Z_STRVAL(overloaded_property->element));
  4142. break;
  4143. }
  4144. pval_destructor(&overloaded_property->element);
  4145. }
  4146. Z_STRVAL(result) = estrndup("testing", 7);
  4147. Z_STRLEN(result) = 7;
  4148. Z_TYPE(result) = IS_STRING;
  4149. return result;
  4150. }
  4151. /* }}} */
  4152. /* hw_api_object_class_set_property(zend_property_reference *property_reference, pval *value) {{{
  4153. */
  4154. int hw_api_object_class_set_property(zend_property_reference *property_reference, pval *value) {
  4155. zend_overloaded_element *overloaded_property;
  4156. zend_llist_element *element;
  4157. printf("Writing to a property from a HW_API_Object object:\n");
  4158. printf("Writing '");
  4159. zend_print_variable(value);
  4160. printf("'\n");
  4161. for (element=property_reference->elements_list->head; element; element=element->next) {
  4162. overloaded_property = (zend_overloaded_element *) element->data;
  4163. switch (Z_TYPE_P(overloaded_property)) {
  4164. case OE_IS_ARRAY:
  4165. printf("Array offset: ");
  4166. break;
  4167. case OE_IS_OBJECT:
  4168. printf("Object property: ");
  4169. break;
  4170. }
  4171. switch (Z_TYPE(overloaded_property->element)) {
  4172. case IS_LONG:
  4173. printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
  4174. break;
  4175. case IS_STRING:
  4176. printf("'%s'\n", Z_STRVAL(overloaded_property->element));
  4177. break;
  4178. }
  4179. pval_destructor(&overloaded_property->element);
  4180. }
  4181. return 0;
  4182. }
  4183. /* }}} */
  4184. /* {{{ hw_api_object_class_startup()
  4185. */
  4186. void hw_api_object_class_startup() {
  4187. zend_class_entry ce;
  4188. INIT_OVERLOADED_CLASS_ENTRY(ce, "hw_api_object", php_hw_api_object_functions,
  4189. NULL,
  4190. NULL,
  4191. NULL);
  4192. hw_api_object_class_entry_ptr = zend_register_internal_class_ex(&ce, NULL, NULL);
  4193. }
  4194. /* }}} */
  4195. /* hw_api_attribute_class_get_property(zend_property_reference *property_reference) {{{
  4196. */
  4197. pval hw_api_attribute_class_get_property(zend_property_reference *property_reference) {
  4198. pval result;
  4199. zend_overloaded_element *overloaded_property;
  4200. zend_llist_element *element;
  4201. printf("Reading a property from a HW_API_Attribute object:\n");
  4202. for (element=property_reference->elements_list->head; element; element=element->next) {
  4203. overloaded_property = (zend_overloaded_element *) element->data;
  4204. switch (Z_TYPE_P(overloaded_property)) {
  4205. case OE_IS_ARRAY:
  4206. printf("Array offset: ");
  4207. break;
  4208. case OE_IS_OBJECT:
  4209. printf("Object property: ");
  4210. break;
  4211. }
  4212. switch (Z_TYPE(overloaded_property->element)) {
  4213. case IS_LONG:
  4214. printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
  4215. break;
  4216. case IS_STRING:
  4217. printf("'%s'\n", Z_STRVAL(overloaded_property->element));
  4218. break;
  4219. }
  4220. pval_destructor(&overloaded_property->element);
  4221. }
  4222. Z_STRVAL(result) = estrndup("testing", 7);
  4223. Z_STRLEN(result) = 7;
  4224. Z_TYPE(result) = IS_STRING;
  4225. return result;
  4226. }
  4227. /* }}} */
  4228. /* hw_api_attribute_class_set_property(zend_property_reference *property_reference, pval *value) {{{
  4229. */
  4230. int hw_api_attribute_class_set_property(zend_property_reference *property_reference, pval *value) {
  4231. zend_overloaded_element *overloaded_property;
  4232. zend_llist_element *element;
  4233. printf("Writing to a property from a HW_API_Attribute object:\n");
  4234. printf("Writing '");
  4235. zend_print_variable(value);
  4236. printf("'\n");
  4237. for (element=property_reference->elements_list->head; element; element=element->next) {
  4238. overloaded_property = (zend_overloaded_element *) element->data;
  4239. switch (Z_TYPE_P(overloaded_property)) {
  4240. case OE_IS_ARRAY:
  4241. printf("Array offset: ");
  4242. break;
  4243. case OE_IS_OBJECT:
  4244. printf("Object property: ");
  4245. break;
  4246. }
  4247. switch (Z_TYPE(overloaded_property->element)) {
  4248. case IS_LONG:
  4249. printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
  4250. break;
  4251. case IS_STRING:
  4252. printf("'%s'\n", Z_STRVAL(overloaded_property->element));
  4253. break;
  4254. }
  4255. pval_destructor(&overloaded_property->element);
  4256. }
  4257. return 0;
  4258. }
  4259. /* }}} */
  4260. /* hw_api_attribute_class_startup() {{{
  4261. */
  4262. void hw_api_attribute_class_startup() {
  4263. zend_class_entry hw_api_attribute_class_entry;
  4264. INIT_OVERLOADED_CLASS_ENTRY(hw_api_attribute_class_entry, "HW_API_Attribute", php_hw_api_attribute_functions,
  4265. NULL,
  4266. NULL,
  4267. NULL);
  4268. hw_api_attribute_class_entry_ptr = zend_register_internal_class(&hw_api_attribute_class_entry);
  4269. }
  4270. /* }}} */
  4271. /* hw_api_error_class_startup() {{{
  4272. */
  4273. void hw_api_error_class_startup() {
  4274. zend_class_entry hw_api_error_class_entry;
  4275. INIT_OVERLOADED_CLASS_ENTRY(hw_api_error_class_entry, "HW_API_Error", php_hw_api_error_functions,
  4276. NULL,
  4277. NULL,
  4278. NULL);
  4279. hw_api_error_class_entry_ptr = zend_register_internal_class(&hw_api_error_class_entry);
  4280. }
  4281. /* }}} */
  4282. /* hw_api_content_class_startup() {{{
  4283. */
  4284. void hw_api_content_class_startup() {
  4285. zend_class_entry hw_api_content_class_entry;
  4286. INIT_OVERLOADED_CLASS_ENTRY(hw_api_content_class_entry, "HW_API_Content", php_hw_api_content_functions,
  4287. NULL,
  4288. NULL,
  4289. NULL);
  4290. hw_api_content_class_entry_ptr = zend_register_internal_class(&hw_api_content_class_entry);
  4291. }
  4292. /* }}} */
  4293. /* hw_api_reason_class_startup() {{{
  4294. */
  4295. void hw_api_reason_class_startup() {
  4296. zend_class_entry hw_api_reason_class_entry;
  4297. INIT_OVERLOADED_CLASS_ENTRY(hw_api_reason_class_entry, "HW_API_Reason", php_hw_api_reason_functions,
  4298. NULL,
  4299. NULL,
  4300. NULL);
  4301. hw_api_reason_class_entry_ptr = zend_register_internal_class(&hw_api_reason_class_entry);
  4302. }
  4303. /* }}} */
  4304. #endif
  4305. /*
  4306. * Local variables:
  4307. * tab-width: 4
  4308. * c-basic-offset: 4
  4309. * End:
  4310. */