1 diff -ur php-4.2.2/ext/mnogosearch.orig/php_mnogo.c php-4.2.2/ext/mnogosearch/php_mnogo.c
2 --- php-4.2.2/ext/mnogosearch.orig/php_mnogo.c Thu Feb 28 09:26:23 2002
3 +++ php-4.2.2/ext/mnogosearch/php_mnogo.c Mon Jun 17 19:39:17 2002
10 +----------------------------------------------------------------------+
12 #define UDM_PARAM_SEARCHD 22
13 #define UDM_PARAM_QSTRING 23
14 #define UDM_PARAM_REMOTE_ADDR 24
15 +#define UDM_PARAM_QUERY 25
17 /* udm_add_search_limit constants */
18 #define UDM_LIMIT_URL 1
20 #define UDM_PARAM_SEARCHTIME 259
21 #define UDM_PARAM_FIRST_DOC 260
22 #define UDM_PARAM_LAST_DOC 261
23 +#define UDM_PARAM_WORDINFO_ALL 262
25 /* udm_load_ispell_data constants */
26 #define UDM_ISPELL_TYPE_AFFIX 1
29 function_entry mnogosearch_functions[] = {
30 PHP_FE(udm_api_version, NULL)
32 #if UDM_VERSION_ID >= 30200
33 PHP_FE(udm_check_charset, NULL)
36 -#if UDM_VERSION_ID >= 30203
37 - PHP_FE(udm_crc32, NULL)
38 +#if UDM_VERSION_ID == 30203
39 PHP_FE(udm_open_stored, NULL)
40 PHP_FE(udm_check_stored,NULL)
41 PHP_FE(udm_close_stored,NULL)
43 +#if UDM_VERSION_ID >= 30203
44 + PHP_FE(udm_crc32, NULL)
46 +#if UDM_VERSION_ID >= 30204
47 + PHP_FE(udm_parse_query_string,NULL)
51 PHP_FE(udm_alloc_agent, NULL)
52 PHP_FE(udm_set_agent_param, NULL)
54 static void _free_udm_agent(zend_rsrc_list_entry *rsrc TSRMLS_DC)
56 UDM_AGENT * Agent = (UDM_AGENT *)rsrc->ptr;
57 +#if UDM_VERSION_ID >= 30204
58 + UdmEnvFree(Agent->Conf);
59 + UdmAgentFree(Agent);
61 UdmFreeEnv(Agent->Conf);
66 static void _free_udm_res(zend_rsrc_list_entry *rsrc TSRMLS_DC)
68 UDM_RESULT * Res = (UDM_RESULT *)rsrc->ptr;
71 +#if UDM_VERSION_ID >= 30204
78 /* {{{ PHP_MINIT_FUNCTION
81 REGISTER_LONG_CONSTANT("UDM_PARAM_QSTRING", UDM_PARAM_QSTRING,CONST_CS | CONST_PERSISTENT);
82 REGISTER_LONG_CONSTANT("UDM_PARAM_REMOTE_ADDR", UDM_PARAM_REMOTE_ADDR,CONST_CS | CONST_PERSISTENT);
83 + REGISTER_LONG_CONSTANT("UDM_PARAM_QUERY", UDM_PARAM_QUERY,CONST_CS | CONST_PERSISTENT);
85 /* udm_add_search_limit constants */
86 REGISTER_LONG_CONSTANT("UDM_LIMIT_CAT", UDM_LIMIT_CAT,CONST_CS | CONST_PERSISTENT);
88 REGISTER_LONG_CONSTANT("UDM_PARAM_FOUND", UDM_PARAM_FOUND,CONST_CS | CONST_PERSISTENT);
89 REGISTER_LONG_CONSTANT("UDM_PARAM_NUM_ROWS", UDM_PARAM_NUM_ROWS,CONST_CS | CONST_PERSISTENT);
90 REGISTER_LONG_CONSTANT("UDM_PARAM_WORDINFO", UDM_PARAM_WORDINFO,CONST_CS | CONST_PERSISTENT);
91 + REGISTER_LONG_CONSTANT("UDM_PARAM_WORDINFO_ALL",UDM_PARAM_WORDINFO_ALL,CONST_CS | CONST_PERSISTENT);
92 REGISTER_LONG_CONSTANT("UDM_PARAM_WORD_INFO", UDM_PARAM_WORDINFO,CONST_CS | CONST_PERSISTENT);
93 REGISTER_LONG_CONSTANT("UDM_PARAM_SEARCHTIME", UDM_PARAM_SEARCHTIME,CONST_CS | CONST_PERSISTENT);
94 REGISTER_LONG_CONSTANT("UDM_PARAM_SEARCH_TIME", UDM_PARAM_SEARCHTIME,CONST_CS | CONST_PERSISTENT);
97 convert_to_string_ex(yydbaddr);
98 dbaddr = Z_STRVAL_PP(yydbaddr);
101 +#if UDM_VERSION_ID >= 30204
102 + Env=UdmEnvInit(NULL);
103 + UdmVarListReplaceStr(&Env->Vars,"SyslogFacility","local7");
104 + UdmSetLogLevel(Env,0);
105 + UdmOpenLog("mnoGoSearch-php",Env,0);
107 + if(!memcmp(dbaddr,"searchd:",8)){
109 + UdmURLParse(&Url,dbaddr);
110 + UdmDBListAdd(&Env->sdcl,Url.hostinfo);
112 + UdmVarListReplaceStr(&Env->Vars,"DBAddr",dbaddr);
113 + if(UDM_OK!=UdmDBSetAddr(Env->db,dbaddr,UDM_OPEN_MODE_READ)){
114 + sprintf(Env->errstr,"Invalid DBAddr: '%s'",dbaddr);
116 + php_error(E_WARNING,"Udm_Alloc_Agent: Invalid DBAddr");
119 + Agent=UdmAgentInit(NULL,Env,0);
120 +#elif UDM_VERSION_ID >= 30200
123 -#if UDM_VERSION_ID >= 30200
124 Env->vars=UdmAllocVarList();
125 Env->DBAddr=strdup(dbaddr);
126 UdmEnvSetDBMode(Env,"single");
127 + Agent=UdmAllocAgent(Env,0,UDM_OPEN_MODE_READ);
130 UdmEnvSetDBAddr(Env,dbaddr);
133 Agent=UdmAllocAgent(Env,0,UDM_OPEN_MODE_READ);
136 ZEND_REGISTER_RESOURCE(return_value,Agent,le_link);
139 @@ -432,18 +469,37 @@
140 dbaddr = Z_STRVAL_PP(yydbaddr);
141 dbmode = Z_STRVAL_PP(yydbmode);
144 -#if UDM_VERSION_ID >= 30200
145 +#if UDM_VERSION_ID >= 30204
146 + Env=UdmEnvInit(NULL);
147 + UdmVarListReplaceStr(&Env->Vars,"SyslogFacility","local7");
148 + UdmSetLogLevel(Env,0);
149 + UdmOpenLog("mnoGoSearch-php",Env,0);
151 + if(!memcmp(dbaddr,"searchd:",8)){
153 + UdmURLParse(&Url,dbaddr);
154 + UdmDBListAdd(&Env->sdcl,Url.hostinfo);
156 + UdmVarListReplaceStr(&Env->Vars,"DBAddr",dbaddr);
157 + if(UDM_OK!=UdmDBSetAddr(Env->db,dbaddr,UDM_OPEN_MODE_READ)){
158 + sprintf(Env->errstr,"Invalid DBAddr: '%s'",dbaddr);
160 + php_error(E_WARNING,"Udm_Alloc_Agent: Invalid DBAddr");
163 + Agent=UdmAgentInit(NULL,Env,0);
164 +#elif UDM_VERSION_ID >= 30200
166 Env->vars=UdmAllocVarList();
167 Env->DBAddr=strdup(dbaddr);
168 UdmEnvSetDBMode(Env,dbmode);
170 + Agent=UdmAllocAgent(Env,0,UDM_OPEN_MODE_READ);
173 UdmEnvSetDBAddr(Env,dbaddr);
174 - UdmEnvSetDBMode(Env,dbmode);
177 + UdmEnvSetDBMode(Env,dbmode);
178 Agent=UdmAllocAgent(Env,0,UDM_OPEN_MODE_READ);
181 ZEND_REGISTER_RESOURCE(return_value,Agent,le_link);
184 @@ -485,66 +541,110 @@
187 case UDM_PARAM_PAGE_SIZE:
188 +#if UDM_VERSION_ID >= 30204
189 + UdmVarListReplaceStr(&Agent->Conf->Vars,"ps",val);
191 Agent->page_size=atoi(val);
192 if(Agent->page_size<1)Agent->page_size=20;
197 case UDM_PARAM_PAGE_NUM:
198 +#if UDM_VERSION_ID >= 30204
199 + UdmVarListReplaceStr(&Agent->Conf->Vars,"np",val);
201 Agent->page_number=atoi(val);
202 if(Agent->page_number<0)Agent->page_number=0;
208 case UDM_PARAM_SEARCH_MODE:
211 +#if UDM_VERSION_ID >= 30204
212 + UdmVarListReplaceStr(&Agent->Conf->Vars,"m","all");
214 Agent->search_mode=UDM_MODE_ALL;
219 +#if UDM_VERSION_ID >= 30204
220 + UdmVarListReplaceStr(&Agent->Conf->Vars,"m","any");
222 Agent->search_mode=UDM_MODE_ANY;
227 +#if UDM_VERSION_ID >= 30204
228 + UdmVarListReplaceStr(&Agent->Conf->Vars,"m","all");
230 Agent->search_mode=UDM_MODE_BOOL;
234 case UDM_MODE_PHRASE:
235 +#if UDM_VERSION_ID >= 30200
236 + php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown search mode");
239 Agent->search_mode=UDM_MODE_PHRASE;
244 +#if UDM_VERSION_ID >= 30204
245 + UdmVarListReplaceStr(&Agent->Conf->Vars,"m","all");
247 Agent->search_mode=UDM_MODE_ALL;
249 - php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown search mode");
251 + php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown search mode");
258 case UDM_PARAM_WORD_MATCH:
261 +#if UDM_VERSION_ID >= 30204
262 + UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","wrd");
264 Agent->word_match=UDM_MATCH_WORD;
268 case UDM_MATCH_BEGIN:
269 +#if UDM_VERSION_ID >= 30204
270 + UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","beg");
272 Agent->word_match=UDM_MATCH_BEGIN;
277 +#if UDM_VERSION_ID >= 30204
278 + UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","end");
280 Agent->word_match=UDM_MATCH_END;
284 case UDM_MATCH_SUBSTR:
285 +#if UDM_VERSION_ID >= 30204
286 + UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","sub");
288 Agent->word_match=UDM_MATCH_SUBSTR;
293 +#if UDM_VERSION_ID >= 30204
294 + UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","wrd");
296 Agent->word_match=UDM_MATCH_WORD;
299 php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown word match mode");
303 case UDM_PARAM_CACHE_MODE:
305 case UDM_CACHE_ENABLED:
306 -#if UDM_VERSION_ID < 30200
307 +#if UDM_VERSION_ID < 30200
308 Agent->cache_mode=UDM_CACHE_ENABLED;
310 +#elif UDM_VERSION_ID >= 30204
311 + UdmVarListReplaceStr(&Agent->Conf->Vars,"Cache","yes");
313 UdmReplaceStrVar(Agent->Conf->vars,"Cache","yes",UDM_VARSRC_GLOBAL);
317 case UDM_CACHE_DISABLED:
318 #if UDM_VERSION_ID < 30200
319 Agent->cache_mode=UDM_CACHE_DISABLED;
320 +#elif UDM_VERSION_ID >= 30204
321 + UdmVarListReplaceStr(&Agent->Conf->Vars,"Cache","no");
323 UdmReplaceStrVar(Agent->Conf->vars,"Cache","no",UDM_VARSRC_GLOBAL);
327 #if UDM_VERSION_ID < 30200
328 Agent->cache_mode=UDM_CACHE_DISABLED;
329 +#elif UDM_VERSION_ID >= 30204
330 + UdmVarListReplaceStr(&Agent->Conf->Vars,"Cache","no");
332 UdmReplaceStrVar(Agent->Conf->vars,"Cache","no",UDM_VARSRC_GLOBAL);
335 case UDM_TRACK_ENABLED:
336 #if UDM_VERSION_ID < 30200
337 Agent->track_mode|=UDM_TRACK_QUERIES;
338 +#elif UDM_VERSION_ID >= 30204
339 + UdmVarListReplaceStr(&Agent->Conf->Vars,"TrackQuery","yes");
341 UdmReplaceStrVar(Agent->Conf->vars,"TrackQuery","yes",UDM_VARSRC_GLOBAL);
344 case UDM_TRACK_DISABLED:
345 #if UDM_VERSION_ID < 30200
346 Agent->track_mode &= ~(UDM_TRACK_QUERIES);
347 +#elif UDM_VERSION_ID >= 30204
348 + UdmVarListReplaceStr(&Agent->Conf->Vars,"TrackQuery","no");
350 UdmReplaceStrVar(Agent->Conf->vars,"TrackQuery","no",UDM_VARSRC_GLOBAL);
354 #if UDM_VERSION_ID < 30200
355 Agent->track_mode &= ~(UDM_TRACK_QUERIES);
356 +#elif UDM_VERSION_ID >= 30204
357 + UdmVarListReplaceStr(&Agent->Conf->Vars,"TrackQuery","no");
359 UdmReplaceStrVar(Agent->Conf->vars,"TrackQuery","no",UDM_VARSRC_GLOBAL);
361 @@ -633,11 +745,12 @@
364 case UDM_PARAM_ISPELL_PREFIXES:
367 case UDM_PREFIXES_ENABLED:
368 #if UDM_VERSION_ID < 30200
369 Agent->Conf->ispell_mode |= UDM_ISPELL_USE_PREFIXES;
370 +#elif UDM_VERSION_ID >= 30204
371 + UdmVarListReplaceStr(&Agent->Conf->Vars,"IspellUsePrefixes","1");
373 UdmAddIntVar(Agent->Conf->vars, "IspellUsePrefixes", 1, UDM_VARSRC_GLOBAL);
376 case UDM_PREFIXES_DISABLED:
377 #if UDM_VERSION_ID < 30200
378 Agent->Conf->ispell_mode &= ~UDM_ISPELL_USE_PREFIXES;
379 +#elif UDM_VERSION_ID >= 30204
380 + UdmVarListReplaceStr(&Agent->Conf->Vars,"IspellUsePrefixes","0");
382 UdmAddIntVar(Agent->Conf->vars, "IspellUsePrefixes", 0, UDM_VARSRC_GLOBAL);
386 #if UDM_VERSION_ID < 30200
387 Agent->Conf->ispell_mode |= UDM_ISPELL_USE_PREFIXES;
388 +#elif UDM_VERSION_ID >= 30204
389 + UdmVarListReplaceStr(&Agent->Conf->Vars,"IspellUsePrefixes","0");
391 UdmAddIntVar(Agent->Conf->vars, "IspellUsePrefixes", 1, UDM_VARSRC_GLOBAL);
394 #if UDM_VERSION_ID < 30200
395 Agent->Conf->local_charset=UdmGetCharset(val);
396 Agent->charset=Agent->Conf->local_charset;
397 +#elif UDM_VERSION_ID >= 30204
398 + UdmVarListReplaceStr(&Agent->Conf->Vars,"LocalCharset",val);
400 + const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"LocalCharset","iso-8859-1");
401 + Agent->Conf->lcs=UdmGetCharSet(charset);
404 Agent->Conf->local_charset=strdup(val);
405 UdmReplaceStrVar(Agent->Conf->vars,"LocalCharset",val,UDM_VARSRC_GLOBAL);
406 @@ -679,29 +802,47 @@
408 #if UDM_VERSION_ID >= 30200
409 case UDM_PARAM_BROWSER_CHARSET:
410 +#if UDM_VERSION_ID >= 30204
411 + UdmVarListReplaceStr(&Agent->Conf->Vars,"BrowserCharset",val);
413 + const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"BrowserCharset","iso-8859-1");
414 + Agent->Conf->lcs=UdmGetCharSet(charset);
417 Agent->Conf->browser_charset=strdup(val);
418 UdmReplaceStrVar(Agent->Conf->vars,"BrowserCharset",val,UDM_VARSRC_GLOBAL);
423 case UDM_PARAM_HLBEG:
424 +#if UDM_VERSION_ID >= 30204
425 + UdmVarListReplaceStr(&Agent->Conf->Vars,"HlBeg",val);
427 UdmReplaceStrVar(Agent->Conf->vars,"HlBeg",val,UDM_VARSRC_GLOBAL);
432 case UDM_PARAM_HLEND:
433 - UdmReplaceStrVar(Agent->Conf->vars,"HlBeg",val,UDM_VARSRC_GLOBAL);
435 +#if UDM_VERSION_ID >= 30204
436 + UdmVarListReplaceStr(&Agent->Conf->Vars,"HlEnd",val);
438 + UdmReplaceStrVar(Agent->Conf->vars,"HlEnd",val,UDM_VARSRC_GLOBAL);
442 case UDM_PARAM_SYNONYM:
443 if (UdmSynonymListLoad(Agent->Conf,val)) {
444 php_error(E_WARNING,Agent->Conf->errstr);
446 +#if UDM_VERSION_ID >= 30204
447 + } else UdmSynonymListSort(&(Agent->Conf->Synonyms));
449 } else UdmSynonymListSort(&(Agent->Conf->SynList));
453 case UDM_PARAM_SEARCHD:
454 +#if UDM_VERSION_ID <= 30203
455 UdmSDCLientListAdd(&(Agent->Conf->sdcl),val);
458 @@ -709,17 +850,24 @@
459 UdmSDCLientListAdd(&Agent->sdcl,Agent->Conf->sdcl.Clients[i].addr);
466 case UDM_PARAM_QSTRING:
467 +#if UDM_VERSION_ID >= 30204
468 + UdmVarListReplaceStr(&Agent->Conf->Vars,"QUERY_STRING",val);
470 UdmReplaceStrVar(Agent->Conf->vars,"QUERY_STRING",val,UDM_VARSRC_GLOBAL);
476 case UDM_PARAM_REMOTE_ADDR:
477 +#if UDM_VERSION_ID >= 30204
478 + UdmVarListReplaceStr(&Agent->Conf->Vars,"IP",val);
480 UdmReplaceStrVar(Agent->Conf->vars,"IP",val,UDM_VARSRC_GLOBAL);
489 case UDM_PARAM_STOPFILE:
490 +#if UDM_VERSION_ID >= 30204
491 + if (UdmStopListLoad(Agent->Conf,val)) {
493 if (UdmFileLoadStopList(Agent->Conf,val)) {
495 php_error(E_WARNING,Agent->Conf->errstr);
499 case UDM_PARAM_WEIGHT_FACTOR:
500 #if UDM_VERSION_ID < 30200
501 Agent->weight_factor=strdup(val);
502 +#elif UDM_VERSION_ID >= 30204
503 + UdmVarListReplaceStr(&Agent->Conf->Vars,"wf",val);
505 UdmReplaceStrVar(Agent->Conf->vars,"wf",val,UDM_VARSRC_GLOBAL);
507 @@ -763,23 +917,37 @@
510 case UDM_PARAM_MIN_WORD_LEN:
511 +#if UDM_VERSION_ID >= 30204
512 + Agent->Conf->WordParam.min_word_len=atoi(val);
514 Agent->Conf->min_word_len=atoi(val);
519 case UDM_PARAM_MAX_WORD_LEN:
520 +#if UDM_VERSION_ID >= 30204
521 + Agent->Conf->WordParam.max_word_len=atoi(val);
523 Agent->Conf->max_word_len=atoi(val);
528 case UDM_PARAM_CROSS_WORDS:
530 case UDM_CROSS_WORDS_ENABLED:
531 +#if UDM_VERSION_ID >= 30204
532 + UdmVarListReplaceStr(&Agent->Conf->Vars,"CrossWords","yes");
534 Agent->Conf->use_crossword=UDM_CROSS_WORDS_ENABLED;
538 case UDM_CROSS_WORDS_DISABLED:
539 +#if UDM_VERSION_ID >= 30204
540 + UdmVarListReplaceStr(&Agent->Conf->Vars,"CrossWords","no");
542 Agent->Conf->use_crossword=UDM_CROSS_WORDS_DISABLED;
547 @@ -795,14 +963,22 @@
548 case UDM_PARAM_VARDIR:
549 #if UDM_VERSION_ID < 30200
550 udm_snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR);
551 +#elif UDM_VERSION_ID >= 30204
552 + UdmVarListReplaceStr(&Agent->Conf->Vars,"Vardir",val);
553 + snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR);
555 snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR);
560 +#if UDM_VERSION_ID >= 30204
561 + case UDM_PARAM_QUERY:
562 + UdmVarListReplaceStr(&Agent->Conf->Vars,"q",val);
570 php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown agent session parameter");
572 @@ -938,10 +1114,17 @@
576 +#if UDM_VERSION_ID >= 30204
577 + if(Agent->Conf->Spells.nspell) {
578 + UdmSortDictionary(&Agent->Conf->Spells);
579 + UdmSortAffixes(&Agent->Conf->Affixes,&Agent->Conf->Spells);
582 if(Agent->Conf->nspell) {
583 UdmSortDictionary(Agent->Conf);
584 UdmSortAffixes(Agent->Conf);
590 @@ -966,8 +1149,11 @@
593 ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link);
595 -#if UDM_VERSION_ID > 30111
597 +#if UDM_VERSION_ID >= 30204
598 + UdmSpellListFree(&Agent->Conf->Spells);
599 + UdmAffixListFree(&Agent->Conf->Affixes);
600 +#elif UDM_VERSION_ID > 30111
601 UdmFreeIspell(Agent->Conf);
604 @@ -1005,26 +1191,40 @@
608 +#if UDM_VERSION_ID >= 30204
609 + UdmVarListAddStr(&Agent->Conf->Vars,"ul",val);
611 UdmAddURLLimit(Agent->Conf,val);
617 +#if UDM_VERSION_ID >= 30204
618 + UdmVarListAddStr(&Agent->Conf->Vars,"t",val);
620 UdmAddTagLimit(Agent->Conf,val);
626 +#if UDM_VERSION_ID >= 30204
627 + UdmVarListAddStr(&Agent->Conf->Vars,"lang",val);
629 UdmAddLangLimit(Agent->Conf,val);
635 +#if UDM_VERSION_ID >= 30204
636 + UdmVarListAddStr(&Agent->Conf->Vars,"cat",val);
638 UdmAddCatLimit(Agent->Conf,val);
643 - case UDM_LIMIT_DATE: {
644 + case UDM_LIMIT_DATE:
645 +#if UDM_VERSION_ID < 30200
647 struct udm_stl_info_t stl_info = { 0, 0, 0 };
650 @@ -1038,9 +1238,9 @@
652 stl_info.t1=(time_t)(atol(val+1));
653 UdmAddTimeLimit(Agent->Conf,&stl_info);
660 php_error(E_WARNING,"Udm_Add_Search_Limit: Unknown search limit parameter");
662 @@ -1056,6 +1256,8 @@
668 switch(ZEND_NUM_ARGS()){
670 if (zend_get_parameters_ex(1, &yyagent)==FAILURE) {
671 @@ -1068,9 +1270,20 @@
674 ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link);
676 +#if UDM_VERSION_ID >= 30204
677 + for(i=0;i<Agent->Conf->Vars.nvars;i++){
678 + if ((!strcasecmp("ul",Agent->Conf->Vars.Var[i].name))||
679 + (!strcasecmp("cat",Agent->Conf->Vars.Var[i].name))||
680 + (!strcasecmp("t",Agent->Conf->Vars.Var[i].name))||
681 + (!strcasecmp("lang",Agent->Conf->Vars.Var[i].name))) {
682 + UDM_FREE(Agent->Conf->Vars.Var[i].name);
683 + UDM_FREE(Agent->Conf->Vars.Var[i].val);
684 + Agent->Conf->Vars.nvars--;
688 UdmClearLimits(Agent->Conf);
694 @@ -1141,7 +1354,9 @@
695 RETURN_STRING(buf,1);
700 +#if UDM_VERSION_ID == 30203
701 /* {{{ proto int udm_open_stored(int agent, string storedaddr)
702 Open connection to stored */
703 DLEXPORT PHP_FUNCTION(udm_open_stored)
704 @@ -1260,6 +1475,37 @@
708 +#if UDM_VERSION_ID >= 30204
709 +/* {{{ proto int udm_parse_query_string(int agent, string str)
710 + Parses query string, initialises variables and search limits taken from it */
711 +DLEXPORT PHP_FUNCTION(udm_parse_query_string)
713 + pval ** yystr, ** yyagent;
718 + switch(ZEND_NUM_ARGS()){
720 + if (zend_get_parameters_ex(2, &yyagent,&yystr)==FAILURE) {
729 + ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link);
730 + convert_to_string_ex(yystr);
731 + str = Z_STRVAL_PP(yystr);
733 + UdmParseQueryString(Agent,&Agent->Conf->Vars,str);
739 /* {{{ proto int udm_find(int agent, string query)
741 DLEXPORT PHP_FUNCTION(udm_find)
742 @@ -1283,7 +1529,7 @@
743 ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link);
744 convert_to_string_ex(yyquery);
746 -#if UDM_VERSION_ID < 30200
747 +#if UDM_VERSION_ID < 30200
748 if ((Res=UdmFind(Agent,UdmTolower(Z_STRVAL_PP(yyquery),Agent->charset)))) {
750 if ((Res=UdmFind(Agent,Z_STRVAL_PP(yyquery)))) {
751 @@ -1323,64 +1569,124 @@
752 if(row<Res->num_rows){
755 +#if UDM_VERSION_ID >= 30204
756 + RETURN_STRING((char *)UdmVarListFindStr(&Res->Doc[row].Sections,"URL",""),1);
758 RETURN_STRING((Res->Doc[row].url)?(Res->Doc[row].url):"",1);
762 case UDM_FIELD_CONTENT:
763 +#if UDM_VERSION_ID >= 30204
764 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Content-Type",""),1);
766 RETURN_STRING((Res->Doc[row].content_type)?(Res->Doc[row].content_type):"",1);
770 case UDM_FIELD_TITLE:
771 +#if UDM_VERSION_ID >= 30204
772 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Title",""),1);
774 RETURN_STRING((Res->Doc[row].title)?(Res->Doc[row].title):"",1);
778 case UDM_FIELD_KEYWORDS:
779 +#if UDM_VERSION_ID >= 30204
780 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Meta.Keywords",""),1);
782 RETURN_STRING((Res->Doc[row].keywords)?(Res->Doc[row].keywords):"",1);
787 +#if UDM_VERSION_ID >= 30204
788 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Meta.Description",""),1);
790 RETURN_STRING((Res->Doc[row].description)?(Res->Doc[row].description):"",1);
795 +#if UDM_VERSION_ID >= 30204
796 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Body",""),1);
798 RETURN_STRING((Res->Doc[row].text)?(Res->Doc[row].text):"",1);
803 +#if UDM_VERSION_ID >= 30204
804 + RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"Content-Length",0));
806 RETURN_LONG((Res->Doc[row].size));
810 - case UDM_FIELD_URLID:
811 + case UDM_FIELD_URLID:
812 +#if UDM_VERSION_ID >= 30204
813 + RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"ID",0));
815 RETURN_LONG((Res->Doc[row].url_id));
819 case UDM_FIELD_RATING:
820 +#if UDM_VERSION_ID >= 30204
821 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Score",""),1);
823 RETURN_LONG((Res->Doc[row].rating));
827 case UDM_FIELD_MODIFIED:
828 +#if UDM_VERSION_ID >= 30204
829 + RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"Last-Modified",0));
831 RETURN_LONG((Res->Doc[row].last_mod_time));
835 case UDM_FIELD_ORDER:
836 +#if UDM_VERSION_ID >= 30204
837 + RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"Order",0));
839 RETURN_LONG((Res->Doc[row].order));
844 +#if UDM_VERSION_ID >= 30204
845 + RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"crc32",0));
847 RETURN_LONG((Res->Doc[row].crc32));
851 case UDM_FIELD_CATEGORY:
852 +#if UDM_VERSION_ID >= 30204
853 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Category",""),1);
855 RETURN_STRING((Res->Doc[row].category)?(Res->Doc[row].category):"",1);
859 #if UDM_VERSION_ID >= 30203
861 +#if UDM_VERSION_ID >= 30204
862 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Content-Language",""),1);
864 RETURN_STRING((Res->Doc[row].lang)?(Res->Doc[row].lang):"",1);
868 case UDM_FIELD_CHARSET:
869 +#if UDM_VERSION_ID >= 30204
870 + RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Charset",""),1);
872 RETURN_STRING((Res->Doc[row].charset)?(Res->Doc[row].charset):"",1);
877 @@ -1426,9 +1732,73 @@
878 RETURN_LONG(Res->total_found);
881 - case UDM_PARAM_WORDINFO:
882 + case UDM_PARAM_WORDINFO:
883 +#if UDM_VERSION_ID >= 30204
886 + for(len = i = 0; i < Res->WWList.nwords; i++)
887 + len += Res->WWList.Word[i].len;
889 + size_t wsize=(1+len*15)*sizeof(char);
890 + char *wordinfo = (char*) malloc(wsize);
891 + int corder = -1, ccount = 0;
895 + for(i = 0; i < Res->WWList.nwords; i++){
896 + if ((Res->WWList.Word[i].count > 0) || (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_QUERY)) {
897 + if(wordinfo[0]) strcat(wordinfo,", ");
898 + sprintf(UDM_STREND(wordinfo)," %s : %d", Res->WWList.Word[i].word, Res->WWList.Word[i].count);
899 + } else if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_STOP) {
900 + if(wordinfo[0]) strcat(wordinfo,", ");
901 + sprintf(UDM_STREND(wordinfo)," %s : stopword", Res->WWList.Word[i].word);
904 + RETURN_STRING(wordinfo,1);
908 RETURN_STRING((Res->wordinfo)?(Res->wordinfo):"",1);
912 +#if UDM_VERSION_ID >= 30204
913 + case UDM_PARAM_WORDINFO_ALL:
916 + for(len = i = 0; i < Res->WWList.nwords; i++)
917 + len += Res->WWList.Word[i].len;
919 + size_t wsize=(1+len*15)*sizeof(char);
920 + char *wordinfo = (char*) malloc(wsize);
921 + int corder = -1, ccount = 0;
925 + for(i = 0; i < Res->WWList.nwords; i++){
926 + if (Res->WWList.Word[i].order != corder) {
928 + sprintf(UDM_STREND(wordinfo)," / %d, ", ccount);
930 + ccount = Res->WWList.Word[i].count;
931 + if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_STOP) {
932 + sprintf(UDM_STREND(wordinfo)," %s : stopword", Res->WWList.Word[i].word);
934 + sprintf(UDM_STREND(wordinfo)," %s : %d", Res->WWList.Word[i].word, Res->WWList.Word[i].count);
935 + corder = Res->WWList.Word[i].order;
938 + ccount += Res->WWList.Word[i].count;
941 + if (Res->WWList.nwords) {
942 + sprintf(UDM_STREND(wordinfo)," / %d", ccount);
944 + RETURN_STRING(wordinfo,1);
950 case UDM_PARAM_SEARCHTIME:
951 RETURN_DOUBLE(((double)Res->work_time)/1000);
952 @@ -1516,7 +1886,11 @@
955 ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link);
956 +#if UDM_VERSION_ID >= 30204
957 + RETURN_LONG(UdmEnvErrCode(Agent->Conf));
959 RETURN_LONG(UdmDBErrorCode(Agent->db));
964 @@ -1539,7 +1913,11 @@
967 ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link);
968 +#if UDM_VERSION_ID >= 30204
969 + RETURN_STRING((UdmEnvErrMsg(Agent->Conf))?(UdmEnvErrMsg(Agent->Conf)):"",1);
971 RETURN_STRING((UdmDBErrorMsg(Agent->db))?(UdmDBErrorMsg(Agent->db)):"",1);
976 @@ -1577,7 +1955,14 @@
977 convert_to_string_ex(yycat);
978 cat = Z_STRVAL_PP(yycat);
980 +#if UDM_VERSION_ID >= 30204
981 + if (NULL==(c=(UDM_CATEGORY *)malloc(sizeof(UDM_CATEGORY)))) RETURN_FALSE;
982 + if (NULL==(c->Category=malloc(sizeof(UDM_CATITEM)))) RETURN_FALSE;
983 + strncpy(c->addr,cat,sizeof(c->addr)-1);
984 + if(UdmCatAction(Agent,c,UDM_CAT_ACTION_LIST,Agent->Conf->db)){
986 if((c=UdmCatList(Agent,cat))){
988 if (array_init(return_value)==FAILURE) {
991 @@ -1586,15 +1971,30 @@
995 +#if UDM_VERSION_ID >= 30204
998 + for(i==0;i<c->ncategories;i++){
999 + snprintf(buf, UDMSTRSIZ, "%s%s",c->Category[i].link[0]?"@ ":"", c->Category[i].name);
1000 + add_next_index_string(return_value, c->Category[i].link[0]?c->Category[i].link:c->Category[i].path, 1);
1001 + add_next_index_string(return_value, buf, 1);
1007 snprintf(buf, UDMSTRSIZ, "%s%s",c->link[0]?"@ ":"", c->name);
1008 add_next_index_string(return_value, c->link[0]?c->link:c->path, 1);
1009 add_next_index_string(return_value, buf, 1);
1016 +#if UDM_VERSION_ID >= 30204
1017 + free(c->Category);
1024 @@ -1626,7 +2026,14 @@
1025 convert_to_string_ex(yycat);
1026 cat = Z_STRVAL_PP(yycat);
1028 +#if UDM_VERSION_ID >= 30204
1029 + if (NULL==(c=(UDM_CATEGORY *)malloc(sizeof(UDM_CATEGORY)))) RETURN_FALSE;
1030 + if (NULL==(c->Category=malloc(sizeof(UDM_CATITEM)))) RETURN_FALSE;
1031 + strncpy(c->addr,cat,sizeof(c->addr)-1);
1032 + if(UdmCatAction(Agent,c,UDM_CAT_ACTION_PATH,Agent->Conf->db)){
1034 if((c=UdmCatPath(Agent,cat))){
1036 if (array_init(return_value)==FAILURE) {
1039 @@ -1635,14 +2042,29 @@
1043 +#if UDM_VERSION_ID >= 30204
1046 + for(i==0;i<c->ncategories;i++){
1047 + snprintf(buf, UDMSTRSIZ, "%s%s",c->Category[i].link[0]?"@ ":"", c->Category[i].name);
1048 + add_next_index_string(return_value, c->Category[i].link[0]?c->Category[i].link:c->Category[i].path, 1);
1049 + add_next_index_string(return_value, buf, 1);
1055 snprintf(buf, UDMSTRSIZ, "%s%s",c->link[0]?"@ ":"", c->name);
1056 add_next_index_string(return_value, c->link[0]?c->link:c->path, 1);
1057 add_next_index_string(return_value, buf, 1);
1063 +#if UDM_VERSION_ID >= 30204
1064 + free(c->Category);
1070 @@ -1670,7 +2092,11 @@
1073 ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link);
1074 +#if UDM_VERSION_ID >= 30204
1075 + RETURN_LONG(UdmURLAction(Agent,NULL,UDM_URL_ACTION_DOCCOUNT,Agent->Conf->db));
1077 RETURN_LONG(UdmGetDocCount(Agent));
1082 diff -ur php-4.2.2/ext/mnogosearch.orig/php_mnogo.h php-4.2.2/ext/mnogosearch/php_mnogo.h
1083 --- php-4.2.2/ext/mnogosearch.orig/php_mnogo.h Thu Feb 28 09:26:23 2002
1084 +++ php-4.2.2/ext/mnogosearch/php_mnogo.h Thu Jun 6 07:45:45 2002
1091 +----------------------------------------------------------------------+
1093 DLEXPORT PHP_FUNCTION(udm_api_version);
1094 #if UDM_VERSION_ID >= 30200
1095 DLEXPORT PHP_FUNCTION(udm_check_charset);
1098 -#if UDM_VERSION_ID >= 30203
1099 -DLEXPORT PHP_FUNCTION(udm_crc32);
1100 +#if UDM_VERSION_ID == 30203
1101 DLEXPORT PHP_FUNCTION(udm_open_stored);
1102 DLEXPORT PHP_FUNCTION(udm_check_stored);
1103 DLEXPORT PHP_FUNCTION(udm_close_stored);
1105 +#if UDM_VERSION_ID >= 30203
1106 +DLEXPORT PHP_FUNCTION(udm_crc32);
1108 +#if UDM_VERSION_ID >= 30204
1109 +DLEXPORT PHP_FUNCTION(udm_parse_query_string);
1113 DLEXPORT PHP_FUNCTION(udm_alloc_agent);
1114 DLEXPORT PHP_FUNCTION(udm_set_agent_param);