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.31 - (show annotations) (download) (as text)
Wed Feb 9 02:14:15 2005 UTC (19 years, 2 months ago) by aga
Branch: MAIN
Changes since 1.30: +8 -3 lines
File MIME type: text/x-c++src
・initializeDB()にdbtype引数を追加(SQLite用).

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

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