Develop and Download Open Source Software

Browse CVS Repository

Contents of /xoonips/AL/xnpal.cc

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


Revision 1.49 - (show annotations) (download) (as text)
Thu Jul 21 01:50:07 2005 UTC (18 years, 8 months ago) by tani
Branch: MAIN
Changes since 1.48: +3 -7 lines
File MIME type: text/x-c++src
resolve confict.

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