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.29 - (show annotations) (download) (as text)
Sat Jan 29 09:52:30 2005 UTC (19 years, 2 months ago) by youi
Branch: MAIN
Changes since 1.28: +2 -17 lines
File MIME type: text/x-c++src
未使用のローカル変数を削除した.

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

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