]> git.pld-linux.org Git - packages/php.git/blob - php-mnogosearch-update.patch
- removed garbage,
[packages/php.git] / php-mnogosearch-update.patch
1 Index: php-src/ext/mnogosearch/php_mnogo.c
2 ===================================================================
3 RCS file: /repository/php-src/ext/mnogosearch/php_mnogo.c,v
4 retrieving revision 1.66.2.1
5 retrieving revision 1.66.2.5
6 diff -u -r1.66.2.1 -r1.66.2.5
7 --- php-src/ext/mnogosearch/php_mnogo.c 31 Dec 2002 16:34:55 -0000      1.66.2.1
8 +++ php-src/ext/mnogosearch/php_mnogo.c 8 Jul 2003 14:00:57 -0000       1.66.2.5
9 @@ -1,5 +1,5 @@
10  /* $Source$ */
11 -/* $Id$ */
12 +/* $Id$ */
13  
14  /*
15     +----------------------------------------------------------------------+
16 @@ -7,10 +7,10 @@
17     +----------------------------------------------------------------------+
18     | Copyright (c) 1997-2003 The PHP Group                                |
19     +----------------------------------------------------------------------+
20 -   | This source file is subject to version 2.02 of the PHP license,      |
21 +   | This source file is subject to version 3.0 of the PHP license,       |
22     | that is bundled with this package in the file LICENSE, and is        |
23 -   | available at through the world-wide-web at                           |
24 -   | http://www.php.net/license/2_02.txt.                                 |
25 +   | available through the world-wide-web at the following url:           |
26 +   | http://www.php.net/license/3_0.txt.                                  |
27     | If you did not receive a copy of the PHP license and are unable to   |
28     | obtain it through the world-wide-web, please send a note to          |
29     | license@php.net so we can mail you a copy immediately.               |
30 @@ -163,6 +163,12 @@
31  #if UDM_VERSION_ID >= 30204
32         PHP_FE(udm_parse_query_string,  NULL)
33         PHP_FE(udm_make_excerpt,        NULL)
34 +       PHP_FE(udm_set_agent_param_ex,  NULL)
35 +       PHP_FE(udm_get_res_field_ex,    NULL)
36 +#endif
37 +#if UDM_VERSION_ID >= 30211
38 +       PHP_FE(udm_hash32,              NULL)
39 +       PHP_FE(udm_alloc_agent_array,   NULL)
40  #endif
41  #endif
42  
43 @@ -456,7 +462,7 @@
44                                 UdmVarListReplaceStr(&Env->Vars,"SyslogFacility","local7");
45                                 UdmSetLogLevel(Env,0);
46                                 UdmOpenLog("mnoGoSearch-php",Env,0);
47 -
48 +#if UDM_VERSION_ID <= 30210
49                                 if(!memcmp(dbaddr,"searchd:",8)){
50                                         UDM_URL Url;
51                                         UdmURLParse(&Url,dbaddr);
52 @@ -464,13 +470,18 @@
53                                 }
54                                 
55                                 UdmVarListReplaceStr(&Env->Vars,"DBAddr",dbaddr);
56 +                               
57                                 if(UDM_OK!=UdmDBSetAddr(Env->db,dbaddr,UDM_OPEN_MODE_READ)){
58                                     sprintf(Env->errstr,"Invalid DBAddr: '%s'",dbaddr);
59 +#if UDM_VERSION_ID <= 30207
60                                     Env->errcode=1;
61 -                                   php_error(E_WARNING,"%s(): Invalid DBAddr", get_active_function_name(TSRMLS_C));
62 +#endif
63 +                                   php_error_docref(NULL TSRMLS_CC, E_WARNING,"Invalid DBAddr");
64                                     RETURN_FALSE;
65                                 }
66 -                               
67 +#else
68 +                               UdmDBListAdd(&Env->dbl,dbaddr, UDM_OPEN_MODE_WRITE);
69 +#endif
70                                 Agent=UdmAgentInit(NULL,Env,0);
71  #elif UDM_VERSION_ID >= 30200
72                                 Env=UdmAllocEnv();
73 @@ -508,7 +519,7 @@
74                                 UdmVarListReplaceStr(&Env->Vars,"SyslogFacility","local7");
75                                 UdmSetLogLevel(Env,0);
76                                 UdmOpenLog("mnoGoSearch-php",Env,0);
77 -
78 +#if UDM_VERSION_ID <= 30210
79                                 if(!memcmp(dbaddr,"searchd:",8)){
80                                         UDM_URL Url;
81                                         UdmURLParse(&Url,dbaddr);
82 @@ -517,10 +528,15 @@
83                                 UdmVarListReplaceStr(&Env->Vars,"DBAddr",dbaddr);
84                                 if(UDM_OK!=UdmDBSetAddr(Env->db,dbaddr,UDM_OPEN_MODE_READ)){
85                                     sprintf(Env->errstr,"Invalid DBAddr: '%s'",dbaddr);
86 +#if UDM_VERSION_ID <= 30207
87                                     Env->errcode=1;
88 -                                   php_error(E_WARNING,"%s(): Invalid DBAddr", get_active_function_name(TSRMLS_C));
89 +#endif
90 +                                   php_error_docref(NULL TSRMLS_CC, E_WARNING,"Invalid DBAddr");
91                                     RETURN_FALSE;
92                                 }
93 +#else
94 +                               UdmDBListAdd(&Env->dbl,dbaddr, UDM_OPEN_MODE_WRITE);
95 +#endif
96                                 Agent=UdmAgentInit(NULL,Env,0);
97  #elif UDM_VERSION_ID >= 30200
98                                 Env=UdmAllocEnv();
99 @@ -620,7 +636,7 @@
100  
101                                         case UDM_MODE_PHRASE: 
102  #if UDM_VERSION_ID >= 30200
103 -                                               php_error(E_WARNING,"%s(): Unknown search mode", get_active_function_name(TSRMLS_C));
104 +                                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown search mode");
105                                                 RETURN_FALSE;
106  #else
107                                                 Agent->search_mode=UDM_MODE_PHRASE;
108 @@ -633,7 +649,7 @@
109  #else
110                                                 Agent->search_mode=UDM_MODE_ALL;
111  #endif                                         
112 -                                               php_error(E_WARNING,"%s(): Unknown search mode", get_active_function_name(TSRMLS_C));
113 +                                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown search mode");
114                                                 RETURN_FALSE;
115                                                 break;
116                         }
117 @@ -679,7 +695,7 @@
118  #else
119                                                 Agent->word_match=UDM_MATCH_WORD;
120  #endif                                         
121 -                                               php_error(E_WARNING,"%s(): Unknown word match mode", get_active_function_name(TSRMLS_C));
122 +                                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown word match mode");
123                                                 RETURN_FALSE;
124                                                 break;
125                         }
126 @@ -714,7 +730,7 @@
127  #else                                                                  
128                                         UdmReplaceStrVar(Agent->Conf->vars,"Cache","no",UDM_VARSRC_GLOBAL);
129  #endif                                         
130 -                                       php_error(E_WARNING,"%s(): Unknown cache mode", get_active_function_name(TSRMLS_C));
131 +                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown cache mode");
132                                         RETURN_FALSE;
133                                         break;
134                         }
135 @@ -752,7 +768,7 @@
136  #else
137                                         UdmReplaceStrVar(Agent->Conf->vars,"TrackQuery","no",UDM_VARSRC_GLOBAL);
138  #endif                         
139 -                                       php_error(E_WARNING,"%s(): Unknown track mode", get_active_function_name(TSRMLS_C));
140 +                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown track mode");
141                                         RETURN_FALSE;
142                                         break;
143                         }
144 @@ -771,7 +787,7 @@
145                                         break;
146                                         
147                                 default:
148 -                                       php_error(E_WARNING,"%s(): Unknown phrase mode", get_active_function_name(TSRMLS_C));
149 +                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown phrase mode");
150                                         RETURN_FALSE;
151                                         break;
152                         }
153 @@ -809,7 +825,7 @@
154  #else
155                                         UdmAddIntVar(Agent->Conf->vars, "IspellUsePrefixes", 1, UDM_VARSRC_GLOBAL);                                     
156  #endif                                                                                         
157 -                                       php_error(E_WARNING,"%s(): Unknown ispell prefixes mode", get_active_function_name(TSRMLS_C));
158 +                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown ispell prefixes mode");
159                                         RETURN_FALSE;
160                                         break;
161                         }
162 @@ -866,7 +882,7 @@
163                         
164                 case UDM_PARAM_SYNONYM:
165                         if (UdmSynonymListLoad(Agent->Conf,val)) {
166 -                               php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C),Agent->Conf->errstr);
167 +                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",Agent->Conf->errstr);
168                                 RETURN_FALSE;
169  #if UDM_VERSION_ID >= 30204
170                         } else UdmSynonymListSort(&(Agent->Conf->Synonyms));
171 @@ -918,7 +934,7 @@
172  #else
173                         if (UdmFileLoadStopList(Agent->Conf,val)) {
174  #endif
175 -                               php_error(E_WARNING, "%s(): %s", Agent->Conf->errstr, get_active_function_name(TSRMLS_C));
176 +                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", Agent->Conf->errstr);
177                                 RETURN_FALSE;
178                         }
179                         break;
180 @@ -985,7 +1001,7 @@
181                                         break;
182                                         
183                                 default:
184 -                                       php_error(E_WARNING,"%s(): Unknown crosswords mode", get_active_function_name(TSRMLS_C));
185 +                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown crosswords mode");
186                                         RETURN_FALSE;
187                                         break;
188                         }
189 @@ -997,6 +1013,8 @@
190                 case UDM_PARAM_VARDIR:
191  #if UDM_VERSION_ID < 30200
192                         udm_snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR);
193 +#elif UDM_VERSION_ID >= 30208
194 +                       UdmVarListReplaceStr(&Agent->Conf->Vars,"Vardir",val);
195  #elif UDM_VERSION_ID >= 30204
196                         UdmVarListReplaceStr(&Agent->Conf->Vars,"Vardir",val);
197                         snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR);
198 @@ -1032,7 +1050,7 @@
199                                         break;
200                                         
201                                 default:
202 -                                       php_error(E_WARNING,"%s(): Unknown groupbysite mode", get_active_function_name(TSRMLS_C));
203 +                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown groupbysite mode");
204                                         RETURN_FALSE;
205                                         break;
206                         }
207 @@ -1057,7 +1075,7 @@
208                                         break;
209                                         
210                                 default:
211 -                                       php_error(E_WARNING,"%s(): Unknown clones mode", get_active_function_name(TSRMLS_C));
212 +                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown clones mode");
213                                         RETURN_FALSE;
214                                         break;
215                         }
216 @@ -1066,7 +1084,7 @@
217  #endif
218  
219                 default:
220 -                       php_error(E_WARNING,"%s(): Unknown agent session parameter", get_active_function_name(TSRMLS_C));
221 +                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown agent session parameter");
222                         RETURN_FALSE;
223                         break;
224         }
225 @@ -1160,12 +1178,12 @@
226  #endif
227                         
228                         if (UdmImportAffixes(Agent->Conf,val1,val2,NULL,0)) {
229 -                               php_error(E_WARNING,"%s(): Cannot load affix file %s", get_active_function_name(TSRMLS_C),val2);
230 +                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load affix file %s",val2);
231                                 RETURN_FALSE;
232                         }
233  #else
234                         if (UdmImportAffixes(Agent->Conf,val1,charset,val2)) {
235 -                               php_error(E_WARNING,"%s(): Cannot load affix file %s", get_active_function_name(TSRMLS_C),val2);
236 +                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load affix file %s",val2);
237                                 RETURN_FALSE;
238                         }
239      
240 @@ -1181,12 +1199,12 @@
241  #endif
242                         
243                         if (UdmImportDictionary(Agent->Conf,val1,val2,1,"")) {
244 -                               php_error(E_WARNING,"%s(): Cannot load spell file %s", get_active_function_name(TSRMLS_C),val2);
245 +                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load spell file %s",val2);
246                                 RETURN_FALSE;
247                         }
248  #else
249                         if (UdmImportDictionary(Agent->Conf,val1,charset,val2,0,"")) {
250 -                               php_error(E_WARNING,"%s(): Cannot load spell file %s", get_active_function_name(TSRMLS_C),val2);
251 +                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load spell file %s",val2);
252                                 RETURN_FALSE;
253                         }
254  #endif
255 @@ -1194,7 +1212,7 @@
256  
257  
258                 default:
259 -                       php_error(E_WARNING,"%s(): Unknown ispell type parameter", get_active_function_name(TSRMLS_C));
260 +                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown ispell type parameter");
261                         RETURN_FALSE;
262                         break;
263         }
264 @@ -1328,7 +1346,7 @@
265                                 Z_TYPE(stl_info)=2;
266                                 stl_info.t2=(time_t)(atol(edate+1));
267                         } else {
268 -                               php_error(E_WARNING,"%s(): Incorrect date limit format", get_active_function_name(TSRMLS_C));
269 +                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Incorrect date limit format");
270                                 RETURN_FALSE;
271                         }                       
272                         
273 @@ -1338,7 +1356,7 @@
274  #endif
275                         break;
276                 default:
277 -                       php_error(E_WARNING,"%s(): Unknown search limit parameter", get_active_function_name(TSRMLS_C));
278 +                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown search limit parameter");
279                         RETURN_FALSE;
280                         break;
281         }
282 @@ -1647,24 +1665,212 @@
283                 
284                 Excerpt = UdmExcerptDoc(Agent, Res, &(Res->Doc[row]), 256);
285                 
286 -               if (Excerpt != NULL) {
287 +               if ((Excerpt != NULL) && (strlen(Excerpt) > 6)) {
288                         char *HlExcerpt = UdmHlConvert(&Res->WWList, Excerpt, Agent->Conf->lcs, Agent->Conf->bcs);
289 -                       UdmVarListReplaceInt(&(Res->Doc[row].Sections),"ST",1);
290                         UdmVarListReplaceStr(&(Res->Doc[row].Sections),"Body",HlExcerpt);
291                         UDM_FREE(HlExcerpt);
292 +               }
293 +               if (Excerpt != NULL && (UdmVarListFindStr(&(Res->Doc[row].Sections), "Z", NULL) == NULL)) {
294 +                       UdmVarListReplaceInt(&(Res->Doc[row].Sections),"ST",1);
295                         UDM_FREE(Excerpt);
296                 } else {
297                         UdmVarListReplaceInt(&(Res->Doc[row].Sections),"ST",0);
298                         RETURN_FALSE;
299                 }
300         }else{
301 -               php_error(E_WARNING,"%s(): row number too large", get_active_function_name(TSRMLS_C));
302 +               php_error_docref(NULL TSRMLS_CC, E_WARNING,"row number too large");
303                 RETURN_FALSE;
304         }
305         
306         RETURN_TRUE;
307  }
308  /* }}} */
309 +
310 +/* {{{ proto int udm_set_agent_param_ex(int agent, string var, string val)
311 +   Set mnoGoSearch agent session parameters extended */
312 +DLEXPORT PHP_FUNCTION(udm_set_agent_param_ex)
313 +{
314 +       pval **yyagent, **yyvar, **yyval;
315 +       char *val, *var;
316 +       UDM_AGENT * Agent;
317 +
318 +       switch(ZEND_NUM_ARGS()){
319 +       
320 +               case 3:                 
321 +                       if(zend_get_parameters_ex(3,&yyagent,&yyvar,&yyval)==FAILURE){
322 +                               RETURN_FALSE;
323 +                       }
324 +                       convert_to_string_ex(yyvar);
325 +                       convert_to_string_ex(yyval);
326 +                       ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link);
327 +                       var = Z_STRVAL_PP(yyvar);
328 +                       val = Z_STRVAL_PP(yyval);
329 +                       
330 +                       break;
331 +                       
332 +               default:
333 +                       WRONG_PARAM_COUNT;
334 +                       break;
335 +       }
336 +       
337 +       UdmVarListReplaceStr(&Agent->Conf->Vars,var,val);
338 +       
339 +       if (!strcasecmp(var,"LocalCharset")) {
340 +               const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"LocalCharset","iso-8859-1");
341 +               Agent->Conf->lcs=UdmGetCharSet(charset);
342 +       } else if (!strcasecmp(var,"BrowserCharset")) {
343 +               const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"BrowserCharset","iso-8859-1");
344 +               Agent->Conf->bcs=UdmGetCharSet(charset);
345 +       } else if (!strcasecmp(var,"Synonym")) {
346 +               if (UdmSynonymListLoad(Agent->Conf,val)) {
347 +                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",Agent->Conf->errstr);
348 +                       RETURN_FALSE;
349 +               } else UdmSynonymListSort(&(Agent->Conf->Synonyms));
350 +       } else if (!strcasecmp(var,"Stopwordfile")) {
351 +               if (UdmStopListLoad(Agent->Conf,val)) {
352 +                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", Agent->Conf->errstr);
353 +                       RETURN_FALSE;
354 +               }
355 +       } else if (!strcasecmp(var,"MinWordLen")) {
356 +               Agent->Conf->WordParam.min_word_len=atoi(val);
357 +       } else if (!strcasecmp(var,"MaxWordLen")) {
358 +               Agent->Conf->WordParam.max_word_len=atoi(val);
359 +#if UDM_VERSION_ID <= 30207
360 +       } else if (!strcasecmp(var,"VarDir")) {
361 +               snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR);
362 +#endif
363 +       }
364 +
365 +       RETURN_TRUE;
366 +}
367 +
368 +/* {{{ proto string udm_get_res_field_ex(int res, int row, string field)
369 +   Fetch mnoGoSearch result field */
370 +DLEXPORT PHP_FUNCTION(udm_get_res_field_ex)
371 +{
372 +       pval **yyres, **yyrow_num, **yyfield_name;
373 +
374 +       UDM_RESULT * Res;
375 +       int row;
376 +       char *field;
377 +       
378 +       switch(ZEND_NUM_ARGS()){
379 +               case 3: {
380 +                               if (zend_get_parameters_ex(3, &yyres,&yyrow_num,&yyfield_name)==FAILURE){
381 +                                       RETURN_FALSE;
382 +                               }
383 +                               convert_to_string_ex(yyrow_num);
384 +                               convert_to_string_ex(yyfield_name);
385 +                               field = Z_STRVAL_PP(yyfield_name);
386 +                               row = atoi(Z_STRVAL_PP(yyrow_num));
387 +                       }
388 +                       break;
389 +               default:
390 +                       WRONG_PARAM_COUNT;
391 +                       break;
392 +       }
393 +       
394 +       ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result", le_res);
395 +       if(row<Res->num_rows){
396 +               if (!strcasecmp(field,"URL")) {
397 +                   char        *al;
398 +                   al = (char *)MyRemoveHiLightDup((const char *)(UdmVarListFindStr(&(Res->Doc[row].Sections), field, "")));
399 +                   UdmVarListReplaceStr(&Res->Doc[row].Sections,field,al);
400 +                   free(al);
401 +               }
402 +               RETURN_STRING((char *)UdmVarListFindStr(&Res->Doc[row].Sections,field,""),1);
403 +       } else {
404 +               php_error_docref(NULL TSRMLS_CC, E_WARNING,"row number too large");
405 +               RETURN_FALSE;
406 +       }
407 +}
408 +/* }}} */
409 +#endif
410 +
411 +#if UDM_VERSION_ID >= 30211
412 +/* {{{ proto int udm_alloc_agent_array(array dbaddr)
413 +   Allocate mnoGoSearch session */
414 +DLEXPORT PHP_FUNCTION(udm_alloc_agent_array)
415 +{
416 +       switch(ZEND_NUM_ARGS()){
417 +
418 +               case 1: {
419 +                               pval **yydbaddr;
420 +                               zval **tmp;
421 +                               char *dbaddr;
422 +                               UDM_ENV   * Env;
423 +                               UDM_AGENT * Agent;
424 +                               HashPosition   pos;
425 +                               
426 +                               if(zend_get_parameters_ex(1,&yydbaddr)==FAILURE){
427 +                                       RETURN_FALSE;
428 +                               }
429 +                               
430 +                               if (Z_TYPE_PP(yydbaddr) != IS_ARRAY) {
431 +                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument DBAddr must be an array.");
432 +                                       RETURN_FALSE;
433 +                               }
434 +                               convert_to_array_ex(yydbaddr);
435 +                               
436 +                               Env=UdmEnvInit(NULL);
437 +                               UdmVarListReplaceStr(&Env->Vars,"SyslogFacility","local7");
438 +                               UdmSetLogLevel(Env,0);
439 +                               UdmOpenLog("mnoGoSearch-php",Env,0);
440 +                               
441 +                               zend_hash_internal_pointer_reset_ex(HASH_OF(*yydbaddr), &pos);
442 +                               
443 +                               while (zend_hash_get_current_data_ex(HASH_OF(*yydbaddr), (void **)&tmp, &pos) == SUCCESS) {
444 +                                   convert_to_string_ex(tmp);
445 +                                   dbaddr = Z_STRVAL_PP(tmp);
446 +                                   UdmDBListAdd(&Env->dbl,dbaddr, UDM_OPEN_MODE_WRITE);
447 +                                   
448 +                                   zend_hash_move_forward_ex(HASH_OF(*yydbaddr), &pos);
449 +                               }
450 +                               
451 +                               Agent=UdmAgentInit(NULL,Env,0);
452 +                               ZEND_REGISTER_RESOURCE(return_value,Agent,le_link);
453 +                       }
454 +                       break;
455 +                       
456 +               default:
457 +                       WRONG_PARAM_COUNT;
458 +                       break;
459 +       }
460 +}
461 +/* }}} */
462 +
463 +/* {{{ proto int udm_hash32(int agent, string str)
464 +   Return Hash32 checksum of gived string */
465 +DLEXPORT PHP_FUNCTION(udm_hash32)
466 +{
467 +       pval ** yystr, ** yyagent;
468 +       char *str;
469 +       udmhash32_t hash32;
470 +       char buf[32];
471 +       UDM_AGENT * Agent;
472 +       int id=-1;
473 +
474 +       switch(ZEND_NUM_ARGS()){
475 +               case 2: {
476 +                               if (zend_get_parameters_ex(2, &yyagent,&yystr)==FAILURE) {
477 +                                       RETURN_FALSE;
478 +                               }
479 +                       }
480 +                       break;
481 +               default:                                
482 +                       WRONG_PARAM_COUNT;
483 +                       break;
484 +       }
485 +       ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link);
486 +       convert_to_string_ex(yystr);
487 +       str = Z_STRVAL_PP(yystr);
488 +
489 +       hash32=UdmHash32((str),strlen(str));
490 +       snprintf(buf,sizeof(buf)-1,"%u",hash32);
491 +       
492 +       RETURN_STRING(buf,1);
493 +}
494 +/* }}} */
495  #endif
496  
497  /* {{{ proto int udm_find(int agent, string query)
498 @@ -1677,6 +1883,14 @@
499         int id=-1;
500  
501         switch(ZEND_NUM_ARGS()){
502 +#if UDM_VERSION_ID >= 30213
503 +               case 1: {
504 +                               if (zend_get_parameters_ex(1, &yyagent)==FAILURE) {
505 +                                       RETURN_FALSE;
506 +                               }
507 +                       }
508 +                       break;
509 +#endif
510                 case 2: {
511                                 if (zend_get_parameters_ex(2, &yyagent,&yyquery)==FAILURE) {
512                                         RETURN_FALSE;
513 @@ -1693,7 +1907,11 @@
514  #if UDM_VERSION_ID < 30200
515         if ((Res=UdmFind(Agent,UdmTolower(Z_STRVAL_PP(yyquery),Agent->charset)))) {
516  #else
517 +#if UDM_VERSION_ID >= 30213
518 +       if ((Res=UdmFind(Agent))) {
519 +#else
520         if ((Res=UdmFind(Agent,Z_STRVAL_PP(yyquery)))) {
521 +#endif
522  #endif 
523             ZEND_REGISTER_RESOURCE(return_value,Res,le_res);
524         } else {
525 @@ -1876,12 +2094,12 @@
526  #endif
527                                 
528                         default: 
529 -                               php_error(E_WARNING,"%s(): Unknown mnoGoSearch field name", get_active_function_name(TSRMLS_C));
530 +                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown mnoGoSearch field name");
531                                 RETURN_FALSE;
532                                 break;
533                 }
534         }else{
535 -               php_error(E_WARNING,"%s(): row number too large", get_active_function_name(TSRMLS_C));
536 +               php_error_docref(NULL TSRMLS_CC, E_WARNING,"row number too large");
537                 RETURN_FALSE;
538         }
539  }
540 @@ -1926,13 +2144,13 @@
541                             {   
542                                 size_t wsize=(1+len*15)*sizeof(char);
543                                 char *wordinfo = (char*) malloc(wsize);
544 -                               int corder = -1, ccount = 0;
545           
546                                 *wordinfo = '\0';
547           
548                                 for(i = 0; i < Res->WWList.nwords; i++){
549 -                                   if ((Res->WWList.Word[i].count > 0) || (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_QUERY)) {
550 -                                   if(wordinfo[0]) strcat(wordinfo,", ");
551 +                                   if ((Res->WWList.Word[i].count > 0) || 
552 +                                       (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_QUERY)) {
553 +                                       if(wordinfo[0]) strcat(wordinfo,", ");
554                                         sprintf(UDM_STREND(wordinfo)," %s : %d", Res->WWList.Word[i].word, Res->WWList.Word[i].count);
555                                     } else if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_STOP) {
556                                         if(wordinfo[0]) strcat(wordinfo,", ");
557 @@ -1950,33 +2168,29 @@
558  #if UDM_VERSION_ID >= 30204
559                 case UDM_PARAM_WORDINFO_ALL: 
560                         {
561 -                           int len,i;
562 +                           int len,i,j;
563                             for(len = i = 0; i < Res->WWList.nwords; i++) 
564                                 len += Res->WWList.Word[i].len;
565                             {   
566                                 size_t wsize=(1+len*15)*sizeof(char);
567                                 char *wordinfo = (char*) malloc(wsize);
568 -                               int corder = -1, ccount = 0;
569 +                               int corder = (size_t)-1, ccount = 0;
570           
571                                 *wordinfo = '\0';
572                                 
573 -                               for(i = 0; i < Res->WWList.nwords; i++){
574 -                                   if (Res->WWList.Word[i].order != corder) {
575 -                                       if(wordinfo[0]) {
576 -                                           sprintf(UDM_STREND(wordinfo)," / %d, ", ccount);
577 -                                       }
578 -                                       ccount = Res->WWList.Word[i].count;
579 -                                       if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_STOP) {
580 -                                           sprintf(UDM_STREND(wordinfo)," %s : stopword", Res->WWList.Word[i].word);
581 -                                       } else {
582 -                                           sprintf(UDM_STREND(wordinfo)," %s : %d", Res->WWList.Word[i].word, Res->WWList.Word[i].count);
583 -                                           corder = Res->WWList.Word[i].order; 
584 -                                       }
585 -                                   } else {
586 -                                       ccount += Res->WWList.Word[i].count;
587 +                               for(i = 0; i < Res->WWList.nwords; i++) {
588 +                                   corder = Res->WWList.Word[i].order;
589 +                                   ccount = 0;
590 +                                   for(j = 0; j < Res->WWList.nwords; j++) {
591 +                                       if (Res->WWList.Word[j].order == corder) {
592 +                                           ccount += Res->WWList.Word[j].count;
593 +                                       }
594                                     }
595 -                               }
596 -                               if (Res->WWList.nwords) {
597 +                                   if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_STOP) {
598 +                                       sprintf(UDM_STREND(wordinfo),"%s%s : stopword", (*wordinfo) ? ", " : "",  Res->WWList.Word[i].word);
599 +                                   } else if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_QUERY) {
600 +                                       sprintf(UDM_STREND(wordinfo),"%s%s : %d", (*wordinfo) ? ", " : "", Res->WWList.Word[i].word, Res->WWList.Word[i].count);
601 +                                   } else continue;
602                                     sprintf(UDM_STREND(wordinfo)," / %d", ccount);
603                                 }
604                                 RETURN_STRING(wordinfo,1);
605 @@ -1998,7 +2212,7 @@
606                         break;
607  
608                 default:
609 -                       php_error(E_WARNING,"%s(): Unknown mnoGoSearch param name", get_active_function_name(TSRMLS_C));
610 +                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown mnoGoSearch param name");
611                         RETURN_FALSE;
612                         break;
613         }
614 @@ -2071,7 +2285,13 @@
615                         break;
616         }
617         ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link);
618 -#if UDM_VERSION_ID >= 30204
619 +#if UDM_VERSION_ID >= 30208
620 +       if (UdmEnvErrMsg(Agent->Conf) && strlen(UdmEnvErrMsg(Agent->Conf))) {
621 +           RETURN_LONG(1);
622 +       } else {
623 +           RETURN_LONG(0);
624 +       }
625 +#elif UDM_VERSION_ID >= 30204
626         RETURN_LONG(UdmEnvErrCode(Agent->Conf));
627  #else
628         RETURN_LONG(UdmDBErrorCode(Agent->db));
629 @@ -2147,13 +2367,15 @@
630  #if UDM_VERSION_ID >= 30204
631         bzero(&C,sizeof(C));
632         strncpy(C.addr,cat,sizeof(C.addr)-1);
633 +#if UDM_VERSION_ID <= 30210
634         if(!UdmCatAction(Agent,&C,UDM_CAT_ACTION_LIST,Agent->Conf->db)){
635  #else
636 +       if(UDM_OK == UdmCatAction(Agent,&C,UDM_CAT_ACTION_LIST)){
637 +#endif
638 +#else
639         if((c=UdmCatList(Agent,cat))){
640  #endif
641 -               if (array_init(return_value)==FAILURE) {
642 -                       RETURN_FALSE;
643 -               }
644 +               array_init(return_value);
645                 
646                 if (!(buf=calloc(1,UDMSTRSIZ+1))) {
647                         RETURN_FALSE;
648 @@ -2164,11 +2386,9 @@
649                     int i;
650                     if (C.ncategories) {
651                         for(i=0;i<C.ncategories;i++){
652 -                           snprintf(buf, UDMSTRSIZ, "%s%s",C.Category[i].link[0]?"@ ":"", C.Category[i].name);
653 -                           add_next_index_string(return_value, C.Category[i].link[0]?C.Category[i].link:C.Category[i].path, 1);
654 -                           add_next_index_string(return_value, buf, 1);
655 +                           add_next_index_stringl(return_value, C.Category[i].path,strlen(C.Category[i].path),1);
656 +                           add_next_index_stringl(return_value, C.Category[i].name,strlen(C.Category[i].name),1);
657                         }
658 -                       free(C.Category);
659                     } else {
660                         RETURN_FALSE;
661                     }
662 @@ -2221,13 +2441,15 @@
663  #if UDM_VERSION_ID >= 30204
664         bzero(&C,sizeof(C));
665         strncpy(C.addr,cat,sizeof(C.addr)-1);
666 +#if UDM_VERSION_ID <= 30210
667         if(!UdmCatAction(Agent,&C,UDM_CAT_ACTION_PATH,Agent->Conf->db)){
668  #else
669 +       if(UDM_OK == UdmCatAction(Agent,&C,UDM_CAT_ACTION_PATH)){
670 +#endif
671 +#else
672         if((c=UdmCatPath(Agent,cat))){
673  #endif
674 -               if (array_init(return_value)==FAILURE) {
675 -                       RETURN_FALSE;
676 -               }
677 +               array_init(return_value);
678                 
679                 if (!(buf=calloc(1,UDMSTRSIZ+1))) {
680                         RETURN_FALSE;
681 @@ -2238,11 +2460,9 @@
682                     int i;
683                     if (C.ncategories) {
684                         for(i=0;i<C.ncategories;i++){                   
685 -                           snprintf(buf, UDMSTRSIZ, "%s%s",C.Category[i].link[0]?"@ ":"", C.Category[i].name);
686 -                           add_next_index_string(return_value, C.Category[i].link[0]?C.Category[i].link:C.Category[i].path, 1);
687 -                           add_next_index_string(return_value, buf, 1);
688 +                           add_next_index_stringl(return_value, C.Category[i].path,strlen(C.Category[i].path),1);
689 +                           add_next_index_stringl(return_value, C.Category[i].name,strlen(C.Category[i].name),1);
690                         }
691 -                       free(C.Category);
692                     } else {
693                         RETURN_FALSE;
694                     }
695 @@ -2284,7 +2504,11 @@
696         }
697         ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link);
698  #if UDM_VERSION_ID >= 30204
699 +#if UDM_VERSION_ID <= 30210
700         if (!Agent->doccount) UdmURLAction(Agent,NULL,UDM_URL_ACTION_DOCCOUNT,Agent->Conf->db);
701 +#else
702 +       if (!Agent->doccount) UdmURLAction(Agent,NULL,UDM_URL_ACTION_DOCCOUNT);
703 +#endif
704         RETURN_LONG(Agent->doccount);
705  #else
706         RETURN_LONG(UdmGetDocCount(Agent));
707 Index: php-src/ext/mnogosearch/php_mnogo.h
708 ===================================================================
709 RCS file: /repository/php-src/ext/mnogosearch/php_mnogo.h,v
710 retrieving revision 1.19.4.2
711 retrieving revision 1.19.4.3
712 diff -u -r1.19.4.2 -r1.19.4.3
713 --- php-src/ext/mnogosearch/php_mnogo.h 19 Apr 2003 05:10:27 -0000      1.19.4.2
714 +++ php-src/ext/mnogosearch/php_mnogo.h 14 Jun 2003 18:45:23 -0000      1.19.4.3
715 @@ -1,5 +1,5 @@
716  /* $Source$ */
717 -/* $Id$ */
718 +/* $Id$ */
719  
720  /* 
721     +----------------------------------------------------------------------+
722 @@ -27,8 +27,6 @@
723  
724  #if HAVE_MNOGOSEARCH
725  
726 -#undef HAVE_PGSQL
727 -#undef HAVE_MYSQL
728  #include <udm_config.h>
729  #include <udmsearch.h>
730  
731 @@ -70,6 +68,12 @@
732  #if UDM_VERSION_ID >= 30204
733  DLEXPORT PHP_FUNCTION(udm_parse_query_string);
734  DLEXPORT PHP_FUNCTION(udm_make_excerpt);
735 +DLEXPORT PHP_FUNCTION(udm_set_agent_param_ex);
736 +DLEXPORT PHP_FUNCTION(udm_get_res_field_ex);
737 +#endif
738 +#if UDM_VERSION_ID >= 30211
739 +DLEXPORT PHP_FUNCTION(udm_hash32);
740 +DLEXPORT PHP_FUNCTION(udm_alloc_agent_array);
741  #endif
742  #endif
743  
This page took 0.077961 seconds and 3 git commands to generate.