Develop and Download Open Source Software

Browse CVS Repository

Annotation of /xoonips/AL/xnpal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.27 - (hide annotations) (download) (as text)
Tue Jan 25 11:07:41 2005 UTC (19 years, 2 months ago) by youi
Branch: MAIN
Changes since 1.26: +35 -4 lines
File MIME type: text/x-c++src
関数の処理追加.
  xnp_get_item_permission, xnp_get_index_permission, xnp_get_certify_permission

1 aga 1.1 /*
2 youi 1.27 $Revision: 1.26 $
3 youi 1.21 XNPAL: XooNiPs Platform Abstract Layer
4 youi 1.24
5 aga 1.1 zend_parse_parameters??hp4.1.0??綽?荀?
6     .so???<?ゃ?????????荀????????贋????舟??鴻????
7     C++?с????extern "C"{}, BEGIN/END_EXTERN_C()??綽?荀???
8     */
9    
10    
11     #include <stdio.h>
12 aga 1.2 #include "criteria.h"
13     #include "common.h"
14     #include "commonal.h"
15     #include "session.h"
16     #include "group.h"
17 youi 1.24 #include "index.h"
18 youi 1.21 #include "xnpal.h"
19 youi 1.24 #include "amazonbook.h"
20 aga 1.1
21 aga 1.2 // for inet_aton
22     #include <sys/socket.h>
23     #include <netinet/in.h>
24     #include <arpa/inet.h>
25    
26 aga 1.1 // global variables
27    
28 youi 1.21 PHP_MSHUTDOWN_FUNCTION(xnpalmod)
29 aga 1.18 {
30     uninitializeDB();
31     return SUCCESS;
32     }
33 aga 1.1
34     /* declaration of functions to be exported */
35     extern "C" {
36 aga 1.2 ZEND_FUNCTION(first_module );
37 youi 1.21 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 aga 1.2
67 aga 1.22 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 youi 1.21 ZEND_FUNCTION(xnp_is_valid_session_id );
78     ZEND_FUNCTION(xnp_get_last_error_string );
79 aga 1.9
80 youi 1.21 ZEND_FUNCTION(xnp_test_criteria );
81     ZEND_FUNCTION(xnp_test_uids );
82 youi 1.24
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 youi 1.26 ZEND_FUNCTION(xnp_get_uncertified_link );
120     ZEND_FUNCTION(xnp_get_private_item_id );
121    
122     ZEND_FUNCTION(xnp_get_item_types );
123    
124 aga 1.1 };
125     /* compiled function list so Zend knows what's in this module */
126 youi 1.21 zend_function_entry xnpalmod_functions[] =
127 aga 1.1 {
128 youi 1.24 ZEND_FE(first_module ,NULL)
129     ZEND_FE(xnp_initialize_db ,NULL)
130     ZEND_FE(xnp_login_user ,NULL)
131     ZEND_FE(xnp_logout_user ,NULL)
132     ZEND_FE(xnp_create_session ,NULL)
133     ZEND_FE(xnp_get_session ,NULL)
134     ZEND_FE(xnp_is_activated ,NULL)
135     ZEND_FE(xnp_activate ,NULL)
136     ZEND_FE(xnp_get_account_count ,NULL)
137     ZEND_FE(xnp_delete_account ,NULL)
138     ZEND_FE(xnp_get_account ,NULL)
139     ZEND_FE(xnp_get_accounts ,NULL)
140     ZEND_FE(xnp_insert_account ,NULL)
141     ZEND_FE(xnp_update_account ,NULL)
142     ZEND_FE(xnp_dump_uids ,NULL)
143     ZEND_FE(xnp_get_group_count ,NULL)
144     ZEND_FE(xnp_get_groups_by_uid ,NULL)
145     ZEND_FE(xnp_is_group_admin ,NULL)
146     ZEND_FE(xnp_dump_gids ,NULL)
147     ZEND_FE(xnp_dump_group_admins ,NULL)
148     ZEND_FE(xnp_delete_member ,NULL)
149     ZEND_FE(xnp_insert_member ,NULL)
150     ZEND_FE(xnp_get_members ,NULL)
151     ZEND_FE(xnp_delete_group ,NULL)
152     ZEND_FE(xnp_insert_group ,NULL)
153     ZEND_FE(xnp_update_group ,NULL)
154     ZEND_FE(xnp_get_group ,NULL)
155     ZEND_FE(xnp_get_groups ,NULL)
156     ZEND_FE(xnp_is_moderator ,NULL)
157     ZEND_FE(xnp_get_uid ,NULL)
158    
159     ZEND_FE(xnp_get_all_indexes ,NULL)
160     ZEND_FE(xnp_get_indexes ,NULL)
161     ZEND_FE(xnp_insert_index ,NULL)
162     ZEND_FE(xnp_update_index ,NULL)
163     ZEND_FE(xnp_delete_index ,NULL)
164     ZEND_FE(xnp_get_index ,NULL)
165     ZEND_FE(xnp_is_index_readable ,NULL)
166     ZEND_FE(xnp_is_index_writable ,NULL)
167     ZEND_FE(xnp_swap_index_sort_number ,NULL)
168    
169     ZEND_FE(xnp_is_valid_session_id ,NULL)
170     ZEND_FE(xnp_get_last_error_string ,NULL)
171     ZEND_FE(xnp_test_criteria ,NULL)
172     ZEND_FE(xnp_test_uids ,NULL)
173    
174     ZEND_FE(xnp_get_item_permission ,NULL)
175     ZEND_FE(xnp_get_index_permission ,NULL)
176     ZEND_FE(xnp_get_certify_permission ,NULL)
177    
178     ZEND_FE(xnp_get_certify_state ,NULL)
179     ZEND_FE(xnp_set_certify_state ,NULL)
180    
181     ZEND_FE(xnp_insert_change_log ,NULL)
182     ZEND_FE(xnp_get_change_logs ,NULL)
183    
184     ZEND_FE(xnp_get_config_value ,NULL)
185     ZEND_FE(xnp_set_config_value ,NULL)
186    
187     ZEND_FE(xnp_dump_item_id ,NULL)
188     ZEND_FE(xnp_get_item_id_by_binder_id ,NULL)
189     ZEND_FE(xnp_get_item_id_by_index_id ,NULL)
190     ZEND_FE(xnp_get_overlapped_items ,NULL)
191    
192     ZEND_FE(xnp_insert_item ,NULL)
193     ZEND_FE(xnp_update_item ,NULL)
194     ZEND_FE(xnp_delete_item ,NULL)
195     ZEND_FE(xnp_get_item ,NULL)
196     ZEND_FE(xnp_get_items ,NULL)
197    
198     ZEND_FE(xnp_pubmed_complete ,NULL)
199     ZEND_FE(xnp_amazon_complete ,NULL)
200    
201     // ZEND_FE(xnp_uninitialize_db ,NULL)
202    
203     ZEND_FE(xnp_register_binder_item ,NULL)
204     ZEND_FE(xnp_unregister_binder_item ,NULL)
205    
206     ZEND_FE(xnp_register_item ,NULL)
207     ZEND_FE(xnp_unregister_item ,NULL)
208    
209 youi 1.26 ZEND_FE(xnp_get_uncertified_link ,NULL)
210     ZEND_FE(xnp_get_private_item_id ,NULL)
211    
212     ZEND_FE(xnp_get_item_types ,NULL)
213    
214 youi 1.24 {NULL, NULL, NULL}
215 aga 1.1 };
216    
217     /* compiled module information */
218 youi 1.21 zend_module_entry xnpalmod_module_entry =
219 aga 1.1 {
220 youi 1.24 STANDARD_MODULE_HEADER,
221     "Visiome Platform Abstract Layer",
222     xnpalmod_functions,
223     NULL,
224 youi 1.21 PHP_MSHUTDOWN(xnpalmod),
225 youi 1.24 NULL,
226     NULL,
227     NULL,
228     NO_VERSION_YET,
229     STANDARD_MODULE_PROPERTIES
230 aga 1.1 };
231    
232     /* implement standard "stub" routine to introduce ourselves to Zend */
233     #if COMPILE_DL_FIRST_MODULE
234     BEGIN_EXTERN_C()
235 youi 1.21 ZEND_GET_MODULE(xnpalmod)
236 aga 1.1 END_EXTERN_C()
237     #endif
238    
239 aga 1.16
240 aga 1.1 /* implement function that is meant to be made available to PHP */
241     ZEND_FUNCTION(first_module)
242     {
243 youi 1.24 long parameter;
244 aga 1.1 // if(ZEND_NUM_ARGS() != 2) WRONG_PARAM_COUNT;
245 youi 1.24 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &parameter) == FAILURE) {
246     return;
247     }
248 aga 1.1 parameter++;
249 youi 1.24 RETURN_LONG(parameter);
250 aga 1.1 }
251     /** zval????C????絖?????緇?????
252     */
253     char *getZvalString( zval **p ){
254     convert_to_string_ex(p);
255     return Z_STRVAL_PP(p); //(**p).value.str.val;
256     }
257    
258     /** zval????int??緇?????
259     */
260     int getZvalInt( zval **p ){
261     convert_to_long_ex(p);
262     return Z_LVAL_PP(p); // (int)(**p).value.lval;
263     }
264    
265 aga 1.2 // keylen????鮎??0????????
266     static void print_hash_key( int res, const char *key, uint keyLen, ulong index ){
267     zend_printf( "print_hash_key : key=0x%08x keylen=%08d index=%08d<br> ", key, keyLen, index );
268     if ( res == HASH_KEY_IS_STRING ){
269     char *p = new char[keyLen+1];
270     memcpy( p, key, keyLen );
271     p[keyLen] = 0;
272     zend_printf( " key is string[%s]<br>\n", p );
273     }
274     else {
275     zend_printf( " key is integer[%d]<br>\n", index );
276     }
277     }
278    
279    
280 aga 1.16 /** zval*????criteria_t?????????????????????鴻??????紊掩??????getResult()!=RES_OK <br>
281 youi 1.24 criteria :
282     array( 'start'=>0, 'rows'=>10,
283     'orders'=>array(
284     array('name'=>'id','order'=>'0'),
285     array('name'=>'timestamp','name'=>'1'), ...)
286     ); ??????就???f?渇????
287 aga 1.2 */
288     class zCriteria_t : public criteria {
289     private:
290     result_t result;
291 aga 1.16
292 aga 1.2 // pz: array('name'=>'timestamp','name'=>'1')
293     // ????????orderby??篏???????申????
294     void setOrder( zval *pz ){
295     char *column = 0;
296     order_t order = (order_t)0;
297 youi 1.24
298 aga 1.2 HashPosition pos;
299     zval **ppzTmp = 0;
300     int res2;
301     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
302     while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
303     char *key = 0;
304     uint keyLen = 0;
305     ulong index = 0;
306     int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
307     if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
308 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
309     if ( strncasecmp( key, "name", keyLen ) == 0 && keyLen == 5 ){
310 aga 1.2 SEPARATE_ZVAL(ppzTmp);
311     column = getZvalString(ppzTmp);
312     // zend_printf( "column=%s<br>\n", column );
313     }
314     else if ( strncasecmp( key, "order", keyLen ) == 0 && keyLen == 6 ){
315     SEPARATE_ZVAL(ppzTmp);
316     order = (order_t)getZvalInt(ppzTmp);
317     // zend_printf( "order=%d<br>\n", order );
318     }
319     }
320 youi 1.24
321 aga 1.2 zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
322     }
323     if ( column ){
324     orderby *o = new orderby( column, order );
325     addOrderBy( o );
326     }
327 youi 1.24
328 aga 1.2 result = RES_OK;
329     }
330 youi 1.24
331 aga 1.2 // pz: array( array('column'=>'hoge','order'=>'1'), array('column'=>'huga','order'=>'2'), ...)
332     void setOrders( zval *pz ){
333     HashPosition pos;
334 youi 1.24
335 aga 1.2 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
336 youi 1.24
337 aga 1.2 zval **ppzTmp = 0;
338     int res2;
339     while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
340     char *key = 0;
341     uint keyLen = 0;
342     ulong index = 0;
343     int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
344     if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
345 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
346 aga 1.2 setOrder( *ppzTmp );
347     }
348     zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
349     }
350     result = RES_OK;
351     }
352 youi 1.24
353 aga 1.2 void initialize( zval *pz ){
354     HashPosition pos;
355     zval **ppzTmp = 0;
356     int res2;
357     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
358     while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
359     char *key = 0;
360     uint keyLen = 0;
361     ulong index = 0;
362     int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
363     if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
364 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
365 aga 1.2 if ( strncasecmp( key, "start", keyLen ) == 0 && keyLen == 6 ){
366     SEPARATE_ZVAL(ppzTmp);
367     int tmp = getZvalInt(ppzTmp);
368     // zend_printf( "start=%d<br>\n", tmp );
369     setLimit( tmp, getLimitRows() );
370     }
371     else if ( strncasecmp( key, "rows", keyLen ) == 0 && keyLen == 5 ){
372     SEPARATE_ZVAL(ppzTmp);
373     int tmp = getZvalInt(ppzTmp);
374     // zend_printf( "rows=%d<br>\n", tmp );
375     setLimit( getLimitStart(), tmp );
376     }
377     else if ( strncasecmp( key, "orders", keyLen ) == 0 && keyLen == 7 ){
378     setOrders( *ppzTmp );
379     }
380     else
381     ; // ignore unknown key
382     }
383     else
384     ; // ignore bad key
385     zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
386     }
387     result = RES_OK;
388     }
389 aga 1.16
390     public:
391 aga 1.2 zCriteria_t() : criteria(){ result = RES_ERROR; }
392     zCriteria_t( zval *pz ) : criteria(){ initialize(pz); }
393     zCriteria_t( zval **ppz ) : criteria() { initialize(*ppz); }
394     result_t getResult(){ return result; };
395 youi 1.24
396 aga 1.2 void dump(){
397     zend_printf( "dumping zCriteria...<br>\n" );
398     zend_printf( "result=%d<br>\n", (int)result );
399     zend_printf( "start=%d, rows=%d<br>\n", getLimitStart(), getLimitRows() );
400     const orderby *p = headOrderBy();
401     while ( p ){
402     zend_printf( "column=%s, order=%d<br>\n", p->getColumn(), p->getOrder() );
403     p = nextOrderBy();
404     }
405     }
406     };
407    
408 aga 1.16
409     /** ?f?渇???????≪???祉?鴻????ong?ゃ??緇?????
410     @param ht ?f?渇????
411     @param key ????/span>
412     @param val long?ゃ?????????????ゃ?潟??/span>
413     @return ????????true
414     */
415     static bool hashGetLong( HashTable *ht, const char *key, long *val ){
416 youi 1.24 zval **tmp;
417     if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
418     convert_to_long_ex( tmp );
419     *val = Z_LVAL_PP(tmp);
420     return true;
421     }
422     return false;
423 aga 1.14 }
424    
425 aga 1.16 /** ?f?渇???????≪???祉?鴻??????絖?????緇?????
426     @param ht ?f?渇????
427     @param key ????/span>
428     @param val ??絖????????????????ゃ?潟??/span>
429     @return ????????true
430     */
431     static bool hashGetString( HashTable *ht, const char *key, char **val ){
432 youi 1.24 zval **tmp;
433     if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
434     convert_to_string_ex( tmp );
435     *val = Z_STRVAL_PP(tmp);
436     return true;
437     }
438     return false;
439 aga 1.14 }
440    
441 aga 1.16 /** ?f?渇???????≪???祉?鴻????ouble?ゃ??緇?????
442     @param ht ?f?渇????
443     @param key ????/span>
444     @param val double?ゃ?????????????ゃ?潟??/span>
445     @return ????????true
446     */
447     static bool hashGetDouble( HashTable *ht, const char *key, double *val ){
448 youi 1.24 zval **tmp;
449     if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
450     convert_to_double_ex( tmp );
451     *val = Z_DVAL_PP(tmp);
452     return true;
453     }
454     return false;
455 aga 1.14 }
456 aga 1.2
457 aga 1.16 /** zval*????account?????????????????????鴻?? <br>
458 youi 1.24 ????紊掩??????getResult()!=RES_OK <br>
459 aga 1.16 */
460 aga 1.2 class zAccount_t : public account {
461     private:
462     result_t result;
463     void initialize(zval *pz){
464 aga 1.14 HashTable *ht = Z_ARRVAL_P(pz);
465     long l;
466     char *p;
467     double d;
468     if ( hashGetLong ( ht, "uid" , &l ) ) setUID ( l );
469     if ( hashGetString( ht, "uname" , &p ) ) setUname ( p );
470     if ( hashGetString( ht, "name" , &p ) ) setName ( p );
471     if ( hashGetString( ht, "email" , &p ) ) setEmail ( p );
472     if ( hashGetString( ht, "url" , &p ) ) setURL ( p );
473     if ( hashGetString( ht, "user_avatar" , &p ) ) setUserAvatar ( p );
474     if ( hashGetString( ht, "user_icq" , &p ) ) setUserIcq ( p );
475     if ( hashGetString( ht, "user_from" , &p ) ) setUserFrom ( p );
476     if ( hashGetString( ht, "user_sig" , &p ) ) setUserSig ( p );
477     if ( hashGetString( ht, "actkey" , &p ) ) setActkey ( p );
478     if ( hashGetString( ht, "user_aim" , &p ) ) setUserAim ( p );
479     if ( hashGetString( ht, "user_yim" , &p ) ) setUserYim ( p );
480     if ( hashGetString( ht, "user_msnm" , &p ) ) setUserMsnm ( p );
481     if ( hashGetString( ht, "pass" , &p ) ) setPass ( p );
482     if ( hashGetString( ht, "theme" , &p ) ) setTheme ( p );
483     if ( hashGetString( ht, "umode" , &p ) ) setUmode ( p );
484     if ( hashGetString( ht, "user_occ" , &p ) ) setUserOcc ( p );
485     if ( hashGetString( ht, "bio" , &p ) ) setBio ( p );
486     if ( hashGetString( ht, "user_intrest" , &p ) ) setUserIntrest ( p );
487     if ( hashGetDouble( ht, "timezone_offset" , &d ) ) setTimezoneOffset ( d );
488     if ( hashGetLong ( ht, "attachsig" , &l ) ) setAttachsig ( l );
489     if ( hashGetLong ( ht, "last_login" , &l ) ) setLastLogin ( l );
490     if ( hashGetLong ( ht, "level" , &l ) ) setLevel ( l );
491     if ( hashGetLong ( ht, "notify_method" , &l ) ) setNotifyMethod ( l );
492     if ( hashGetLong ( ht, "notify_mode" , &l ) ) setNotifyMode ( l );
493     if ( hashGetLong ( ht, "posts" , &l ) ) setPosts ( l );
494     if ( hashGetLong ( ht, "rank" , &l ) ) setRank ( l );
495     if ( hashGetLong ( ht, "uorder" , &l ) ) setUorder ( l );
496     if ( hashGetLong ( ht, "user_mailok" , &l ) ) setUserMailok ( l );
497     if ( hashGetLong ( ht, "user_regdate" , &l ) ) setUserRegdate ( l );
498     if ( hashGetLong ( ht, "user_viewemail" , &l ) ) setUserViewemail ( l );
499     if ( hashGetLong ( ht, "activate" , &l ) ) setActivate ( l );
500     if ( hashGetString( ht, "address" , &p ) ) setAddress ( p );
501 aga 1.16 if ( hashGetString( ht, "division" , &p ) ) setDivision ( p );
502 aga 1.14 if ( hashGetString( ht, "tel" , &p ) ) setTel ( p );
503 aga 1.16 if ( hashGetString( ht, "company_name" , &p ) ) setCompanyName ( p );
504 aga 1.14 if ( hashGetString( ht, "country" , &p ) ) setCountry ( p );
505     if ( hashGetString( ht, "zipcode" , &p ) ) setZipcode ( p );
506     if ( hashGetString( ht, "fax" , &p ) ) setFax ( p );
507     if ( hashGetString( ht, "base_url" , &p ) ) setBaseURL ( p );
508     if ( hashGetLong ( ht, "notice_mail" , &l ) ) setNoticeMail ( l );
509     if ( hashGetLong ( ht, "notice_mail_since" , &l ) ) setNoticeMailSince ( l );
510 aga 1.22 if ( hashGetLong ( ht, "private_index_id " , &l ) ) setPrivateIndexID ( l );
511 aga 1.14
512     result = RES_OK;
513 aga 1.2 }
514 aga 1.16 public:
515 aga 1.2 zAccount_t() : account(){ result = RES_ERROR; }
516 youi 1.24
517     /** ?潟?潟?鴻????????/span>
518     @param pz array( 'uid'=>1, 'uname'=>'root', ... ); ??????就???f?渇???? */
519 aga 1.2 zAccount_t( zval *pz ) : account(){ initialize(pz); }
520     zAccount_t( zval **ppz ) : account() { initialize(*ppz); }
521     result_t getResult(){ return result; };
522     };
523    
524 aga 1.22 class zIndex_t : public index {
525     private:
526     result_t result;
527 youi 1.24
528 aga 1.22 void initialize(zval *pz){
529     HashTable *ht = Z_ARRVAL_P(pz);
530     long l;
531     char *p;
532     double d;
533     if ( hashGetLong ( ht, "item_id" , &l ) ) setItemID ( l );
534     if ( hashGetLong ( ht, "item_type_id" , &l ) ) setItemTypeID ( l );
535     if ( hashGetLong ( ht, "contributor_uid" , &l ) ) setContributorUID ( l );
536     if ( hashGetString( ht, "title" , &p ) ) setTitle ( p );
537     if ( hashGetString( ht, "keywords" , &p ) ) setKeywords ( p );
538     if ( hashGetString( ht, "description" , &p ) ) setDescription ( p );
539     if ( hashGetLong ( ht, "last_update_date" , &l ) ) setLastUpdateDate ( l );
540     if ( hashGetLong ( ht, "creation_date" , &l ) ) setCreationDate ( l );
541     if ( hashGetLong ( ht, "parent_index_id" , &l ) ) setParentIndexID ( l );
542     if ( hashGetLong ( ht, "owner_uid" , &l ) ) setOwnerUID ( l );
543     if ( hashGetLong ( ht, "owner_gid" , &l ) ) setOwnerGID ( l );
544     if ( hashGetLong ( ht, "open_level" , &l ) ) setOpenLevel ( l );
545     if ( hashGetLong ( ht, "sort_number" , &l ) ) setSortNumber ( l );
546    
547     result = RES_OK;
548     }
549     public:
550     zIndex_t() : index(){ result = RES_ERROR; }
551     zIndex_t( zval *pz ) : index(){ initialize(pz); }
552     zIndex_t( zval **ppz ) : index() { initialize(*ppz); }
553     result_t getResult(){ return result; };
554 youi 1.24
555 aga 1.22 void dump(){
556     }
557     };
558    
559 aga 1.16 /** zval*????(userid_t *puid,int uidLen)?????????????????????鴻?? <br>
560 youi 1.24 ????紊掩??????getResult()!=RES_OK <br>
561 aga 1.2 */
562     class zUIDs_t {
563     private:
564     result_t result;
565     userid_t *pUID;
566     int len;
567     public:
568     zUIDs_t(){
569     pUID = 0;
570     len = 0;
571     result = RES_ERROR;
572     }
573 youi 1.24
574     /** ?潟?潟?鴻????????/span>
575     @param pza array( '1', '3', '4', '6', ... ); ??????就?????? */
576 aga 1.2 zUIDs_t( zval *pza ){
577     pUID = 0;
578     len = 0;
579     result = RES_ERROR;
580 youi 1.24
581 aga 1.2 if ( Z_TYPE_P(pza) != IS_ARRAY ){
582     result = RES_ERROR;
583     }
584     else {
585     len = zend_hash_num_elements(Z_ARRVAL_P(pza));
586     if(len == 0) {
587     pUID = new userid_t[1];
588     result = RES_OK;
589     }
590     else {
591     /* php/ext/standard/string.c ? implode??????????????????
592     zend_hash_*???????ャ?<?潟???c????????????????鐚?
593     */
594     zval **tmp;
595     HashPosition pos;
596     int i = 0;
597     pUID = new userid_t[len];
598 youi 1.24
599 aga 1.2 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pza), &pos);
600     while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pza), (void **) &tmp, &pos) == SUCCESS ) {
601     SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html ????/span>
602     convert_to_long_ex(tmp);
603     if ( i < len )
604     pUID[i++] = Z_LVAL_PP(tmp);
605     zend_hash_move_forward_ex(Z_ARRVAL_P(pza), &pos);
606     }
607     len = i;
608     result = RES_OK;
609     }
610     }
611     }
612 youi 1.24
613 aga 1.2 ~zUIDs_t(){
614     if ( pUID ) delete[] pUID;
615     }
616     result_t getResult(){ return result; }
617     userid_t *getPUID(){ return pUID; }
618     int getLen(){ return len; }
619     void dump(){
620 youi 1.24 zend_printf( "dumping zUIDs...<br>\n" );
621 aga 1.2 zend_printf( "result=%d<br>\n", (int)result );
622     zend_printf( "len=%d<br>\n", len );
623     for ( int i = 0; i < len; i++ ){
624     zend_printf( "pUID[%d] = %d<br>\n", i, pUID[i] );
625     }
626     }
627     };
628    
629 youi 1.24 /** zval*????(itemid_t *piid,int iidLen)?????????????????????鴻?? <br>
630     ????紊掩??????getResult()!=RES_OK <br>
631     */
632     class zIIDs_t {
633     private:
634     result_t result;
635     itemid_t *pIID;
636     int len;
637     public:
638     zIIDs_t(){
639     pIID = 0;
640     len = 0;
641     result = RES_ERROR;
642     }
643    
644     /** ?潟?潟?鴻????????/span>
645     @param pza array( '1', '3', '4', '6', ... ); ??????就?????? */
646     zIIDs_t( zval *pza ){
647     pIID = 0;
648     len = 0;
649     result = RES_ERROR;
650    
651     if ( Z_TYPE_P(pza) != IS_ARRAY ){
652     result = RES_ERROR;
653     }
654     else {
655     len = zend_hash_num_elements(Z_ARRVAL_P(pza));
656     if(len == 0) {
657     pIID = new itemid_t[1];
658     result = RES_OK;
659     }
660     else {
661     /* php/ext/standard/string.c ? implode??????????????????
662     zend_hash_*???????ャ?<?潟???c????????????????鐚?
663     */
664     zval **tmp;
665     HashPosition pos;
666     int i = 0;
667     pIID = new itemid_t[len];
668    
669     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pza), &pos);
670     while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pza), (void **) &tmp, &pos) == SUCCESS ) {
671     SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html ????/span>
672     convert_to_long_ex(tmp);
673     if ( i < len )
674     pIID[i++] = Z_LVAL_PP(tmp);
675     zend_hash_move_forward_ex(Z_ARRVAL_P(pza), &pos);
676     }
677     len = i;
678     result = RES_OK;
679     }
680     }
681     }
682    
683     ~zIIDs_t(){
684     if ( pIID ) delete[] pIID;
685     }
686     result_t getResult(){ return result; }
687     itemid_t *getPIID(){ return pIID; }
688     int getLen(){ return len; }
689     void dump(){
690     zend_printf( "dumping zIIDs...<br>\n" );
691     zend_printf( "result=%d<br>\n", (int)result );
692     zend_printf( "len=%d<br>\n", len );
693     for ( int i = 0; i < len; i++ ){
694     zend_printf( "pIID[%d] = %d<br>\n", i, pIID[i] );
695     }
696     }
697     };
698    
699     /**
700     *
701     * amazonbook_t????絎鴻??PHP???????????????
702     * @param pAmazonbook 紊???????mazonbook_t*
703     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
704     * @return RES_OK
705     *
706     */
707     result_t amazonbookToZval( const amazonbook_t *pAmazonbook, zval *z )
708     {
709     zend_hash_clean( z -> value.ht );
710    
711     add_assoc_string( z, "title", ( char* )pAmazonbook -> getTitle( ), 1 );
712     add_assoc_string( z, "author", ( char* )pAmazonbook -> getAuthor( ), 1 );
713     add_assoc_string( z, "publisher", ( char* )pAmazonbook -> getPublisher( ), 1 );
714     add_assoc_long( z, "year_of_publication", pAmazonbook -> getYearOfPublication( ) );
715     add_assoc_string( z, "isbn", ( char* )pAmazonbook -> getISBN( ), 1 );
716     add_assoc_string( z, "url", ( char* )pAmazonbook -> getURL( ), 1 );
717    
718     return RES_OK;
719     }
720    
721     /**
722     *
723     * pubmed_t????絎鴻??PHP???????????????
724     * @param pPubmed 紊???????ubmed_t*
725     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
726     * @return RES_OK
727     *
728     */
729     result_t pubmedToZval( const pubmed_t *pPubmed, zval *z )
730     {
731     zend_hash_clean( z -> value.ht );
732    
733     add_assoc_long( z, "pmid", pPubmed -> getID( ) );
734     add_assoc_string( z, "title", ( char* )pPubmed -> getTitle( ), 1 );
735     add_assoc_string( z, "author", ( char* )pPubmed -> getAuthor( ), 1 );
736     add_assoc_string( z, "journal", ( char* )pPubmed -> getJournal( ), 1 );
737     add_assoc_long( z, "year_of_publication", pPubmed -> getYearOfPublication( ) );
738     add_assoc_long( z, "volume", pPubmed -> getVolume( ) );
739     add_assoc_long( z, "number", pPubmed -> getNumber( ) );
740     add_assoc_string( z, "page", ( char* )pPubmed -> getPage( ), 1 );
741     add_assoc_string( z, "abstract", ( char* )pPubmed -> getAbstract( ), 1 );
742    
743     return RES_OK;
744     }
745    
746     /**
747     *
748     * itemid_t????????PHP???????????????
749     * @param piid 紊???????temid_t??????
750     * @param len piid?????????激??
751     * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
752     * @return RES_OK
753     *
754     */
755 youi 1.25 result_t itemidsToZval( const itemid_t *piid, int len, zval **ppz )
756 youi 1.24 {
757     zend_hash_clean( Z_ARRVAL_PP(ppz) );
758    
759 youi 1.26 // add IDs
760     for ( int i = 0; i < len; i++ ){
761     add_next_index_long(*ppz, (long)(piid[i]) );
762     }
763    
764     return RES_OK;
765     }
766    
767     /**
768     *
769     * indexid_t????????PHP???????????????
770     * @param piid 紊???????ndexid_t??????
771     * @param len piid?????????激??
772     * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
773     * @return RES_OK
774     *
775     */
776     result_t indexidsToZval( const indexid_t *piid, int len, zval **ppz )
777     {
778     zend_hash_clean( Z_ARRVAL_PP(ppz) );
779    
780     // add IDs
781 youi 1.24 for ( int i = 0; i < len; i++ ){
782     add_next_index_long(*ppz, (long)(piid[i]) );
783     }
784    
785     return RES_OK;
786     }
787    
788 aga 1.8 /**
789 youi 1.24 *
790 aga 1.8 * uids_t????????PHP???????????????
791 youi 1.24 *
792 aga 1.16 * @param pUID 紊???????serid_t??????
793 aga 1.8 * @param len pUID?????????激??
794     * @param pz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
795     * @return RES_OK
796 youi 1.24 *
797 aga 1.8 */
798 aga 1.4 result_t uidsToZval( userid_t *pUID, int len, zval **ppz )
799     {
800 youi 1.24 zend_hash_clean( Z_ARRVAL_PP(ppz) );
801    
802 aga 1.2 // add UIDs
803     for ( int i = 0; i < len; i++ ){
804 aga 1.8 add_next_index_long(*ppz, (long)(pUID[i]) );
805 aga 1.2 }
806 youi 1.24
807 aga 1.2 return RES_OK;
808     }
809 youi 1.24
810 aga 1.16 /**
811     *
812     * groupid_t????????PHP???????????????
813     * @param pGID 紊???????roupid_t??????
814     * @param len pGID?????????激??
815     * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
816     * @return RES_OK
817     *
818     */
819 aga 1.4 result_t gidsToZval( groupid_t *pGID, int len, zval **ppz )
820     {
821 youi 1.24 zend_hash_clean( Z_ARRVAL_PP(ppz) );
822    
823 aga 1.2 // add GIDs
824     for ( int i = 0; i < len; i++ ){
825 aga 1.8 add_next_index_long(*ppz, (long)(pGID[i]) );
826 aga 1.2 }
827 youi 1.24
828     return RES_OK;
829     }
830    
831     /**
832     *
833     * changelog_t????絎鴻??PHP???????????????
834     * @param pChangelog 紊???????hangelog_t*
835     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
836     * @return RES_OK
837     *
838     */
839     result_t changelogToZval( const changelog_t *pChangelog, zval *z )
840     {
841     zend_hash_clean( z -> value.ht );
842    
843     add_assoc_long( z, "log_id", pChangelog -> getChangelogID( ) );
844     add_assoc_long( z, "item_id", pChangelog -> getItemID( ) );
845     add_assoc_long( z, "log_date", pChangelog -> getDate( ) );
846     add_assoc_string( z, "log", ( char* )pChangelog -> getLog( ), 1 );
847    
848     return RES_OK;
849     }
850    
851     /**
852     *
853     * item_t????絎鴻??PHP???????????????
854     * @param pItem 紊???????tem_t*
855     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
856     * @return RES_OK
857     *
858     */
859     result_t itemToZval( const item_t *pItem, zval *z )
860     {
861     zend_hash_clean( z -> value.ht );
862    
863     add_assoc_long( z, "item_id", pItem -> getItemID( ) );
864     add_assoc_long( z, "item_type_id", pItem -> getItemTypeID( ) );
865     add_assoc_long( z, "uid", pItem -> getContributorUID( ) );
866     add_assoc_string( z, "title", ( char* )pItem -> getTitle( ), 1 );
867     add_assoc_string( z, "keywords", ( char* )pItem -> getKeywords( ), 1 );
868     add_assoc_string( z, "description", ( char* )pItem -> getDescription( ), 1 );
869     add_assoc_string( z, "doi", ( char* )pItem -> getDOI( ), 1 );
870     add_assoc_long( z, "last_update_date", pItem -> getLastUpdateDate( ) );
871     add_assoc_long( z, "creation_date", pItem -> getCreationDate( ) );
872    
873     return RES_OK;
874     }
875    
876    
877     result_t itemsToZval( const item_t *pItems, int itemsLen, zval *z )
878     {
879     zend_hash_clean( z -> value.ht );
880     for( int i = 0; i < itemsLen; i++ ){
881     zval *new_array;
882     MAKE_STD_ZVAL(new_array);
883     if(array_init(new_array) != SUCCESS){
884     return RES_ERROR;
885     }
886     add_index_zval( z, i, new_array );
887     itemToZval( &pItems[ i ], new_array );
888     }
889 aga 1.2 return RES_OK;
890     }
891    
892 youi 1.24 /**
893     *
894     * PHP???f?渇????????絎鴻??group_t?????????
895     *
896     * @param z 紊????????f?渇????
897     * @param pGroup 紊???腟??????吾??莨若???違???若??
898     * @return RES_OK
899     *
900     */
901     result_t zvalToItem( zval *z, item_t* pItem )
902     {
903     zval **tmp;
904     HashPosition pos;
905     int i = 0;
906     char* key = 0;
907    
908     key = "item_id";
909     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
910     convert_to_long_ex( tmp ) ;
911     pItem -> setItemID( (*tmp) -> value.lval );
912     }
913     key = "item_type_id";
914     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
915     convert_to_long_ex( tmp ) ;
916     pItem -> setItemTypeID( (*tmp) -> value.lval );
917     }
918     key = "uid";
919     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
920     convert_to_long_ex( tmp ) ;
921     pItem -> setContributorUID( (*tmp) -> value.lval );
922     }
923     key = "title";
924     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
925     convert_to_string_ex( tmp ) ;
926     pItem -> setTitle( (*tmp) -> value.str.val );
927     }
928     key = "keywords";
929     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
930     convert_to_string_ex( tmp ) ;
931     pItem -> setKeywords( (*tmp) -> value.str.val );
932     }
933     key = "description";
934     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
935     convert_to_string_ex( tmp ) ;
936     pItem -> setDescription( (*tmp) -> value.str.val );
937     }
938     key = "doi";
939     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
940     convert_to_string_ex( tmp ) ;
941     pItem -> setDOI( (*tmp) -> value.str.val );
942     }
943     key = "last_update_date";
944     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
945     convert_to_long_ex( tmp ) ;
946     pItem -> setLastUpdateDate( (*tmp) -> value.lval );
947     }
948     key = "creation_date";
949     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
950     convert_to_long_ex( tmp ) ;
951     pItem -> setCreationDate( (*tmp) -> value.lval );
952     }
953     return RES_OK;
954     }
955 aga 1.16
956     /**
957     *
958     * account_t????絎鴻??PHP???????????????
959     * @param pAccount 紊???????ccount_t*
960     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
961     * @return RES_OK
962     *
963     */
964 youi 1.6 result_t accountToZval( const account_t *pAccount, zval *z )
965     {
966 youi 1.24 zend_hash_clean( z -> value.ht );
967    
968     add_assoc_long( z, "uid", pAccount -> getUID( ) );
969     add_assoc_string( z, "uname", ( char* )pAccount -> getUname( ), 1 );
970     add_assoc_string( z, "name", ( char* )pAccount -> getName( ), 1 );
971     add_assoc_string( z, "email", ( char* )pAccount -> getEmail( ), 1 );
972     add_assoc_string( z, "url", ( char* )pAccount -> getURL( ), 1 );
973     add_assoc_string( z, "user_avatar", ( char* )pAccount -> getUserAvatar( ), 1 );
974     add_assoc_string( z, "user_icq", ( char* )pAccount -> getUserIcq( ), 1 );
975     add_assoc_string( z, "user_from", ( char* )pAccount -> getUserFrom( ), 1 );
976     add_assoc_string( z, "user_sig", ( char* )pAccount -> getUserSig( ), 1 );
977     add_assoc_string( z, "actkey", ( char* )pAccount -> getActkey( ), 1 );
978     add_assoc_string( z, "user_aim", ( char* )pAccount -> getUserAim( ), 1 );
979     add_assoc_string( z, "user_yim", ( char* )pAccount -> getUserYim( ), 1 );
980     add_assoc_string( z, "user_msnm", ( char* )pAccount -> getUserMsnm( ), 1 );
981     add_assoc_string( z, "pass", ( char* )pAccount -> getPass( ), 1 );
982     add_assoc_string( z, "theme", ( char* )pAccount -> getTheme( ), 1 );
983     add_assoc_string( z, "umode", ( char* )pAccount -> getUmode( ), 1 );
984     add_assoc_string( z, "user_occ", ( char* )pAccount -> getUserOcc( ), 1 );
985     add_assoc_string( z, "bio", ( char* )pAccount -> getBio( ), 1 );
986     add_assoc_string( z, "user_intrest", ( char* )pAccount -> getUserIntrest( ), 1 );
987     add_assoc_double( z, "timezone_offset", pAccount -> getTimezoneOffset( ) );
988     add_assoc_long( z, "attachsig", pAccount -> getAttachsig( ) );
989     add_assoc_long( z, "last_login", pAccount -> getLastLogin( ) );
990     add_assoc_long( z, "level", pAccount -> getLevel( ) );
991     add_assoc_long( z, "notify_method", pAccount -> getNotifyMethod( ) );
992     add_assoc_long( z, "notify_mode", pAccount -> getNotifyMode( ) );
993     add_assoc_long( z, "posts", pAccount -> getPosts( ) );
994     add_assoc_long( z, "rank", pAccount -> getRank( ) );
995     add_assoc_long( z, "uorder", pAccount -> getUorder( ) );
996     add_assoc_long( z, "user_mailok", pAccount -> getUserMailok( ) );
997     add_assoc_long( z, "user_regdate", pAccount -> getUserRegdate( ) );
998     add_assoc_long( z, "user_viewemail", pAccount -> getUserViewemail( ) );
999    
1000     add_assoc_long( z, "activate", pAccount -> getActivate( ) );
1001     add_assoc_string( z, "address", ( char* )pAccount -> getAddress( ), 1 );
1002     add_assoc_string( z, "division", ( char* )pAccount -> getDivision( ), 1 );
1003     add_assoc_string( z, "tel", ( char* )pAccount -> getTel( ), 1 );
1004     add_assoc_string( z, "company_name", ( char* )pAccount -> getCompanyName( ), 1 );
1005     add_assoc_string( z, "country", ( char* )pAccount -> getCountry( ), 1 );
1006     add_assoc_string( z, "zipcode", ( char* )pAccount -> getZipcode( ), 1 );
1007     add_assoc_string( z, "fax", ( char* )pAccount -> getFax( ), 1 );
1008     add_assoc_string( z, "base_url", ( char* )pAccount -> getBaseURL( ), 1 );
1009     add_assoc_long( z, "notice_mail", pAccount -> getNoticeMail( ) );
1010     add_assoc_long( z, "notice_mail_since", pAccount -> getNoticeMailSince( ) );
1011     add_assoc_long( z, "private_index_id", pAccount -> getPrivateIndexID( ) );
1012 youi 1.6 return RES_OK;
1013     }
1014 youi 1.24
1015 aga 1.16 /**
1016     *
1017     * 茲??違??ccount_t????絎鴻??PHP?????????????????????
1018     * @param pAccounts 紊???????ccount_t*
1019     * @param accountsLen pAccounts?????????激??
1020     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
1021     * @return RES_OK
1022     *
1023     z: ?????????????????????????? <br>
1024 youi 1.24 array(
1025     array(
1026     'uid'=>100,
1027     'activate'=>1,
1028     'division'=>'foo',
1029     'tel'=>'123-456-789',
1030     ...
1031     ),
1032     ...
1033     )
1034 aga 1.16 */
1035 youi 1.6 result_t accountsToZval( const account_t *pAccounts, int accountsLen, zval *z )
1036 aga 1.4 {
1037 youi 1.24 zend_hash_clean( z -> value.ht );
1038     for( int i = 0; i < accountsLen; i++ ){
1039     zval *new_array;
1040     MAKE_STD_ZVAL(new_array);
1041     if(array_init(new_array) != SUCCESS){
1042     return RES_ERROR;
1043     }
1044     add_index_zval( z, i, new_array );
1045     accountToZval( &pAccounts[ i ], new_array );
1046     }
1047 youi 1.6 return RES_OK;
1048 aga 1.2 }
1049    
1050 aga 1.16 /**
1051     *
1052     * 茲??違??roup_t????絎鴻??PHP?????????????????????
1053     * @param pGroups 紊???????roup_t*
1054     * @param groupsLen pGroups?????????激??
1055     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
1056     * @return RES_OK
1057     *
1058     z: ?????????????????????????? <br>
1059 youi 1.24 array(
1060     array(
1061     'gid'=>1,
1062     'gname'=>'foo group',
1063     'gdesc'=>'group of foo'
1064     ),
1065     ...
1066     )
1067 aga 1.16 */
1068 youi 1.6 result_t groupsToZval( const group_t *pGroups, int groupsLen, zval *z )
1069 aga 1.4 {
1070 youi 1.24 zend_hash_clean( z -> value.ht );
1071     for( int i = 0; i < groupsLen; i++ ){
1072     zval *new_array;
1073     MAKE_STD_ZVAL(new_array);
1074     if(array_init(new_array) != SUCCESS){
1075     return RES_ERROR;
1076     }
1077     add_index_zval( z, i, new_array );
1078     add_assoc_long( new_array, "gid", pGroups[ i ].getGID( ) );
1079     add_assoc_string( new_array, "gname", ( char* )pGroups[ i ].getGname( ), 1 );
1080     add_assoc_string( new_array, "gdesc", ( char* )pGroups[ i ].getDesc( ), 1 );
1081     add_assoc_long( new_array, "group_index_id", pGroups[ i ].getGroupIndexID( ) );
1082     }
1083 youi 1.6 return RES_OK;
1084 aga 1.2 }
1085    
1086 youi 1.7 /**
1087 youi 1.24 *
1088 youi 1.7 * group_t????絎鴻??PHP???f?渇?????????????
1089 youi 1.24 *
1090 aga 1.16 * @param pGroup 紊????????違???若??????/span>
1091 youi 1.7 * @param z 紊???腟??????吾??莨若???f?渇????(??????羝??帥?с????????
1092     * @return RES_OK
1093 youi 1.24 *
1094 youi 1.7 */
1095     result_t groupToZval( const group_t *pGroup, zval *z )
1096 youi 1.6 {
1097 youi 1.24 zend_hash_clean( z -> value.ht );
1098     add_assoc_long( z, "gid", pGroup -> getGID( ) );
1099     add_assoc_string( z, "gname", ( char* )pGroup -> getGname( ), 1 );
1100     add_assoc_string( z, "gdesc", ( char* )pGroup -> getDesc( ), 1 );
1101     add_assoc_long( z, "group_index_id", pGroup -> getGroupIndexID( ) );
1102 youi 1.6 return RES_OK;
1103     }
1104    
1105 aga 1.16 /**
1106 youi 1.24 *
1107 aga 1.16 * PHP???f?渇????????絎鴻??group_t?????????
1108 youi 1.24 *
1109 aga 1.16 * @param z 紊????????f?渇????
1110     * @param pGroup 紊???腟??????吾??莨若???違???若??
1111     * @return RES_OK
1112 youi 1.24 *
1113 aga 1.16 */
1114 youi 1.7 result_t zvalToGroup( zval *z, group_t *pGroup )
1115     {
1116 youi 1.24 zval **tmp;
1117     HashPosition pos;
1118     int i = 0;
1119     char* key = 0;
1120    
1121     key = "gid";
1122     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1123     convert_to_long_ex( tmp ) ;
1124     pGroup -> setGID( (*tmp) -> value.lval );
1125     }
1126     key = "gname";
1127     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1128     convert_to_string_ex( tmp ) ;
1129     pGroup -> setGname( (*tmp) -> value.str.val );
1130     }
1131     key = "gdesc";
1132     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1133     convert_to_string_ex( tmp ) ;
1134     pGroup -> setDesc( (*tmp) -> value.str.val );
1135     }
1136     key = "group_index_id";
1137     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1138     convert_to_long_ex( tmp ) ;
1139     pGroup -> setGroupIndexID( (*tmp) -> value.lval );
1140     }
1141 youi 1.7 return RES_OK;
1142     }
1143    
1144 aga 1.16 /**
1145 youi 1.24 *
1146 aga 1.16 * session_t????絎鴻??PHP???f?渇?????????????
1147 youi 1.24 *
1148 aga 1.16 * @param pSession 紊???????ession_t
1149     * @param z 紊???腟??????吾??莨若???f?渇????(??????羝??帥?с????????
1150     * @return RES_OK
1151 youi 1.24 *
1152 aga 1.16 */
1153     result_t sessionToZval( const session_t *pSession, zval *z )
1154     {
1155     string sessionID(unsignedIntToString(pSession->getSessionID()));
1156     add_assoc_string(z, "session_id", (char *)sessionID.c_str(), 1);
1157 youi 1.24
1158 aga 1.16 string date(unsignedIntToString((unsigned int)pSession->getDate()));
1159     add_assoc_string(z, "date", (char *)date.c_str(), 1);
1160 youi 1.24
1161 aga 1.20 string userID(unsignedIntToString((unsigned int)pSession->getUID()));
1162 aga 1.16 add_assoc_string(z, "user_id", (char *)userID.c_str(), 1);
1163 youi 1.24
1164 aga 1.16 return RES_OK;
1165     }
1166    
1167 aga 1.22 /**
1168     *
1169     * index_t????絎鴻??PHP???????????????
1170     * @param pIndex 紊???????ndex_t*
1171     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
1172     * @return RES_OK
1173     *
1174     */
1175     result_t indexToZval( const index_t *pIndex, zval *z )
1176     {
1177 youi 1.24 zend_hash_clean( z -> value.ht );
1178    
1179     add_assoc_long( z, "item_id", pIndex -> getItemID( ) );
1180     add_assoc_long( z, "item_type_id", pIndex -> getItemTypeID( ) );
1181     add_assoc_long( z, "contributor_uid", pIndex -> getContributorUID( ) );
1182     add_assoc_string( z, "title", ( char* )pIndex -> getTitle( ), 1 );
1183     add_assoc_string( z, "keywords", ( char* )pIndex -> getKeywords( ), 1 );
1184     add_assoc_string( z, "description", ( char* )pIndex -> getDescription( ), 1 );
1185     add_assoc_long( z, "last_update_date", pIndex -> getLastUpdateDate( ) );
1186     add_assoc_long( z, "creation_date", pIndex-> getCreationDate( ) );
1187     add_assoc_long( z, "parent_index_id", pIndex -> getParentIndexID( ) );
1188     add_assoc_long( z, "owner_uid", pIndex -> getOwnerUID( ) );
1189     add_assoc_long( z, "owner_gid", pIndex -> getOwnerGID( ) );
1190     add_assoc_long( z, "open_level", pIndex -> getOpenLevel( ) );
1191     add_assoc_long( z, "sort_number", pIndex -> getSortNumber( ) );
1192 aga 1.22 return RES_OK;
1193     }
1194    
1195     result_t indexesToZval( const index_t *pIndexes, int indexesLen, zval *z )
1196     {
1197 youi 1.24 zend_hash_clean( z -> value.ht );
1198     for( int i = 0; i < indexesLen; i++ ){
1199     zval *new_array;
1200     MAKE_STD_ZVAL(new_array);
1201     if(array_init(new_array) != SUCCESS){
1202     return RES_ERROR;
1203     }
1204     add_index_zval( z, i, new_array );
1205     indexToZval( &pIndexes[ i ], new_array );
1206     }
1207 aga 1.22 return RES_OK;
1208     }
1209    
1210    
1211 youi 1.7
1212 aga 1.16
1213     /** ??絎??????違???若???????宴??緇???<br>
1214 youi 1.24 int xnp_get_group( int sid, int gid, array group );
1215     @param sid XNP???祉???激?с??D
1216     @param gid XNP ? group_id
1217     @param group 腟?????????????????
1218     @return 0 success <br>
1219 aga 1.16 */
1220 youi 1.21 ZEND_FUNCTION(xnp_get_group)
1221 aga 1.4 {
1222 youi 1.6 long sid, gid;
1223     zval *zgroup;
1224 youi 1.24
1225 youi 1.6 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
1226 youi 1.24 &sid, &gid, &zgroup) == FAILURE) {
1227 youi 1.6 return;
1228     }
1229 youi 1.24
1230 youi 1.6 const group_t *pgroup;
1231     result_t result = getGroup( (sessionid_t)sid, (groupid_t)gid, &pgroup );
1232     if ( RES_OK == result ){
1233 youi 1.7 groupToZval( pgroup, zgroup );
1234 youi 1.19 freeGroup( pgroup );
1235 youi 1.6 }
1236 youi 1.24
1237     RETURN_LONG(result);
1238 youi 1.6 }
1239    
1240 aga 1.2
1241 aga 1.16 /** ??絎??????違???若??(茲????????宴??緇???<br>
1242 youi 1.24 xnp_get_groups( int sid, array gids, array criteria, array groups );
1243     @param sid XNP???祉???激?с??D
1244     @param gids XNP ? group_id ??????
1245     @param criteria ?>散
1246     @param groups 腟???????????????????????
1247     @return 0 success <br>
1248 aga 1.16 */
1249 youi 1.21 ZEND_FUNCTION(xnp_get_groups)
1250 youi 1.6 {
1251     result_t result;
1252     long sid, uid;
1253     zval *zcriteria;
1254     zval *zgids;
1255     zval *zgroups;
1256 youi 1.24 zval **ppzTmp = 0;
1257     HashPosition pos;
1258     int res2;
1259     int gidsLen;
1260     const group_t* groups;
1261     int groupsLen;
1262    
1263 youi 1.6 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
1264 youi 1.24 &sid, &zgids, &zcriteria, &zgroups) == FAILURE) {
1265 youi 1.6 return;
1266     }
1267 youi 1.24
1268     //gids???違???若??ID???潟???若????
1269     gidsLen = zend_hash_num_elements(Z_ARRVAL_P(zgids));
1270     groupid_t *gids = new groupid_t[ gidsLen ];
1271     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zgids), &pos);
1272     for( int i = 0; i < gidsLen; i++ ){
1273     if( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(zgids), (void **)&ppzTmp, &pos)) == SUCCESS ){
1274     SEPARATE_ZVAL(ppzTmp);
1275     convert_to_long_ex(ppzTmp);
1276     gids[ i ] = Z_LVAL_PP(ppzTmp);
1277     }
1278     zend_hash_move_forward_ex(Z_ARRVAL_P(zgids), &pos);
1279     }
1280    
1281 youi 1.6 zCriteria_t zcri(zcriteria);
1282     result = zcri.getResult();
1283     if ( RES_OK == result ){
1284 youi 1.24 result = getGroups( (sessionid_t)sid, gids, gidsLen, &zcri, &groups, &groupsLen );
1285     if ( RES_OK == result ){
1286     groupsToZval( groups, groupsLen, zgroups );
1287     delete[] gids;
1288     freeGroup( groups );
1289     }
1290     }
1291     RETURN_LONG(result);
1292 youi 1.6 }
1293    
1294    
1295 aga 1.16 /** ??絎????????若?吟???≪?????若?帥??????????茯帥?鴻??<br>
1296 youi 1.24 int xnp_is_moderator(int sid, int uid)
1297     @param sid XNP???祉???激?с??D
1298     @param uid xoops ? uid (xoops_users.uid)
1299     @return true ?≪?????若?帥?с???? <br>
1300 aga 1.16 */
1301 youi 1.21 ZEND_FUNCTION(xnp_is_moderator)
1302 youi 1.6 {
1303 youi 1.21 long xnpSessionID;
1304 youi 1.6 userid_t uid;
1305 youi 1.24
1306     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
1307     &xnpSessionID, &uid) == FAILURE) {
1308 youi 1.6 return;
1309     }
1310 youi 1.24
1311 youi 1.21 bool result = isModerator( (sessionid_t)xnpSessionID, uid );
1312 youi 1.24 RETURN_BOOL(result)
1313 youi 1.6 }
1314    
1315 aga 1.16 /** ???若?九??????uid??茯帥?鴻??<br>
1316 youi 1.24 int xnp_get_uid(string uname,int &uid)
1317     @param sid XNP???祉???激?с??D
1318     @param uname xoops ? uname (xoops_users.uname)
1319     @param uid xoops ? uid (xoops_users.uid) ??????????紊???/span>
1320     @return 0 success
1321 aga 1.16 */
1322 youi 1.21 ZEND_FUNCTION(xnp_get_uid)
1323 youi 1.6 {
1324     char *uname;
1325     int unameLen;
1326 aga 1.14 zval *zuid;
1327 youi 1.6 userid_t uid;
1328 youi 1.24
1329     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
1330 aga 1.14 &uname, &unameLen, &zuid) == FAILURE) {
1331 youi 1.6 return;
1332     }
1333 youi 1.24
1334 aga 1.14 if (!PZVAL_IS_REF(zuid)) {
1335     zend_error(E_WARNING, "2nd parameter wasn't passed by reference");
1336     RETURN_LONG(RES_PHP_NONREF);
1337     }
1338 youi 1.24
1339 youi 1.6 string strUname( uname, unameLen );
1340     result_t result = getUid( strUname.c_str(), &uid );
1341 aga 1.14 ZVAL_LONG(zuid, (long)uid);
1342     RETURN_LONG((long)result);
1343 aga 1.2 }
1344    
1345 youi 1.21 ZEND_FUNCTION(xnp_test_criteria)
1346 aga 1.2 {
1347     zval *z;
1348 youi 1.24
1349     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
1350 aga 1.2 &z) == FAILURE) {
1351     return;
1352     }
1353     zend_printf("zend_printf...<br>\n");
1354     zCriteria_t zcri(z);
1355     zcri.dump();
1356     RETURN_FALSE
1357     }
1358    
1359 youi 1.21 ZEND_FUNCTION(xnp_test_uids)
1360 aga 1.2 {
1361     zval *z;
1362 youi 1.24
1363     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
1364 aga 1.2 &z) == FAILURE) {
1365     return;
1366     }
1367     zend_printf("zend_printf...<br>\n");
1368     zUIDs_t zuids(z);
1369     zuids.dump();
1370     RETURN_FALSE
1371     }
1372    
1373    
1374    
1375 aga 1.4 /** DB??・膓????????≪??・膓?筝???・膓???????????????<br>
1376 youi 1.24 int initialize_db( string host[, string user[, string password[, string dbname[, string prefix]]]] );
1377     @param host ?ョ????????ユ????ULL
1378     @param user DB?ョ????????若?九???????ユ????ULL
1379     @param password DB?ョ????????鴻???若???????ユ????ULL
1380     @param dbname DB?ョ?????B???????ユ????quot;"
1381     @param prefix XOOPS DB ??refix??
1382     @return 0 success <br>
1383 aga 1.1 */
1384 youi 1.21 ZEND_FUNCTION(xnp_initialize_db)
1385 aga 1.1 {
1386     zval **parameters[5];
1387     char *host;
1388     char *user;
1389 aga 1.2 char *password;
1390     char *dbname;
1391     char *prefix;
1392 aga 1.1
1393     /* get the number of arguments */
1394     int argNum = ZEND_NUM_ARGS();
1395     if (argNum > 5)
1396     WRONG_PARAM_COUNT;
1397    
1398     /* argument count is correct, now retrieve arguments */
1399     if(zend_get_parameters_array_ex(argNum, parameters) != SUCCESS)
1400     WRONG_PARAM_COUNT;
1401    
1402 aga 1.2 if (argNum < 1) host = NULL;
1403 aga 1.1 else host = getZvalString( parameters[0] );
1404 youi 1.24
1405 aga 1.1 if (argNum < 2) user = NULL;
1406     else user = getZvalString( parameters[1] );
1407 youi 1.24
1408 aga 1.2 if (argNum < 3) password = NULL;
1409     else password = getZvalString( parameters[2] );
1410 youi 1.24
1411 aga 1.2 if (argNum < 4) dbname = "";
1412     else dbname = getZvalString( parameters[3] );
1413 youi 1.24
1414 aga 1.2 if (argNum < 5) prefix = "";
1415     else prefix = getZvalString( parameters[4] );
1416 youi 1.24
1417 aga 1.2 result_t result = initializeDB( host, user, password, dbname, prefix );
1418 youi 1.24
1419 aga 1.2 RETURN_LONG(result);
1420 aga 1.1 }
1421    
1422 aga 1.4 /** ???違?ゃ?潟??????<br>
1423 youi 1.24 int xnp_login_user(string uname, string password, int &session_id)
1424     @param uname ???若?九??(xoops_users.uname)
1425     @param password ???鴻???若??(md5(password)=xoops_users.pass)
1426     @return 0 success
1427 aga 1.4 */
1428 youi 1.21 ZEND_FUNCTION(xnp_login_user)
1429 aga 1.1 {
1430     char *uname;
1431     int unameLen;
1432     char *passwd;
1433     int passwdLen;
1434 youi 1.21 zval *zXNPSessionID;
1435 youi 1.24
1436     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssz",
1437 youi 1.21 &uname, &unameLen, &passwd, &passwdLen, &zXNPSessionID) == FAILURE) {
1438 aga 1.1 return;
1439     }
1440 youi 1.24
1441 youi 1.21 if (!PZVAL_IS_REF(zXNPSessionID)) {
1442 aga 1.14 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
1443     RETURN_LONG(RES_PHP_NONREF);
1444     }
1445 youi 1.24
1446 youi 1.21 sessionid_t xnpSessionID;
1447     result_t result = loginUser( uname, passwd, &xnpSessionID );
1448 aga 1.14 if ( result == RES_OK )
1449 youi 1.21 ZVAL_LONG(zXNPSessionID, (long)xnpSessionID);
1450 aga 1.14 RETURN_LONG((long)result);
1451 aga 1.1 }
1452    
1453 aga 1.4 /** ???違?≪??????????<br>
1454 youi 1.24 void xnp_logout_user(int xnp_session_id)
1455     @param xnp_session_id XNP???祉???激?с??D
1456     @return ????
1457 aga 1.4 */
1458 youi 1.21 ZEND_FUNCTION(xnp_logout_user)
1459 aga 1.1 {
1460 youi 1.21 long xnpSessionID;
1461 youi 1.24
1462 youi 1.21 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &xnpSessionID) == FAILURE) {
1463 aga 1.1 return;
1464     }
1465 youi 1.21 logoutUser( (sessionid_t)xnpSessionID );
1466 youi 1.24
1467     RETURN_NULL();
1468 aga 1.1 }
1469    
1470 youi 1.21 /** XNP???祉???激?с??D 篏???<br>
1471 youi 1.24 int xnp_create_session( string xoops_sess_id, int uid, int &session )
1472     @param xoops_sess_id xoops???祉???激?с??D
1473     @param uid xoops ? uid (xoops_users.uid)
1474     @param session 篏???????XNP??ession??????????紊???/span>
1475     @return 0 ????
1476 aga 1.4 */
1477 youi 1.21 ZEND_FUNCTION(xnp_create_session)
1478 aga 1.2 {
1479     char *xoopsSessionID;
1480     int xoopsSessionIDLen;
1481 aga 1.5 long uid;
1482 youi 1.21 zval *zXNPSessionID;
1483 youi 1.24
1484 aga 1.14 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "slz",
1485 youi 1.21 &xoopsSessionID, &xoopsSessionIDLen, &uid, &zXNPSessionID) == FAILURE) {
1486 aga 1.2 return;
1487     }
1488 youi 1.24
1489 youi 1.21 if (!PZVAL_IS_REF(zXNPSessionID)) {
1490 aga 1.14 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
1491     RETURN_LONG(RES_PHP_NONREF);
1492     }
1493 youi 1.24
1494 youi 1.21 sessionid_t xnpSessionID = 0;
1495     result_t result = createSession( xoopsSessionID, (userid_t)uid, &xnpSessionID );
1496 aga 1.14 if ( result == RES_OK )
1497 youi 1.21 ZVAL_LONG(zXNPSessionID, (long)xnpSessionID);
1498 aga 1.14 RETURN_LONG((long)result);
1499 aga 1.4 }
1500    
1501 youi 1.21 /** XNP ? session ???膣井???宴??緇???<br>
1502 youi 1.24 int xnp_get_session( int xnp_session_id, array session_info )
1503     @param xnp_session_id XNP???祉???激?с??D
1504     @param session_info 腟?????????????????
1505     @return 0 success
1506 aga 1.4 */
1507 youi 1.21 ZEND_FUNCTION(xnp_get_session)
1508 aga 1.4 {
1509 youi 1.21 long xnpSessionID;
1510 aga 1.4 zval *sessionInfo;
1511     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1512 youi 1.21 &xnpSessionID, &sessionInfo) == FAILURE) {
1513 aga 1.4 return;
1514     }
1515     const session_t *session = 0;
1516 youi 1.21 result_t result = getSession( (sessionid_t)xnpSessionID, &session );
1517 aga 1.4 if ( result == RES_OK ){
1518     sessionToZval( session, sessionInfo );
1519 youi 1.19 freeSession( session );
1520 aga 1.4 }
1521 youi 1.24
1522 aga 1.4 RETURN_LONG((long)result);
1523 aga 1.2 }
1524 aga 1.1
1525 aga 1.16 /** ???若?吟??ctivate?倶??????緇?????<br>
1526 youi 1.24 bool xnp_is_activated( int xnp_session_id, int user_id )
1527     @param xnp_session_id XNP???祉???激?с??D
1528     @param user_id xoops_users.uid
1529     @return 0 success
1530 aga 1.5 */
1531 youi 1.21 ZEND_FUNCTION(xnp_is_activated)
1532 aga 1.2 {
1533     long sid, uid;
1534 youi 1.24
1535 aga 1.5 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &sid, &uid) == FAILURE) {
1536 aga 1.2 return;
1537     }
1538 youi 1.24
1539 aga 1.2 bool result = isActivated( (sessionid_t)sid, (userid_t)uid );
1540 youi 1.24
1541     RETURN_BOOL(result);
1542 aga 1.2 }
1543 aga 1.1
1544 youi 1.17 /** activate??????<br>
1545 youi 1.24 bool xnp_activate( int xnp_session_id, int user_id, bool activated )
1546     @param xnp_session_id xnp ? session id
1547     @param user_id xoops_users.uid
1548     @param activated true:activate, false:inactivate
1549     @return 0 success
1550 aga 1.5 */
1551 youi 1.21 ZEND_FUNCTION(xnp_activate)
1552 aga 1.2 {
1553     long sid, uid;
1554     bool activated;
1555 youi 1.24
1556 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llb",
1557     &sid, &uid, &activated) == FAILURE) {
1558     return;
1559     }
1560 youi 1.24
1561 aga 1.2 result_t result = activate( (sessionid_t)sid, (userid_t)uid, activated );
1562 youi 1.24
1563     RETURN_LONG(result);
1564 aga 1.2 }
1565 aga 1.1
1566 youi 1.21 /** XNP???≪?????潟???違??緇?????<br>
1567 youi 1.24 int xnp_get_account_count( int xnp_session_id )
1568     @param xnp_session_id XNP???祉???激?с??D
1569     @return 0 success
1570 aga 1.5 */
1571 youi 1.21 ZEND_FUNCTION(xnp_get_account_count)
1572 aga 1.2 {
1573     long sid;
1574 youi 1.24
1575 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1576     &sid) == FAILURE) {
1577     return;
1578     }
1579 youi 1.24
1580 aga 1.2 long count = getAccountCount( (sessionid_t)sid );
1581 youi 1.24 RETURN_LONG(count);
1582 aga 1.2 }
1583 aga 1.1
1584 aga 1.5 /** ?≪?????潟???????ゃ??????<br>
1585 youi 1.24 bool xnp_delete_account( int xnp_session_id, int user_id )
1586     @param xnp_session_id XNP???祉???激?с??D
1587     @param user_id xoops_users.uid
1588     @return 0 success
1589 aga 1.5 */
1590 youi 1.21 ZEND_FUNCTION(xnp_delete_account)
1591 aga 1.2 {
1592     long sid, uid;
1593 youi 1.24
1594 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
1595     &sid, &uid) == FAILURE) {
1596     return;
1597     }
1598 youi 1.24
1599 aga 1.2 result_t result = deleteAccount( (sessionid_t)sid, (userid_t)uid );
1600 youi 1.24
1601     RETURN_LONG(result);
1602 aga 1.2 }
1603 aga 1.1
1604 aga 1.5 /** ?≪?????潟?????宴??緇?????<br>
1605 youi 1.24 int xnp_get_account( int xnp_session_id, int user_id, array account_info )
1606     @param xnp_session_id XNP???祉???激?с??D
1607     @param user_id xoops_users.uid
1608     @param account_info ?≪?????潟?????宴???????????f?渇????
1609     @return 0 success
1610 aga 1.5 */
1611 youi 1.21 ZEND_FUNCTION(xnp_get_account)
1612 aga 1.2 {
1613     long sid, uid;
1614     zval *zaccount;
1615 youi 1.24
1616 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
1617     &sid, &uid, &zaccount) == FAILURE) {
1618 youi 1.24 fprintf( stderr, "error occured " );
1619 aga 1.2 return;
1620     }
1621 youi 1.24
1622 aga 1.2 const account_t *paccount;
1623     result_t result = getAccount( (sessionid_t)sid, (userid_t)uid, &paccount );
1624     if ( RES_OK == result ){
1625     accountToZval( paccount, zaccount );
1626 youi 1.19 freeAccount( paccount );
1627 aga 1.2 }
1628 youi 1.24
1629     RETURN_LONG(result);
1630 aga 1.2 }
1631 aga 1.1
1632 aga 1.5 /** ?>散????眼?????≪?????潟???????宴??緇?????<br>
1633 youi 1.24 int xnp_get_accoutns( int sid, array uids, array criteria, array accounts );
1634     @param xnp_session_id XNP???祉???激?с??D
1635     @param user_id xoops_users.uid
1636     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1637     @param account_info ?≪?????潟?????宴???????????f?渇????
1638     @return 0 success
1639 aga 1.5 */
1640 youi 1.21 ZEND_FUNCTION(xnp_get_accounts)
1641 aga 1.2 {
1642     result_t result;
1643     long sid;
1644     zval *zuids;
1645     zval *zcriteria;
1646     zval *zaccount;
1647 youi 1.24
1648 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
1649     &sid, &zuids, &zcriteria, &zaccount) == FAILURE) {
1650     return;
1651     }
1652 youi 1.24
1653 aga 1.2 zCriteria_t zcri(zcriteria);
1654     result = zcri.getResult();
1655     if ( RES_OK == result ){
1656     zUIDs_t zUIDs(zuids);
1657     result = zUIDs.getResult();
1658     if ( RES_OK == result ){
1659     const account_t *paccounts;
1660     int accountLen;
1661 youi 1.24 result = getAccounts( (sessionid_t)sid,
1662 aga 1.2 zUIDs.getPUID(), zUIDs.getLen(),
1663     &zcri, &paccounts, &accountLen );
1664     if ( RES_OK == result ){
1665     accountsToZval( paccounts, accountLen, zaccount );
1666 youi 1.19 freeAccount( paccounts );
1667 aga 1.2 }
1668     }
1669     }
1670 youi 1.24
1671     RETURN_LONG(result);
1672 aga 1.2 }
1673 aga 1.1
1674 youi 1.17 /** ?≪?????潟?????宴??荐??蚊??????<br>
1675 youi 1.24 int xnp_insert_account( int sid, array account_info, int &user_id );
1676     @param xnp_session_id xnp ? session id
1677     @param account_info 荐??蚊???????≪?????潟????????/span>
1678     @param user_id ???若??D(xoops_users.uid)???吾??莨若???????<???潟??/span>
1679     @return 0 success
1680 aga 1.5 */
1681 youi 1.21 ZEND_FUNCTION(xnp_insert_account)
1682 aga 1.2 {
1683     result_t result;
1684     long sid;
1685     zval *zaccount;
1686 youi 1.17 zval *zuid;
1687 youi 1.24 userid_t uid;
1688    
1689 youi 1.17 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
1690     &sid, &zaccount, &zuid) == FAILURE) {
1691 aga 1.2 return;
1692     }
1693 youi 1.24
1694 aga 1.2 zAccount_t zacc(zaccount);
1695     result = zacc.getResult();
1696     if ( RES_OK == result ){
1697 youi 1.17 result = insertAccount( (sessionid_t)sid, &zacc, &uid );
1698 aga 1.2 }
1699 youi 1.24 zuid -> type = IS_LONG;
1700     zuid -> value.lval = uid;
1701     RETURN_LONG(result);
1702 aga 1.2 }
1703 aga 1.1
1704 aga 1.5 /** ?≪?????潟?????宴???贋?違??????<br>
1705 youi 1.24 int xnp_update_account( int sid, array account );
1706     @param xnp_session_id XNP???祉???激?с??D
1707     @param account_info ?吾??莨若???鴻???≪?????潟?????宴??茵????f?渇????
1708     @return 0 success
1709 aga 1.5 */
1710 youi 1.21 ZEND_FUNCTION(xnp_update_account)
1711 aga 1.2 {
1712     result_t result;
1713     long sid;
1714     zval *zaccount;
1715 youi 1.24
1716 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1717     &sid, &zaccount) == FAILURE) {
1718     return;
1719     }
1720 youi 1.24
1721 aga 1.2 zAccount_t zacc(zaccount);
1722     result = zacc.getResult();
1723     if ( RES_OK == result ){
1724     result = updateAccount( (sessionid_t)sid, &zacc );
1725     }
1726 youi 1.24
1727     RETURN_LONG(result);
1728 aga 1.2 }
1729 aga 1.1
1730 aga 1.5 /** ?>散???????≪?????潟????id???荀с??緇?????<br>
1731 youi 1.24 int xnp_dump_uids( int xnp_session_id, array criteria, array uids );
1732     @param xnp_session_id XNP???祉???激?с??D
1733     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1734     @param uids uid??????????????
1735     @return 0 success
1736 aga 1.5 */
1737 youi 1.21 ZEND_FUNCTION(xnp_dump_uids)
1738 aga 1.2 {
1739     result_t result;
1740     long sid;
1741     zval *zcriteria;
1742     zval *zuids;
1743 youi 1.24
1744 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1745     &sid, &zcriteria, &zuids) == FAILURE) {
1746     return;
1747     }
1748 youi 1.24
1749 aga 1.2 zCriteria_t zcri(zcriteria);
1750     result = zcri.getResult();
1751     if ( RES_OK == result ){
1752     userid_t *puid;
1753     int uidLen;
1754     result = dumpUids( (sessionid_t)sid, &zcri, &puid, &uidLen );
1755     if ( RES_OK == result ){
1756     uidsToZval( puid, uidLen, &zuids );
1757 youi 1.19 freeUID( puid );
1758 aga 1.2 }
1759     }
1760 youi 1.24
1761     RETURN_LONG(result);
1762 aga 1.2 }
1763 aga 1.1
1764 youi 1.21 /** XNP???違???若?????違??緇???<br>
1765 youi 1.24 int xnp_get_group_count( int xnp_session_id );
1766     @param xnp_session_id XNP???祉???激?с??D
1767     @return ?違???若????/span>
1768 aga 1.5 */
1769 youi 1.21 ZEND_FUNCTION(xnp_get_group_count)
1770 aga 1.1 {
1771 aga 1.2 result_t result;
1772     long sid;
1773 youi 1.24
1774 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1775     &sid) == FAILURE) {
1776     return;
1777     }
1778 youi 1.24
1779 aga 1.2 int count = getGroupCount( (sessionid_t)sid );
1780 youi 1.24
1781     RETURN_LONG(count);
1782 aga 1.2 }
1783 aga 1.1
1784 aga 1.5 /** uid?ф??絎????????若?吟??絮????違???若???с?????ゆ?>散????眼?????違???若????id??緇???<br>
1785 youi 1.24 int xnp_get_group_by_uid( int xnp_session_id, int uid, array criteria, array gids );
1786     @param xnp_session_id XNP???祉???激?с??D
1787     @param user_id xoops_users.uid
1788     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1789     @param gids gid??????????????
1790     @return 0 success
1791 aga 1.5 */
1792 youi 1.21 ZEND_FUNCTION(xnp_get_groups_by_uid)
1793 aga 1.2 {
1794     result_t result;
1795     long sid, uid;
1796     zval *zcriteria;
1797     zval *zgids;
1798 youi 1.24
1799 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1800     &sid, &uid, &zcriteria, &zgids) == FAILURE) {
1801     return;
1802 aga 1.1 }
1803 youi 1.24
1804 aga 1.2 zCriteria_t zcri(zcriteria);
1805     result = zcri.getResult();
1806     if ( RES_OK == result ){
1807     groupid_t *pgids;
1808     int gidLen;
1809     result = getGroupsByUid( (sessionid_t)sid, (userid_t)uid, &zcri, &pgids, &gidLen );
1810     if ( RES_OK == result ){
1811     gidsToZval( pgids, gidLen, &zgids );
1812 youi 1.19 freeGID( pgids );
1813 aga 1.2 }
1814 aga 1.1 }
1815 youi 1.24
1816     RETURN_LONG(result);
1817 aga 1.2 }
1818    
1819    
1820 aga 1.5
1821     /** uid?ф??絎????????若?吟??gid?ф??絎??????違???若?????違???若??膊∞??????????????緇???<br>
1822 youi 1.24 int xnp_is_group_admin( int sid, int gid, int uid );
1823     @param xnp_session_id XNP???祉???激?с??D
1824     @param group_id XNP???違???若??ID
1825     @param user_id xoops_users.uid
1826     @return true: ?違???若??膊∞?????с??????
1827     @return false: ?違???若??膊∞?????с???????????????????若?с??????
1828 aga 1.5 */
1829 youi 1.21 ZEND_FUNCTION(xnp_is_group_admin)
1830 aga 1.2 {
1831     result_t result;
1832     long sid, gid, uid;
1833 youi 1.24
1834 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1835     &sid, &gid, &uid) == FAILURE) {
1836     return;
1837 aga 1.1 }
1838 youi 1.24
1839 aga 1.2 bool b = isGroupAdmin( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1840 youi 1.24
1841     RETURN_BOOL(b);
1842 aga 1.2 }
1843    
1844 aga 1.5 /** ?>散????眼?????違???若????id???荀с??緇?????<br>
1845 youi 1.24 int xnp_dump_gids( int sid, array criteria, array gids );
1846     @param xnp_session_id XNP???祉???激?с??D
1847     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1848     @param gids gid??????????????
1849     @return 0 success
1850 aga 1.5 */
1851 youi 1.21 ZEND_FUNCTION(xnp_dump_gids)
1852 aga 1.2 {
1853     result_t result;
1854     long sid;
1855     zval *zcriteria;
1856     zval *zgids;
1857 youi 1.24
1858 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1859     &sid, &zcriteria, &zgids) == FAILURE) {
1860     return;
1861     }
1862 youi 1.24
1863 aga 1.2 zCriteria_t zcri(zcriteria);
1864     result = zcri.getResult();
1865     if ( RES_OK == result ){
1866     groupid_t *pgid;
1867     int gidLen;
1868     result = dumpGids( (sessionid_t)sid, &zcri, &pgid, &gidLen );
1869     if ( RES_OK == result ){
1870     gidsToZval( pgid, gidLen, &zgids );
1871 youi 1.19 freeGID( pgid );
1872 aga 1.1 }
1873     }
1874 youi 1.24
1875     RETURN_LONG(result);
1876 aga 1.1 }
1877 aga 1.8
1878     /** gid?ф??絎??????違???若??????????с?????ゆ?>散????眼?????違???若??膊∞??????id???荀с??緇?????<br>
1879 youi 1.24 int xnp_dump_group_admins(int sid, int group_id, array criteria, array uids )
1880     @param sid XNP???祉???激?с??D
1881     @param group_id XNP???違???若??ID
1882     @param criteria ?>散
1883     @param uids uid???荀с??????????????
1884     @return 0 success
1885 aga 1.8 */
1886    
1887 youi 1.21 ZEND_FUNCTION(xnp_dump_group_admins)
1888 aga 1.8 {
1889     long sid, gid;
1890     zval *zcriteria;
1891     zval *zuids;
1892 youi 1.24
1893     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1894     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1895 aga 1.8 return;
1896     }
1897 youi 1.24
1898 aga 1.8 zCriteria_t zcri(zcriteria);
1899     result_t result = zcri.getResult();
1900     if ( result == RES_OK ){
1901     userid_t *uids;
1902     int uidsLen;
1903     result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
1904     if ( result == RES_OK ){
1905     uidsToZval( uids, uidsLen, &zuids );
1906 youi 1.19 freeUID( uids );
1907 aga 1.8 }
1908     }
1909     RETURN_LONG( result );
1910     }
1911    
1912 aga 1.11 /** ?違???若???????<?潟???若?????ゃ??????<br>
1913 youi 1.24 int xnp_delete_member(int sid, int group_id, int user_id )
1914     @param sid XNP???祉???激?с??D
1915     @param group_id XNP???違???若??ID
1916     @param user_id ???若??D
1917     @return 0 success
1918 aga 1.11 */
1919    
1920 youi 1.21 ZEND_FUNCTION(xnp_delete_member)
1921 aga 1.11 {
1922     long sid, gid, uid;
1923 youi 1.24
1924     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1925     &sid, &gid, &uid) == FAILURE) {
1926 aga 1.11 return;
1927     }
1928 youi 1.24
1929 aga 1.11 result_t result = deleteMember( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1930     RETURN_LONG( result );
1931     }
1932    
1933     /** ?違???若?????<?潟???若??菴遵??????<br>
1934 youi 1.24 int xnp_insert_member(int sid, int group_id, int user_id, bool admin )
1935     @param sid XNP???祉???激?с??D
1936     @param group_id XNP???違???若??ID
1937     @param user_id ???若??D
1938     @param admin ?違???若??膊∞????????true
1939     @return 0 success
1940 aga 1.11 */
1941    
1942 youi 1.21 ZEND_FUNCTION(xnp_insert_member)
1943 aga 1.11 {
1944     long sid, gid, uid;
1945     zend_bool admin;
1946 youi 1.24
1947     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllb",
1948     &sid, &gid, &uid, &admin) == FAILURE) {
1949 aga 1.11 return;
1950     }
1951 youi 1.24
1952 aga 1.11 result_t result = insertMember( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid, (bool)admin );
1953     RETURN_LONG( result );
1954     }
1955    
1956     /** gid?ф??絎??????違???若?????<?潟???若??id???荀с??緇???<br>
1957 youi 1.24 int xnp_get_members(int sid, int group_id, array criteria, array uids )
1958     @param sid XNP???祉???激?с??D
1959     @param group_id XNP???違???若??ID
1960     @param criteria ?>散
1961     @param uids uid???荀с??????????????
1962     @return 0 success
1963 aga 1.11 */
1964    
1965 youi 1.21 ZEND_FUNCTION(xnp_get_members)
1966 aga 1.11 {
1967     long sid, gid;
1968     zval *zcriteria;
1969     zval *zuids;
1970 youi 1.24
1971     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1972     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1973 aga 1.11 return;
1974     }
1975 youi 1.24
1976 aga 1.11 zCriteria_t zcri(zcriteria);
1977     result_t result = zcri.getResult();
1978     if ( result == RES_OK ){
1979     userid_t *uids;
1980     int uidsLen;
1981     result = getMembers( (sessionid_t)sid, (groupid_t)gid, &zcri, &uids, &uidsLen );
1982     if ( result == RES_OK ){
1983     uidsToZval( uids, uidsLen, &zuids );
1984 youi 1.19 freeUID( uids );
1985 aga 1.11 }
1986     }
1987     RETURN_LONG( result );
1988     }
1989 youi 1.7
1990     /** ?違???若?????宴??紊??眼??????<br>
1991 youi 1.24 int xnp_update_group(int sid, array group )
1992     @param sid XNP???祉???激?с??D
1993     @param group ?違???若?????宴???f?渇????
1994     @return 0 success
1995 youi 1.7 */
1996 youi 1.21 ZEND_FUNCTION(xnp_update_group)
1997 youi 1.7 {
1998     long sid;
1999     zval *zgroup;
2000 youi 1.24 group_t group;
2001    
2002     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
2003     &sid, &zgroup) == FAILURE) {
2004 youi 1.7 return;
2005     }
2006 youi 1.24
2007     zvalToGroup( zgroup, &group );
2008     result_t result = updateGroup( sid, &group );
2009     RETURN_LONG( result );
2010 aga 1.10 }
2011    
2012 youi 1.12 /** ?違???若?????宴??菴遵????????<br>
2013 youi 1.24 int xnp_insert_group( int sid, array group, int &gid )
2014     @param sid ?祉???激?с??D
2015     @param group ?違???若?????宴???f?渇????
2016     @param gid 絲上??????違???若??ID???吾??莨若???????<???潟??/span>
2017     @return RES_OK
2018     @return RES_DB_NOT_INITIALIZED
2019     @return RES_NO_SUCH_SESSION
2020     @return RES_DB_QUERY_ERROR
2021 youi 1.12 */
2022 youi 1.21 ZEND_FUNCTION(xnp_insert_group)
2023 youi 1.12 {
2024     long sid;
2025     zval *zgroup;
2026 youi 1.24 zval *zgid;
2027     group_t group;
2028     groupid_t gid;
2029    
2030     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
2031     &sid, &zgroup, &zgid ) == FAILURE) {
2032 youi 1.12 return;
2033     }
2034 youi 1.24
2035     zvalToGroup( zgroup, &group );
2036     result_t result = insertGroup( sid, &group, &gid );
2037     zgid -> type = IS_LONG;
2038     zgid -> value.lval = gid;
2039     RETURN_LONG( result );
2040 youi 1.12 }
2041    
2042    
2043     /** ?違???若?????宴?????ゃ??????<br>
2044 youi 1.24 int xnp_delete_group( int sid, int gid )
2045     @param sid XNP???祉???激?с??D
2046     @param gid ???ゃ???????違???若????D
2047     @return RES_OK
2048     @return RES_DB_QUERY_ERROR
2049     @return RES_NO_SUCH_SESSION
2050     @return RES_DB_NOT_INITIALIZED
2051 youi 1.12 */
2052 youi 1.21 ZEND_FUNCTION(xnp_delete_group)
2053 youi 1.12 {
2054     long sid;
2055     long gid;
2056 youi 1.24
2057     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2058     &sid, &gid) == FAILURE) {
2059 youi 1.12 return;
2060     }
2061 youi 1.24 RETURN_LONG( deleteGroup( sid, gid ) );
2062 youi 1.12 }
2063    
2064     /** ?違???若?????????????緇???<br>
2065 youi 1.24 int xnp_dump_group_admins( int sid, int gid, array criteria, array uids )
2066     @param sid XNP???祉???激?с??D
2067     @param gid XNP?違???若????D
2068     @param criteria uids???吾??莨若?????????純?若???>散鐚?膀??蚊????絎?
2069     @param uids 膊∞??????ID???吾??莨若??????
2070     @return RES_OK
2071     @return RES_DB_QUERY_ERROR
2072     @return RES_NO_SUCH_SESSION
2073     @return RES_DB_NOT_INITIALIZED
2074 youi 1.12 */
2075     /*
2076 youi 1.21 ZEND_FUNCTION(xnp_dump_group_admins)
2077 youi 1.12 {
2078     long sid;
2079     long gid;
2080     zval *zcriteria;
2081     zval *zuids;
2082 youi 1.24
2083     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
2084     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
2085 youi 1.12 return;
2086     }
2087     zCriteria_t zcri(zcriteria);
2088     result_t result = zcri.getResult();
2089     if ( RES_OK == result ){
2090 youi 1.24 userid_t* uids;
2091     int uidsLen;
2092     result_t result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
2093     if( result != RES_OK ) RETURN_LONG( result );
2094     uidsToZval( uids, uidsLen, &zuids );
2095     fprintf( stderr, "uidsLen=%d\n", uidsLen );
2096     for( int i = 0; i < uidsLen; i++ ){
2097     fprintf( stderr, "%d, \n", uids[ i ] );
2098     }
2099     freeUID( uids );
2100     RETURN_LONG( result );
2101     }
2102     RETURN_LONG( result );
2103 youi 1.12 }
2104     */
2105 aga 1.22
2106     /** ???????ゃ?潟???????鴻??緇???<br>
2107     * int xnp_get_all_indexes( int sid, array criteria, array indexes );
2108     * @param sid XNP???祉???激?с??D
2109     * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2110     * @return RES_OK
2111     */
2112     ZEND_FUNCTION(xnp_get_all_indexes)
2113     {
2114     long sid;
2115     zval *zcriteria;
2116     zval *zindexes;
2117 youi 1.24
2118     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
2119     &sid, &zcriteria, &zindexes) == FAILURE) {
2120 aga 1.22 return;
2121     }
2122     zCriteria_t zcri(zcriteria);
2123     result_t result = zcri.getResult();
2124     if ( RES_OK == result ){
2125     const index_t *indexes;
2126     int indexesLen;
2127     result = getAllIndexes( sid, &zcri, &indexes, &indexesLen );
2128     if ( RES_OK == result ){
2129     result = indexesToZval( indexes, indexesLen, zindexes );
2130     freeIndex( indexes );
2131     }
2132     }
2133     RETURN_LONG(result);
2134     }
2135    
2136     /** ?????ゃ?潟???????鴻??????????ゃ?潟???????鴻??緇???<br>
2137     * int xnp_get_indexes( int sid, int parentXID, array criteria, array indexes );
2138     * @param sid XNP???祉???激?с??D
2139     * @param parentXID 荀???ndexID
2140     * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2141     * @param indexes 腟?????????????????
2142     * @return RES_OK
2143     */
2144     ZEND_FUNCTION(xnp_get_indexes)
2145     {
2146     long sid;
2147     long parentXID;
2148     zval *zcriteria;
2149     zval *zindexes;
2150 youi 1.24
2151     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
2152     &sid, &parentXID, &zcriteria, &zindexes) == FAILURE) {
2153 aga 1.22 return;
2154     }
2155     zCriteria_t zcri(zcriteria);
2156     result_t result = zcri.getResult();
2157     if ( RES_OK == result ){
2158     const index_t *indexes;
2159     int indexesLen;
2160     result = getIndexes( sid, parentXID, &zcri, &indexes, &indexesLen );
2161     if ( RES_OK == result ){
2162     result = indexesToZval( indexes, indexesLen, zindexes );
2163     freeIndex( indexes );
2164     }
2165     }
2166     RETURN_LONG(result);
2167     }
2168    
2169    
2170     /** ?ゃ?潟???????鴻??篏???????<br>
2171     * int xnp_insert_index( int sid, array index, int &indexID );
2172     * @param sid XNP???祉???激?с??D
2173     * @param index 篏????????ゃ?潟????????/span>
2174     * @param indexID 篏??????????ゃ?潟???????鴻??D??????????紊???/span>
2175     * @return RES_OK
2176     */
2177     ZEND_FUNCTION(xnp_insert_index)
2178     {
2179     long sid;
2180     zval *zindex;
2181     zval *zIndexID;
2182 youi 1.24
2183     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
2184     &sid, &zindex, &zIndexID) == FAILURE) {
2185 aga 1.22 return;
2186     }
2187 youi 1.24
2188 aga 1.22 if (!PZVAL_IS_REF(zIndexID)) {
2189     zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
2190     RETURN_LONG(RES_PHP_NONREF);
2191     }
2192     zIndex_t index( zindex );
2193     indexid_t xid;
2194     result_t result = insertIndex( sid, &index, &xid );
2195     if ( RES_OK == result )
2196     ZVAL_LONG(zIndexID, (long)xid);
2197     RETURN_LONG(result);
2198     }
2199    
2200     /** ?ゃ?潟???????鴻???贋?違????<br>
2201     * int xnp_update_index( int sid, array index );
2202     * @param sid XNP???祉???激?с??D
2203     * @param index ?贋?違?????ゃ?潟????????/span>
2204     * @return RES_OK
2205     */
2206     ZEND_FUNCTION(xnp_update_index)
2207     {
2208     long sid;
2209     zval *zindex;
2210 youi 1.24
2211     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
2212     &sid, &zindex) == FAILURE) {
2213 aga 1.22 return;
2214     }
2215     zIndex_t index(zindex);
2216     result_t result = index.getResult();
2217     if ( RES_OK == result ){
2218     result = updateIndex( sid, &index );
2219     }
2220     RETURN_LONG(result);
2221     }
2222    
2223     /** ?ゃ?潟???????鴻?????ゃ????<br>
2224     * int xnp_delete_index( int sid, int indexID );
2225     * @param sid XNP???祉???激?с??D
2226     * @param indexID ???ゃ?????ゃ?潟????????/span>
2227     * @return RES_OK
2228     */
2229     ZEND_FUNCTION(xnp_delete_index)
2230     {
2231     long sid;
2232     long xid;
2233 youi 1.24
2234     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2235     &sid, &xid) == FAILURE) {
2236 aga 1.22 return;
2237     }
2238 youi 1.24
2239 aga 1.22 result_t result = deleteIndex( sid, xid );
2240     RETURN_LONG(result);
2241     }
2242    
2243    
2244     /** ?ゃ?潟???????鴻????緇?????<br>
2245     * int xnp_get_index( int sid, int indexID, array index );
2246     * @param sid XNP???祉???激?с??D
2247     * @param indexID ??緇??????ゃ?潟???????鴻??D
2248     * @param index ??緇?腟??????????????f?渇????
2249     * @return RES_OK
2250     */
2251     ZEND_FUNCTION(xnp_get_index)
2252     {
2253     long sid;
2254     long xid;
2255     zval *zindex;
2256 youi 1.24
2257     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
2258     &sid, &xid, &zindex) == FAILURE) {
2259 aga 1.22 return;
2260     }
2261 youi 1.24
2262 aga 1.22 const index_t *index;
2263     result_t result = getIndex( sid, xid, &index );
2264     if ( RES_OK == result ){
2265     result = indexToZval( index, zindex );
2266     freeIndex( index );
2267     }
2268     RETURN_LONG(result);
2269     }
2270    
2271    
2272    
2273     /** ?ゃ?潟???????鴻??茯??粋昭?水??純??????????茯帥?鴻??<br>
2274     * int xnp_is_index_readable( int sid, int indexID );
2275     * @param sid XNP???祉???激?с??D
2276     * @param indexID 絲乗院?ゃ?潟???????鴻??D
2277     * @return true false
2278     */
2279     ZEND_FUNCTION(xnp_is_index_readable)
2280     {
2281     long sid;
2282     long xid;
2283 youi 1.24
2284     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2285     &sid, &xid) == FAILURE) {
2286 aga 1.22 return;
2287     }
2288     RETURN_BOOL(isIndexReadable(sid,xid));
2289     }
2290    
2291    
2292     /** ?ゃ?潟???????鴻???吾??莨若?水??純??????????茯帥?鴻??<br>
2293     * int xnp_is_index_writable( int sid, int indexID );
2294     * @param sid XNP???祉???激?с??D
2295     * @param indexID 絲乗院?ゃ?潟???????鴻??D
2296     * @return true false
2297     */
2298     ZEND_FUNCTION(xnp_is_index_writable)
2299     {
2300     long sid;
2301     long xid;
2302 youi 1.24
2303     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2304     &sid, &xid) == FAILURE) {
2305 aga 1.22 return;
2306     }
2307     RETURN_BOOL(isIndexWritable(sid,xid));
2308     }
2309    
2310     /** ?ゃ?潟???????鴻????綺???ャ???帥????<br>
2311     * int xnp_swap_index_sort_number( int sid, int indexID1, int indexID2 );
2312     * @param sid XNP???祉???激?с??D
2313     * @param indexID1 絲乗院?ゃ?潟???????鴻??D
2314     * @param indexID2 絲乗院?ゃ?潟???????鴻??D
2315     * @return true false
2316     */
2317     ZEND_FUNCTION(xnp_swap_index_sort_number)
2318     {
2319     long sid;
2320     long xid1, xid2;
2321 youi 1.24
2322     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
2323     &sid, &xid1, &xid2) == FAILURE) {
2324 aga 1.22 return;
2325     }
2326 youi 1.24
2327 aga 1.22 result_t result = swapIndexSortNumber( sid, xid1, xid2 );
2328     RETURN_LONG(result);
2329     }
2330    
2331    
2332    
2333 youi 1.21 /** XNP??ession_id???綵??с???с????lt;br>
2334 youi 1.24 bool xnp_is_valid_session_id( int xnp_session_id)
2335     @return true ???鴻??NP??ession_id?с????<br>
2336     @return false ?≦?鴻??ession_id?障??????????/span>
2337 aga 1.10 */
2338 youi 1.21 ZEND_FUNCTION(xnp_is_valid_session_id)
2339 aga 1.10 {
2340     long sid;
2341     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &sid ) == FAILURE) {
2342     return;
2343     }
2344 youi 1.24
2345 aga 1.10 RETURN_BOOL(isValidSessionID((sessionid_t)sid));
2346 aga 1.9 }
2347    
2348     /** ?????惹??絖?????緇???<br>
2349 youi 1.24 string xnp_get_last_error_string()
2350     @return 0 success
2351 aga 1.9 */
2352 youi 1.21 ZEND_FUNCTION(xnp_get_last_error_string)
2353 aga 1.9 {
2354     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "" ) == FAILURE) {
2355     return;
2356     }
2357 youi 1.24
2358 aga 1.9 string str( getLastErrorString() );
2359     RETURN_STRING((char *)str.c_str(), 1);
2360 youi 1.7 }
2361    
2362 youi 1.24
2363     /**
2364     *
2365     * ?≪?ゃ?????吾???≪???祉?号┤???????с????????
2366     *
2367     * @refer itemop_t
2368     * @param sid ?祉???激?с??D
2369     * @param iid ???с?????莟<???????≪?ゃ??????D
2370     * @param op ?≪???祉?鴻??┏蕁?
2371     * @return true 罔???????
2372     * @return false 罔???????
2373     *
2374     */
2375     ZEND_FUNCTION(xnp_get_item_permission)
2376     {
2377 youi 1.27 long sid;
2378     itemid_t iid;
2379     long op;
2380     bool result = false;
2381    
2382     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
2383     &sid, &iid, &op) == FAILURE) {
2384     fprintf( stderr, "error occured " );
2385     return;
2386     }
2387     RETURN_BOOL( getItemPermission( (sessionid_t)sid, iid, op ) );
2388 youi 1.24 }
2389    
2390    
2391     /**
2392     *
2393     * ?ゃ?潟???????鴻?吾???≪???祉?号┤???????с????????
2394     *
2395     * @refer indexop_t
2396     * @param sid ?祉???激?с??D
2397     * @param xid ???с?????莟<???????ゃ?潟???????鴻??D
2398     * @param op ?≪???祉?鴻??┏蕁?
2399     * @return true 罔???????
2400     * @return false 罔???????
2401     *
2402     */
2403     ZEND_FUNCTION(xnp_get_index_permission)
2404     {
2405 youi 1.27 long sid;
2406     indexid_t xid;
2407     long op;
2408     bool result = false;
2409    
2410     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
2411     &sid, &xid, &op) == FAILURE) {
2412     fprintf( stderr, "error occured " );
2413     return;
2414     }
2415     RETURN_BOOL( getIndexPermission( (sessionid_t)sid, xid, op ) );
2416 youi 1.24 }
2417    
2418    
2419     /**
2420     *
2421     * ?≪?ゃ???????粋??倶????紊??眼????罔????????<??茯帥?鴻?障??鐚?/span>
2422     * @refer certify_t
2423     * @param sid ?祉???激?с??D
2424     * @param xid 紊??翫?莟<?≪?ゃ???????脂?蚊???????????ゃ?潟???????鴻??D
2425     * @param iid 紊??翫?莟<?≪?ゃ??????D
2426     * @param state ?違???鎀??眼???????粋??倶??
2427     * @return true 罔???????
2428     * @return false 罔???????
2429     *
2430     */
2431     ZEND_FUNCTION(xnp_get_certify_permission)
2432     {
2433 youi 1.27 long sid;
2434     itemid_t iid;
2435     indexid_t xid;
2436     certify_t state;
2437     bool result = false;
2438    
2439     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",
2440     &sid, &xid, &iid, &state) == FAILURE) {
2441     fprintf( stderr, "error occured " );
2442     return;
2443     }
2444     RETURN_BOOL( getCertifyPermission( (sessionid_t)sid, xid, iid, state ) );
2445 youi 1.24