Develop and Download Open Source Software

Browse CVS Repository

Contents of /xoonips/AL/xnpal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.26 - (show annotations) (download) (as text)
Mon Jan 24 10:53:38 2005 UTC (19 years, 2 months ago) by youi
Branch: MAIN
Changes since 1.25: +162 -2 lines
File MIME type: text/x-c++src
関数追加
 xnp_get_private_item_id, xnp_get_uncertified_link, xnp_get_item_types

1 /*
2 $Revision: 1.25 $
3 XNPAL: XooNiPs Platform Abstract Layer
4
5 zend_parse_parameters??hp4.1.0??綽?荀?
6 .so???<?ゃ?????????荀????????贋????舟??鴻????
7 C++?с????extern "C"{}, BEGIN/END_EXTERN_C()??綽?荀???
8 */
9
10
11 #include <stdio.h>
12 #include "criteria.h"
13 #include "common.h"
14 #include "commonal.h"
15 #include "session.h"
16 #include "group.h"
17 #include "index.h"
18 #include "xnpal.h"
19 #include "amazonbook.h"
20
21 // for inet_aton
22 #include <sys/socket.h>
23 #include <netinet/in.h>
24 #include <arpa/inet.h>
25
26 // global variables
27
28 PHP_MSHUTDOWN_FUNCTION(xnpalmod)
29 {
30 uninitializeDB();
31 return SUCCESS;
32 }
33
34 /* declaration of functions to be exported */
35 extern "C" {
36 ZEND_FUNCTION(first_module );
37 ZEND_FUNCTION(xnp_initialize_db );
38 ZEND_FUNCTION(xnp_login_user );
39 ZEND_FUNCTION(xnp_logout_user );
40 ZEND_FUNCTION(xnp_create_session );
41 ZEND_FUNCTION(xnp_get_session );
42 ZEND_FUNCTION(xnp_is_activated );
43 ZEND_FUNCTION(xnp_activate );
44 ZEND_FUNCTION(xnp_get_account_count );
45 ZEND_FUNCTION(xnp_delete_account );
46 ZEND_FUNCTION(xnp_get_account );
47 ZEND_FUNCTION(xnp_get_accounts );
48 ZEND_FUNCTION(xnp_insert_account );
49 ZEND_FUNCTION(xnp_update_account );
50 ZEND_FUNCTION(xnp_dump_uids );
51 ZEND_FUNCTION(xnp_get_group_count );
52 ZEND_FUNCTION(xnp_get_groups_by_uid );
53 ZEND_FUNCTION(xnp_is_group_admin );
54 ZEND_FUNCTION(xnp_dump_gids );
55 ZEND_FUNCTION(xnp_dump_group_admins );
56 ZEND_FUNCTION(xnp_delete_member );
57 ZEND_FUNCTION(xnp_insert_member );
58 ZEND_FUNCTION(xnp_get_members );
59 ZEND_FUNCTION(xnp_delete_group );
60 ZEND_FUNCTION(xnp_insert_group );
61 ZEND_FUNCTION(xnp_update_group );
62 ZEND_FUNCTION(xnp_get_group );
63 ZEND_FUNCTION(xnp_get_groups );
64 ZEND_FUNCTION(xnp_is_moderator );
65 ZEND_FUNCTION(xnp_get_uid );
66
67 ZEND_FUNCTION(xnp_get_all_indexes );
68 ZEND_FUNCTION(xnp_get_indexes );
69 ZEND_FUNCTION(xnp_insert_index );
70 ZEND_FUNCTION(xnp_update_index );
71 ZEND_FUNCTION(xnp_delete_index );
72 ZEND_FUNCTION(xnp_get_index );
73 ZEND_FUNCTION(xnp_is_index_readable );
74 ZEND_FUNCTION(xnp_is_index_writable );
75 ZEND_FUNCTION(xnp_swap_index_sort_number );
76
77 ZEND_FUNCTION(xnp_is_valid_session_id );
78 ZEND_FUNCTION(xnp_get_last_error_string );
79
80 ZEND_FUNCTION(xnp_test_criteria );
81 ZEND_FUNCTION(xnp_test_uids );
82
83
84 ZEND_FUNCTION(xnp_get_item_permission );
85 ZEND_FUNCTION(xnp_get_index_permission );
86 ZEND_FUNCTION(xnp_get_certify_permission );
87
88 ZEND_FUNCTION(xnp_get_certify_state );
89 ZEND_FUNCTION(xnp_set_certify_state );
90
91 ZEND_FUNCTION(xnp_insert_change_log );
92 ZEND_FUNCTION(xnp_get_change_logs );
93
94 ZEND_FUNCTION(xnp_get_config_value );
95 ZEND_FUNCTION(xnp_set_config_value );
96
97 ZEND_FUNCTION(xnp_dump_item_id );
98 ZEND_FUNCTION(xnp_get_item_id_by_binder_id );
99 ZEND_FUNCTION(xnp_get_item_id_by_index_id );
100 ZEND_FUNCTION(xnp_get_overlapped_items );
101
102 ZEND_FUNCTION(xnp_insert_item );
103 ZEND_FUNCTION(xnp_update_item );
104 ZEND_FUNCTION(xnp_delete_item );
105 ZEND_FUNCTION(xnp_get_item );
106 ZEND_FUNCTION(xnp_get_items );
107
108 ZEND_FUNCTION(xnp_pubmed_complete );
109 ZEND_FUNCTION(xnp_amazon_complete );
110
111 //ZEND_FUNCTION(xnp_uninitialize_db );
112
113 ZEND_FUNCTION(xnp_register_binder_item );
114 ZEND_FUNCTION(xnp_unregister_binder_item );
115
116 ZEND_FUNCTION(xnp_register_item );
117 ZEND_FUNCTION(xnp_unregister_item );
118
119 ZEND_FUNCTION(xnp_get_uncertified_link );
120 ZEND_FUNCTION(xnp_get_private_item_id );
121
122 ZEND_FUNCTION(xnp_get_item_types );
123
124 };
125 /* compiled function list so Zend knows what's in this module */
126 zend_function_entry xnpalmod_functions[] =
127 {
128 ZEND_FE(first_module ,NULL)
129 ZEND_FE(xnp_initialize_db ,NULL)
130 ZEND_FE(xnp_login_user ,NULL)
131 ZEND_FE(xnp_logout_user ,NULL)
132 ZEND_FE(xnp_create_session ,NULL)
133 ZEND_FE(xnp_get_session ,NULL)
134 ZEND_FE(xnp_is_activated ,NULL)
135 ZEND_FE(xnp_activate ,NULL)
136 ZEND_FE(xnp_get_account_count ,NULL)
137 ZEND_FE(xnp_delete_account ,NULL)
138 ZEND_FE(xnp_get_account ,NULL)
139 ZEND_FE(xnp_get_accounts ,NULL)
140 ZEND_FE(xnp_insert_account ,NULL)
141 ZEND_FE(xnp_update_account ,NULL)
142 ZEND_FE(xnp_dump_uids ,NULL)
143 ZEND_FE(xnp_get_group_count ,NULL)
144 ZEND_FE(xnp_get_groups_by_uid ,NULL)
145 ZEND_FE(xnp_is_group_admin ,NULL)
146 ZEND_FE(xnp_dump_gids ,NULL)
147 ZEND_FE(xnp_dump_group_admins ,NULL)
148 ZEND_FE(xnp_delete_member ,NULL)
149 ZEND_FE(xnp_insert_member ,NULL)
150 ZEND_FE(xnp_get_members ,NULL)
151 ZEND_FE(xnp_delete_group ,NULL)
152 ZEND_FE(xnp_insert_group ,NULL)
153 ZEND_FE(xnp_update_group ,NULL)
154 ZEND_FE(xnp_get_group ,NULL)
155 ZEND_FE(xnp_get_groups ,NULL)
156 ZEND_FE(xnp_is_moderator ,NULL)
157 ZEND_FE(xnp_get_uid ,NULL)
158
159 ZEND_FE(xnp_get_all_indexes ,NULL)
160 ZEND_FE(xnp_get_indexes ,NULL)
161 ZEND_FE(xnp_insert_index ,NULL)
162 ZEND_FE(xnp_update_index ,NULL)
163 ZEND_FE(xnp_delete_index ,NULL)
164 ZEND_FE(xnp_get_index ,NULL)
165 ZEND_FE(xnp_is_index_readable ,NULL)
166 ZEND_FE(xnp_is_index_writable ,NULL)
167 ZEND_FE(xnp_swap_index_sort_number ,NULL)
168
169 ZEND_FE(xnp_is_valid_session_id ,NULL)
170 ZEND_FE(xnp_get_last_error_string ,NULL)
171 ZEND_FE(xnp_test_criteria ,NULL)
172 ZEND_FE(xnp_test_uids ,NULL)
173
174 ZEND_FE(xnp_get_item_permission ,NULL)
175 ZEND_FE(xnp_get_index_permission ,NULL)
176 ZEND_FE(xnp_get_certify_permission ,NULL)
177
178 ZEND_FE(xnp_get_certify_state ,NULL)
179 ZEND_FE(xnp_set_certify_state ,NULL)
180
181 ZEND_FE(xnp_insert_change_log ,NULL)
182 ZEND_FE(xnp_get_change_logs ,NULL)
183
184 ZEND_FE(xnp_get_config_value ,NULL)
185 ZEND_FE(xnp_set_config_value ,NULL)
186
187 ZEND_FE(xnp_dump_item_id ,NULL)
188 ZEND_FE(xnp_get_item_id_by_binder_id ,NULL)
189 ZEND_FE(xnp_get_item_id_by_index_id ,NULL)
190 ZEND_FE(xnp_get_overlapped_items ,NULL)
191
192 ZEND_FE(xnp_insert_item ,NULL)
193 ZEND_FE(xnp_update_item ,NULL)
194 ZEND_FE(xnp_delete_item ,NULL)
195 ZEND_FE(xnp_get_item ,NULL)
196 ZEND_FE(xnp_get_items ,NULL)
197
198 ZEND_FE(xnp_pubmed_complete ,NULL)
199 ZEND_FE(xnp_amazon_complete ,NULL)
200
201 // ZEND_FE(xnp_uninitialize_db ,NULL)
202
203 ZEND_FE(xnp_register_binder_item ,NULL)
204 ZEND_FE(xnp_unregister_binder_item ,NULL)
205
206 ZEND_FE(xnp_register_item ,NULL)
207 ZEND_FE(xnp_unregister_item ,NULL)
208
209 ZEND_FE(xnp_get_uncertified_link ,NULL)
210 ZEND_FE(xnp_get_private_item_id ,NULL)
211
212 ZEND_FE(xnp_get_item_types ,NULL)
213
214 {NULL, NULL, NULL}
215 };
216
217 /* compiled module information */
218 zend_module_entry xnpalmod_module_entry =
219 {
220 STANDARD_MODULE_HEADER,
221 "Visiome Platform Abstract Layer",
222 xnpalmod_functions,
223 NULL,
224 PHP_MSHUTDOWN(xnpalmod),
225 NULL,
226 NULL,
227 NULL,
228 NO_VERSION_YET,
229 STANDARD_MODULE_PROPERTIES
230 };
231
232 /* implement standard "stub" routine to introduce ourselves to Zend */
233 #if COMPILE_DL_FIRST_MODULE
234 BEGIN_EXTERN_C()
235 ZEND_GET_MODULE(xnpalmod)
236 END_EXTERN_C()
237 #endif
238
239
240 /* implement function that is meant to be made available to PHP */
241 ZEND_FUNCTION(first_module)
242 {
243 long parameter;
244 // if(ZEND_NUM_ARGS() != 2) WRONG_PARAM_COUNT;
245 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &parameter) == FAILURE) {
246 return;
247 }
248 parameter++;
249 RETURN_LONG(parameter);
250 }
251 /** zval????C????絖?????緇?????
252 */
253 char *getZvalString( zval **p ){
254 convert_to_string_ex(p);
255 return Z_STRVAL_PP(p); //(**p).value.str.val;
256 }
257
258 /** zval????int??緇?????
259 */
260 int getZvalInt( zval **p ){
261 convert_to_long_ex(p);
262 return Z_LVAL_PP(p); // (int)(**p).value.lval;
263 }
264
265 // keylen????鮎??0????????
266 static void print_hash_key( int res, const char *key, uint keyLen, ulong index ){
267 zend_printf( "print_hash_key : key=0x%08x keylen=%08d index=%08d<br> ", key, keyLen, index );
268 if ( res == HASH_KEY_IS_STRING ){
269 char *p = new char[keyLen+1];
270 memcpy( p, key, keyLen );
271 p[keyLen] = 0;
272 zend_printf( " key is string[%s]<br>\n", p );
273 }
274 else {
275 zend_printf( " key is integer[%d]<br>\n", index );
276 }
277 }
278
279
280 /** zval*????criteria_t?????????????????????鴻??????紊掩??????getResult()!=RES_OK <br>
281 criteria :
282 array( 'start'=>0, 'rows'=>10,
283 'orders'=>array(
284 array('name'=>'id','order'=>'0'),
285 array('name'=>'timestamp','name'=>'1'), ...)
286 ); ??????就???f?渇????
287 */
288 class zCriteria_t : public criteria {
289 private:
290 result_t result;
291
292 // pz: array('name'=>'timestamp','name'=>'1')
293 // ????????orderby??篏???????申????
294 void setOrder( zval *pz ){
295 char *column = 0;
296 order_t order = (order_t)0;
297
298 HashPosition pos;
299 zval **ppzTmp = 0;
300 int res2;
301 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
302 while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
303 char *key = 0;
304 uint keyLen = 0;
305 ulong index = 0;
306 int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
307 if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
308 //print_hash_key( keyType, key, keyLen, index );
309 if ( strncasecmp( key, "name", keyLen ) == 0 && keyLen == 5 ){
310 SEPARATE_ZVAL(ppzTmp);
311 column = getZvalString(ppzTmp);
312 // zend_printf( "column=%s<br>\n", column );
313 }
314 else if ( strncasecmp( key, "order", keyLen ) == 0 && keyLen == 6 ){
315 SEPARATE_ZVAL(ppzTmp);
316 order = (order_t)getZvalInt(ppzTmp);
317 // zend_printf( "order=%d<br>\n", order );
318 }
319 }
320
321 zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
322 }
323 if ( column ){
324 orderby *o = new orderby( column, order );
325 addOrderBy( o );
326 }
327
328 result = RES_OK;
329 }
330
331 // pz: array( array('column'=>'hoge','order'=>'1'), array('column'=>'huga','order'=>'2'), ...)
332 void setOrders( zval *pz ){
333 HashPosition pos;
334
335 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
336
337 zval **ppzTmp = 0;
338 int res2;
339 while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
340 char *key = 0;
341 uint keyLen = 0;
342 ulong index = 0;
343 int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
344 if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
345 //print_hash_key( keyType, key, keyLen, index );
346 setOrder( *ppzTmp );
347 }
348 zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
349 }
350 result = RES_OK;
351 }
352
353 void initialize( zval *pz ){
354 HashPosition pos;
355 zval **ppzTmp = 0;
356 int res2;
357 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
358 while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
359 char *key = 0;
360 uint keyLen = 0;
361 ulong index = 0;
362 int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
363 if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
364 //print_hash_key( keyType, key, keyLen, index );
365 if ( strncasecmp( key, "start", keyLen ) == 0 && keyLen == 6 ){
366 SEPARATE_ZVAL(ppzTmp);
367 int tmp = getZvalInt(ppzTmp);
368 // zend_printf( "start=%d<br>\n", tmp );
369 setLimit( tmp, getLimitRows() );
370 }
371 else if ( strncasecmp( key, "rows", keyLen ) == 0 && keyLen == 5 ){
372 SEPARATE_ZVAL(ppzTmp);
373 int tmp = getZvalInt(ppzTmp);
374 // zend_printf( "rows=%d<br>\n", tmp );
375 setLimit( getLimitStart(), tmp );
376 }
377 else if ( strncasecmp( key, "orders", keyLen ) == 0 && keyLen == 7 ){
378 setOrders( *ppzTmp );
379 }
380 else
381 ; // ignore unknown key
382 }
383 else
384 ; // ignore bad key
385 zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
386 }
387 result = RES_OK;
388 }
389
390 public:
391 zCriteria_t() : criteria(){ result = RES_ERROR; }
392 zCriteria_t( zval *pz ) : criteria(){ initialize(pz); }
393 zCriteria_t( zval **ppz ) : criteria() { initialize(*ppz); }
394 result_t getResult(){ return result; };
395
396 void dump(){
397 zend_printf( "dumping zCriteria...<br>\n" );
398 zend_printf( "result=%d<br>\n", (int)result );
399 zend_printf( "start=%d, rows=%d<br>\n", getLimitStart(), getLimitRows() );
400 const orderby *p = headOrderBy();
401 while ( p ){
402 zend_printf( "column=%s, order=%d<br>\n", p->getColumn(), p->getOrder() );
403 p = nextOrderBy();
404 }
405 }
406 };
407
408
409 /** ?f?渇???????≪???祉?鴻????ong?ゃ??緇?????
410 @param ht ?f?渇????
411 @param key ????/span>
412 @param val long?ゃ?????????????ゃ?潟??/span>
413 @return ????????true
414 */
415 static bool hashGetLong( HashTable *ht, const char *key, long *val ){
416 zval **tmp;
417 if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
418 convert_to_long_ex( tmp );
419 *val = Z_LVAL_PP(tmp);
420 return true;
421 }
422 return false;
423 }
424
425 /** ?f?渇???????≪???祉?鴻??????絖?????緇?????
426 @param ht ?f?渇????
427 @param key ????/span>
428 @param val ??絖????????????????ゃ?潟??/span>
429 @return ????????true
430 */
431 static bool hashGetString( HashTable *ht, const char *key, char **val ){
432 zval **tmp;
433 if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
434 convert_to_string_ex( tmp );
435 *val = Z_STRVAL_PP(tmp);
436 return true;
437 }
438 return false;
439 }
440
441 /** ?f?渇???????≪???祉?鴻????ouble?ゃ??緇?????
442 @param ht ?f?渇????
443 @param key ????/span>
444 @param val double?ゃ?????????????ゃ?潟??/span>
445 @return ????????true
446 */
447 static bool hashGetDouble( HashTable *ht, const char *key, double *val ){
448 zval **tmp;
449 if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
450 convert_to_double_ex( tmp );
451 *val = Z_DVAL_PP(tmp);
452 return true;
453 }
454 return false;
455 }
456
457 /** zval*????account?????????????????????鴻?? <br>
458 ????紊掩??????getResult()!=RES_OK <br>
459 */
460 class zAccount_t : public account {
461 private:
462 result_t result;
463 void initialize(zval *pz){
464 HashTable *ht = Z_ARRVAL_P(pz);
465 long l;
466 char *p;
467 double d;
468 if ( hashGetLong ( ht, "uid" , &l ) ) setUID ( l );
469 if ( hashGetString( ht, "uname" , &p ) ) setUname ( p );
470 if ( hashGetString( ht, "name" , &p ) ) setName ( p );
471 if ( hashGetString( ht, "email" , &p ) ) setEmail ( p );
472 if ( hashGetString( ht, "url" , &p ) ) setURL ( p );
473 if ( hashGetString( ht, "user_avatar" , &p ) ) setUserAvatar ( p );
474 if ( hashGetString( ht, "user_icq" , &p ) ) setUserIcq ( p );
475 if ( hashGetString( ht, "user_from" , &p ) ) setUserFrom ( p );
476 if ( hashGetString( ht, "user_sig" , &p ) ) setUserSig ( p );
477 if ( hashGetString( ht, "actkey" , &p ) ) setActkey ( p );
478 if ( hashGetString( ht, "user_aim" , &p ) ) setUserAim ( p );
479 if ( hashGetString( ht, "user_yim" , &p ) ) setUserYim ( p );
480 if ( hashGetString( ht, "user_msnm" , &p ) ) setUserMsnm ( p );
481 if ( hashGetString( ht, "pass" , &p ) ) setPass ( p );
482 if ( hashGetString( ht, "theme" , &p ) ) setTheme ( p );
483 if ( hashGetString( ht, "umode" , &p ) ) setUmode ( p );
484 if ( hashGetString( ht, "user_occ" , &p ) ) setUserOcc ( p );
485 if ( hashGetString( ht, "bio" , &p ) ) setBio ( p );
486 if ( hashGetString( ht, "user_intrest" , &p ) ) setUserIntrest ( p );
487 if ( hashGetDouble( ht, "timezone_offset" , &d ) ) setTimezoneOffset ( d );
488 if ( hashGetLong ( ht, "attachsig" , &l ) ) setAttachsig ( l );
489 if ( hashGetLong ( ht, "last_login" , &l ) ) setLastLogin ( l );
490 if ( hashGetLong ( ht, "level" , &l ) ) setLevel ( l );
491 if ( hashGetLong ( ht, "notify_method" , &l ) ) setNotifyMethod ( l );
492 if ( hashGetLong ( ht, "notify_mode" , &l ) ) setNotifyMode ( l );
493 if ( hashGetLong ( ht, "posts" , &l ) ) setPosts ( l );
494 if ( hashGetLong ( ht, "rank" , &l ) ) setRank ( l );
495 if ( hashGetLong ( ht, "uorder" , &l ) ) setUorder ( l );
496 if ( hashGetLong ( ht, "user_mailok" , &l ) ) setUserMailok ( l );
497 if ( hashGetLong ( ht, "user_regdate" , &l ) ) setUserRegdate ( l );
498 if ( hashGetLong ( ht, "user_viewemail" , &l ) ) setUserViewemail ( l );
499 if ( hashGetLong ( ht, "activate" , &l ) ) setActivate ( l );
500 if ( hashGetString( ht, "address" , &p ) ) setAddress ( p );
501 if ( hashGetString( ht, "division" , &p ) ) setDivision ( p );
502 if ( hashGetString( ht, "tel" , &p ) ) setTel ( p );
503 if ( hashGetString( ht, "company_name" , &p ) ) setCompanyName ( p );
504 if ( hashGetString( ht, "country" , &p ) ) setCountry ( p );
505 if ( hashGetString( ht, "zipcode" , &p ) ) setZipcode ( p );
506 if ( hashGetString( ht, "fax" , &p ) ) setFax ( p );
507 if ( hashGetString( ht, "base_url" , &p ) ) setBaseURL ( p );
508 if ( hashGetLong ( ht, "notice_mail" , &l ) ) setNoticeMail ( l );
509 if ( hashGetLong ( ht, "notice_mail_since" , &l ) ) setNoticeMailSince ( l );
510 if ( hashGetLong ( ht, "private_index_id " , &l ) ) setPrivateIndexID ( l );
511
512 result = RES_OK;
513 }
514 public:
515 zAccount_t() : account(){ result = RES_ERROR; }
516
517 /** ?潟?潟?鴻????????/span>
518 @param pz array( 'uid'=>1, 'uname'=>'root', ... ); ??????就???f?渇???? */
519 zAccount_t( zval *pz ) : account(){ initialize(pz); }
520 zAccount_t( zval **ppz ) : account() { initialize(*ppz); }
521 result_t getResult(){ return result; };
522 };
523
524 class zIndex_t : public index {
525 private:
526 result_t result;
527
528 void initialize(zval *pz){
529 HashTable *ht = Z_ARRVAL_P(pz);
530 long l;
531 char *p;
532 double d;
533 if ( hashGetLong ( ht, "item_id" , &l ) ) setItemID ( l );
534 if ( hashGetLong ( ht, "item_type_id" , &l ) ) setItemTypeID ( l );
535 if ( hashGetLong ( ht, "contributor_uid" , &l ) ) setContributorUID ( l );
536 if ( hashGetString( ht, "title" , &p ) ) setTitle ( p );
537 if ( hashGetString( ht, "keywords" , &p ) ) setKeywords ( p );
538 if ( hashGetString( ht, "description" , &p ) ) setDescription ( p );
539 if ( hashGetLong ( ht, "last_update_date" , &l ) ) setLastUpdateDate ( l );
540 if ( hashGetLong ( ht, "creation_date" , &l ) ) setCreationDate ( l );
541 if ( hashGetLong ( ht, "parent_index_id" , &l ) ) setParentIndexID ( l );
542 if ( hashGetLong ( ht, "owner_uid" , &l ) ) setOwnerUID ( l );
543 if ( hashGetLong ( ht, "owner_gid" , &l ) ) setOwnerGID ( l );
544 if ( hashGetLong ( ht, "open_level" , &l ) ) setOpenLevel ( l );
545 if ( hashGetLong ( ht, "sort_number" , &l ) ) setSortNumber ( l );
546
547 result = RES_OK;
548 }
549 public:
550 zIndex_t() : index(){ result = RES_ERROR; }
551 zIndex_t( zval *pz ) : index(){ initialize(pz); }
552 zIndex_t( zval **ppz ) : index() { initialize(*ppz); }
553 result_t getResult(){ return result; };
554
555 void dump(){
556 }
557 };
558
559 /** zval*????(userid_t *puid,int uidLen)?????????????????????鴻?? <br>
560 ????紊掩??????getResult()!=RES_OK <br>
561 */
562 class zUIDs_t {
563 private:
564 result_t result;
565 userid_t *pUID;
566 int len;
567 public:
568 zUIDs_t(){
569 pUID = 0;
570 len = 0;
571 result = RES_ERROR;
572 }
573
574 /** ?潟?潟?鴻????????/span>
575 @param pza array( '1', '3', '4', '6', ... ); ??????就?????? */
576 zUIDs_t( zval *pza ){
577 pUID = 0;
578 len = 0;
579 result = RES_ERROR;
580
581 if ( Z_TYPE_P(pza) != IS_ARRAY ){
582 result = RES_ERROR;
583 }
584 else {
585 len = zend_hash_num_elements(Z_ARRVAL_P(pza));
586 if(len == 0) {
587 pUID = new userid_t[1];
588 result = RES_OK;
589 }
590 else {
591 /* php/ext/standard/string.c ? implode??????????????????
592 zend_hash_*???????ャ?<?潟???c????????????????鐚?
593 */
594 zval **tmp;
595 HashPosition pos;
596 int i = 0;
597 pUID = new userid_t[len];
598
599 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pza), &pos);
600 while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pza), (void **) &tmp, &pos) == SUCCESS ) {
601 SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html ????/span>
602 convert_to_long_ex(tmp);
603 if ( i < len )
604 pUID[i++] = Z_LVAL_PP(tmp);
605 zend_hash_move_forward_ex(Z_ARRVAL_P(pza), &pos);
606 }
607 len = i;
608 result = RES_OK;
609 }
610 }
611 }
612
613 ~zUIDs_t(){
614 if ( pUID ) delete[] pUID;
615 }
616 result_t getResult(){ return result; }
617 userid_t *getPUID(){ return pUID; }
618 int getLen(){ return len; }
619 void dump(){
620 zend_printf( "dumping zUIDs...<br>\n" );
621 zend_printf( "result=%d<br>\n", (int)result );
622 zend_printf( "len=%d<br>\n", len );
623 for ( int i = 0; i < len; i++ ){
624 zend_printf( "pUID[%d] = %d<br>\n", i, pUID[i] );
625 }
626 }
627 };
628
629 /** zval*????(itemid_t *piid,int iidLen)?????????????????????鴻?? <br>
630 ????紊掩??????getResult()!=RES_OK <br>
631 */
632 class zIIDs_t {
633 private:
634 result_t result;
635 itemid_t *pIID;
636 int len;
637 public:
638 zIIDs_t(){
639 pIID = 0;
640 len = 0;
641 result = RES_ERROR;
642 }
643
644 /** ?潟?潟?鴻????????/span>
645 @param pza array( '1', '3', '4', '6', ... ); ??????就?????? */
646 zIIDs_t( zval *pza ){
647 pIID = 0;
648 len = 0;
649 result = RES_ERROR;
650
651 if ( Z_TYPE_P(pza) != IS_ARRAY ){
652 result = RES_ERROR;
653 }
654 else {
655 len = zend_hash_num_elements(Z_ARRVAL_P(pza));
656 if(len == 0) {
657 pIID = new itemid_t[1];
658 result = RES_OK;
659 }
660 else {
661 /* php/ext/standard/string.c ? implode??????????????????
662 zend_hash_*???????ャ?<?潟???c????????????????鐚?
663 */
664 zval **tmp;
665 HashPosition pos;
666 int i = 0;
667 pIID = new itemid_t[len];
668
669 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pza), &pos);
670 while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pza), (void **) &tmp, &pos) == SUCCESS ) {
671 SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html ????/span>
672 convert_to_long_ex(tmp);
673 if ( i < len )
674 pIID[i++] = Z_LVAL_PP(tmp);
675 zend_hash_move_forward_ex(Z_ARRVAL_P(pza), &pos);
676 }
677 len = i;
678 result = RES_OK;
679 }
680 }
681 }
682
683 ~zIIDs_t(){
684 if ( pIID ) delete[] pIID;
685 }
686 result_t getResult(){ return result; }
687 itemid_t *getPIID(){ return pIID; }
688 int getLen(){ return len; }
689 void dump(){
690 zend_printf( "dumping zIIDs...<br>\n" );
691 zend_printf( "result=%d<br>\n", (int)result );
692 zend_printf( "len=%d<br>\n", len );
693 for ( int i = 0; i < len; i++ ){
694 zend_printf( "pIID[%d] = %d<br>\n", i, pIID[i] );
695 }
696 }
697 };
698
699 /**
700 *
701 * amazonbook_t????絎鴻??PHP???????????????
702 * @param pAmazonbook 紊???????mazonbook_t*
703 * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
704 * @return RES_OK
705 *
706 */
707 result_t amazonbookToZval( const amazonbook_t *pAmazonbook, zval *z )
708 {
709 zend_hash_clean( z -> value.ht );
710
711 add_assoc_string( z, "title", ( char* )pAmazonbook -> getTitle( ), 1 );
712 add_assoc_string( z, "author", ( char* )pAmazonbook -> getAuthor( ), 1 );
713 add_assoc_string( z, "publisher", ( char* )pAmazonbook -> getPublisher( ), 1 );
714 add_assoc_long( z, "year_of_publication", pAmazonbook -> getYearOfPublication( ) );
715 add_assoc_string( z, "isbn", ( char* )pAmazonbook -> getISBN( ), 1 );
716 add_assoc_string( z, "url", ( char* )pAmazonbook -> getURL( ), 1 );
717
718 return RES_OK;
719 }
720
721 /**
722 *
723 * pubmed_t????絎鴻??PHP???????????????
724 * @param pPubmed 紊???????ubmed_t*
725 * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
726 * @return RES_OK
727 *
728 */
729 result_t pubmedToZval( const pubmed_t *pPubmed, zval *z )
730 {
731 zend_hash_clean( z -> value.ht );
732
733 add_assoc_long( z, "pmid", pPubmed -> getID( ) );
734 add_assoc_string( z, "title", ( char* )pPubmed -> getTitle( ), 1 );
735 add_assoc_string( z, "author", ( char* )pPubmed -> getAuthor( ), 1 );
736 add_assoc_string( z, "journal", ( char* )pPubmed -> getJournal( ), 1 );
737 add_assoc_long( z, "year_of_publication", pPubmed -> getYearOfPublication( ) );
738 add_assoc_long( z, "volume", pPubmed -> getVolume( ) );
739 add_assoc_long( z, "number", pPubmed -> getNumber( ) );
740 add_assoc_string( z, "page", ( char* )pPubmed -> getPage( ), 1 );
741 add_assoc_string( z, "abstract", ( char* )pPubmed -> getAbstract( ), 1 );
742
743 return RES_OK;
744 }
745
746 /**
747 *
748 * itemid_t????????PHP???????????????
749 * @param piid 紊???????temid_t??????
750 * @param len piid?????????激??
751 * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
752 * @return RES_OK
753 *
754 */
755 result_t itemidsToZval( const itemid_t *piid, int len, zval **ppz )
756 {
757 zend_hash_clean( Z_ARRVAL_PP(ppz) );
758
759 // add IDs
760 for ( int i = 0; i < len; i++ ){
761 add_next_index_long(*ppz, (long)(piid[i]) );
762 }
763
764 return RES_OK;
765 }
766
767 /**
768 *
769 * indexid_t????????PHP???????????????
770 * @param piid 紊???????ndexid_t??????
771 * @param len piid?????????激??
772 * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
773 * @return RES_OK
774 *
775 */
776 result_t indexidsToZval( const indexid_t *piid, int len, zval **ppz )
777 {
778 zend_hash_clean( Z_ARRVAL_PP(ppz) );
779
780 // add IDs
781 for ( int i = 0; i < len; i++ ){
782 add_next_index_long(*ppz, (long)(piid[i]) );
783 }
784
785 return RES_OK;
786 }
787
788 /**
789 *
790 * uids_t????????PHP???????????????
791 *
792 * @param pUID 紊???????serid_t??????
793 * @param len pUID?????????激??
794 * @param pz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
795 * @return RES_OK
796 *
797 */
798 result_t uidsToZval( userid_t *pUID, int len, zval **ppz )
799 {
800 zend_hash_clean( Z_ARRVAL_PP(ppz) );
801
802 // add UIDs
803 for ( int i = 0; i < len; i++ ){
804 add_next_index_long(*ppz, (long)(pUID[i]) );
805 }
806
807 return RES_OK;
808 }
809
810 /**
811 *
812 * groupid_t????????PHP???????????????
813 * @param pGID 紊???????roupid_t??????
814 * @param len pGID?????????激??
815 * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
816 * @return RES_OK
817 *
818 */
819 result_t gidsToZval( groupid_t *pGID, int len, zval **ppz )
820 {
821 zend_hash_clean( Z_ARRVAL_PP(ppz) );
822
823 // add GIDs
824 for ( int i = 0; i < len; i++ ){
825 add_next_index_long(*ppz, (long)(pGID[i]) );
826 }
827
828 return RES_OK;
829 }
830
831 /**
832 *
833 * changelog_t????絎鴻??PHP???????????????
834 * @param pChangelog 紊???????hangelog_t*
835 * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
836 * @return RES_OK
837 *
838 */
839 result_t changelogToZval( const changelog_t *pChangelog, zval *z )
840 {
841 zend_hash_clean( z -> value.ht );
842
843 add_assoc_long( z, "log_id", pChangelog -> getChangelogID( ) );
844 add_assoc_long( z, "item_id", pChangelog -> getItemID( ) );
845 add_assoc_long( z, "log_date", pChangelog -> getDate( ) );
846 add_assoc_string( z, "log", ( char* )pChangelog -> getLog( ), 1 );
847
848 return RES_OK;
849 }
850
851 /**
852 *
853 * item_t????絎鴻??PHP???????????????
854 * @param pItem 紊???????tem_t*
855 * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
856 * @return RES_OK
857 *
858 */
859 result_t itemToZval( const item_t *pItem, zval *z )
860 {
861 zend_hash_clean( z -> value.ht );
862
863 add_assoc_long( z, "item_id", pItem -> getItemID( ) );
864 add_assoc_long( z, "item_type_id", pItem -> getItemTypeID( ) );
865 add_assoc_long( z, "uid", pItem -> getContributorUID( ) );
866 add_assoc_string( z, "title", ( char* )pItem -> getTitle( ), 1 );
867 add_assoc_string( z, "keywords", ( char* )pItem -> getKeywords( ), 1 );
868 add_assoc_string( z, "description", ( char* )pItem -> getDescription( ), 1 );
869 add_assoc_string( z, "doi", ( char* )pItem -> getDOI( ), 1 );
870 add_assoc_long( z, "last_update_date", pItem -> getLastUpdateDate( ) );
871 add_assoc_long( z, "creation_date", pItem -> getCreationDate( ) );
872
873 return RES_OK;
874 }
875
876
877 result_t itemsToZval( const item_t *pItems, int itemsLen, zval *z )
878 {
879 zend_hash_clean( z -> value.ht );
880 for( int i = 0; i < itemsLen; i++ ){
881 zval *new_array;
882 MAKE_STD_ZVAL(new_array);
883 if(array_init(new_array) != SUCCESS){
884 return RES_ERROR;
885 }
886 add_index_zval( z, i, new_array );
887 itemToZval( &pItems[ i ], new_array );
888 }
889 return RES_OK;
890 }
891
892 /**
893 *
894 * PHP???f?渇????????絎鴻??group_t?????????
895 *
896 * @param z 紊????????f?渇????
897 * @param pGroup 紊???腟??????吾??莨若???違???若??
898 * @return RES_OK
899 *
900 */
901 result_t zvalToItem( zval *z, item_t* pItem )
902 {
903 zval **tmp;
904 HashPosition pos;
905 int i = 0;
906 char* key = 0;
907
908 key = "item_id";
909 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
910 convert_to_long_ex( tmp ) ;
911 pItem -> setItemID( (*tmp) -> value.lval );
912 }
913 key = "item_type_id";
914 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
915 convert_to_long_ex( tmp ) ;
916 pItem -> setItemTypeID( (*tmp) -> value.lval );
917 }
918 key = "uid";
919 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
920 convert_to_long_ex( tmp ) ;
921 pItem -> setContributorUID( (*tmp) -> value.lval );
922 }
923 key = "title";
924 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
925 convert_to_string_ex( tmp ) ;
926 pItem -> setTitle( (*tmp) -> value.str.val );
927 }
928 key = "keywords";
929 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
930 convert_to_string_ex( tmp ) ;
931 pItem -> setKeywords( (*tmp) -> value.str.val );
932 }
933 key = "description";
934 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
935 convert_to_string_ex( tmp ) ;
936 pItem -> setDescription( (*tmp) -> value.str.val );
937 }
938 key = "doi";
939 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
940 convert_to_string_ex( tmp ) ;
941 pItem -> setDOI( (*tmp) -> value.str.val );
942 }
943 key = "last_update_date";
944 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
945 convert_to_long_ex( tmp ) ;
946 pItem -> setLastUpdateDate( (*tmp) -> value.lval );
947 }
948 key = "creation_date";
949 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
950 convert_to_long_ex( tmp ) ;
951 pItem -> setCreationDate( (*tmp) -> value.lval );
952 }
953 return RES_OK;
954 }
955
956 /**
957 *
958 * account_t????絎鴻??PHP???????????????
959 * @param pAccount 紊???????ccount_t*
960 * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
961 * @return RES_OK
962 *
963 */
964 result_t accountToZval( const account_t *pAccount, zval *z )
965 {
966 zend_hash_clean( z -> value.ht );
967
968 add_assoc_long( z, "uid", pAccount -> getUID( ) );
969 add_assoc_string( z, "uname", ( char* )pAccount -> getUname( ), 1 );
970 add_assoc_string( z, "name", ( char* )pAccount -> getName( ), 1 );
971 add_assoc_string( z, "email", ( char* )pAccount -> getEmail( ), 1 );
972 add_assoc_string( z, "url", ( char* )pAccount -> getURL( ), 1 );
973 add_assoc_string( z, "user_avatar", ( char* )pAccount -> getUserAvatar( ), 1 );
974 add_assoc_string( z, "user_icq", ( char* )pAccount -> getUserIcq( ), 1 );
975 add_assoc_string( z, "user_from", ( char* )pAccount -> getUserFrom( ), 1 );
976 add_assoc_string( z, "user_sig", ( char* )pAccount -> getUserSig( ), 1 );
977 add_assoc_string( z, "actkey", ( char* )pAccount -> getActkey( ), 1 );
978 add_assoc_string( z, "user_aim", ( char* )pAccount -> getUserAim( ), 1 );
979 add_assoc_string( z, "user_yim", ( char* )pAccount -> getUserYim( ), 1 );
980 add_assoc_string( z, "user_msnm", ( char* )pAccount -> getUserMsnm( ), 1 );
981 add_assoc_string( z, "pass", ( char* )pAccount -> getPass( ), 1 );
982 add_assoc_string( z, "theme", ( char* )pAccount -> getTheme( ), 1 );
983 add_assoc_string( z, "umode", ( char* )pAccount -> getUmode( ), 1 );
984 add_assoc_string( z, "user_occ", ( char* )pAccount -> getUserOcc( ), 1 );
985 add_assoc_string( z, "bio", ( char* )pAccount -> getBio( ), 1 );
986 add_assoc_string( z, "user_intrest", ( char* )pAccount -> getUserIntrest( ), 1 );
987 add_assoc_double( z, "timezone_offset", pAccount -> getTimezoneOffset( ) );
988 add_assoc_long( z, "attachsig", pAccount -> getAttachsig( ) );
989 add_assoc_long( z, "last_login", pAccount -> getLastLogin( ) );
990 add_assoc_long( z, "level", pAccount -> getLevel( ) );
991 add_assoc_long( z, "notify_method", pAccount -> getNotifyMethod( ) );
992 add_assoc_long( z, "notify_mode", pAccount -> getNotifyMode( ) );
993 add_assoc_long( z, "posts", pAccount -> getPosts( ) );
994 add_assoc_long( z, "rank", pAccount -> getRank( ) );
995 add_assoc_long( z, "uorder", pAccount -> getUorder( ) );
996 add_assoc_long( z, "user_mailok", pAccount -> getUserMailok( ) );
997 add_assoc_long( z, "user_regdate", pAccount -> getUserRegdate( ) );
998 add_assoc_long( z, "user_viewemail", pAccount -> getUserViewemail( ) );
999
1000 add_assoc_long( z, "activate", pAccount -> getActivate( ) );
1001 add_assoc_string( z, "address", ( char* )pAccount -> getAddress( ), 1 );
1002 add_assoc_string( z, "division", ( char* )pAccount -> getDivision( ), 1 );
1003 add_assoc_string( z, "tel", ( char* )pAccount -> getTel( ), 1 );
1004 add_assoc_string( z, "company_name", ( char* )pAccount -> getCompanyName( ), 1 );
1005 add_assoc_string( z, "country", ( char* )pAccount -> getCountry( ), 1 );
1006 add_assoc_string( z, "zipcode", ( char* )pAccount -> getZipcode( ), 1 );
1007 add_assoc_string( z, "fax", ( char* )pAccount -> getFax( ), 1 );
1008 add_assoc_string( z, "base_url", ( char* )pAccount -> getBaseURL( ), 1 );
1009 add_assoc_long( z, "notice_mail", pAccount -> getNoticeMail( ) );
1010 add_assoc_long( z, "notice_mail_since", pAccount -> getNoticeMailSince( ) );
1011 add_assoc_long( z, "private_index_id", pAccount -> getPrivateIndexID( ) );
1012 return RES_OK;
1013 }
1014
1015 /**
1016 *
1017 * 茲??違??ccount_t????絎鴻??PHP?????????????????????
1018 * @param pAccounts 紊???????ccount_t*
1019 * @param accountsLen pAccounts?????????激??
1020 * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
1021 * @return RES_OK
1022 *
1023 z: ?????????????????????????? <br>
1024 array(
1025 array(
1026 'uid'=>100,
1027 'activate'=>1,
1028 'division'=>'foo',
1029 'tel'=>'123-456-789',
1030 ...
1031 ),
1032 ...
1033 )
1034 */
1035 result_t accountsToZval( const account_t *pAccounts, int accountsLen, zval *z )
1036 {
1037 zend_hash_clean( z -> value.ht );
1038 for( int i = 0; i < accountsLen; i++ ){
1039 zval *new_array;
1040 MAKE_STD_ZVAL(new_array);
1041 if(array_init(new_array) != SUCCESS){
1042 return RES_ERROR;
1043 }
1044 add_index_zval( z, i, new_array );
1045 accountToZval( &pAccounts[ i ], new_array );
1046 }
1047 return RES_OK;
1048 }
1049
1050 /**
1051 *
1052 * 茲??違??roup_t????絎鴻??PHP?????????????????????
1053 * @param pGroups 紊???????roup_t*
1054 * @param groupsLen pGroups?????????激??
1055 * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
1056 * @return RES_OK
1057 *
1058 z: ?????????????????????????? <br>
1059 array(
1060 array(
1061 'gid'=>1,
1062 'gname'=>'foo group',
1063 'gdesc'=>'group of foo'
1064 ),
1065 ...
1066 )
1067 */
1068 result_t groupsToZval( const group_t *pGroups, int groupsLen, zval *z )
1069 {
1070 zend_hash_clean( z -> value.ht );
1071 for( int i = 0; i < groupsLen; i++ ){
1072 zval *new_array;
1073 MAKE_STD_ZVAL(new_array);
1074 if(array_init(new_array) != SUCCESS){
1075 return RES_ERROR;
1076 }
1077 add_index_zval( z, i, new_array );
1078 add_assoc_long( new_array, "gid", pGroups[ i ].getGID( ) );
1079 add_assoc_string( new_array, "gname", ( char* )pGroups[ i ].getGname( ), 1 );
1080 add_assoc_string( new_array, "gdesc", ( char* )pGroups[ i ].getDesc( ), 1 );
1081 add_assoc_long( new_array, "group_index_id", pGroups[ i ].getGroupIndexID( ) );
1082 }
1083 return RES_OK;
1084 }
1085
1086 /**
1087 *
1088 * group_t????絎鴻??PHP???f?渇?????????????
1089 *
1090 * @param pGroup 紊????????違???若??????/span>
1091 * @param z 紊???腟??????吾??莨若???f?渇????(??????羝??帥?с????????
1092 * @return RES_OK
1093 *
1094 */
1095 result_t groupToZval( const group_t *pGroup, zval *z )
1096 {
1097 zend_hash_clean( z -> value.ht );
1098 add_assoc_long( z, "gid", pGroup -> getGID( ) );
1099 add_assoc_string( z, "gname", ( char* )pGroup -> getGname( ), 1 );
1100 add_assoc_string( z, "gdesc", ( char* )pGroup -> getDesc( ), 1 );
1101 add_assoc_long( z, "group_index_id", pGroup -> getGroupIndexID( ) );
1102 return RES_OK;
1103 }
1104
1105 /**
1106 *
1107 * PHP???f?渇????????絎鴻??group_t?????????
1108 *
1109 * @param z 紊????????f?渇????
1110 * @param pGroup 紊???腟??????吾??莨若???違???若??
1111 * @return RES_OK
1112 *
1113 */
1114 result_t zvalToGroup( zval *z, group_t *pGroup )
1115 {
1116 zval **tmp;
1117 HashPosition pos;
1118 int i = 0;
1119 char* key = 0;
1120
1121 key = "gid";
1122 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1123 convert_to_long_ex( tmp ) ;
1124 pGroup -> setGID( (*tmp) -> value.lval );
1125 }
1126 key = "gname";
1127 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1128 convert_to_string_ex( tmp ) ;
1129 pGroup -> setGname( (*tmp) -> value.str.val );
1130 }
1131 key = "gdesc";
1132 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1133 convert_to_string_ex( tmp ) ;
1134 pGroup -> setDesc( (*tmp) -> value.str.val );
1135 }
1136 key = "group_index_id";
1137 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1138 convert_to_long_ex( tmp ) ;
1139 pGroup -> setGroupIndexID( (*tmp) -> value.lval );
1140 }
1141 return RES_OK;
1142 }
1143
1144 /**
1145 *
1146 * session_t????絎鴻??PHP???f?渇?????????????
1147 *
1148 * @param pSession 紊???????ession_t
1149 * @param z 紊???腟??????吾??莨若???f?渇????(??????羝??帥?с????????
1150 * @return RES_OK
1151 *
1152 */
1153 result_t sessionToZval( const session_t *pSession, zval *z )
1154 {
1155 string sessionID(unsignedIntToString(pSession->getSessionID()));
1156 add_assoc_string(z, "session_id", (char *)sessionID.c_str(), 1);
1157
1158 string date(unsignedIntToString((unsigned int)pSession->getDate()));
1159 add_assoc_string(z, "date", (char *)date.c_str(), 1);
1160
1161 string userID(unsignedIntToString((unsigned int)pSession->getUID()));
1162 add_assoc_string(z, "user_id", (char *)userID.c_str(), 1);
1163
1164 return RES_OK;
1165 }
1166
1167 /**
1168 *
1169 * index_t????絎鴻??PHP???????????????
1170 * @param pIndex 紊???????ndex_t*
1171 * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
1172 * @return RES_OK
1173 *
1174 */
1175 result_t indexToZval( const index_t *pIndex, zval *z )
1176 {
1177 zend_hash_clean( z -> value.ht );
1178
1179 add_assoc_long( z, "item_id", pIndex -> getItemID( ) );
1180 add_assoc_long( z, "item_type_id", pIndex -> getItemTypeID( ) );
1181 add_assoc_long( z, "contributor_uid", pIndex -> getContributorUID( ) );
1182 add_assoc_string( z, "title", ( char* )pIndex -> getTitle( ), 1 );
1183 add_assoc_string( z, "keywords", ( char* )pIndex -> getKeywords( ), 1 );
1184 add_assoc_string( z, "description", ( char* )pIndex -> getDescription( ), 1 );
1185 add_assoc_long( z, "last_update_date", pIndex -> getLastUpdateDate( ) );
1186 add_assoc_long( z, "creation_date", pIndex-> getCreationDate( ) );
1187 add_assoc_long( z, "parent_index_id", pIndex -> getParentIndexID( ) );
1188 add_assoc_long( z, "owner_uid", pIndex -> getOwnerUID( ) );
1189 add_assoc_long( z, "owner_gid", pIndex -> getOwnerGID( ) );
1190 add_assoc_long( z, "open_level", pIndex -> getOpenLevel( ) );
1191 add_assoc_long( z, "sort_number", pIndex -> getSortNumber( ) );
1192 return RES_OK;
1193 }
1194
1195 result_t indexesToZval( const index_t *pIndexes, int indexesLen, zval *z )
1196 {
1197 zend_hash_clean( z -> value.ht );
1198 for( int i = 0; i < indexesLen; i++ ){
1199 zval *new_array;
1200 MAKE_STD_ZVAL(new_array);
1201 if(array_init(new_array) != SUCCESS){
1202 return RES_ERROR;
1203 }
1204 add_index_zval( z, i, new_array );
1205 indexToZval( &pIndexes[ i ], new_array );
1206 }
1207 return RES_OK;
1208 }
1209
1210
1211
1212
1213 /** ??絎??????違???若???????宴??緇???<br>
1214 int xnp_get_group( int sid, int gid, array group );
1215 @param sid XNP???祉???激?с??D
1216 @param gid XNP ? group_id
1217 @param group 腟?????????????????
1218 @return 0 success <br>
1219 */
1220 ZEND_FUNCTION(xnp_get_group)
1221 {
1222 long sid, gid;
1223 zval *zgroup;
1224
1225 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
1226 &sid, &gid, &zgroup) == FAILURE) {
1227 return;
1228 }
1229
1230 const group_t *pgroup;
1231 result_t result = getGroup( (sessionid_t)sid, (groupid_t)gid, &pgroup );
1232 if ( RES_OK == result ){
1233 groupToZval( pgroup, zgroup );
1234 freeGroup( pgroup );
1235 }
1236
1237 RETURN_LONG(result);
1238 }
1239
1240
1241 /** ??絎??????違???若??(茲????????宴??緇???<br>
1242 xnp_get_groups( int sid, array gids, array criteria, array groups );
1243 @param sid XNP???祉???激?с??D
1244 @param gids XNP ? group_id ??????
1245 @param criteria ?>散
1246 @param groups 腟???????????????????????
1247 @return 0 success <br>
1248 */
1249 ZEND_FUNCTION(xnp_get_groups)
1250 {
1251 result_t result;
1252 long sid, uid;
1253 zval *zcriteria;
1254 zval *zgids;
1255 zval *zgroups;
1256 zval **ppzTmp = 0;
1257 HashPosition pos;
1258 int res2;
1259 int gidsLen;
1260 const group_t* groups;
1261 int groupsLen;
1262
1263 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
1264 &sid, &zgids, &zcriteria, &zgroups) == FAILURE) {
1265 return;
1266 }
1267
1268 //gids???違???若??ID???潟???若????
1269 gidsLen = zend_hash_num_elements(Z_ARRVAL_P(zgids));
1270 groupid_t *gids = new groupid_t[ gidsLen ];
1271 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zgids), &pos);
1272 for( int i = 0; i < gidsLen; i++ ){
1273 if( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(zgids), (void **)&ppzTmp, &pos)) == SUCCESS ){
1274 SEPARATE_ZVAL(ppzTmp);
1275 convert_to_long_ex(ppzTmp);
1276 gids[ i ] = Z_LVAL_PP(ppzTmp);
1277 }
1278 zend_hash_move_forward_ex(Z_ARRVAL_P(zgids), &pos);
1279 }
1280
1281 zCriteria_t zcri(zcriteria);
1282 result = zcri.getResult();
1283 if ( RES_OK == result ){
1284 result = getGroups( (sessionid_t)sid, gids, gidsLen, &zcri, &groups, &groupsLen );
1285 if ( RES_OK == result ){
1286 groupsToZval( groups, groupsLen, zgroups );
1287 delete[] gids;
1288 freeGroup( groups );
1289 }
1290 }
1291 RETURN_LONG(result);
1292 }
1293
1294
1295 /** ??絎????????若?吟???≪?????若?帥??????????茯帥?鴻??<br>
1296 int xnp_is_moderator(int sid, int uid)
1297 @param sid XNP???祉???激?с??D
1298 @param uid xoops ? uid (xoops_users.uid)
1299 @return true ?≪?????若?帥?с???? <br>
1300 */
1301 ZEND_FUNCTION(xnp_is_moderator)
1302 {
1303 long xnpSessionID;
1304 userid_t uid;
1305
1306 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
1307 &xnpSessionID, &uid) == FAILURE) {
1308 return;
1309 }
1310
1311 bool result = isModerator( (sessionid_t)xnpSessionID, uid );
1312 RETURN_BOOL(result)
1313 }
1314
1315 /** ???若?九??????uid??茯帥?鴻??<br>
1316 int xnp_get_uid(string uname,int &uid)
1317 @param sid XNP???祉???激?с??D
1318 @param uname xoops ? uname (xoops_users.uname)
1319 @param uid xoops ? uid (xoops_users.uid) ??????????紊???/span>
1320 @return 0 success
1321 */
1322 ZEND_FUNCTION(xnp_get_uid)
1323 {
1324 char *uname;
1325 int unameLen;
1326 zval *zuid;
1327 userid_t uid;
1328
1329 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
1330 &uname, &unameLen, &zuid) == FAILURE) {
1331 return;
1332 }
1333
1334 if (!PZVAL_IS_REF(zuid)) {
1335 zend_error(E_WARNING, "2nd parameter wasn't passed by reference");
1336 RETURN_LONG(RES_PHP_NONREF);
1337 }
1338
1339 string strUname( uname, unameLen );
1340 result_t result = getUid( strUname.c_str(), &uid );
1341 ZVAL_LONG(zuid, (long)uid);
1342 RETURN_LONG((long)result);
1343 }
1344
1345 ZEND_FUNCTION(xnp_test_criteria)
1346 {
1347 zval *z;
1348
1349 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
1350 &z) == FAILURE) {
1351 return;
1352 }
1353 zend_printf("zend_printf...<br>\n");
1354 zCriteria_t zcri(z);
1355 zcri.dump();
1356 RETURN_FALSE
1357 }
1358
1359 ZEND_FUNCTION(xnp_test_uids)
1360 {
1361 zval *z;
1362
1363 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
1364 &z) == FAILURE) {
1365 return;
1366 }
1367 zend_printf("zend_printf...<br>\n");
1368 zUIDs_t zuids(z);
1369 zuids.dump();
1370 RETURN_FALSE
1371 }
1372
1373
1374
1375 /** DB??・膓????????≪??・膓?筝???・膓???????????????<br>
1376 int initialize_db( string host[, string user[, string password[, string dbname[, string prefix]]]] );
1377 @param host ?ョ????????ユ????ULL
1378 @param user DB?ョ????????若?九???????ユ????ULL
1379 @param password DB?ョ????????鴻???若???????ユ????ULL
1380 @param dbname DB?ョ?????B???????ユ????quot;"
1381 @param prefix XOOPS DB ??refix??
1382 @return 0 success <br>
1383 */
1384 ZEND_FUNCTION(xnp_initialize_db)
1385 {
1386 zval **parameters[5];
1387 char *host;
1388 char *user;
1389 char *password;
1390 char *dbname;
1391 char *prefix;
1392
1393 /* get the number of arguments */
1394 int argNum = ZEND_NUM_ARGS();
1395 if (argNum > 5)
1396 WRONG_PARAM_COUNT;
1397
1398 /* argument count is correct, now retrieve arguments */
1399 if(zend_get_parameters_array_ex(argNum, parameters) != SUCCESS)
1400 WRONG_PARAM_COUNT;
1401
1402 if (argNum < 1) host = NULL;
1403 else host = getZvalString( parameters[0] );
1404
1405 if (argNum < 2) user = NULL;
1406 else user = getZvalString( parameters[1] );
1407
1408 if (argNum < 3) password = NULL;
1409 else password = getZvalString( parameters[2] );
1410
1411 if (argNum < 4) dbname = "";
1412 else dbname = getZvalString( parameters[3] );
1413
1414 if (argNum < 5) prefix = "";
1415 else prefix = getZvalString( parameters[4] );
1416
1417 result_t result = initializeDB( host, user, password, dbname, prefix );
1418
1419 RETURN_LONG(result);
1420 }
1421
1422 /** ???違?ゃ?潟??????<br>
1423 int xnp_login_user(string uname, string password, int &session_id)
1424 @param uname ???若?九??(xoops_users.uname)
1425 @param password ???鴻???若??(md5(password)=xoops_users.pass)
1426 @return 0 success
1427 */
1428 ZEND_FUNCTION(xnp_login_user)
1429 {
1430 char *uname;
1431 int unameLen;
1432 char *passwd;
1433 int passwdLen;
1434 zval *zXNPSessionID;
1435
1436 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssz",
1437 &uname, &unameLen, &passwd, &passwdLen, &zXNPSessionID) == FAILURE) {
1438 return;
1439 }
1440
1441 if (!PZVAL_IS_REF(zXNPSessionID)) {
1442 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
1443 RETURN_LONG(RES_PHP_NONREF);
1444 }
1445
1446 sessionid_t xnpSessionID;
1447 result_t result = loginUser( uname, passwd, &xnpSessionID );
1448 if ( result == RES_OK )
1449 ZVAL_LONG(zXNPSessionID, (long)xnpSessionID);
1450 RETURN_LONG((long)result);
1451 }
1452
1453 /** ???違?≪??????????<br>
1454 void xnp_logout_user(int xnp_session_id)
1455 @param xnp_session_id XNP???祉???激?с??D
1456 @return ????
1457 */
1458 ZEND_FUNCTION(xnp_logout_user)
1459 {
1460 long xnpSessionID;
1461
1462 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &xnpSessionID) == FAILURE) {
1463 return;
1464 }
1465 logoutUser( (sessionid_t)xnpSessionID );
1466
1467 RETURN_NULL();
1468 }
1469
1470 /** XNP???祉???激?с??D 篏???<br>
1471 int xnp_create_session( string xoops_sess_id, int uid, int &session )
1472 @param xoops_sess_id xoops???祉???激?с??D
1473 @param uid xoops ? uid (xoops_users.uid)
1474 @param session 篏???????XNP??ession??????????紊???/span>
1475 @return 0 ????
1476 */
1477 ZEND_FUNCTION(xnp_create_session)
1478 {
1479 char *xoopsSessionID;
1480 int xoopsSessionIDLen;
1481 long uid;
1482 zval *zXNPSessionID;
1483
1484 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "slz",
1485 &xoopsSessionID, &xoopsSessionIDLen, &uid, &zXNPSessionID) == FAILURE) {
1486 return;
1487 }
1488
1489 if (!PZVAL_IS_REF(zXNPSessionID)) {
1490 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
1491 RETURN_LONG(RES_PHP_NONREF);
1492 }
1493
1494 sessionid_t xnpSessionID = 0;
1495 result_t result = createSession( xoopsSessionID, (userid_t)uid, &xnpSessionID );
1496 if ( result == RES_OK )
1497 ZVAL_LONG(zXNPSessionID, (long)xnpSessionID);
1498 RETURN_LONG((long)result);
1499 }
1500
1501 /** XNP ? session ???膣井???宴??緇???<br>
1502 int xnp_get_session( int xnp_session_id, array session_info )
1503 @param xnp_session_id XNP???祉???激?с??D
1504 @param session_info 腟?????????????????
1505 @return 0 success
1506 */
1507 ZEND_FUNCTION(xnp_get_session)
1508 {
1509 long xnpSessionID;
1510 zval *sessionInfo;
1511 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1512 &xnpSessionID, &sessionInfo) == FAILURE) {
1513 return;
1514 }
1515 const session_t *session = 0;
1516 result_t result = getSession( (sessionid_t)xnpSessionID, &session );
1517 if ( result == RES_OK ){
1518 sessionToZval( session, sessionInfo );
1519 freeSession( session );
1520 }
1521
1522 RETURN_LONG((long)result);
1523 }
1524
1525 /** ???若?吟??ctivate?倶??????緇?????<br>
1526 bool xnp_is_activated( int xnp_session_id, int user_id )
1527 @param xnp_session_id XNP???祉???激?с??D
1528 @param user_id xoops_users.uid
1529 @return 0 success
1530 */
1531 ZEND_FUNCTION(xnp_is_activated)
1532 {
1533 long sid, uid;
1534
1535 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &sid, &uid) == FAILURE) {
1536 return;
1537 }
1538
1539 bool result = isActivated( (sessionid_t)sid, (userid_t)uid );
1540
1541 RETURN_BOOL(result);
1542 }
1543
1544 /** activate??????<br>
1545 bool xnp_activate( int xnp_session_id, int user_id, bool activated )
1546 @param xnp_session_id xnp ? session id
1547 @param user_id xoops_users.uid
1548 @param activated true:activate, false:inactivate
1549 @return 0 success
1550 */
1551 ZEND_FUNCTION(xnp_activate)
1552 {
1553 long sid, uid;
1554 bool activated;
1555
1556 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llb",
1557 &sid, &uid, &activated) == FAILURE) {
1558 return;
1559 }
1560
1561 result_t result = activate( (sessionid_t)sid, (userid_t)uid, activated );
1562
1563 RETURN_LONG(result);
1564 }
1565
1566 /** XNP???≪?????潟???違??緇?????<br>
1567 int xnp_get_account_count( int xnp_session_id )
1568 @param xnp_session_id XNP???祉???激?с??D
1569 @return 0 success
1570 */
1571 ZEND_FUNCTION(xnp_get_account_count)
1572 {
1573 long sid;
1574
1575 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1576 &sid) == FAILURE) {
1577 return;
1578 }
1579
1580 long count = getAccountCount( (sessionid_t)sid );
1581 RETURN_LONG(count);
1582 }
1583
1584 /** ?≪?????潟???????ゃ??????<br>
1585 bool xnp_delete_account( int xnp_session_id, int user_id )
1586 @param xnp_session_id XNP???祉???激?с??D
1587 @param user_id xoops_users.uid
1588 @return 0 success
1589 */
1590 ZEND_FUNCTION(xnp_delete_account)
1591 {
1592 long sid, uid;
1593
1594 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
1595 &sid, &uid) == FAILURE) {
1596 return;
1597 }
1598
1599 result_t result = deleteAccount( (sessionid_t)sid, (userid_t)uid );
1600
1601 RETURN_LONG(result);
1602 }
1603
1604 /** ?≪?????潟?????宴??緇?????<br>
1605 int xnp_get_account( int xnp_session_id, int user_id, array account_info )
1606 @param xnp_session_id XNP???祉???激?с??D
1607 @param user_id xoops_users.uid
1608 @param account_info ?≪?????潟?????宴???????????f?渇????
1609 @return 0 success
1610 */
1611 ZEND_FUNCTION(xnp_get_account)
1612 {
1613 long sid, uid;
1614 zval *zaccount;
1615
1616 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
1617 &sid, &uid, &zaccount) == FAILURE) {
1618 fprintf( stderr, "error occured " );
1619 return;
1620 }
1621
1622 const account_t *paccount;
1623 result_t result = getAccount( (sessionid_t)sid, (userid_t)uid, &paccount );
1624 if ( RES_OK == result ){
1625 accountToZval( paccount, zaccount );
1626 freeAccount( paccount );
1627 }
1628
1629 RETURN_LONG(result);
1630 }
1631
1632 /** ?>散????眼?????≪?????潟???????宴??緇?????<br>
1633 int xnp_get_accoutns( int sid, array uids, array criteria, array accounts );
1634 @param xnp_session_id XNP???祉???激?с??D
1635 @param user_id xoops_users.uid
1636 @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1637 @param account_info ?≪?????潟?????宴???????????f?渇????
1638 @return 0 success
1639 */
1640 ZEND_FUNCTION(xnp_get_accounts)
1641 {
1642 result_t result;
1643 long sid;
1644 zval *zuids;
1645 zval *zcriteria;
1646 zval *zaccount;
1647
1648 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
1649 &sid, &zuids, &zcriteria, &zaccount) == FAILURE) {
1650 return;
1651 }
1652
1653 zCriteria_t zcri(zcriteria);
1654 result = zcri.getResult();
1655 if ( RES_OK == result ){
1656 zUIDs_t zUIDs(zuids);
1657 result = zUIDs.getResult();
1658 if ( RES_OK == result ){
1659 const account_t *paccounts;
1660 int accountLen;
1661 result = getAccounts( (sessionid_t)sid,
1662 zUIDs.getPUID(), zUIDs.getLen(),
1663 &zcri, &paccounts, &accountLen );
1664 if ( RES_OK == result ){
1665 accountsToZval( paccounts, accountLen, zaccount );
1666 freeAccount( paccounts );
1667 }
1668 }
1669 }
1670
1671 RETURN_LONG(result);
1672 }
1673
1674 /** ?≪?????潟?????宴??荐??蚊??????<br>
1675 int xnp_insert_account( int sid, array account_info, int &user_id );
1676 @param xnp_session_id xnp ? session id
1677 @param account_info 荐??蚊???????≪?????潟????????/span>
1678 @param user_id ???若??D(xoops_users.uid)???吾??莨若???????<???潟??/span>
1679 @return 0 success
1680 */
1681 ZEND_FUNCTION(xnp_insert_account)
1682 {
1683 result_t result;
1684 long sid;
1685 zval *zaccount;
1686 zval *zuid;
1687 userid_t uid;
1688
1689 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
1690 &sid, &zaccount, &zuid) == FAILURE) {
1691 return;
1692 }
1693
1694 zAccount_t zacc(zaccount);
1695 result = zacc.getResult();
1696 if ( RES_OK == result ){
1697 result = insertAccount( (sessionid_t)sid, &zacc, &uid );
1698 }
1699 zuid -> type = IS_LONG;
1700 zuid -> value.lval = uid;
1701 RETURN_LONG(result);
1702 }
1703
1704 /** ?≪?????潟?????宴???贋?違??????<br>
1705 int xnp_update_account( int sid, array account );
1706 @param xnp_session_id XNP???祉???激?с??D
1707 @param account_info ?吾??莨若???鴻???≪?????潟?????宴??茵????f?渇????
1708 @return 0 success
1709 */
1710 ZEND_FUNCTION(xnp_update_account)
1711 {
1712 result_t result;
1713 long sid;
1714 zval *zaccount;
1715
1716 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1717 &sid, &zaccount) == FAILURE) {
1718 return;
1719 }
1720
1721 zAccount_t zacc(zaccount);
1722 result = zacc.getResult();
1723 if ( RES_OK == result ){
1724 result = updateAccount( (sessionid_t)sid, &zacc );
1725 }
1726
1727 RETURN_LONG(result);
1728 }
1729
1730 /** ?>散???????≪?????潟????id???荀с??緇?????<br>
1731 int xnp_dump_uids( int xnp_session_id, array criteria, array uids );
1732 @param xnp_session_id XNP???祉???激?с??D
1733 @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1734 @param uids uid??????????????
1735 @return 0 success
1736 */
1737 ZEND_FUNCTION(xnp_dump_uids)
1738 {
1739 result_t result;
1740 long sid;
1741 zval *zcriteria;
1742 zval *zuids;
1743
1744 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1745 &sid, &zcriteria, &zuids) == FAILURE) {
1746 return;
1747 }
1748
1749 zCriteria_t zcri(zcriteria);
1750 result = zcri.getResult();
1751 if ( RES_OK == result ){
1752 userid_t *puid;
1753 int uidLen;
1754 result = dumpUids( (sessionid_t)sid, &zcri, &puid, &uidLen );
1755 if ( RES_OK == result ){
1756 uidsToZval( puid, uidLen, &zuids );
1757 freeUID( puid );
1758 }
1759 }
1760
1761 RETURN_LONG(result);
1762 }
1763
1764 /** XNP???違???若?????違??緇???<br>
1765 int xnp_get_group_count( int xnp_session_id );
1766 @param xnp_session_id XNP???祉???激?с??D
1767 @return ?違???若????/span>
1768 */
1769 ZEND_FUNCTION(xnp_get_group_count)
1770 {
1771 result_t result;
1772 long sid;
1773
1774 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1775 &sid) == FAILURE) {
1776 return;
1777 }
1778
1779 int count = getGroupCount( (sessionid_t)sid );
1780
1781 RETURN_LONG(count);
1782 }
1783
1784 /** uid?ф??絎????????若?吟??絮????違???若???с?????ゆ?>散????眼?????違???若????id??緇???<br>
1785 int xnp_get_group_by_uid( int xnp_session_id, int uid, array criteria, array gids );
1786 @param xnp_session_id XNP???祉???激?с??D
1787 @param user_id xoops_users.uid
1788 @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1789 @param gids gid??????????????
1790 @return 0 success
1791 */
1792 ZEND_FUNCTION(xnp_get_groups_by_uid)
1793 {
1794 result_t result;
1795 long sid, uid;
1796 zval *zcriteria;
1797 zval *zgids;
1798
1799 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1800 &sid, &uid, &zcriteria, &zgids) == FAILURE) {
1801 return;
1802 }
1803
1804 zCriteria_t zcri(zcriteria);
1805 result = zcri.getResult();
1806 if ( RES_OK == result ){
1807 groupid_t *pgids;
1808 int gidLen;
1809 result = getGroupsByUid( (sessionid_t)sid, (userid_t)uid, &zcri, &pgids, &gidLen );
1810 if ( RES_OK == result ){
1811 gidsToZval( pgids, gidLen, &zgids );
1812 freeGID( pgids );
1813 }
1814 }
1815
1816 RETURN_LONG(result);
1817 }
1818
1819
1820
1821 /** uid?ф??絎????????若?吟??gid?ф??絎??????違???若?????違???若??膊∞??????????????緇???<br>
1822 int xnp_is_group_admin( int sid, int gid, int uid );
1823 @param xnp_session_id XNP???祉???激?с??D
1824 @param group_id XNP???違???若??ID
1825 @param user_id xoops_users.uid
1826 @return true: ?違???若??膊∞?????с??????
1827 @return false: ?違???若??膊∞?????с???????????????????若?с??????
1828 */
1829 ZEND_FUNCTION(xnp_is_group_admin)
1830 {
1831 result_t result;
1832 long sid, gid, uid;
1833
1834 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1835 &sid, &gid, &uid) == FAILURE) {
1836 return;
1837 }
1838
1839 bool b = isGroupAdmin( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1840
1841 RETURN_BOOL(b);
1842 }
1843
1844 /** ?>散????眼?????違???若????id???荀с??緇?????<br>
1845 int xnp_dump_gids( int sid, array criteria, array gids );
1846 @param xnp_session_id XNP???祉???激?с??D
1847 @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1848 @param gids gid??????????????
1849 @return 0 success
1850 */
1851 ZEND_FUNCTION(xnp_dump_gids)
1852 {
1853 result_t result;
1854 long sid;
1855 zval *zcriteria;
1856 zval *zgids;
1857
1858 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1859 &sid, &zcriteria, &zgids) == FAILURE) {
1860 return;
1861 }
1862
1863 zCriteria_t zcri(zcriteria);
1864 result = zcri.getResult();
1865 if ( RES_OK == result ){
1866 groupid_t *pgid;
1867 int gidLen;
1868 result = dumpGids( (sessionid_t)sid, &zcri, &pgid, &gidLen );
1869 if ( RES_OK == result ){
1870 gidsToZval( pgid, gidLen, &zgids );
1871 freeGID( pgid );
1872 }
1873 }
1874
1875 RETURN_LONG(result);
1876 }
1877
1878 /** gid?ф??絎??????違???若??????????с?????ゆ?>散????眼?????違???若??膊∞??????id???荀с??緇?????<br>
1879 int xnp_dump_group_admins(int sid, int group_id, array criteria, array uids )
1880 @param sid XNP???祉???激?с??D
1881 @param group_id XNP???違???若??ID
1882 @param criteria ?>散
1883 @param uids uid???荀с??????????????
1884 @return 0 success
1885 */
1886
1887 ZEND_FUNCTION(xnp_dump_group_admins)
1888 {
1889 long sid, gid;
1890 zval *zcriteria;
1891 zval *zuids;
1892
1893 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1894 &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1895 return;
1896 }
1897
1898 zCriteria_t zcri(zcriteria);
1899 result_t result = zcri.getResult();
1900 if ( result == RES_OK ){
1901 userid_t *uids;
1902 int uidsLen;
1903 result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
1904 if ( result == RES_OK ){
1905 uidsToZval( uids, uidsLen, &zuids );
1906 freeUID( uids );
1907 }
1908 }
1909 RETURN_LONG( result );
1910 }
1911
1912 /** ?違???若???????<?潟???若?????ゃ??????<br>
1913 int xnp_delete_member(int sid, int group_id, int user_id )
1914 @param sid XNP???祉???激?с??D
1915 @param group_id XNP???違???若??ID
1916 @param user_id ???若??D
1917 @return 0 success
1918 */
1919
1920 ZEND_FUNCTION(xnp_delete_member)
1921 {
1922 long sid, gid, uid;
1923
1924 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1925 &sid, &gid, &uid) == FAILURE) {
1926 return;
1927 }
1928
1929 result_t result = deleteMember( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1930 RETURN_LONG( result );
1931 }
1932
1933 /** ?違???若?????<?潟???若??菴遵??????<br>
1934 int xnp_insert_member(int sid, int group_id, int user_id, bool admin )
1935 @param sid XNP???祉???激?с??D
1936 @param group_id XNP???違???若??ID
1937 @param user_id ???若??D
1938 @param admin ?違???若??膊∞????????true
1939 @return 0 success
1940 */
1941
1942 ZEND_FUNCTION(xnp_insert_member)
1943 {
1944 long sid, gid, uid;
1945 zend_bool admin;
1946
1947 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllb",
1948 &sid, &gid, &uid, &admin) == FAILURE) {
1949 return;
1950 }
1951
1952 result_t result = insertMember( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid, (bool)admin );
1953 RETURN_LONG( result );
1954 }
1955
1956 /** gid?ф??絎??????違???若?????<?潟???若??id???荀с??緇???<br>
1957 int xnp_get_members(int sid, int group_id, array criteria, array uids )
1958 @param sid XNP???祉???激?с??D
1959 @param group_id XNP???違???若??ID
1960 @param criteria ?>散
1961 @param uids uid???荀с??????????????
1962 @return 0 success
1963 */
1964
1965 ZEND_FUNCTION(xnp_get_members)
1966 {
1967 long sid, gid;
1968 zval *zcriteria;
1969 zval *zuids;
1970
1971 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1972 &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1973 return;
1974 }
1975
1976 zCriteria_t zcri(zcriteria);
1977 result_t result = zcri.getResult();
1978 if ( result == RES_OK ){
1979 userid_t *uids;
1980 int uidsLen;
1981 result = getMembers( (sessionid_t)sid, (groupid_t)gid, &zcri, &uids, &uidsLen );
1982 if ( result == RES_OK ){
1983 uidsToZval( uids, uidsLen, &zuids );
1984 freeUID( uids );
1985 }
1986 }
1987 RETURN_LONG( result );
1988 }
1989
1990 /** ?違???若?????宴??紊??眼??????<br>
1991 int xnp_update_group(int sid, array group )
1992 @param sid XNP???祉???激?с??D
1993 @param group ?違???若?????宴???f?渇????
1994 @return 0 success
1995 */
1996 ZEND_FUNCTION(xnp_update_group)
1997 {
1998 long sid;
1999 zval *zgroup;
2000 group_t group;
2001
2002 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
2003 &sid, &zgroup) == FAILURE) {
2004 return;
2005 }
2006
2007 zvalToGroup( zgroup, &group );
2008 result_t result = updateGroup( sid, &group );
2009 RETURN_LONG( result );
2010 }
2011
2012 /** ?違???若?????宴??菴遵????????<br>
2013 int xnp_insert_group( int sid, array group, int &gid )
2014 @param sid ?祉???激?с??D
2015 @param group ?違???若?????宴???f?渇????
2016 @param gid 絲上??????違???若??ID???吾??莨若???????<???潟??/span>
2017 @return RES_OK
2018 @return RES_DB_NOT_INITIALIZED
2019 @return RES_NO_SUCH_SESSION
2020 @return RES_DB_QUERY_ERROR
2021 */
2022 ZEND_FUNCTION(xnp_insert_group)
2023 {
2024 long sid;
2025 zval *zgroup;
2026 zval *zgid;
2027 group_t group;
2028 groupid_t gid;
2029
2030 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
2031 &sid, &zgroup, &zgid ) == FAILURE) {
2032 return;
2033 }
2034
2035 zvalToGroup( zgroup, &group );
2036 result_t result = insertGroup( sid, &group, &gid );
2037 zgid -> type = IS_LONG;
2038 zgid -> value.lval = gid;
2039 RETURN_LONG( result );
2040 }
2041
2042
2043 /** ?違???若?????宴?????ゃ??????<br>
2044 int xnp_delete_group( int sid, int gid )
2045 @param sid XNP???祉???激?с??D
2046 @param gid ???ゃ???????違???若????D
2047 @return RES_OK
2048 @return RES_DB_QUERY_ERROR
2049 @return RES_NO_SUCH_SESSION
2050 @return RES_DB_NOT_INITIALIZED
2051 */
2052 ZEND_FUNCTION(xnp_delete_group)
2053 {
2054 long sid;
2055 long gid;
2056
2057 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2058 &sid, &gid) == FAILURE) {
2059 return;
2060 }
2061 RETURN_LONG( deleteGroup( sid, gid ) );
2062 }
2063
2064 /** ?違???若?????????????緇???<br>
2065 int xnp_dump_group_admins( int sid, int gid, array criteria, array uids )
2066 @param sid XNP???祉???激?с??D
2067 @param gid XNP?違???若????D
2068 @param criteria uids???吾??莨若?????????純?若???>散鐚?膀??蚊????絎?
2069 @param uids 膊∞??????ID???吾??莨若??????
2070 @return RES_OK
2071 @return RES_DB_QUERY_ERROR
2072 @return RES_NO_SUCH_SESSION
2073 @return RES_DB_NOT_INITIALIZED
2074 */
2075 /*
2076 ZEND_FUNCTION(xnp_dump_group_admins)
2077 {
2078 long sid;
2079 long gid;
2080 zval *zcriteria;
2081 zval *zuids;
2082
2083 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
2084 &sid, &gid, &zcriteria, &zuids) == FAILURE) {
2085 return;
2086 }
2087 zCriteria_t zcri(zcriteria);
2088 result_t result = zcri.getResult();
2089 if ( RES_OK == result ){
2090 userid_t* uids;
2091 int uidsLen;
2092 result_t result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
2093 if( result != RES_OK ) RETURN_LONG( result );
2094 uidsToZval( uids, uidsLen, &zuids );
2095 fprintf( stderr, "uidsLen=%d\n", uidsLen );
2096 for( int i = 0; i < uidsLen; i++ ){
2097 fprintf( stderr, "%d, \n", uids[ i ] );
2098 }
2099 freeUID( uids );
2100 RETURN_LONG( result );
2101 }
2102 RETURN_LONG( result );
2103 }
2104 */
2105
2106 /** ???????ゃ?潟???????鴻??緇???<br>
2107 * int xnp_get_all_indexes( int sid, array criteria, array indexes );
2108 * @param sid XNP???祉???激?с??D
2109 * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2110 * @return RES_OK
2111 */
2112 ZEND_FUNCTION(xnp_get_all_indexes)
2113 {
2114 long sid;
2115 zval *zcriteria;
2116 zval *zindexes;
2117
2118 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
2119 &sid, &zcriteria, &zindexes) == FAILURE) {
2120 return;
2121 }
2122 zCriteria_t zcri(zcriteria);
2123 result_t result = zcri.getResult();
2124 if ( RES_OK == result ){
2125 const index_t *indexes;
2126 int indexesLen;
2127 result = getAllIndexes( sid, &zcri, &indexes, &indexesLen );
2128 if ( RES_OK == result ){
2129 result = indexesToZval( indexes, indexesLen, zindexes );
2130 freeIndex( indexes );
2131 }
2132 }
2133 RETURN_LONG(result);
2134 }
2135
2136 /** ?????ゃ?潟???????鴻??????????ゃ?潟???????鴻??緇???<br>
2137 * int xnp_get_indexes( int sid, int parentXID, array criteria, array indexes );
2138 * @param sid XNP???祉???激?с??D
2139 * @param parentXID 荀???ndexID
2140 * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2141 * @param indexes 腟?????????????????
2142 * @return RES_OK
2143 */
2144 ZEND_FUNCTION(xnp_get_indexes)
2145 {
2146 long sid;
2147 long parentXID;
2148 zval *zcriteria;
2149 zval *zindexes;
2150
2151 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
2152 &sid, &parentXID, &zcriteria, &zindexes) == FAILURE) {
2153 return;
2154 }
2155 zCriteria_t zcri(zcriteria);
2156 result_t result = zcri.getResult();
2157 if ( RES_OK == result ){
2158 const index_t *indexes;
2159 int indexesLen;
2160 result = getIndexes( sid, parentXID, &zcri, &indexes, &indexesLen );
2161 if ( RES_OK == result ){
2162 result = indexesToZval( indexes, indexesLen, zindexes );
2163 freeIndex( indexes );
2164 }
2165 }
2166 RETURN_LONG(result);
2167 }
2168
2169
2170 /** ?ゃ?潟???????鴻??篏???????<br>
2171 * int xnp_insert_index( int sid, array index, int &indexID );
2172 * @param sid XNP???祉???激?с??D
2173 * @param index 篏????????ゃ?潟????????/span>
2174 * @param indexID 篏??????????ゃ?潟???????鴻??D??????????紊???/span>
2175 * @return RES_OK
2176 */
2177 ZEND_FUNCTION(xnp_insert_index)
2178 {
2179 long sid;
2180 zval *zindex;
2181 zval *zIndexID;
2182
2183 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
2184 &sid, &zindex, &zIndexID) == FAILURE) {
2185 return;
2186 }
2187
2188 if (!PZVAL_IS_REF(zIndexID)) {
2189 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
2190 RETURN_LONG(RES_PHP_NONREF);
2191 }
2192 zIndex_t index( zindex );
2193 indexid_t xid;
2194 result_t result = insertIndex( sid, &index, &xid );
2195 if ( RES_OK == result )
2196 ZVAL_LONG(zIndexID, (long)xid);
2197 RETURN_LONG(result);
2198 }
2199
2200 /** ?ゃ?潟???????鴻???贋?違????<br>
2201 * int xnp_update_index( int sid, array index );
2202 * @param sid XNP???祉???激?с??D
2203 * @param index ?贋?違?????ゃ?潟????????/span>
2204 * @return RES_OK
2205 */
2206 ZEND_FUNCTION(xnp_update_index)
2207 {
2208 long sid;
2209 zval *zindex;
2210
2211 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
2212 &sid, &zindex) == FAILURE) {
2213 return;
2214 }
2215 zIndex_t index(zindex);
2216 result_t result = index.getResult();
2217 if ( RES_OK == result ){
2218 result = updateIndex( sid, &index );
2219 }
2220 RETURN_LONG(result);
2221 }
2222
2223 /** ?ゃ?潟???????鴻?????ゃ????<br>
2224 * int xnp_delete_index( int sid, int indexID );
2225 * @param sid XNP???祉???激?с??D
2226 * @param indexID ???ゃ?????ゃ?潟????????/span>
2227 * @return RES_OK
2228 */
2229 ZEND_FUNCTION(xnp_delete_index)
2230 {
2231 long sid;
2232 long xid;
2233
2234 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2235 &sid, &xid) == FAILURE) {
2236 return;
2237 }
2238
2239 result_t result = deleteIndex( sid, xid );
2240 RETURN_LONG(result);
2241 }
2242
2243
2244 /** ?ゃ?潟???????鴻????緇?????<br>
2245 * int xnp_get_index( int sid, int indexID, array index );
2246 * @param sid XNP???祉???激?с??D
2247 * @param indexID ??緇??????ゃ?潟???????鴻??D
2248 * @param index ??緇?腟??????????????f?渇????
2249 * @return RES_OK
2250 */
2251 ZEND_FUNCTION(xnp_get_index)
2252 {
2253 long sid;
2254 long xid;
2255 zval *zindex;
2256
2257 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
2258 &sid, &xid, &zindex) == FAILURE) {
2259 return;
2260 }
2261
2262 const index_t *index;
2263 result_t result = getIndex( sid, xid, &index );
2264 if ( RES_OK == result ){
2265 result = indexToZval( index, zindex );
2266 freeIndex( index );
2267 }
2268 RETURN_LONG(result);
2269 }
2270
2271
2272
2273 /** ?ゃ?潟???????鴻??茯??粋昭?水??純??????????茯帥?鴻??<br>
2274 * int xnp_is_index_readable( int sid, int indexID );
2275 * @param sid XNP???祉???激?с??D
2276 * @param indexID 絲乗院?ゃ?潟???????鴻??D
2277 * @return true false
2278 */
2279 ZEND_FUNCTION(xnp_is_index_readable)
2280 {
2281 long sid;
2282 long xid;
2283
2284 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2285 &sid, &xid) == FAILURE) {
2286 return;
2287 }
2288 RETURN_BOOL(isIndexReadable(sid,xid));
2289 }
2290
2291
2292 /** ?ゃ?潟???????鴻???吾??莨若?水??純??????????茯帥?鴻??<br>
2293 * int xnp_is_index_writable( int sid, int indexID );
2294 * @param sid XNP???祉???激?с??D
2295 * @param indexID 絲乗院?ゃ?潟???????鴻??D
2296 * @return true false
2297 */
2298 ZEND_FUNCTION(xnp_is_index_writable)
2299 {
2300 long sid;
2301 long xid;
2302
2303 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2304 &sid, &xid) == FAILURE) {
2305 return;
2306 }
2307 RETURN_BOOL(isIndexWritable(sid,xid));
2308 }
2309
2310 /** ?ゃ?潟???????鴻????綺???ャ???帥????<br>
2311 * int xnp_swap_index_sort_number( int sid, int indexID1, int indexID2 );
2312 * @param sid XNP???祉???激?с??D
2313 * @param indexID1 絲乗院?ゃ?潟???????鴻??D
2314 * @param indexID2 絲乗院?ゃ?潟???????鴻??D
2315 * @return true false
2316 */
2317 ZEND_FUNCTION(xnp_swap_index_sort_number)
2318 {
2319 long sid;
2320 long xid1, xid2;
2321
2322 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
2323 &sid, &xid1, &xid2) == FAILURE) {
2324 return;
2325 }
2326
2327 result_t result = swapIndexSortNumber( sid, xid1, xid2 );
2328 RETURN_LONG(result);
2329 }
2330
2331
2332
2333 /** XNP??ession_id???綵??с???с????lt;br>
2334 bool xnp_is_valid_session_id( int xnp_session_id)
2335 @return true ???鴻??NP??ession_id?с????<br>
2336 @return false ?≦?鴻??ession_id?障??????????/span>
2337 */
2338 ZEND_FUNCTION(xnp_is_valid_session_id)
2339 {
2340 long sid;
2341 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &sid ) == FAILURE) {
2342 return;
2343 }
2344
2345 RETURN_BOOL(isValidSessionID((sessionid_t)sid));
2346 }
2347
2348 /** ?????惹??絖?????緇???<br>
2349 string xnp_get_last_error_string()
2350 @return 0 success
2351 */
2352 ZEND_FUNCTION(xnp_get_last_error_string)
2353 {
2354 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "" ) == FAILURE) {
2355 return;
2356 }
2357
2358 string str( getLastErrorString() );
2359 RETURN_STRING((char *)str.c_str(), 1);
2360 }
2361
2362
2363 /**
2364 *
2365 * ?≪?ゃ?????吾???≪???祉?号┤???????с????????
2366 *
2367 * @refer itemop_t
2368 * @param sid ?祉???激?с??D
2369 * @param iid ???с?????莟<???????≪?ゃ??????D
2370 * @param op ?≪???祉?鴻??┏蕁?
2371 * @return true 罔???????
2372 * @return false 罔???????
2373 *
2374 */
2375 ZEND_FUNCTION(xnp_get_item_permission)
2376 {
2377 RETURN_LONG( RES_ERROR );
2378 }
2379
2380
2381 /**
2382 *
2383 * ?ゃ?潟???????鴻?吾???≪???祉?号┤???????с????????
2384 *
2385 * @refer indexop_t
2386 * @param sid ?祉???激?с??D
2387 * @param xid ???с?????莟<???????ゃ?潟???????鴻??D
2388 * @param op ?≪???祉?鴻??┏蕁?
2389 * @return true 罔???????
2390 * @return false 罔???????
2391 *
2392 */
2393 ZEND_FUNCTION(xnp_get_index_permission)
2394 {
2395 RETURN_LONG( RES_ERROR );
2396 }
2397
2398
2399 /**
2400 *
2401 * ?≪?ゃ???????粋??倶????紊??眼????罔????????<??茯帥?鴻?障??鐚?/span>
2402 * @refer certify_t
2403 * @param sid ?祉???激?с??D
2404 * @param xid 紊??翫?莟<?≪?ゃ???????脂?蚊???????????ゃ?潟???????鴻??D
2405 * @param iid 紊??翫?莟<?≪?ゃ??????D
2406 * @param state ?違???鎀??眼???????粋??倶??
2407 * @return true 罔???????
2408 * @return false 罔???????
2409 *
2410 */
2411 ZEND_FUNCTION(xnp_get_certify_permission)
2412 {
2413 RETURN_LONG( RES_ERROR );
2414 }
2415
2416
2417 /**
2418 *
2419 * ?≪?ゃ???????粋??倶??????緇????障??鐚?/span>
2420 * @refer certify_t
2421 * @param sid ?祉???激?с??D
2422 * @param xid 絲乗院?≪?ゃ???????脂?蚊???????????ゃ?潟???????鴻??D
2423 * @param iid 絲乗院?≪?ゃ??????D
2424 * @param state ?粋??倶????????????綣???/span>
2425 * @return RES_OK
2426 * @return RES_NO_WRITE_ACCESS_RIGHT
2427 *
2428 */
2429 ZEND_FUNCTION(xnp_get_certify_state)
2430 {
2431 long sid;
2432 indexid_t xid;
2433 itemid_t iid;
2434 zval *zstate;
2435 result_t result = RES_ERROR;
2436
2437 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllz",
2438 &sid, &xid, &iid, &zstate) == FAILURE) {
2439 fprintf( stderr, "error occured " );
2440 return;
2441 }
2442 certify_t st;
2443 result = getCertifyState( (sessionid_t)sid, xid, iid, &st );
2444 if ( RES_OK == result ){
2445 zstate -> type = IS_LONG;
2446 zstate -> value.lval = st;
2447 }
2448 RETURN_LONG( result );
2449 }
2450
2451
2452 /**
2453 *
2454 * ?≪?ゃ???????粋??倶????紊??眼???障??鐚?/span>
2455 * @refer certify_t
2456 * @param sid ?祉???激?с??D
2457 * @param xid 紊??翫?莟<?≪?ゃ???????脂?蚊???????????ゃ?潟???????鴻??D
2458 * @param iid 紊??翫?莟<?≪?ゃ??????D
2459 * @param state ?違???鎀??眼???????粋??倶??
2460 * @return RES_OK
2461 * @return RES_NO_WRITE_ACCESS_RIGHT
2462 *
2463 */
2464 ZEND_FUNCTION(xnp_set_certify_state)
2465 {
2466 long sid;
2467 indexid_t xid;
2468 itemid_t iid;
2469 certify_t state;
2470 result_t result = RES_ERROR;
2471
2472 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",
2473 &sid, &xid, &iid, &state) == FAILURE) {
2474 fprintf( stderr, "error occured " );
2475 return;
2476 }
2477 certify_t st;
2478 result = setCertifyState( (sessionid_t)sid, xid, iid, state );
2479 RETURN_LONG( result );
2480 }
2481
2482
2483 /**
2484 *
2485 * 紊??翫吋罩眼???違??荐??蚊????鐚?/span>
2486 *
2487 * @param sid ?祉???激?с??D
2488 * @param itemid 紊??翫吋罩眼??荐??蚊?????≪?ゃ??????D
2489 * @param log ???医??絎?/span>
2490 * @return RES_OK
2491 * @return RES_NO_SUCH_SESSION
2492 * @return RES_DB_QUERY_ERROR
2493 * @return RES_NO_WRITE_ACCESS_RIGHT
2494 * @return RES_DB_NOT_INITIALIZED
2495 * @return RES_ERROR
2496 *
2497 */
2498 ZEND_FUNCTION(xnp_insert_change_log)
2499 {
2500 long sid;
2501 itemid_t iid;
2502 zval *zlog;
2503 result_t result = RES_ERROR;
2504
2505 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llz",
2506 &sid, &iid, &zlog) == FAILURE) {
2507 fprintf( stderr, "error occured " );
2508 return;
2509 }
2510
2511 result = insertChangeLog( sid, iid, getZvalString( &zlog ) );
2512 RETURN_LONG( result );
2513 }
2514
2515
2516 /**
2517 *
2518 * ?≪?ゃ????????翫吋罩眼???違????緇?????鐚?/span>
2519 *
2520 * @param sid ?祉???激?с??D
2521 * @param itemid 紊??翫吋罩眼????緇??????≪?ゃ??????D
2522 * @param logs ???医??絎鴻?????????????ゃ?潟??/span>
2523 * @param logsLen logs???主??????????違??????/span>
2524 * @return RES_OK
2525 * @return RES_NO_SUCH_SESSION
2526 * @return RES_NO_READ_ACCESS_RIGHT
2527 * @return RES_DB_NOT_INITIALIZED
2528 * @return RES_ERROR
2529 *
2530 */
2531 ZEND_FUNCTION(xnp_get_change_logs)
2532 {
2533 result_t result;
2534 long sid;
2535 itemid_t iid;
2536 zval *zlogs;
2537
2538 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
2539 &sid, &iid, &zlogs) == FAILURE) {
2540 return;
2541 }
2542
2543 const changelog_t *plogs;
2544 int logLen;
2545 result = getChangeLogs( (sessionid_t)sid, iid, &plogs, &logLen );
2546 if ( RES_OK == result ){
2547 zend_hash_clean( zlogs -> value.ht );
2548 for( int i = 0; i < logLen; i++ ){
2549 zval *new_array;
2550 MAKE_STD_ZVAL(new_array);
2551 if(array_init(new_array) != SUCCESS){
2552 result = RES_ERROR;
2553 break;
2554 }
2555 add_index_zval( zlogs, i, new_array );
2556 changelogToZval( &plogs[ i ], new_array );
2557 }
2558 freeChangeLog( plogs );
2559 }
2560 RETURN_LONG(result);
2561 }
2562
2563
2564 /**
2565 *
2566 * 荐????key???綽??????ゃ??vaule????????鐚?/span>
2567 * value??戎?????reeString?цВ?障????鐚?/span>
2568 * @param key 荐?????弱??
2569 * @param value 荐???ゃ?????????????ゃ?潟??/span>
2570 *
2571 * @return RES_OK
2572 * @return RES_DB_QUERY_ERROR
2573 * @return RES_ERROR
2574 */
2575 ZEND_FUNCTION(xnp_get_config_value)
2576 {
2577 zval *zname;
2578 zval *zvalue;
2579 const char* name;
2580 char* value;
2581 result_t result = RES_ERROR;
2582
2583 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz",
2584 &zname, &zvalue) == FAILURE) {
2585 return;
2586 }
2587 result = getConfigValue( getZvalString( &zname ), &value );
2588 if( result == RES_OK ){
2589 zvalue -> type = IS_STRING;
2590 zvalue -> value.str.len = strlen(value);
2591 zvalue -> value.str.val = estrdup(value);
2592 freeString( value );
2593 }
2594 RETURN_LONG( result );
2595 }
2596
2597
2598 /**
2599 *
2600 * 荐????key???ゃ??vaule??荐??????
2601 *
2602 * @param key 荐?????弱??
2603 * @param value 荐????/span>
2604 *
2605 * @return RES_OK
2606 * @return RES_DB_QUERY_ERROR
2607 * @return RES_ERROR
2608 */
2609 ZEND_FUNCTION(xnp_set_config_value)
2610 {
2611 zval *zname;
2612 zval *zvalue;
2613 const char* name;
2614 char* value;
2615 result_t result = RES_ERROR;
2616
2617 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz",
2618 &zname, &zvalue) == FAILURE) {
2619 return;
2620 }
2621 result = setConfigValue( getZvalString( &zname ), getZvalString( &zvalue ) );
2622 RETURN_LONG( result );
2623 }
2624
2625
2626 /**
2627 *
2628 * ?≪?ゃ????ID???荀у??.
2629 * ?≪???祉?劫??純???≪?ゃ??????D??菴???.
2630 *
2631 * int xnp_dump_item_id( int sid, array cri, array iids )
2632 * @param sid ?祉???激?с??D
2633 * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2634 * @param iids ??緇?腟?????????????????
2635 * @return RES_OK
2636 * @return RES_DB_NOT_INITIALIZED
2637 * @return RES_NO_SUCH_SESSION
2638 * @return RES_DB_QUERY_ERROR
2639 *
2640 */
2641 ZEND_FUNCTION(xnp_dump_item_id)
2642 {
2643 long sid;
2644 zval *zcriteria;
2645 zval *ziids;
2646 result_t result = RES_ERROR;
2647
2648 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
2649 &sid, &zcriteria, &ziids) == FAILURE) {
2650 fprintf( stderr, "error occured " );
2651 return;
2652 }
2653
2654 zCriteria_t zcri(zcriteria);
2655 result = zcri.getResult();
2656 if ( RES_OK == result ){
2657 const itemid_t *piids;
2658 int iidsLen;
2659 result = dumpItemID( (sessionid_t)sid, &zcri, &piids, &iidsLen );
2660 if ( RES_OK == result ){
2661 itemidsToZval( piids, iidsLen, &ziids );
2662 freeItemID( piids );
2663 }
2664 }
2665
2666 RETURN_LONG( result );
2667 }
2668
2669
2670 /**
2671 *
2672 * ???ゃ?潟???若???脂?蚊???????≪?ゃ??????D????緇????障??鐚?/span>
2673 * @param sid ?祉???激?с??D
2674 * @param binderid 絲乗院???ゃ?潟???若??D
2675 * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2676 * @param iids ?脂?蚊???????≪?ゃ????ID??????????綣???/span>
2677 * @param iidsLen iids???主??????????違??????????綣???/span>
2678 * @return RES_OK
2679 * @return RES_DB_NOT_INITIALIZED
2680 * @return RES_NO_SUCH_SESSION
2681 * @return RES_DB_QUERY_ERROR
2682 * @return RES_ERROR
2683 *
2684 */
2685 ZEND_FUNCTION(xnp_get_item_id_by_binder_id)
2686 {
2687 result_t result;
2688 long sid;
2689 itemid_t iid;
2690 zval *zcriteria;
2691 zval *ziids;
2692
2693 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
2694 &sid, &iid, &zcriteria, &ziids) == FAILURE) {
2695 return;
2696 }
2697
2698 zCriteria_t zcri(zcriteria);
2699 result = zcri.getResult();
2700 if ( RES_OK == result ){
2701 const itemid_t *pitemids;
2702 int itemidLen;
2703 result = getItemIDByBinderID( (sessionid_t)sid, iid, &zcri, &pitemids, &itemidLen );
2704 if ( RES_OK == result ){
2705 itemidsToZval( pitemids, itemidLen, &ziids );
2706 freeItemID( pitemids );
2707 }
2708 }
2709 RETURN_LONG(result);
2710 }
2711
2712
2713 /**
2714 *
2715 * ?ゃ?潟???????鴻???脂?蚊???????≪?ゃ??????D????緇????障??鐚?/span>
2716 * 罔??????<????????????????????????帥?障????鐚?/span>
2717 * ???粋??ц?????????????腟????????帥?障????鐚?/span>
2718 *
2719 * @param sid ?祉???激?с??D
2720 * @param xid 絲乗院?ゃ?潟???????鴻??D
2721 * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2722 * @param iids ?脂?蚊???????≪?ゃ????ID??????????綣???/span>
2723 * @param iidsLen iids???主??????????違??????????綣???/span>
2724 * @return RES_OK
2725 * @return RES_DB_NOT_INITIALIZED
2726 * @return RES_NO_SUCH_SESSION
2727 * @return RES_DB_QUERY_ERROR
2728 * @return RES_ERROR
2729 *
2730 */
2731 ZEND_FUNCTION(xnp_get_item_id_by_index_id)
2732 {
2733 result_t result;
2734 long sid;
2735 indexid_t xid;
2736 zval *zcriteria;
2737 zval *ziids;
2738
2739 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
2740 &sid, &xid, &zcriteria, &ziids) == FAILURE) {
2741 return;
2742 }
2743
2744 zCriteria_t zcri(zcriteria);
2745 result = zcri.getResult();
2746 if ( RES_OK == result ){
2747 const itemid_t *pitemids;
2748 int itemidLen;
2749 result = getItemIDByIndexID( (sessionid_t)sid, xid, &zcri, &pitemids, &itemidLen );
2750 if ( RES_OK == result ){
2751 itemidsToZval( pitemids, itemidLen, &ziids );
2752 freeItemID( pitemids );
2753 }
2754 }
2755 RETURN_LONG(result);
2756 }
2757
2758
2759 ZEND_FUNCTION(xnp_get_overlapped_items)
2760 {
2761 RETURN_LONG( RES_ERROR );
2762 }
2763
2764 /**
2765 *
2766 * ?≪?ゃ????(Basic Information)???脂?蚊????.
2767 * Platform???若?銀札筝???┤????綽?荀?.
2768 *
2769 * @param sid ?祉???激?с??D
2770 * @param item ?脂?蚊???????≪?ゃ??????????/span>
2771 * @param itemid ?脂?蚊?????≪?ゃ??????D??????????綣???/span>
2772 * @return RES_OK
2773 * @return RES_ERROR
2774 * @return RES_NO_SUCH_SESSION
2775 * @return RES_DB_QUERY_ERROR
2776 * @return RES_DB_NOT_INITIALIZED
2777 * @return RES_NO_WRITE_ACCESS_RIGHT
2778 *
2779 */
2780 ZEND_FUNCTION(xnp_insert_item)
2781 {
2782 long sid;
2783 zval *ziid;
2784 zval *zitem;
2785 item_t item;
2786 itemid_t iid;
2787 result_t result = RES_ERROR;
2788
2789 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
2790 &sid, &zitem, &ziid) == FAILURE) {
2791 fprintf( stderr, "error occured " );
2792 return;
2793 }
2794
2795 zvalToItem( zitem, &item );
2796 result = insertItem( (sessionid_t)sid, &item, &iid );
2797 if ( RES_OK == result ){
2798 ziid -> type = IS_LONG;
2799 ziid -> value.lval = iid;
2800 }
2801 RETURN_LONG( result );
2802 }
2803
2804 /**
2805 *
2806 * ?≪?ゃ????(Basic Information)???贋?違????.
2807 * Platform???若?銀札筝???┤????綽?荀?.
2808 * item??tem_id??罩c????祉????????????
2809 *
2810 * @param sid ?祉???激?с??D
2811 * @param item ?贋?違???????≪?ゃ??????????/span>
2812 * @return RES_OK
2813 * @return RES_ERROR
2814 * @return RES_NO_SUCH_SESSION
2815 * @return RES_DB_QUERY_ERROR
2816 * @return RES_DB_NOT_INITIALIZED
2817 * @return RES_NO_WRITE_ACCESS_RIGHT
2818 */
2819 ZEND_FUNCTION(xnp_update_item)
2820 {
2821 long sid;
2822 zval *zitem;
2823 item_t item;
2824 itemid_t iid;
2825 result_t result = RES_ERROR;
2826
2827 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
2828 &sid, &zitem) == FAILURE) {
2829 fprintf( stderr, "error occured " );
2830 return;
2831 }
2832
2833 zvalToItem( zitem, &item );
2834 result = updateItem( (sessionid_t)sid, &item );
2835 RETURN_LONG( result );
2836 }
2837
2838 /**
2839 *
2840 * ?≪?ゃ????(Basic Information)?????ゃ????.
2841 *
2842 * @param sid ?祉???激?с??D
2843 * @param item ???ゃ???????≪?ゃ??????????/span>
2844 * @return RES_OK
2845 * @return RES_ERROR
2846 * @return RES_NO_SUCH_SESSION
2847 * @return RES_DB_QUERY_ERROR
2848 * @return RES_DB_NOT_INITIALIZED
2849 * @return RES_NO_WRITE_ACCESS_RIGHT
2850 */
2851 ZEND_FUNCTION(xnp_delete_item)
2852 {
2853 long sid;
2854 itemid_t iid;
2855 result_t result = RES_ERROR;
2856
2857 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2858 &sid, &iid) == FAILURE) {
2859 fprintf( stderr, "error occured " );
2860 return;
2861 }
2862 result = deleteItem( (sessionid_t)sid, iid );
2863 RETURN_LONG( result );
2864 }
2865
2866
2867 /**
2868 *
2869 * ??篋冴?????????≪?ゃ??????D????緇????障??鐚?/span>
2870 * ?????ゃ?潟???????鴻???脂?我?粋?????????????????????帥?障????
2871 *
2872 * @param sid ?祉???激?с??D
2873 * @param uid 絲乗院???若?吟??D
2874 * @param iids ?脂?蚊???????≪?ゃ????ID??????????綣???/span>
2875 * @param iidsLen iids???主??????????違??????????綣???/span>
2876 * @return RES_OK
2877 * @return RES_DB_NOT_INITIALIZED
2878 * @return RES_NO_SUCH_SESSION
2879 * @return RES_DB_QUERY_ERROR
2880 * @return RES_ERROR
2881 *
2882 */
2883 //result_t getPrivateItemID( sessionid_t sid, userid_t uid, const itemid_t** iids, int* iidsLen )
2884 ZEND_FUNCTION(xnp_get_private_item_id)
2885 {
2886 long sid;
2887 userid_t uid;
2888 zval* ziids;
2889
2890 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
2891 &sid, &uid, &ziids) == FAILURE) {
2892 return;
2893 }
2894
2895 const itemid_t *piids;
2896 int iidsLen;
2897 result_t result = getPrivateItemID( (sessionid_t)sid, uid, &piids, &iidsLen );
2898 if ( RES_OK == result ){
2899 itemidsToZval( piids, iidsLen, &ziids );
2900 freeItemID( piids );
2901 }
2902
2903 RETURN_LONG( result );
2904
2905 }
2906
2907
2908 /**
2909 *
2910 * ?≪?ゃ???????怨??.
2911 * ??緇??????≪?ゃ???????篏睡???freeItem?цВ?障????.
2912 *
2913 * @refer freeItem
2914 * @param sid ?祉???激?с??D
2915 * @param iid ??緇????????≪?ゃ??????D
2916 * @param item 腟??????≪?ゃ???????宴??????????綣???/span>
2917 * @return RES_OK
2918 * @return RES_DB_NOT_INITIALIZED
2919 * @return RES_NO_SUCH_SESSION
2920 * @return RES_NO_SUCH_ITEM
2921 * @return RES_DB_QUERY_ERROR
2922 *
2923 */
2924 ZEND_FUNCTION(xnp_get_item)
2925 {
2926 long sid;
2927 long iid;
2928 zval *zitem;
2929 result_t result = RES_ERROR;
2930
2931 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
2932 &sid, &iid, &zitem) == FAILURE) {
2933 fprintf( stderr, "error occured " );
2934 return;
2935 }
2936
2937 const item_t* pitem;
2938 result = getItem( (sessionid_t)sid, iid, &pitem );
2939 if ( RES_OK == result ){
2940 itemToZval( pitem, zitem );
2941 freeItem( pitem );
2942 }
2943 RETURN_LONG( result );
2944 }
2945
2946
2947 /**
2948 *
2949 * ?≪?ゃ???????怨??.
2950 * ??緇??????≪?ゃ???????篏睡???freeItem?цВ?障????.
2951 *
2952 * @refer freeItem
2953 * @param sid ?祉???激?с??D
2954 * @param iids ??緇????????≪?ゃ??????D??????
2955 * @param iidsLen iids???????膣???/span>
2956 * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2957 * @param items 罎?膣∝??????????????ゃ?潟?帥???吾??莨若??綣???/span>
2958 * @param itemsLen 罎?膣∝???????????*items???膣???
2959 * @return RES_OK
2960 * @return RES_DB_NOT_INITIALIZED
2961 * @return RES_NO_SUCH_SESSION
2962 * @return RES_DB_QUERY_ERROR
2963 *
2964 */
2965 ZEND_FUNCTION(xnp_get_items)
2966 {
2967 result_t result;
2968 long sid;
2969 zval *ziids;
2970 zval *zcriteria;
2971 zval *zitem;
2972
2973 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
2974 &sid, &ziids, &zcriteria, &zitem) == FAILURE) {
2975 return;
2976 }
2977
2978 zCriteria_t zcri(zcriteria);
2979 result = zcri.getResult();
2980 if ( RES_OK == result ){
2981 zIIDs_t zIIDs(ziids);
2982 result = zIIDs.getResult();
2983 if ( RES_OK == result ){
2984 const item_t *pitems;
2985 int itemLen;
2986 result = getItems( (sessionid_t)sid,
2987 zIIDs.getPIID(), zIIDs.getLen(),
2988 &zcri, &pitems, &itemLen );
2989 if ( RES_OK == result ){
2990 itemsToZval( pitems, itemLen, zitem );
2991 freeItem( pitems );
2992 }
2993 }
2994 }
2995
2996 RETURN_LONG(result);
2997 }
2998
2999
3000 /**
3001 *
3002 *
3003 * @param pmid PUBMEDID
3004 * @param pubmed 腟??????吾??莨若??pubmed_t?????ゃ?潟?水???/span>
3005 *
3006 *
3007 *
3008 */
3009 ZEND_FUNCTION(xnp_pubmed_complete)
3010 {
3011 long pmid;
3012 zval *zpubmed;
3013 result_t result = RES_ERROR;
3014
3015 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
3016 &pmid, &zpubmed) == FAILURE) {
3017 fprintf( stderr, "error occured " );
3018 return;
3019 }
3020
3021 const pubmed_t* ppubmed;
3022 result = pubmedComplete( pmid, &ppubmed );
3023 if ( RES_OK == result ){
3024 pubmedToZval( ppubmed, zpubmed );
3025 freePubmed( ppubmed );
3026 }
3027 RETURN_LONG( result );
3028 }
3029
3030
3031 /**
3032 *
3033 *
3034 * @param isbn ISBN
3035 * @param amazonbook 腟??????吾??莨若??amazonbook_t?????ゃ?潟?水???/span>
3036 *
3037 *
3038 *
3039 */
3040 ZEND_FUNCTION(xnp_amazon_complete)
3041 {
3042 zval *zurl;
3043 zval *zamazonbook;
3044 result_t result = RES_ERROR;
3045
3046 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za",
3047 &zurl, &zamazonbook) == FAILURE) {
3048 fprintf( stderr, "error occured " );
3049 return;
3050 }
3051
3052 const amazonbook_t* pamazonbook;
3053 result = amazonComplete( getZvalString( &zurl ) , &pamazonbook );
3054 if ( RES_OK == result ){
3055 amazonbookToZval( pamazonbook, zamazonbook );
3056 //freeAmazonbook( pamazonbook );
3057 }
3058 RETURN_LONG( result );
3059 }
3060
3061
3062 //ZEND_FUNCTION(xnp_uninitialize_db)
3063 //{
3064 // RETURN_LONG( RES_ERROR );
3065 //}
3066
3067
3068 /**
3069 *
3070 * ???ゃ?潟???若???≪?ゃ??????菴遵??????
3071 *
3072 * @param sid ?祉???激?с??D
3073 * @param binderid ????絲乗院?????ゃ?潟???若??D
3074 * @param iid ???ゃ?潟???若??申?????????≪?ゃ??????D
3075 * @return RES_OK
3076 * @return RES_DB_QUERY_ERROR
3077 * @return RES_NO_SUCH_SESSION
3078 * @return RES_NO_WRITE_ACCESS_RIGHT
3079 * @return RES_ERROR
3080 *
3081 */
3082 ZEND_FUNCTION(xnp_register_binder_item)
3083 {
3084 result_t result = RES_ERROR;
3085 long sid;
3086 long bid;
3087 long iid;
3088
3089 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
3090 &sid, &bid, &iid) == FAILURE) {
3091 return;
3092 }
3093
3094 result = registerBinderItem( (sessionid_t)sid, bid, iid );
3095 RETURN_LONG(result);
3096 }
3097
3098
3099 /**
3100 *
3101 * ???ゃ?潟???若?????≪?ゃ?????????ゃ????
3102 *
3103 * @param sid ?祉???激?с??D
3104 * @param binderid ????絲乗院?????ゃ?潟???若??D
3105 * @param iid ???ゃ?潟???若???????ゃ???????≪?ゃ??????D
3106 * @return RES_OK
3107 * @return RES_DB_QUERY_ERROR
3108 * @return RES_NO_SUCH_SESSION
3109 * @return RES_NO_WRITE_ACCESS_RIGHT
3110 * @return RES_ERROR
3111 *
3112 */
3113 ZEND_FUNCTION(xnp_unregister_binder_item)
3114 {
3115 result_t result = RES_ERROR;
3116 long sid;
3117 long bid;
3118 long iid;
3119
3120 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
3121 &sid, &bid, &iid) == FAILURE) {
3122 return;
3123 }
3124
3125 result = registerBinderItem( (sessionid_t)sid, bid, iid );
3126 RETURN_LONG(result);
3127 }
3128
3129
3130 /**
3131 *
3132 * ?ゃ?潟???????鴻???≪?ゃ??????菴遵??????
3133 *
3134 * @param sid ?祉???激?с??D
3135 * @param xid ????絲乗院???ゃ?潟???????鴻??D
3136 * @param iid ?ゃ?潟???????鴻??申?????????≪?ゃ??????D
3137 * @return RES_OK
3138 * @return RES_DB_QUERY_ERROR
3139 * @return RES_NO_SUCH_SESSION
3140 * @return RES_NO_WRITE_ACCESS_RIGHT
3141 * @return RES_ERROR
3142 *
3143 */
3144 ZEND_FUNCTION(xnp_register_item)
3145 {
3146 result_t result = RES_ERROR;
3147 long sid;
3148 long xid;
3149 long iid;
3150
3151 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
3152 &sid, &xid, &iid) == FAILURE) {
3153 return;
3154 }
3155
3156 result = registerItem( (sessionid_t)sid, xid, iid );
3157 RETURN_LONG(result);
3158 }
3159
3160
3161 /**
3162 *
3163 * ?ゃ?潟???????鴻?????≪?ゃ?????????ゃ????
3164 *
3165 * @param sid ?祉???激?с??D
3166 * @param xid ????絲乗院???ゃ?潟???????鴻??D
3167 * @param iid ?ゃ?潟???????鴻???????ゃ???????≪?ゃ??????D
3168 * @return RES_OK
3169 * @return RES_DB_QUERY_ERROR
3170 * @return RES_NO_SUCH_SESSION
3171 * @return RES_NO_WRITE_ACCESS_RIGHT
3172 * @return RES_ERROR
3173 *
3174 */
3175 ZEND_FUNCTION(xnp_unregister_item)
3176 {
3177 result_t result = RES_ERROR;
3178 long sid;
3179 long xid;
3180 long iid;
3181
3182 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
3183 &sid, &xid, &iid) == FAILURE) {
3184 return;
3185 }
3186
3187 result = unregisterItem( (sessionid_t)sid, xid, iid );
3188 RETURN_LONG(result);
3189 }
3190
3191
3192 /**
3193 *
3194 * ?粋?緇??∞?倶?????≪?ゃ?????????¥??粋?罔??????????≪?ゃ??????D???脂?峨???ゃ?潟???????鴻??D?????≪?у?????障??.
3195 * ?≪?ゃ????iids[i]???上??ids[i]?吾???脂?蚊???粋?緇??∞?倶??????????????菴????障??鐚?/span>
3196 *
3197 * @param sid ?祉???激?с??D
3198 * @param xids ?粋?緇??<?≪?ゃ???????脂?蚊?????ゃ?潟????????D??????????綣???/span>
3199 * @param iids ?粋?緇??<?≪?ゃ????ID??????????綣???/span>
3200 * @param len iids,xids???主??????????違??????????綣???/span>
3201 * @return RES_OK
3202 * @return RES_DB_NOT_INITIALIZED
3203 * @return RES_NO_SUCH_SESSION
3204 * @return RES_DB_QUERY_ERROR
3205 * @return RES_ERROR
3206 *
3207 */
3208 //result_t getUncertifiedLink( sessionid_t sid, const itemid_t** xids, const itemid_t** iids, int* len )
3209 ZEND_FUNCTION(xnp_get_uncertified_link)
3210 {
3211 long sid;
3212 zval* zxids;
3213 zval* ziids;
3214
3215 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
3216 &sid, &zxids, &ziids) == FAILURE) {
3217 return;
3218 }
3219
3220 const itemid_t *pxids;
3221 const itemid_t *piids;
3222 int len;
3223 result_t result = getUncertifiedLink( (sessionid_t)sid, &pxids, &piids, &len );
3224 if ( RES_OK == result ){
3225 indexidsToZval( piids, len, &zxids );
3226 itemidsToZval( piids, len, &ziids );
3227 freeIndexID( pxids );
3228 freeItemID( piids );
3229 }
3230 RETURN_LONG( result );
3231 }
3232
3233 /**
3234 *
3235 * @param types
3236 * @return RES_OK
3237 * @return RES_DB_NOT_INITIALIZED
3238 * @return RES_NO_SUCH_SESSION
3239 * @return RES_DB_QUERY_ERROR
3240 * @return RES_ERROR
3241 *
3242 */
3243 ZEND_FUNCTION(xnp_get_item_types)
3244 {
3245 zval* ztypes;
3246
3247 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
3248 &ztypes) == FAILURE) {
3249 return;
3250 }
3251
3252 const itemtype_t *ptypes;
3253 int len;
3254 result_t result = getItemTypes( &ptypes, &len );
3255 if ( RES_OK == result ){
3256
3257 zend_hash_clean( ztypes -> value.ht );
3258 for( int i = 0; i < len; i++ ){
3259 zval *new_array;
3260 MAKE_STD_ZVAL(new_array);
3261 if(array_init(new_array) != SUCCESS){
3262 result = RES_ERROR;
3263 break;
3264 }
3265 add_index_zval( ztypes, i, new_array );
3266
3267 zend_hash_clean( new_array -> value.ht );
3268 add_assoc_long( new_array, "item_type_id", ptypes[ i ].getItemTypeID( ) );
3269 add_assoc_long( new_array, "mid", ptypes[ i ].getModuleID( ) );
3270 add_assoc_string( new_array, "name", ( char* )ptypes[ i ].getName( ), 1 );
3271 add_assoc_string( new_array, "display_name", ( char* )ptypes[ i ].getDisplayName( ), 1 );
3272 }
3273 result = RES_OK;
3274 freeItemType( ptypes );
3275 }
3276 RETURN_LONG( result );
3277 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26