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.33 - (hide annotations) (download) (as text)
Wed Feb 9 11:12:39 2005 UTC (19 years, 2 months ago) by youi
Branch: MAIN
Changes since 1.32: +52 -1 lines
File MIME type: text/x-c++src
xnp_zip_createを追加.

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