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.29 - (hide annotations) (download) (as text)
Sat Jan 29 09:52:30 2005 UTC (19 years, 2 months ago) by youi
Branch: MAIN
Changes since 1.28: +2 -17 lines
File MIME type: text/x-c++src
未使用のローカル変数を削除した.

1 aga 1.1 /*
2 youi 1.29 $Revision: 1.28 $
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 youi 1.28 ZEND_FUNCTION(xnp_get_item_types );
123     ZEND_FUNCTION(xnp_get_index_id_by_item_id );
124 youi 1.26
125 aga 1.1 };
126     /* compiled function list so Zend knows what's in this module */
127 youi 1.21 zend_function_entry xnpalmod_functions[] =
128 aga 1.1 {
129 youi 1.24 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 youi 1.26 ZEND_FE(xnp_get_uncertified_link ,NULL)
211     ZEND_FE(xnp_get_private_item_id ,NULL)
212    
213 youi 1.28 ZEND_FE(xnp_get_item_types ,NULL)
214 youi 1.26
215 youi 1.28 ZEND_FE(xnp_get_index_id_by_item_id ,NULL)
216    
217 youi 1.24 {NULL, NULL, NULL}
218 aga 1.1 };
219    
220     /* compiled module information */
221 youi 1.21 zend_module_entry xnpalmod_module_entry =
222 aga 1.1 {
223 youi 1.24 STANDARD_MODULE_HEADER,
224     "Visiome Platform Abstract Layer",
225     xnpalmod_functions,
226     NULL,
227 youi 1.21 PHP_MSHUTDOWN(xnpalmod),
228 youi 1.24 NULL,
229     NULL,
230     NULL,
231     NO_VERSION_YET,
232     STANDARD_MODULE_PROPERTIES
233 aga 1.1 };
234    
235     /* implement standard "stub" routine to introduce ourselves to Zend */
236     #if COMPILE_DL_FIRST_MODULE
237     BEGIN_EXTERN_C()
238 youi 1.21 ZEND_GET_MODULE(xnpalmod)
239 aga 1.1 END_EXTERN_C()
240     #endif
241    
242 aga 1.16
243 aga 1.1 /* implement function that is meant to be made available to PHP */
244     ZEND_FUNCTION(first_module)
245     {
246 youi 1.24 long parameter;
247 aga 1.1 // if(ZEND_NUM_ARGS() != 2) WRONG_PARAM_COUNT;
248 youi 1.24 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &parameter) == FAILURE) {
249     return;
250     }
251 aga 1.1 parameter++;
252 youi 1.24 RETURN_LONG(parameter);
253 aga 1.1 }
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 aga 1.2 // 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 aga 1.16 /** zval*????criteria_t?????????????????????鴻??????紊掩??????getResult()!=RES_OK <br>
284 youi 1.24 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 aga 1.2 */
291     class zCriteria_t : public criteria {
292     private:
293     result_t result;
294 aga 1.16
295 aga 1.2 // 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 youi 1.24
301 aga 1.2 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 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
312     if ( strncasecmp( key, "name", keyLen ) == 0 && keyLen == 5 ){
313 aga 1.2 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 youi 1.24
324 aga 1.2 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 youi 1.24
331 aga 1.2 result = RES_OK;
332     }
333 youi 1.24
334 aga 1.2 // pz: array( array('column'=>'hoge','order'=>'1'), array('column'=>'huga','order'=>'2'), ...)
335     void setOrders( zval *pz ){
336     HashPosition pos;
337 youi 1.24
338 aga 1.2 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
339 youi 1.24
340 aga 1.2 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 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
349 aga 1.2 setOrder( *ppzTmp );
350     }
351     zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
352     }
353     result = RES_OK;
354     }
355 youi 1.24
356 aga 1.2 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 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
368 aga 1.2 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 aga 1.16
393     public:
394 aga 1.2 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 youi 1.24
399 aga 1.2 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 aga 1.16
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 youi 1.24 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 aga 1.14 }
427    
428 aga 1.16 /** ?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 youi 1.24 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 aga 1.14 }
443    
444 aga 1.16 /** ?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 youi 1.24 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 aga 1.14 }
459 aga 1.2
460 aga 1.16 /** zval*????account?????????????????????鴻?? <br>
461 youi 1.24 ????紊掩??????getResult()!=RES_OK <br>
462 aga 1.16 */
463 aga 1.2 class zAccount_t : public account {
464     private:
465     result_t result;
466     void initialize(zval *pz){
467 aga 1.14 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 aga 1.16 if ( hashGetString( ht, "division" , &p ) ) setDivision ( p );
505 aga 1.14 if ( hashGetString( ht, "tel" , &p ) ) setTel ( p );
506 aga 1.16 if ( hashGetString( ht, "company_name" , &p ) ) setCompanyName ( p );
507 aga 1.14 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 aga 1.22 if ( hashGetLong ( ht, "private_index_id " , &l ) ) setPrivateIndexID ( l );
514 aga 1.14
515     result = RES_OK;
516 aga 1.2 }
517 aga 1.16 public:
518 aga 1.2 zAccount_t() : account(){ result = RES_ERROR; }
519 youi 1.24
520     /** ?潟?潟?鴻????????/span>
521     @param pz array( 'uid'=>1, 'uname'=>'root', ... ); ??????就???f?渇???? */
522 aga 1.2 zAccount_t( zval *pz ) : account(){ initialize(pz); }
523     zAccount_t( zval **ppz ) : account() { initialize(*ppz); }
524     result_t getResult(){ return result; };
525     };
526    
527 aga 1.22 class zIndex_t : public index {
528     private:
529     result_t result;
530 youi 1.24
531 aga 1.22 void initialize(zval *pz){
532     HashTable *ht = Z_ARRVAL_P(pz);
533     long l;
534     char *p;
535     if ( hashGetLong ( ht, "item_id" , &l ) ) setItemID ( l );
536     if ( hashGetLong ( ht, "item_type_id" , &l ) ) setItemTypeID ( l );
537     if ( hashGetLong ( ht, "contributor_uid" , &l ) ) setContributorUID ( l );
538     if ( hashGetString( ht, "title" , &p ) ) setTitle ( p );
539     if ( hashGetString( ht, "keywords" , &p ) ) setKeywords ( p );
540     if ( hashGetString( ht, "description" , &p ) ) setDescription ( p );
541     if ( hashGetLong ( ht, "last_update_date" , &l ) ) setLastUpdateDate ( l );
542     if ( hashGetLong ( ht, "creation_date" , &l ) ) setCreationDate ( l );
543     if ( hashGetLong ( ht, "parent_index_id" , &l ) ) setParentIndexID ( l );
544     if ( hashGetLong ( ht, "owner_uid" , &l ) ) setOwnerUID ( l );
545     if ( hashGetLong ( ht, "owner_gid" , &l ) ) setOwnerGID ( l );
546     if ( hashGetLong ( ht, "open_level" , &l ) ) setOpenLevel ( l );
547     if ( hashGetLong ( ht, "sort_number" , &l ) ) setSortNumber ( l );
548    
549     result = RES_OK;
550     }
551     public:
552     zIndex_t() : index(){ result = RES_ERROR; }
553     zIndex_t( zval *pz ) : index(){ initialize(pz); }
554     zIndex_t( zval **ppz ) : index() { initialize(*ppz); }
555     result_t getResult(){ return result; };
556 youi 1.24
557 aga 1.22 void dump(){
558     }
559     };
560    
561 aga 1.16 /** zval*????(userid_t *puid,int uidLen)?????????????????????鴻?? <br>
562 youi 1.24 ????紊掩??????getResult()!=RES_OK <br>
563 aga 1.2 */
564     class zUIDs_t {
565     private:
566     result_t result;
567     userid_t *pUID;
568     int len;
569     public:
570     zUIDs_t(){
571     pUID = 0;
572     len = 0;
573     result = RES_ERROR;
574     }
575 youi 1.24
576     /** ?潟?潟?鴻????????/span>
577     @param pza array( '1', '3', '4', '6', ... ); ??????就?????? */
578 aga 1.2 zUIDs_t( zval *pza ){
579     pUID = 0;
580     len = 0;
581     result = RES_ERROR;
582 youi 1.24
583 aga 1.2 if ( Z_TYPE_P(pza) != IS_ARRAY ){
584     result = RES_ERROR;
585     }
586     else {
587     len = zend_hash_num_elements(Z_ARRVAL_P(pza));
588     if(len == 0) {
589     pUID = new userid_t[1];
590     result = RES_OK;
591     }
592     else {
593     /* php/ext/standard/string.c ? implode??????????????????
594     zend_hash_*???????ャ?<?潟???c????????????????鐚?
595     */
596     zval **tmp;
597     HashPosition pos;
598     int i = 0;
599     pUID = new userid_t[len];
600 youi 1.24
601 aga 1.2 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pza), &pos);
602     while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pza), (void **) &tmp, &pos) == SUCCESS ) {
603     SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html ????/span>
604     convert_to_long_ex(tmp);
605     if ( i < len )
606     pUID[i++] = Z_LVAL_PP(tmp);
607     zend_hash_move_forward_ex(Z_ARRVAL_P(pza), &pos);
608     }
609     len = i;
610     result = RES_OK;
611     }
612     }
613     }
614 youi 1.24
615 aga 1.2 ~zUIDs_t(){
616     if ( pUID ) delete[] pUID;
617     }
618     result_t getResult(){ return result; }
619     userid_t *getPUID(){ return pUID; }
620     int getLen(){ return len; }
621     void dump(){
622 youi 1.24 zend_printf( "dumping zUIDs...<br>\n" );
623 aga 1.2 zend_printf( "result=%d<br>\n", (int)result );
624     zend_printf( "len=%d<br>\n", len );
625     for ( int i = 0; i < len; i++ ){
626     zend_printf( "pUID[%d] = %d<br>\n", i, pUID[i] );
627     }
628     }
629     };
630    
631 youi 1.24 /** zval*????(itemid_t *piid,int iidLen)?????????????????????鴻?? <br>
632     ????紊掩??????getResult()!=RES_OK <br>
633     */
634     class zIIDs_t {
635     private:
636     result_t result;
637     itemid_t *pIID;
638     int len;
639     public:
640     zIIDs_t(){
641     pIID = 0;
642     len = 0;
643     result = RES_ERROR;
644     }
645    
646     /** ?潟?潟?鴻????????/span>
647     @param pza array( '1', '3', '4', '6', ... ); ??????就?????? */
648     zIIDs_t( zval *pza ){
649     pIID = 0;
650     len = 0;
651     result = RES_ERROR;
652    
653     if ( Z_TYPE_P(pza) != IS_ARRAY ){
654     result = RES_ERROR;
655     }
656     else {
657     len = zend_hash_num_elements(Z_ARRVAL_P(pza));
658     if(len == 0) {
659     pIID = new itemid_t[1];
660     result = RES_OK;
661     }
662     else {
663     /* php/ext/standard/string.c ? implode??????????????????
664     zend_hash_*???????ャ?<?潟???c????????????????鐚?
665     */
666     zval **tmp;
667     HashPosition pos;
668     int i = 0;
669     pIID = new itemid_t[len];
670    
671     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pza), &pos);
672     while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pza), (void **) &tmp, &pos) == SUCCESS ) {
673     SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html ????/span>
674     convert_to_long_ex(tmp);
675     if ( i < len )
676     pIID[i++] = Z_LVAL_PP(tmp);
677     zend_hash_move_forward_ex(Z_ARRVAL_P(pza), &pos);
678     }
679     len = i;
680     result = RES_OK;
681     }
682     }
683     }
684    
685     ~zIIDs_t(){
686     if ( pIID ) delete[] pIID;
687     }
688     result_t getResult(){ return result; }
689     itemid_t *getPIID(){ return pIID; }
690     int getLen(){ return len; }
691     void dump(){
692     zend_printf( "dumping zIIDs...<br>\n" );
693     zend_printf( "result=%d<br>\n", (int)result );
694     zend_printf( "len=%d<br>\n", len );
695     for ( int i = 0; i < len; i++ ){
696     zend_printf( "pIID[%d] = %d<br>\n", i, pIID[i] );
697     }
698     }
699     };
700    
701     /**
702     *
703     * amazonbook_t????絎鴻??PHP???????????????
704     * @param pAmazonbook 紊???????mazonbook_t*
705     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
706     * @return RES_OK
707     *
708     */
709     result_t amazonbookToZval( const amazonbook_t *pAmazonbook, zval *z )
710     {
711     zend_hash_clean( z -> value.ht );
712    
713     add_assoc_string( z, "title", ( char* )pAmazonbook -> getTitle( ), 1 );
714     add_assoc_string( z, "author", ( char* )pAmazonbook -> getAuthor( ), 1 );
715     add_assoc_string( z, "publisher", ( char* )pAmazonbook -> getPublisher( ), 1 );
716     add_assoc_long( z, "year_of_publication", pAmazonbook -> getYearOfPublication( ) );
717     add_assoc_string( z, "isbn", ( char* )pAmazonbook -> getISBN( ), 1 );
718     add_assoc_string( z, "url", ( char* )pAmazonbook -> getURL( ), 1 );
719    
720     return RES_OK;
721     }
722    
723     /**
724     *
725     * pubmed_t????絎鴻??PHP???????????????
726     * @param pPubmed 紊???????ubmed_t*
727     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
728     * @return RES_OK
729     *
730     */
731     result_t pubmedToZval( const pubmed_t *pPubmed, zval *z )
732     {
733     zend_hash_clean( z -> value.ht );
734    
735     add_assoc_long( z, "pmid", pPubmed -> getID( ) );
736     add_assoc_string( z, "title", ( char* )pPubmed -> getTitle( ), 1 );
737     add_assoc_string( z, "author", ( char* )pPubmed -> getAuthor( ), 1 );
738     add_assoc_string( z, "journal", ( char* )pPubmed -> getJournal( ), 1 );
739     add_assoc_long( z, "year_of_publication", pPubmed -> getYearOfPublication( ) );
740     add_assoc_long( z, "volume", pPubmed -> getVolume( ) );
741     add_assoc_long( z, "number", pPubmed -> getNumber( ) );
742     add_assoc_string( z, "page", ( char* )pPubmed -> getPage( ), 1 );
743     add_assoc_string( z, "abstract", ( char* )pPubmed -> getAbstract( ), 1 );
744    
745     return RES_OK;
746     }
747    
748     /**
749     *
750     * itemid_t????????PHP???????????????
751     * @param piid 紊???????temid_t??????
752     * @param len piid?????????激??
753     * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
754     * @return RES_OK
755     *
756     */
757 youi 1.25 result_t itemidsToZval( const itemid_t *piid, int len, zval **ppz )
758 youi 1.24 {
759     zend_hash_clean( Z_ARRVAL_PP(ppz) );
760    
761 youi 1.26 // add IDs
762     for ( int i = 0; i < len; i++ ){
763     add_next_index_long(*ppz, (long)(piid[i]) );
764     }
765    
766     return RES_OK;
767     }
768    
769     /**
770     *
771     * indexid_t????????PHP???????????????
772     * @param piid 紊???????ndexid_t??????
773     * @param len piid?????????激??
774     * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
775     * @return RES_OK
776     *
777     */
778     result_t indexidsToZval( const indexid_t *piid, int len, zval **ppz )
779     {
780     zend_hash_clean( Z_ARRVAL_PP(ppz) );
781    
782     // add IDs
783 youi 1.24 for ( int i = 0; i < len; i++ ){
784     add_next_index_long(*ppz, (long)(piid[i]) );
785     }
786    
787     return RES_OK;
788     }
789    
790 aga 1.8 /**
791 youi 1.24 *
792 aga 1.8 * uids_t????????PHP???????????????
793 youi 1.24 *
794 aga 1.16 * @param pUID 紊???????serid_t??????
795 aga 1.8 * @param len pUID?????????激??
796     * @param pz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
797     * @return RES_OK
798 youi 1.24 *
799 aga 1.8 */
800 aga 1.4 result_t uidsToZval( userid_t *pUID, int len, zval **ppz )
801     {
802 youi 1.24 zend_hash_clean( Z_ARRVAL_PP(ppz) );
803    
804 aga 1.2 // add UIDs
805     for ( int i = 0; i < len; i++ ){
806 aga 1.8 add_next_index_long(*ppz, (long)(pUID[i]) );
807 aga 1.2 }
808 youi 1.24
809 aga 1.2 return RES_OK;
810     }
811 youi 1.24
812 aga 1.16 /**
813     *
814     * groupid_t????????PHP???????????????
815     * @param pGID 紊???????roupid_t??????
816     * @param len pGID?????????激??
817     * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
818     * @return RES_OK
819     *
820     */
821 aga 1.4 result_t gidsToZval( groupid_t *pGID, int len, zval **ppz )
822     {
823 youi 1.24 zend_hash_clean( Z_ARRVAL_PP(ppz) );
824    
825 aga 1.2 // add GIDs
826     for ( int i = 0; i < len; i++ ){
827 aga 1.8 add_next_index_long(*ppz, (long)(pGID[i]) );
828 aga 1.2 }
829 youi 1.24
830     return RES_OK;
831     }
832    
833     /**
834     *
835     * changelog_t????絎鴻??PHP???????????????
836     * @param pChangelog 紊???????hangelog_t*
837     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
838     * @return RES_OK
839     *
840     */
841     result_t changelogToZval( const changelog_t *pChangelog, zval *z )
842     {
843     zend_hash_clean( z -> value.ht );
844    
845     add_assoc_long( z, "log_id", pChangelog -> getChangelogID( ) );
846     add_assoc_long( z, "item_id", pChangelog -> getItemID( ) );
847     add_assoc_long( z, "log_date", pChangelog -> getDate( ) );
848     add_assoc_string( z, "log", ( char* )pChangelog -> getLog( ), 1 );
849    
850     return RES_OK;
851     }
852    
853     /**
854     *
855     * item_t????絎鴻??PHP???????????????
856     * @param pItem 紊???????tem_t*
857     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
858     * @return RES_OK
859     *
860     */
861     result_t itemToZval( const item_t *pItem, zval *z )
862     {
863     zend_hash_clean( z -> value.ht );
864    
865     add_assoc_long( z, "item_id", pItem -> getItemID( ) );
866     add_assoc_long( z, "item_type_id", pItem -> getItemTypeID( ) );
867     add_assoc_long( z, "uid", pItem -> getContributorUID( ) );
868     add_assoc_string( z, "title", ( char* )pItem -> getTitle( ), 1 );
869     add_assoc_string( z, "keywords", ( char* )pItem -> getKeywords( ), 1 );
870     add_assoc_string( z, "description", ( char* )pItem -> getDescription( ), 1 );
871     add_assoc_string( z, "doi", ( char* )pItem -> getDOI( ), 1 );
872     add_assoc_long( z, "last_update_date", pItem -> getLastUpdateDate( ) );
873     add_assoc_long( z, "creation_date", pItem -> getCreationDate( ) );
874    
875     return RES_OK;
876     }
877    
878    
879     result_t itemsToZval( const item_t *pItems, int itemsLen, zval *z )
880     {
881     zend_hash_clean( z -> value.ht );
882     for( int i = 0; i < itemsLen; i++ ){
883     zval *new_array;
884     MAKE_STD_ZVAL(new_array);
885     if(array_init(new_array) != SUCCESS){
886     return RES_ERROR;
887     }
888     add_index_zval( z, i, new_array );
889     itemToZval( &pItems[ i ], new_array );
890     }
891 aga 1.2 return RES_OK;
892     }
893    
894 youi 1.24 /**
895     *
896     * PHP???f?渇????????絎鴻??group_t?????????
897     *
898     * @param z 紊????????f?渇????
899     * @param pGroup 紊???腟??????吾??莨若???違???若??
900     * @return RES_OK
901     *
902     */
903     result_t zvalToItem( zval *z, item_t* pItem )
904     {
905     zval **tmp;
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     char* key = 0;
1118    
1119     key = "gid";
1120     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1121     convert_to_long_ex( tmp ) ;
1122     pGroup -> setGID( (*tmp) -> value.lval );
1123     }
1124     key = "gname";
1125     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1126     convert_to_string_ex( tmp ) ;
1127     pGroup -> setGname( (*tmp) -> value.str.val );
1128     }
1129     key = "gdesc";
1130     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1131     convert_to_string_ex( tmp ) ;
1132     pGroup -> setDesc( (*tmp) -> value.str.val );
1133     }
1134     key = "group_index_id";
1135     if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
1136     convert_to_long_ex( tmp ) ;
1137     pGroup -> setGroupIndexID( (*tmp) -> value.lval );
1138     }
1139 youi 1.7 return RES_OK;
1140     }
1141    
1142 aga 1.16 /**
1143 youi 1.24 *
1144 aga 1.16 * session_t????絎鴻??PHP???f?渇?????????????
1145 youi 1.24 *
1146 aga 1.16 * @param pSession 紊???????ession_t
1147     * @param z 紊???腟??????吾??莨若???f?渇????(??????羝??帥?с????????
1148     * @return RES_OK
1149 youi 1.24 *
1150 aga 1.16 */
1151     result_t sessionToZval( const session_t *pSession, zval *z )
1152     {
1153     string sessionID(unsignedIntToString(pSession->getSessionID()));
1154     add_assoc_string(z, "session_id", (char *)sessionID.c_str(), 1);
1155 youi 1.24
1156 aga 1.16 string date(unsignedIntToString((unsigned int)pSession->getDate()));
1157     add_assoc_string(z, "date", (char *)date.c_str(), 1);
1158 youi 1.24
1159 aga 1.20 string userID(unsignedIntToString((unsigned int)pSession->getUID()));
1160 aga 1.16 add_assoc_string(z, "user_id", (char *)userID.c_str(), 1);
1161 youi 1.24
1162 aga 1.16 return RES_OK;
1163     }
1164    
1165 aga 1.22 /**
1166     *
1167     * index_t????絎鴻??PHP???????????????
1168     * @param pIndex 紊???????ndex_t*
1169     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
1170     * @return RES_OK
1171     *
1172     */
1173     result_t indexToZval( const index_t *pIndex, zval *z )
1174     {
1175 youi 1.24 zend_hash_clean( z -> value.ht );
1176    
1177     add_assoc_long( z, "item_id", pIndex -> getItemID( ) );
1178     add_assoc_long( z, "item_type_id", pIndex -> getItemTypeID( ) );
1179     add_assoc_long( z, "contributor_uid", pIndex -> getContributorUID( ) );
1180     add_assoc_string( z, "title", ( char* )pIndex -> getTitle( ), 1 );
1181     add_assoc_string( z, "keywords", ( char* )pIndex -> getKeywords( ), 1 );
1182     add_assoc_string( z, "description", ( char* )pIndex -> getDescription( ), 1 );
1183     add_assoc_long( z, "last_update_date", pIndex -> getLastUpdateDate( ) );
1184     add_assoc_long( z, "creation_date", pIndex-> getCreationDate( ) );
1185     add_assoc_long( z, "parent_index_id", pIndex -> getParentIndexID( ) );
1186     add_assoc_long( z, "owner_uid", pIndex -> getOwnerUID( ) );
1187     add_assoc_long( z, "owner_gid", pIndex -> getOwnerGID( ) );
1188     add_assoc_long( z, "open_level", pIndex -> getOpenLevel( ) );
1189     add_assoc_long( z, "sort_number", pIndex -> getSortNumber( ) );
1190 aga 1.22 return RES_OK;
1191     }
1192    
1193     result_t indexesToZval( const index_t *pIndexes, int indexesLen, zval *z )
1194     {
1195 youi 1.24 zend_hash_clean( z -> value.ht );
1196     for( int i = 0; i < indexesLen; i++ ){
1197     zval *new_array;
1198     MAKE_STD_ZVAL(new_array);
1199     if(array_init(new_array) != SUCCESS){
1200     return RES_ERROR;
1201     }
1202     add_index_zval( z, i, new_array );
1203     indexToZval( &pIndexes[ i ], new_array );
1204     }
1205 aga 1.22 return RES_OK;
1206     }
1207    
1208    
1209 youi 1.7
1210 aga 1.16
1211     /** ??絎??????違???若???????宴??緇???<br>
1212 youi 1.24 int xnp_get_group( int sid, int gid, array group );
1213     @param sid XNP???祉???激?с??D
1214     @param gid XNP ? group_id
1215     @param group 腟?????????????????
1216     @return 0 success <br>
1217 aga 1.16 */
1218 youi 1.21 ZEND_FUNCTION(xnp_get_group)
1219 aga 1.4 {
1220 youi 1.6 long sid, gid;
1221     zval *zgroup;
1222 youi 1.24
1223 youi 1.6 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
1224 youi 1.24 &sid, &gid, &zgroup) == FAILURE) {
1225 youi 1.6 return;
1226     }
1227 youi 1.24
1228 youi 1.6 const group_t *pgroup;
1229     result_t result = getGroup( (sessionid_t)sid, (groupid_t)gid, &pgroup );
1230     if ( RES_OK == result ){
1231 youi 1.7 groupToZval( pgroup, zgroup );
1232 youi 1.19 freeGroup( pgroup );
1233 youi 1.6 }
1234 youi 1.24
1235     RETURN_LONG(result);
1236 youi 1.6 }
1237    
1238 aga 1.2
1239 aga 1.16 /** ??絎??????違???若??(茲????????宴??緇???<br>
1240 youi 1.24 xnp_get_groups( int sid, array gids, array criteria, array groups );
1241     @param sid XNP???祉???激?с??D
1242     @param gids XNP ? group_id ??????
1243     @param criteria ?>散
1244     @param groups 腟???????????????????????
1245     @return 0 success <br>
1246 aga 1.16 */
1247 youi 1.21 ZEND_FUNCTION(xnp_get_groups)
1248 youi 1.6 {
1249     result_t result;
1250 youi 1.29 long sid;
1251 youi 1.6 zval *zcriteria;
1252     zval *zgids;
1253     zval *zgroups;
1254 youi 1.24 zval **ppzTmp = 0;
1255     HashPosition pos;
1256     int res2;
1257     int gidsLen;
1258     const group_t* groups;
1259     int groupsLen;
1260    
1261 youi 1.6 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
1262 youi 1.24 &sid, &zgids, &zcriteria, &zgroups) == FAILURE) {
1263 youi 1.6 return;
1264     }
1265 youi 1.24
1266     //gids???違???若??ID???潟???若????
1267     gidsLen = zend_hash_num_elements(Z_ARRVAL_P(zgids));
1268     groupid_t *gids = new groupid_t[ gidsLen ];
1269     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zgids), &pos);
1270     for( int i = 0; i < gidsLen; i++ ){
1271     if( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(zgids), (void **)&ppzTmp, &pos)) == SUCCESS ){
1272     SEPARATE_ZVAL(ppzTmp);
1273     convert_to_long_ex(ppzTmp);
1274     gids[ i ] = Z_LVAL_PP(ppzTmp);
1275     }
1276     zend_hash_move_forward_ex(Z_ARRVAL_P(zgids), &pos);
1277     }
1278    
1279 youi 1.6 zCriteria_t zcri(zcriteria);
1280     result = zcri.getResult();
1281     if ( RES_OK == result ){
1282 youi 1.24 result = getGroups( (sessionid_t)sid, gids, gidsLen, &zcri, &groups, &groupsLen );
1283     if ( RES_OK == result ){
1284     groupsToZval( groups, groupsLen, zgroups );
1285     delete[] gids;
1286     freeGroup( groups );
1287     }
1288     }
1289     RETURN_LONG(result);
1290 youi 1.6 }
1291    
1292    
1293 aga 1.16 /** ??絎????????若?吟???≪?????若?帥??????????茯帥?鴻??<br>
1294 youi 1.24 int xnp_is_moderator(int sid, int uid)
1295     @param sid XNP???祉???激?с??D
1296     @param uid xoops ? uid (xoops_users.uid)
1297     @return true ?≪?????若?帥?с???? <br>
1298 aga 1.16 */
1299 youi 1.21 ZEND_FUNCTION(xnp_is_moderator)
1300 youi 1.6 {
1301 youi 1.21 long xnpSessionID;
1302 youi 1.6 userid_t uid;
1303 youi 1.24
1304     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
1305     &xnpSessionID, &uid) == FAILURE) {
1306 youi 1.6 return;
1307     }
1308 youi 1.24
1309 youi 1.21 bool result = isModerator( (sessionid_t)xnpSessionID, uid );
1310 youi 1.24 RETURN_BOOL(result)
1311 youi 1.6 }
1312    
1313 aga 1.16 /** ???若?九??????uid??茯帥?鴻??<br>
1314 youi 1.24 int xnp_get_uid(string uname,int &uid)
1315     @param sid XNP???祉???激?с??D
1316     @param uname xoops ? uname (xoops_users.uname)
1317     @param uid xoops ? uid (xoops_users.uid) ??????????紊???/span>
1318     @return 0 success
1319 aga 1.16 */
1320 youi 1.21 ZEND_FUNCTION(xnp_get_uid)
1321 youi 1.6 {
1322     char *uname;
1323     int unameLen;
1324 aga 1.14 zval *zuid;
1325 youi 1.6 userid_t uid;
1326 youi 1.24
1327     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
1328 aga 1.14 &uname, &unameLen, &zuid) == FAILURE) {
1329 youi 1.6 return;
1330     }
1331 youi 1.24
1332 aga 1.14 if (!PZVAL_IS_REF(zuid)) {
1333     zend_error(E_WARNING, "2nd parameter wasn't passed by reference");
1334     RETURN_LONG(RES_PHP_NONREF);
1335     }
1336 youi 1.24
1337 youi 1.6 string strUname( uname, unameLen );
1338     result_t result = getUid( strUname.c_str(), &uid );
1339 aga 1.14 ZVAL_LONG(zuid, (long)uid);
1340     RETURN_LONG((long)result);
1341 aga 1.2 }
1342    
1343 youi 1.21 ZEND_FUNCTION(xnp_test_criteria)
1344 aga 1.2 {
1345     zval *z;
1346 youi 1.24
1347     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
1348 aga 1.2 &z) == FAILURE) {
1349     return;
1350     }
1351     zend_printf("zend_printf...<br>\n");
1352     zCriteria_t zcri(z);
1353     zcri.dump();
1354     RETURN_FALSE
1355     }
1356    
1357 youi 1.21 ZEND_FUNCTION(xnp_test_uids)
1358 aga 1.2 {
1359     zval *z;
1360 youi 1.24
1361     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
1362 aga 1.2 &z) == FAILURE) {
1363     return;
1364     }
1365     zend_printf("zend_printf...<br>\n");
1366     zUIDs_t zuids(z);
1367     zuids.dump();
1368     RETURN_FALSE
1369     }
1370    
1371    
1372    
1373 aga 1.4 /** DB??・膓????????≪??・膓?筝???・膓???????????????<br>
1374 youi 1.24 int initialize_db( string host[, string user[, string password[, string dbname[, string prefix]]]] );
1375     @param host ?ョ????????ユ????ULL
1376     @param user DB?ョ????????若?九???????ユ????ULL
1377     @param password DB?ョ????????鴻???若???????ユ????ULL
1378     @param dbname DB?ョ?????B???????ユ????quot;"
1379     @param prefix XOOPS DB ??refix??
1380     @return 0 success <br>
1381 aga 1.1 */
1382 youi 1.21 ZEND_FUNCTION(xnp_initialize_db)
1383 aga 1.1 {
1384     zval **parameters[5];
1385     char *host;
1386     char *user;
1387 aga 1.2 char *password;
1388     char *dbname;
1389     char *prefix;
1390 aga 1.1
1391     /* get the number of arguments */
1392     int argNum = ZEND_NUM_ARGS();
1393     if (argNum > 5)
1394     WRONG_PARAM_COUNT;
1395    
1396     /* argument count is correct, now retrieve arguments */
1397     if(zend_get_parameters_array_ex(argNum, parameters) != SUCCESS)
1398     WRONG_PARAM_COUNT;
1399    
1400 aga 1.2 if (argNum < 1) host = NULL;
1401 aga 1.1 else host = getZvalString( parameters[0] );
1402 youi 1.24
1403 aga 1.1 if (argNum < 2) user = NULL;
1404     else user = getZvalString( parameters[1] );
1405 youi 1.24
1406 aga 1.2 if (argNum < 3) password = NULL;
1407     else password = getZvalString( parameters[2] );
1408 youi 1.24
1409 aga 1.2 if (argNum < 4) dbname = "";
1410     else dbname = getZvalString( parameters[3] );
1411 youi 1.24
1412 aga 1.2 if (argNum < 5) prefix = "";
1413     else prefix = getZvalString( parameters[4] );
1414 youi 1.24
1415 aga 1.2 result_t result = initializeDB( host, user, password, dbname, prefix );
1416 youi 1.24
1417 aga 1.2 RETURN_LONG(result);
1418 aga 1.1 }
1419    
1420 aga 1.4 /** ???違?ゃ?潟??????<br>
1421 youi 1.24 int xnp_login_user(string uname, string password, int &session_id)
1422     @param uname ???若?九??(xoops_users.uname)
1423     @param password ???鴻???若??(md5(password)=xoops_users.pass)
1424     @return 0 success
1425 aga 1.4 */
1426 youi 1.21 ZEND_FUNCTION(xnp_login_user)
1427 aga 1.1 {
1428     char *uname;
1429     int unameLen;
1430     char *passwd;
1431     int passwdLen;
1432 youi 1.21 zval *zXNPSessionID;
1433 youi 1.24
1434     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssz",
1435 youi 1.21 &uname, &unameLen, &passwd, &passwdLen, &zXNPSessionID) == FAILURE) {
1436 aga 1.1 return;
1437     }
1438 youi 1.24
1439 youi 1.21 if (!PZVAL_IS_REF(zXNPSessionID)) {
1440 aga 1.14 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
1441     RETURN_LONG(RES_PHP_NONREF);
1442     }
1443 youi 1.24
1444 youi 1.21 sessionid_t xnpSessionID;
1445     result_t result = loginUser( uname, passwd, &xnpSessionID );
1446 aga 1.14 if ( result == RES_OK )
1447 youi 1.21 ZVAL_LONG(zXNPSessionID, (long)xnpSessionID);
1448 aga 1.14 RETURN_LONG((long)result);
1449 aga 1.1 }
1450    
1451 aga 1.4 /** ???違?≪??????????<br>
1452 youi 1.24 void xnp_logout_user(int xnp_session_id)
1453     @param xnp_session_id XNP???祉???激?с??D
1454     @return ????
1455 aga 1.4 */
1456 youi 1.21 ZEND_FUNCTION(xnp_logout_user)
1457 aga 1.1 {
1458 youi 1.21 long xnpSessionID;
1459 youi 1.24
1460 youi 1.21 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &xnpSessionID) == FAILURE) {
1461 aga 1.1 return;
1462     }
1463 youi 1.21 logoutUser( (sessionid_t)xnpSessionID );
1464 youi 1.24
1465     RETURN_NULL();
1466 aga 1.1 }
1467    
1468 youi 1.21 /** XNP???祉???激?с??D 篏???<br>
1469 youi 1.24 int xnp_create_session( string xoops_sess_id, int uid, int &session )
1470     @param xoops_sess_id xoops???祉???激?с??D
1471     @param uid xoops ? uid (xoops_users.uid)
1472     @param session 篏???????XNP??ession??????????紊???/span>
1473     @return 0 ????
1474 aga 1.4 */
1475 youi 1.21 ZEND_FUNCTION(xnp_create_session)
1476 aga 1.2 {
1477     char *xoopsSessionID;
1478     int xoopsSessionIDLen;
1479 aga 1.5 long uid;
1480 youi 1.21 zval *zXNPSessionID;
1481 youi 1.24
1482 aga 1.14 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "slz",
1483 youi 1.21 &xoopsSessionID, &xoopsSessionIDLen, &uid, &zXNPSessionID) == FAILURE) {
1484 aga 1.2 return;
1485     }
1486 youi 1.24
1487 youi 1.21 if (!PZVAL_IS_REF(zXNPSessionID)) {
1488 aga 1.14 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
1489     RETURN_LONG(RES_PHP_NONREF);
1490     }
1491 youi 1.24
1492 youi 1.21 sessionid_t xnpSessionID = 0;
1493     result_t result = createSession( xoopsSessionID, (userid_t)uid, &xnpSessionID );
1494 aga 1.14 if ( result == RES_OK )
1495 youi 1.21 ZVAL_LONG(zXNPSessionID, (long)xnpSessionID);
1496 aga 1.14 RETURN_LONG((long)result);
1497 aga 1.4 }
1498    
1499 youi 1.21 /** XNP ? session ???膣井???宴??緇???<br>
1500 youi 1.24 int xnp_get_session( int xnp_session_id, array session_info )
1501     @param xnp_session_id XNP???祉???激?с??D
1502     @param session_info 腟?????????????????
1503     @return 0 success
1504 aga 1.4 */
1505 youi 1.21 ZEND_FUNCTION(xnp_get_session)
1506 aga 1.4 {
1507 youi 1.21 long xnpSessionID;
1508 aga 1.4 zval *sessionInfo;
1509     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1510 youi 1.21 &xnpSessionID, &sessionInfo) == FAILURE) {
1511 aga 1.4 return;
1512     }
1513     const session_t *session = 0;
1514 youi 1.21 result_t result = getSession( (sessionid_t)xnpSessionID, &session );
1515 aga 1.4 if ( result == RES_OK ){
1516     sessionToZval( session, sessionInfo );
1517 youi 1.19 freeSession( session );
1518 aga 1.4 }
1519 youi 1.24
1520 aga 1.4 RETURN_LONG((long)result);
1521 aga 1.2 }
1522 aga 1.1
1523 aga 1.16 /** ???若?吟??ctivate?倶??????緇?????<br>
1524 youi 1.24 bool xnp_is_activated( int xnp_session_id, int user_id )
1525     @param xnp_session_id XNP???祉???激?с??D
1526     @param user_id xoops_users.uid
1527     @return 0 success
1528 aga 1.5 */
1529 youi 1.21 ZEND_FUNCTION(xnp_is_activated)
1530 aga 1.2 {
1531     long sid, uid;
1532 youi 1.24
1533 aga 1.5 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &sid, &uid) == FAILURE) {
1534 aga 1.2 return;
1535     }
1536 youi 1.24
1537 aga 1.2 bool result = isActivated( (sessionid_t)sid, (userid_t)uid );
1538 youi 1.24
1539     RETURN_BOOL(result);
1540 aga 1.2 }
1541 aga 1.1
1542 youi 1.17 /** activate??????<br>
1543 youi 1.24 bool xnp_activate( int xnp_session_id, int user_id, bool activated )
1544     @param xnp_session_id xnp ? session id
1545     @param user_id xoops_users.uid
1546     @param activated true:activate, false:inactivate
1547     @return 0 success
1548 aga 1.5 */
1549 youi 1.21 ZEND_FUNCTION(xnp_activate)
1550 aga 1.2 {
1551     long sid, uid;
1552     bool activated;
1553 youi 1.24
1554 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llb",
1555     &sid, &uid, &activated) == FAILURE) {
1556     return;
1557     }
1558 youi 1.24
1559 aga 1.2 result_t result = activate( (sessionid_t)sid, (userid_t)uid, activated );
1560 youi 1.24
1561     RETURN_LONG(result);
1562 aga 1.2 }
1563 aga 1.1
1564 youi 1.21 /** XNP???≪?????潟???違??緇?????<br>
1565 youi 1.24 int xnp_get_account_count( int xnp_session_id )
1566     @param xnp_session_id XNP???祉???激?с??D
1567     @return 0 success
1568 aga 1.5 */
1569 youi 1.21 ZEND_FUNCTION(xnp_get_account_count)
1570 aga 1.2 {
1571     long sid;
1572 youi 1.24
1573 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1574     &sid) == FAILURE) {
1575     return;
1576     }
1577 youi 1.24
1578 aga 1.2 long count = getAccountCount( (sessionid_t)sid );
1579 youi 1.24 RETURN_LONG(count);
1580 aga 1.2 }
1581 aga 1.1
1582 aga 1.5 /** ?≪?????潟???????ゃ??????<br>
1583 youi 1.24 bool xnp_delete_account( int xnp_session_id, int user_id )
1584     @param xnp_session_id XNP???祉???激?с??D
1585     @param user_id xoops_users.uid
1586     @return 0 success
1587 aga 1.5 */
1588 youi 1.21 ZEND_FUNCTION(xnp_delete_account)
1589 aga 1.2 {
1590     long sid, uid;
1591 youi 1.24
1592 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
1593     &sid, &uid) == FAILURE) {
1594     return;
1595     }
1596 youi 1.24
1597 aga 1.2 result_t result = deleteAccount( (sessionid_t)sid, (userid_t)uid );
1598 youi 1.24
1599     RETURN_LONG(result);
1600 aga 1.2 }
1601 aga 1.1
1602 aga 1.5 /** ?≪?????潟?????宴??緇?????<br>
1603 youi 1.24 int xnp_get_account( int xnp_session_id, int user_id, array account_info )
1604     @param xnp_session_id XNP???祉???激?с??D
1605     @param user_id xoops_users.uid
1606     @param account_info ?≪?????潟?????宴???????????f?渇????
1607     @return 0 success
1608 aga 1.5 */
1609 youi 1.21 ZEND_FUNCTION(xnp_get_account)
1610 aga 1.2 {
1611     long sid, uid;
1612     zval *zaccount;
1613 youi 1.24
1614 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
1615     &sid, &uid, &zaccount) == FAILURE) {
1616 youi 1.24 fprintf( stderr, "error occured " );
1617 aga 1.2 return;
1618     }
1619 youi 1.24
1620 aga 1.2 const account_t *paccount;
1621     result_t result = getAccount( (sessionid_t)sid, (userid_t)uid, &paccount );
1622     if ( RES_OK == result ){
1623     accountToZval( paccount, zaccount );
1624 youi 1.19 freeAccount( paccount );
1625 aga 1.2 }
1626 youi 1.24
1627     RETURN_LONG(result);
1628 aga 1.2 }
1629 aga 1.1
1630 aga 1.5 /** ?>散????眼?????≪?????潟???????宴??緇?????<br>
1631 youi 1.24 int xnp_get_accoutns( int sid, array uids, array criteria, array accounts );
1632     @param xnp_session_id XNP???祉???激?с??D
1633     @param user_id xoops_users.uid
1634     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1635     @param account_info ?≪?????潟?????宴???????????f?渇????
1636     @return 0 success
1637 aga 1.5 */
1638 youi 1.21 ZEND_FUNCTION(xnp_get_accounts)
1639 aga 1.2 {
1640     result_t result;
1641     long sid;
1642     zval *zuids;
1643     zval *zcriteria;
1644     zval *zaccount;
1645 youi 1.24
1646 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
1647     &sid, &zuids, &zcriteria, &zaccount) == FAILURE) {
1648     return;
1649     }
1650 youi 1.24
1651 aga 1.2 zCriteria_t zcri(zcriteria);
1652     result = zcri.getResult();
1653     if ( RES_OK == result ){
1654     zUIDs_t zUIDs(zuids);
1655     result = zUIDs.getResult();
1656     if ( RES_OK == result ){
1657     const account_t *paccounts;
1658     int accountLen;
1659 youi 1.24 result = getAccounts( (sessionid_t)sid,
1660 aga 1.2 zUIDs.getPUID(), zUIDs.getLen(),
1661     &zcri, &paccounts, &accountLen );
1662     if ( RES_OK == result ){
1663     accountsToZval( paccounts, accountLen, zaccount );
1664 youi 1.19 freeAccount( paccounts );
1665 aga 1.2 }
1666     }
1667     }
1668 youi 1.24
1669     RETURN_LONG(result);
1670 aga 1.2 }
1671 aga 1.1
1672 youi 1.17 /** ?≪?????潟?????宴??荐??蚊??????<br>
1673 youi 1.24 int xnp_insert_account( int sid, array account_info, int &user_id );
1674     @param xnp_session_id xnp ? session id
1675     @param account_info 荐??蚊???????≪?????潟????????/span>
1676     @param user_id ???若??D(xoops_users.uid)???吾??莨若???????<???潟??/span>
1677     @return 0 success
1678 aga 1.5 */
1679 youi 1.21 ZEND_FUNCTION(xnp_insert_account)
1680 aga 1.2 {
1681     result_t result;
1682     long sid;
1683     zval *zaccount;
1684 youi 1.17 zval *zuid;
1685 youi 1.24 userid_t uid;
1686    
1687 youi 1.17 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
1688     &sid, &zaccount, &zuid) == FAILURE) {
1689 aga 1.2 return;
1690     }
1691 youi 1.24
1692 aga 1.2 zAccount_t zacc(zaccount);
1693     result = zacc.getResult();
1694     if ( RES_OK == result ){
1695 youi 1.17 result = insertAccount( (sessionid_t)sid, &zacc, &uid );
1696 aga 1.2 }
1697 youi 1.24 zuid -> type = IS_LONG;
1698     zuid -> value.lval = uid;
1699     RETURN_LONG(result);
1700 aga 1.2 }
1701 aga 1.1
1702 aga 1.5 /** ?≪?????潟?????宴???贋?違??????<br>
1703 youi 1.24 int xnp_update_account( int sid, array account );
1704     @param xnp_session_id XNP???祉???激?с??D
1705     @param account_info ?吾??莨若???鴻???≪?????潟?????宴??茵????f?渇????
1706     @return 0 success
1707 aga 1.5 */
1708 youi 1.21 ZEND_FUNCTION(xnp_update_account)
1709 aga 1.2 {
1710     result_t result;
1711     long sid;
1712     zval *zaccount;
1713 youi 1.24
1714 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1715     &sid, &zaccount) == FAILURE) {
1716     return;
1717     }
1718 youi 1.24
1719 aga 1.2 zAccount_t zacc(zaccount);
1720     result = zacc.getResult();
1721     if ( RES_OK == result ){
1722     result = updateAccount( (sessionid_t)sid, &zacc );
1723     }
1724 youi 1.24
1725     RETURN_LONG(result);
1726 aga 1.2 }
1727 aga 1.1
1728 aga 1.5 /** ?>散???????≪?????潟????id???荀с??緇?????<br>
1729 youi 1.24 int xnp_dump_uids( int xnp_session_id, array criteria, array uids );
1730     @param xnp_session_id XNP???祉???激?с??D
1731     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1732     @param uids uid??????????????
1733     @return 0 success
1734 aga 1.5 */
1735 youi 1.21 ZEND_FUNCTION(xnp_dump_uids)
1736 aga 1.2 {
1737     result_t result;
1738     long sid;
1739     zval *zcriteria;
1740     zval *zuids;
1741 youi 1.24
1742 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1743     &sid, &zcriteria, &zuids) == FAILURE) {
1744     return;
1745     }
1746 youi 1.24
1747 aga 1.2 zCriteria_t zcri(zcriteria);
1748     result = zcri.getResult();
1749     if ( RES_OK == result ){
1750     userid_t *puid;
1751     int uidLen;
1752     result = dumpUids( (sessionid_t)sid, &zcri, &puid, &uidLen );
1753     if ( RES_OK == result ){
1754     uidsToZval( puid, uidLen, &zuids );
1755 youi 1.19 freeUID( puid );
1756 aga 1.2 }
1757     }
1758 youi 1.24
1759     RETURN_LONG(result);
1760 aga 1.2 }
1761 aga 1.1
1762 youi 1.21 /** XNP???違???若?????違??緇???<br>
1763 youi 1.24 int xnp_get_group_count( int xnp_session_id );
1764     @param xnp_session_id XNP???祉???激?с??D
1765     @return ?違???若????/span>
1766 aga 1.5 */
1767 youi 1.21 ZEND_FUNCTION(xnp_get_group_count)
1768 aga 1.1 {
1769 aga 1.2 long sid;
1770 youi 1.24
1771 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1772     &sid) == FAILURE) {
1773     return;
1774     }
1775 youi 1.24
1776 aga 1.2 int count = getGroupCount( (sessionid_t)sid );
1777 youi 1.24
1778     RETURN_LONG(count);
1779 aga 1.2 }
1780 aga 1.1
1781 aga 1.5 /** uid?ф??絎????????若?吟??絮????違???若???с?????ゆ?>散????眼?????違???若????id??緇???<br>
1782 youi 1.24 int xnp_get_group_by_uid( int xnp_session_id, int uid, array criteria, array gids );
1783     @param xnp_session_id XNP???祉???激?с??D
1784     @param user_id xoops_users.uid
1785     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1786     @param gids gid??????????????
1787     @return 0 success
1788 aga 1.5 */
1789 youi 1.21 ZEND_FUNCTION(xnp_get_groups_by_uid)
1790 aga 1.2 {
1791     result_t result;
1792     long sid, uid;
1793     zval *zcriteria;
1794     zval *zgids;
1795 youi 1.24
1796 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1797     &sid, &uid, &zcriteria, &zgids) == FAILURE) {
1798     return;
1799 aga 1.1 }
1800 youi 1.24
1801 aga 1.2 zCriteria_t zcri(zcriteria);
1802     result = zcri.getResult();
1803     if ( RES_OK == result ){
1804     groupid_t *pgids;
1805     int gidLen;
1806     result = getGroupsByUid( (sessionid_t)sid, (userid_t)uid, &zcri, &pgids, &gidLen );
1807     if ( RES_OK == result ){
1808     gidsToZval( pgids, gidLen, &zgids );
1809 youi 1.19 freeGID( pgids );
1810 aga 1.2 }
1811 aga 1.1 }
1812 youi 1.24
1813     RETURN_LONG(result);
1814 aga 1.2 }
1815    
1816    
1817 aga 1.5
1818     /** uid?ф??絎????????若?吟??gid?ф??絎??????違???若?????違???若??膊∞??????????????緇???<br>
1819 youi 1.24 int xnp_is_group_admin( int sid, int gid, int uid );
1820     @param xnp_session_id XNP???祉???激?с??D
1821     @param group_id XNP???違???若??ID
1822     @param user_id xoops_users.uid
1823     @return true: ?違???若??膊∞?????с??????
1824     @return false: ?違???若??膊∞?????с???????????????????若?с??????
1825 aga 1.5 */
1826 youi 1.21 ZEND_FUNCTION(xnp_is_group_admin)
1827 aga 1.2 {
1828     long sid, gid, uid;
1829 youi 1.24
1830 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1831     &sid, &gid, &uid) == FAILURE) {
1832     return;
1833 aga 1.1 }
1834 youi 1.24
1835 aga 1.2 bool b = isGroupAdmin( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1836 youi 1.24
1837     RETURN_BOOL(b);
1838 aga 1.2 }
1839    
1840 aga 1.5 /** ?>散????眼?????違???若????id???荀с??緇?????<br>
1841 youi 1.24 int xnp_dump_gids( int sid, array criteria, array gids );
1842     @param xnp_session_id XNP???祉???激?с??D
1843     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1844     @param gids gid??????????????
1845     @return 0 success
1846 aga 1.5 */
1847 youi 1.21 ZEND_FUNCTION(xnp_dump_gids)
1848 aga 1.2 {
1849     result_t result;
1850     long sid;
1851     zval *zcriteria;
1852     zval *zgids;
1853 youi 1.24
1854 aga 1.2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1855     &sid, &zcriteria, &zgids) == FAILURE) {
1856     return;
1857     }
1858 youi 1.24
1859 aga 1.2 zCriteria_t zcri(zcriteria);
1860     result = zcri.getResult();
1861     if ( RES_OK == result ){
1862     groupid_t *pgid;
1863     int gidLen;
1864     result = dumpGids( (sessionid_t)sid, &zcri, &pgid, &gidLen );
1865     if ( RES_OK == result ){
1866     gidsToZval( pgid, gidLen, &zgids );
1867 youi 1.19 freeGID( pgid );
1868 aga 1.1 }
1869     }
1870 youi 1.24
1871     RETURN_LONG(result);
1872 aga 1.1 }
1873 aga 1.8
1874     /** gid?ф??絎??????違???若??????????с?????ゆ?>散????眼?????違???若??膊∞??????id???荀с??緇?????<br>
1875 youi 1.24 int xnp_dump_group_admins(int sid, int group_id, array criteria, array uids )
1876     @param sid XNP???祉???激?с??D
1877     @param group_id XNP???違???若??ID
1878     @param criteria ?>散
1879     @param uids uid???荀с??????????????
1880     @return 0 success
1881 aga 1.8 */
1882    
1883 youi 1.21 ZEND_FUNCTION(xnp_dump_group_admins)
1884 aga 1.8 {
1885     long sid, gid;
1886     zval *zcriteria;
1887     zval *zuids;
1888 youi 1.24
1889     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1890     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1891 aga 1.8 return;
1892     }
1893 youi 1.24
1894 aga 1.8 zCriteria_t zcri(zcriteria);
1895     result_t result = zcri.getResult();
1896     if ( result == RES_OK ){
1897     userid_t *uids;
1898     int uidsLen;
1899     result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
1900     if ( result == RES_OK ){
1901     uidsToZval( uids, uidsLen, &zuids );
1902 youi 1.19 freeUID( uids );
1903 aga 1.8 }
1904     }
1905     RETURN_LONG( result );
1906     }
1907    
1908 aga 1.11 /** ?違???若???????<?潟???若?????ゃ??????<br>
1909 youi 1.24 int xnp_delete_member(int sid, int group_id, int user_id )
1910     @param sid XNP???祉???激?с??D
1911     @param group_id XNP???違???若??ID
1912     @param user_id ???若??D
1913     @return 0 success
1914 aga 1.11 */
1915    
1916 youi 1.21 ZEND_FUNCTION(xnp_delete_member)
1917 aga 1.11 {
1918     long sid, gid, uid;
1919 youi 1.24
1920     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1921     &sid, &gid, &uid) == FAILURE) {
1922 aga 1.11 return;
1923     }
1924 youi 1.24
1925 aga 1.11 result_t result = deleteMember( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1926     RETURN_LONG( result );
1927     }
1928    
1929     /** ?違???若?????<?潟???若??菴遵??????<br>
1930 youi 1.24 int xnp_insert_member(int sid, int group_id, int user_id, bool admin )
1931     @param sid XNP???祉???激?с??D
1932     @param group_id XNP???違???若??ID
1933     @param user_id ???若??D
1934     @param admin ?違???若??膊∞????????true
1935     @return 0 success
1936 aga 1.11 */
1937    
1938 youi 1.21 ZEND_FUNCTION(xnp_insert_member)
1939 aga 1.11 {
1940     long sid, gid, uid;
1941     zend_bool admin;
1942 youi 1.24
1943     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllb",
1944     &sid, &gid, &uid, &admin) == FAILURE) {
1945 aga 1.11 return;
1946     }
1947 youi 1.24
1948 aga 1.11 result_t result = insertMember( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid, (bool)admin );
1949     RETURN_LONG( result );
1950     }
1951    
1952     /** gid?ф??絎??????違???若?????<?潟???若??id???荀с??緇???<br>
1953 youi 1.24 int xnp_get_members(int sid, int group_id, array criteria, array uids )
1954     @param sid XNP???祉???激?с??D
1955     @param group_id XNP???違???若??ID
1956     @param criteria ?>散
1957     @param uids uid???荀с??????????????
1958     @return 0 success
1959 aga 1.11 */
1960    
1961 youi 1.21 ZEND_FUNCTION(xnp_get_members)
1962 aga 1.11 {
1963     long sid, gid;
1964     zval *zcriteria;
1965     zval *zuids;
1966 youi 1.24
1967     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1968     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1969 aga 1.11 return;
1970     }
1971 youi 1.24
1972 aga 1.11 zCriteria_t zcri(zcriteria);
1973     result_t result = zcri.getResult();
1974     if ( result == RES_OK ){
1975     userid_t *uids;
1976     int uidsLen;
1977     result = getMembers( (sessionid_t)sid, (groupid_t)gid, &zcri, &uids, &uidsLen );
1978     if ( result == RES_OK ){
1979     uidsToZval( uids, uidsLen, &zuids );
1980 youi 1.19 freeUID( uids );
1981 aga 1.11 }
1982     }
1983     RETURN_LONG( result );
1984     }
1985 youi 1.7
1986     /** ?違???若?????宴??紊??眼??????<br>
1987 youi 1.24 int xnp_update_group(int sid, array group )
1988     @param sid XNP???祉???激?с??D
1989     @param group ?違???若?????宴???f?渇????
1990     @return 0 success
1991 youi 1.7 */
1992 youi 1.21 ZEND_FUNCTION(xnp_update_group)
1993 youi 1.7 {
1994     long sid;
1995     zval *zgroup;
1996 youi 1.24 group_t group;
1997    
1998     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1999     &sid, &zgroup) == FAILURE) {
2000 youi 1.7 return;
2001     }
2002 youi 1.24
2003     zvalToGroup( zgroup, &group );
2004     result_t result = updateGroup( sid, &group );
2005     RETURN_LONG( result );
2006 aga 1.10 }
2007    
2008 youi 1.12 /** ?違???若?????宴??菴遵????????<br>
2009 youi 1.24 int xnp_insert_group( int sid, array group, int &gid )
2010     @param sid ?祉???激?с??D
2011     @param group ?違???若?????宴???f?渇????
2012     @param gid 絲上??????違???若??ID???吾??莨若???????<???潟??/span>
2013     @return RES_OK
2014     @return RES_DB_NOT_INITIALIZED
2015     @return RES_NO_SUCH_SESSION
2016     @return RES_DB_QUERY_ERROR
2017 youi 1.12 */
2018 youi 1.21 ZEND_FUNCTION(xnp_insert_group)
2019 youi 1.12 {
2020     long sid;
2021     zval *zgroup;
2022 youi 1.24 zval *zgid;
2023     group_t group;
2024     groupid_t gid;
2025    
2026     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
2027     &sid, &zgroup, &zgid ) == FAILURE) {
2028 youi 1.12 return;
2029     }
2030 youi 1.24
2031     zvalToGroup( zgroup, &group );
2032     result_t result = insertGroup( sid, &group, &gid );
2033     zgid -> type = IS_LONG;
2034     zgid -> value.lval = gid;
2035     RETURN_LONG( result );
2036 youi 1.12 }
2037    
2038    
2039     /** ?違???若?????宴?????ゃ??????<br>
2040 youi 1.24 int xnp_delete_group( int sid, int gid )
2041     @param sid XNP???祉???激?с??D
2042     @param gid ???ゃ???????違???若????D
2043     @return RES_OK
2044     @return RES_DB_QUERY_ERROR
2045     @return RES_NO_SUCH_SESSION
2046     @return RES_DB_NOT_INITIALIZED
2047 youi 1.12 */
2048 youi 1.21 ZEND_FUNCTION(xnp_delete_group)
2049 youi 1.12 {
2050     long sid;
2051     long gid;
2052 youi 1.24
2053     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2054     &sid, &gid) == FAILURE) {
2055 youi 1.12 return;
2056     }
2057 youi 1.24 RETURN_LONG( deleteGroup( sid, gid ) );
2058 youi 1.12 }
2059    
2060     /** ?違???若?????????????緇???<br>
2061 youi 1.24 int xnp_dump_group_admins( int sid, int gid, array criteria, array uids )
2062     @param sid XNP???祉???激?с??D
2063     @param gid XNP?違???若????D
2064     @param criteria uids???吾??莨若?????????純?若???>散鐚?膀??蚊????絎?
2065     @param uids 膊∞??????ID???吾??莨若??????
2066     @return RES_OK
2067     @return RES_DB_QUERY_ERROR
2068     @return RES_NO_SUCH_SESSION
2069     @return RES_DB_NOT_INITIALIZED
2070 youi 1.12 */
2071     /*
2072 youi 1.21 ZEND_FUNCTION(xnp_dump_group_admins)
2073 youi 1.12 {
2074     long sid;
2075     long gid;
2076     zval *zcriteria;
2077     zval *zuids;
2078 youi 1.24
2079     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
2080     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
2081 youi 1.12 return;
2082     }
2083     zCriteria_t zcri(zcriteria);
2084     result_t result = zcri.getResult();
2085     if ( RES_OK == result ){
2086 youi 1.24 userid_t* uids;
2087     int uidsLen;
2088     result_t result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
2089     if( result != RES_OK ) RETURN_LONG( result );
2090     uidsToZval( uids, uidsLen, &zuids );
2091     fprintf( stderr, "uidsLen=%d\n", uidsLen );
2092     for( int i = 0; i < uidsLen; i++ ){
2093     fprintf( stderr, "%d, \n", uids[ i ] );
2094     }
2095     freeUID( uids );
2096     RETURN_LONG( result );
2097     }
2098     RETURN_LONG( result );
2099 youi 1.12 }
2100     */
2101 aga 1.22
2102     /** ???????ゃ?潟???????鴻??緇???<br>
2103     * int xnp_get_all_indexes( int sid, array criteria, array indexes );
2104     * @param sid XNP???祉???激?с??D
2105     * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2106     * @return RES_OK
2107     */
2108     ZEND_FUNCTION(xnp_get_all_indexes)
2109     {
2110     long sid;
2111     zval *zcriteria;
2112     zval *zindexes;
2113 youi 1.24
2114     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
2115     &sid, &zcriteria, &zindexes) == FAILURE) {
2116 aga 1.22 return;
2117     }
2118     zCriteria_t zcri(zcriteria);
2119     result_t result = zcri.getResult();
2120     if ( RES_OK == result ){
2121     const index_t *indexes;
2122     int indexesLen;
2123     result = getAllIndexes( sid, &zcri, &indexes, &indexesLen );
2124     if ( RES_OK == result ){
2125     result = indexesToZval( indexes, indexesLen, zindexes );
2126     freeIndex( indexes );
2127     }
2128     }
2129     RETURN_LONG(result);
2130     }
2131    
2132     /** ?????ゃ?潟???????鴻??????????ゃ?潟???????鴻??緇???<br>
2133     * int xnp_get_indexes( int sid, int parentXID, array criteria, array indexes );
2134     * @param sid XNP???祉???激?с??D
2135     * @param parentXID 荀???ndexID
2136     * @param cri 腟???????我??絎?鐚??純?若???>散??絎?
2137     * @param indexes 腟?????????????????
2138     * @return RES_OK
2139     */
2140     ZEND_FUNCTION(xnp_get_indexes)
2141     {
2142     long sid;
2143     long parentXID;
2144     zval *zcriteria;
2145     zval *zindexes;
2146 youi 1.24
2147     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
2148     &sid, &parentXID, &zcriteria, &zindexes) == FAILURE) {
2149 aga 1.22 return;
2150     }
2151     zCriteria_t zcri(zcriteria);
2152     result_t result = zcri.getResult();
2153     if ( RES_OK == result ){
2154     const index_t *indexes;
2155     int indexesLen;
2156     result = getIndexes( sid, parentXID, &zcri, &indexes, &indexesLen );
2157     if ( RES_OK == result ){
2158     result = indexesToZval( indexes, indexesLen, zindexes );
2159     freeIndex( indexes );
2160     }
2161     }
2162     RETURN_LONG(result);
2163     }
2164    
2165    
2166     /** ?ゃ?潟???????鴻??篏???????<br>
2167     * int xnp_insert_index( int sid, array index, int &indexID );
2168     * @param sid XNP???祉???激?с??D
2169     * @param index 篏????????ゃ?潟????????/span>
2170     * @param indexID 篏??????????ゃ?潟???????鴻??D??????????紊???/span>
2171     * @return RES_OK
2172     */
2173     ZEND_FUNCTION(xnp_insert_index)
2174     {
2175     long sid;
2176     zval *zindex;
2177     zval *zIndexID;
2178 youi 1.24
2179     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
2180     &sid, &zindex, &zIndexID) == FAILURE) {
2181 aga 1.22 return;
2182     }
2183 youi 1.24
2184 aga 1.22 if (!PZVAL_IS_REF(zIndexID)) {
2185     zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
2186     RETURN_LONG(RES_PHP_NONREF);
2187     }
2188     zIndex_t index( zindex );
2189     indexid_t xid;
2190     result_t result = insertIndex( sid, &index, &xid );
2191     if ( RES_OK == result )
2192     ZVAL_LONG(zIndexID, (long)xid);
2193     RETURN_LONG(result);
2194     }
2195    
2196     /** ?ゃ?潟???????鴻???贋?違????<br>
2197     * int xnp_update_index( int sid, array index );
2198     * @param sid XNP???祉???激?с??D
2199     * @param index ?贋?違?????ゃ?潟????????/span>
2200     * @return RES_OK
2201     */
2202     ZEND_FUNCTION(xnp_update_index)
2203     {
2204     long sid;
2205     zval *zindex;
2206 youi 1.24
2207     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
2208     &sid, &zindex) == FAILURE) {
2209 aga 1.22 return;
2210     }
2211     zIndex_t index(zindex);
2212     result_t result = index.getResult();
2213     if ( RES_OK == result ){
2214     result = updateIndex( sid, &index );
2215     }
2216     RETURN_LONG(result);
2217     }
2218    
2219     /** ?ゃ?潟???????鴻?????ゃ????<br>
2220     * int xnp_delete_index( int sid, int indexID );
2221     * @param sid XNP???祉???激?с??D
2222     * @param indexID ???ゃ?????ゃ?潟????????/span>
2223     * @return RES_OK
2224     */
2225     ZEND_FUNCTION(xnp_delete_index)
2226     {
2227     long sid;
2228     long xid;
2229 youi 1.24
2230     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2231     &sid, &xid) == FAILURE) {
2232 aga 1.22 return;
2233     }
2234 youi 1.24
2235 aga 1.22 result_t result = deleteIndex( sid, xid );
2236     RETURN_LONG(result);
2237     }
2238    
2239    
2240     /** ?ゃ?潟???????鴻????緇?????<br>
2241     * int xnp_get_index( int sid, int indexID, array index );
2242     * @param sid XNP???祉???激?с??D
2243     * @param indexID ??緇??????ゃ?潟???????鴻??D
2244     * @param index ??緇?腟??????????????f?渇????
2245     * @return RES_OK
2246     */
2247     ZEND_FUNCTION(xnp_get_index)
2248     {
2249     long sid;
2250     long xid;
2251     zval *zindex;
2252 youi 1.24
2253     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
2254     &sid, &xid, &zindex) == FAILURE) {
2255 aga 1.22 return;
2256     }
2257 youi 1.24
2258 aga 1.22 const index_t *index;
2259     result_t result = getIndex( sid, xid, &index );
2260     if ( RES_OK == result ){
2261     result = indexToZval( index, zindex );
2262     freeIndex( index );
2263     }
2264     RETURN_LONG(result);
2265     }
2266    
2267    
2268    
2269     /** ?ゃ?潟???????鴻??茯??粋昭?水??純??????????茯帥?鴻??<br>
2270     * int xnp_is_index_readable( int sid, int indexID );
2271     * @param sid XNP???祉???激?с??D
2272     * @param indexID 絲乗院?ゃ?潟???????鴻??D
2273     * @return true false
2274     */
2275     ZEND_FUNCTION(xnp_is_index_readable)
2276     {
2277     long sid;
2278     long xid;
2279 youi 1.24
2280     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2281     &sid, &xid) == FAILURE) {
2282 aga 1.22 return;
2283     }
2284     RETURN_BOOL(isIndexReadable(sid,xid));
2285     }
2286    
2287    
2288     /** ?ゃ?潟???????鴻???吾??莨若?水??純??????????茯帥?鴻??<br>
2289     * int xnp_is_index_writable( int sid, int indexID );
2290     * @param sid XNP???祉???激?с??D
2291     * @param indexID 絲乗院?ゃ?潟???????鴻??D
2292     * @return true false
2293     */
2294     ZEND_FUNCTION(xnp_is_index_writable)
2295     {
2296     long sid;
2297     long xid;
2298 youi 1.24
2299     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
2300     &sid, &xid) == FAILURE) {
2301 aga 1.22 return;
2302     }
2303     RETURN_BOOL(isIndexWritable(sid,xid));
2304     }
2305    
2306     /** ?ゃ?潟???????鴻????綺???ャ???帥????<br>
2307     * int xnp_swap_index_sort_number( int sid, int indexID1, int indexID2 );
2308     * @param sid XNP???祉???激?с??D
2309     * @param indexID1 絲乗院?ゃ?潟???????鴻??D
2310     * @param indexID2 絲乗院?ゃ?潟???????鴻??D
2311     * @return true false
2312     */
2313     ZEND_FUNCTION(xnp_swap_index_sort_number)
2314     {
2315     long sid;
2316     long xid1, xid2;
2317 youi 1.24
2318     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
2319     &sid, &xid1, &xid2) == FAILURE) {
2320 aga 1.22 return;
2321     }
2322 youi 1.24
2323 aga 1.22 result_t result = swapIndexSortNumber( sid, xid1, xid2 );
2324     RETURN_LONG(result);
2325     }
2326    
2327    
2328    
2329 youi 1.21 /** XNP??ession_id???綵??с???с????lt;br>
2330 youi 1.24 bool xnp_is_valid_session_id( int xnp_session_id)
2331     @return true ???鴻??NP??ession_id?с????<br>
2332     @return false ?≦?鴻??ession_id?障??????????/span>
2333 aga 1.10 */
2334 youi 1.21 ZEND_FUNCTION(xnp_is_valid_session_id)
2335 aga 1.10 {
2336     long sid;
2337     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &sid ) == FAILURE) {
2338     return;
2339     }
2340 youi 1.24
2341 aga 1.10 RETURN_BOOL(isValidSessionID((sessionid_t)sid));
2342 aga 1.9 }
2343    
2344     /** ?????惹??絖?????緇???<br>
2345 youi 1.24 string xnp_get_last_error_string()
2346     @return 0 success
2347 aga 1.9 */
2348 youi 1.21 ZEND_FUNCTION(xnp_get_last_error_string)
2349 aga 1.9 {
2350     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "" ) == FAILURE) {
2351     return;
2352     }
2353 youi 1.24
2354 aga 1.9 string str( getLastErrorString() );
2355     RETURN_STRING((char *)str.c_str(), 1);
2356 youi 1.7 }
2357    
2358 youi 1.24
2359     /**
2360     *
2361     * ?≪?ゃ?????吾???≪???祉?号┤???????с????????
2362     *
2363     * @refer itemop_t
2364     * @param sid ?祉???激?с??D
2365     * @param iid ???с?????莟<???????≪?ゃ??????D
2366     * @param op ?≪???祉?鴻??┏蕁?
2367     * @return true 罔???????
2368     * @return false 罔???????
2369     *
2370     */
2371     ZEND_FUNCTION(xnp_get_item_permission)
2372     {
2373 youi 1.27 long sid;
2374     itemid_t iid;
2375     long op;
2376    
2377     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
2378     &sid, &iid, &op) == FAILURE) {
2379     fprintf( stderr, "error occured " );
2380     return;
2381     }
2382     RETURN_BOOL( getItemPermission( (sessionid_t)sid, iid, op ) );
2383 youi 1.24 }
2384    
2385    
2386     /**
2387     *
2388     * ?ゃ?潟???????鴻?吾???≪???祉?号┤???????с????????
2389     *
2390     * @refer indexop_t
2391     * @param sid ?祉???激?с??D
2392     * @param xid ???с?????莟<???????ゃ?潟???????鴻??D
2393     * @param op ?≪???祉?鴻??┏蕁?
2394     * @return true 罔???????
2395     * @return false 罔???????
2396     *
2397     */
2398     ZEND_FUNCTION(xnp_get_index_permission)
2399     {
2400 youi 1.27 long sid;
2401     indexid_t xid;
2402     long op;
2403    
2404     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
2405     &sid, &xid, &op) == FAILURE) {
2406     fprintf( stderr, "error occured " );
2407     return;
2408     }
2409     RETURN_BOOL( getIndexPermission( (sessionid_t)sid, xid, op ) );
2410 youi 1.24 }
2411    
2412    
2413     /**
2414     *
2415     * ?≪?ゃ???????粋??倶????紊??眼????罔????????<??茯帥?鴻?障??鐚?/span>
2416     * @refer certify_t
2417     * @param sid ?祉???激?с??D
2418     * @param xid 紊??翫?莟<?≪?ゃ???????脂?蚊???????????ゃ?潟???????鴻??D
2419     * @param iid 紊??翫?莟<?≪?ゃ??????D
2420     * @param state ?違???鎀??眼???????粋??倶??
2421     * @return true 罔???????
2422     * @return false 罔???????
2423     *
2424     */
2425     ZEND_FUNCTION(xnp_get_certify_permission)
2426     {
2427 youi 1.27 long sid;
2428     itemid_t iid;
2429     indexid_t xid;
2430     certify_t state;
2431    
2432     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",
2433     &sid, &xid, &iid, &state) == FAILURE) {
2434     fprintf( stderr, "error occured " );
2435     return;
2436     }
2437     RETURN_BOOL( getCertifyPermission( (sessionid_t)sid, xid, iid, state ) );
2438 youi 1.24 }
2439    
2440    
2441     /**
2442     *
2443     * ?≪?ゃ???????粋??倶??????緇????障??鐚?/span>
2444     * @refer certify_t
2445     * @param sid ?祉???激?с??D
2446     * @param xid 絲乗院?≪?ゃ???????脂?蚊???????????ゃ?潟???????鴻??D
2447     * @param iid 絲乗院?≪?ゃ??????D