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.25 - (show annotations) (download) (as text)
Mon Jan 24 01:53:03 2005 UTC (19 years, 2 months ago) by youi
Branch: MAIN
Changes since 1.24: +5 -5 lines
File MIME type: text/x-c++src
引数の型修飾を変更.
itemidsToZval, dumpItemID, getItemIDByBinderID, getItemIDByIndexID

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

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