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.28 - (show annotations) (download) (as text)
Fri Jan 28 05:14:37 2005 UTC (19 years, 2 months ago) by youi
Branch: MAIN
CVS Tags: demo20050128
Changes since 1.27: +30 -4 lines
File MIME type: text/x-c++src
xnp_get_index_id_by_item_id関数を定義した.

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

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