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.45 - (show annotations) (download) (as text)
Wed Jul 6 10:53:08 2005 UTC (18 years, 9 months ago) by orrisroot
Branch: MAIN
Changes since 1.44: +2 -2 lines
File MIME type: text/x-c++src
changed module name from 'Visiome Platform Abstract Layer' to 'XooNIps Abstract Layer'.

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