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.52 - (show annotations) (download) (as text)
Sun Aug 14 07:54:06 2005 UTC (18 years, 7 months ago) by tani
Branch: MAIN
Changes since 1.51: +2 -2 lines
File MIME type: text/x-c++src
PHP_MSHUTDOWN_FUNCTION(xnpalmod): uninitializeDBをコールする.

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