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.

5031 lines
123 KiB

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