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.30 - (show annotations) (download) (as text)
Thu Feb 3 12:02:42 2005 UTC (19 years, 2 months ago) by youi
Branch: MAIN
Changes since 1.29: +24 -1 lines
File MIME type: text/x-c++src
xnp_get_own_public_item_idを追加.

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

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