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.32 - (show annotations) (download) (as text)
Wed Feb 9 07:23:50 2005 UTC (19 years, 2 months ago) by aga
Branch: MAIN
Changes since 1.31: +1 -3 lines
File MIME type: text/x-c++src
・URL to My Personal Archive をDB・ALから消した.

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

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