]>
Commit | Line | Data |
---|---|---|
d0e2567a AM |
1 | diff -urN php-4.3.1.org/ext/mnogosearch/php_mnogo.c php-4.3.1/ext/mnogosearch/php_mnogo.c |
2 | --- php-4.3.1.org/ext/mnogosearch/php_mnogo.c Mon Feb 24 21:42:43 2003 | |
3 | +++ php-4.3.1/ext/mnogosearch/php_mnogo.c Mon Dec 16 20:17:09 2002 | |
4 | @@ -1,5 +1,5 @@ | |
5 | /* $Source$ */ | |
6 | -/* $Id$ */ | |
7 | +/* $Id$ */ | |
8 | ||
9 | /* | |
10 | +----------------------------------------------------------------------+ | |
11 | @@ -163,6 +163,8 @@ | |
12 | #if UDM_VERSION_ID >= 30204 | |
13 | PHP_FE(udm_parse_query_string, NULL) | |
14 | PHP_FE(udm_make_excerpt, NULL) | |
15 | + PHP_FE(udm_set_agent_param_ex, NULL) | |
16 | + PHP_FE(udm_get_res_field_ex, NULL) | |
17 | #endif | |
18 | #endif | |
19 | ||
20 | @@ -466,7 +468,9 @@ | |
21 | UdmVarListReplaceStr(&Env->Vars,"DBAddr",dbaddr); | |
22 | if(UDM_OK!=UdmDBSetAddr(Env->db,dbaddr,UDM_OPEN_MODE_READ)){ | |
23 | sprintf(Env->errstr,"Invalid DBAddr: '%s'",dbaddr); | |
24 | +#if UDM_VERSION_ID <= 30207 | |
25 | Env->errcode=1; | |
26 | +#endif | |
27 | php_error(E_WARNING,"%s(): Invalid DBAddr", get_active_function_name(TSRMLS_C)); | |
28 | RETURN_FALSE; | |
29 | } | |
30 | @@ -517,7 +521,9 @@ | |
31 | UdmVarListReplaceStr(&Env->Vars,"DBAddr",dbaddr); | |
32 | if(UDM_OK!=UdmDBSetAddr(Env->db,dbaddr,UDM_OPEN_MODE_READ)){ | |
33 | sprintf(Env->errstr,"Invalid DBAddr: '%s'",dbaddr); | |
34 | +#if UDM_VERSION_ID <= 30207 | |
35 | Env->errcode=1; | |
36 | +#endif | |
37 | php_error(E_WARNING,"%s(): Invalid DBAddr", get_active_function_name(TSRMLS_C)); | |
38 | RETURN_FALSE; | |
39 | } | |
40 | @@ -997,6 +1003,8 @@ | |
41 | case UDM_PARAM_VARDIR: | |
42 | #if UDM_VERSION_ID < 30200 | |
43 | udm_snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR); | |
44 | +#elif UDM_VERSION_ID >= 30208 | |
45 | + UdmVarListReplaceStr(&Agent->Conf->Vars,"Vardir",val); | |
46 | #elif UDM_VERSION_ID >= 30204 | |
47 | UdmVarListReplaceStr(&Agent->Conf->Vars,"Vardir",val); | |
48 | snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR); | |
49 | @@ -1665,6 +1673,106 @@ | |
50 | RETURN_TRUE; | |
51 | } | |
52 | /* }}} */ | |
53 | + | |
54 | +/* {{{ proto int udm_set_agent_param_ex(int agent, string var, string val) | |
55 | + Set mnoGoSearch agent session parameters extended */ | |
56 | +DLEXPORT PHP_FUNCTION(udm_set_agent_param_ex) | |
57 | +{ | |
58 | + pval **yyagent, **yyvar, **yyval; | |
59 | + char *val, *var; | |
60 | + UDM_AGENT * Agent; | |
61 | + | |
62 | + switch(ZEND_NUM_ARGS()){ | |
63 | + | |
64 | + case 3: | |
65 | + if(zend_get_parameters_ex(3,&yyagent,&yyvar,&yyval)==FAILURE){ | |
66 | + RETURN_FALSE; | |
67 | + } | |
68 | + convert_to_string_ex(yyvar); | |
69 | + convert_to_string_ex(yyval); | |
70 | + ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); | |
71 | + var = Z_STRVAL_PP(yyvar); | |
72 | + val = Z_STRVAL_PP(yyval); | |
73 | + | |
74 | + break; | |
75 | + | |
76 | + default: | |
77 | + WRONG_PARAM_COUNT; | |
78 | + break; | |
79 | + } | |
80 | + | |
81 | + UdmVarListReplaceStr(&Agent->Conf->Vars,var,val); | |
82 | + | |
83 | + if (!strcasecmp(var,"LocalCharset")) { | |
84 | + const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"LocalCharset","iso-8859-1"); | |
85 | + Agent->Conf->lcs=UdmGetCharSet(charset); | |
86 | + } else if (!strcasecmp(var,"BrowserCharset")) { | |
87 | + const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"BrowserCharset","iso-8859-1"); | |
88 | + Agent->Conf->bcs=UdmGetCharSet(charset); | |
89 | + } else if (!strcasecmp(var,"Synonym")) { | |
90 | + if (UdmSynonymListLoad(Agent->Conf,val)) { | |
91 | + php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C),Agent->Conf->errstr); | |
92 | + RETURN_FALSE; | |
93 | + } else UdmSynonymListSort(&(Agent->Conf->Synonyms)); | |
94 | + } else if (!strcasecmp(var,"Stopwordfile")) { | |
95 | + if (UdmStopListLoad(Agent->Conf,val)) { | |
96 | + php_error(E_WARNING, "%s(): %s", Agent->Conf->errstr, get_active_function_name(TSRMLS_C)); | |
97 | + RETURN_FALSE; | |
98 | + } | |
99 | + } else if (!strcasecmp(var,"MinWordLen")) { | |
100 | + Agent->Conf->WordParam.min_word_len=atoi(val); | |
101 | + } else if (!strcasecmp(var,"MaxWordLen")) { | |
102 | + Agent->Conf->WordParam.max_word_len=atoi(val); | |
103 | +#if UDM_VERSION_ID <= 30207 | |
104 | + } else if (!strcasecmp(var,"VarDir")) { | |
105 | + snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR); | |
106 | +#endif | |
107 | + } | |
108 | + | |
109 | + RETURN_TRUE; | |
110 | +} | |
111 | + | |
112 | +/* {{{ proto string udm_get_res_field_ex(int res, int row, string field) | |
113 | + Fetch mnoGoSearch result field */ | |
114 | +DLEXPORT PHP_FUNCTION(udm_get_res_field_ex) | |
115 | +{ | |
116 | + pval **yyres, **yyrow_num, **yyfield_name; | |
117 | + | |
118 | + UDM_RESULT * Res; | |
119 | + int row; | |
120 | + char *field; | |
121 | + | |
122 | + switch(ZEND_NUM_ARGS()){ | |
123 | + case 3: { | |
124 | + if (zend_get_parameters_ex(3, &yyres,&yyrow_num,&yyfield_name)==FAILURE){ | |
125 | + RETURN_FALSE; | |
126 | + } | |
127 | + convert_to_string_ex(yyrow_num); | |
128 | + convert_to_string_ex(yyfield_name); | |
129 | + field = Z_STRVAL_PP(yyfield_name); | |
130 | + row = atoi(Z_STRVAL_PP(yyrow_num)); | |
131 | + } | |
132 | + break; | |
133 | + default: | |
134 | + WRONG_PARAM_COUNT; | |
135 | + break; | |
136 | + } | |
137 | + | |
138 | + ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result", le_res); | |
139 | + if(row<Res->num_rows){ | |
140 | + if (!strcasecmp(field,"URL")) { | |
141 | + char *al; | |
142 | + al = (char *)MyRemoveHiLightDup((const char *)(UdmVarListFindStr(&(Res->Doc[row].Sections), field, ""))); | |
143 | + UdmVarListReplaceStr(&Res->Doc[row].Sections,field,al); | |
144 | + free(al); | |
145 | + } | |
146 | + RETURN_STRING((char *)UdmVarListFindStr(&Res->Doc[row].Sections,field,""),1); | |
147 | + } else { | |
148 | + php_error(E_WARNING,"%s(): row number too large", get_active_function_name(TSRMLS_C)); | |
149 | + RETURN_FALSE; | |
150 | + } | |
151 | +} | |
152 | +/* }}} */ | |
153 | #endif | |
154 | ||
155 | /* {{{ proto int udm_find(int agent, string query) | |
156 | @@ -2071,7 +2179,13 @@ | |
157 | break; | |
158 | } | |
159 | ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link); | |
160 | -#if UDM_VERSION_ID >= 30204 | |
161 | +#if UDM_VERSION_ID >= 30208 | |
162 | + if (UdmEnvErrMsg(Agent->Conf) && strlen(UdmEnvErrMsg(Agent->Conf))) { | |
163 | + RETURN_LONG(1); | |
164 | + } else { | |
165 | + RETURN_LONG(0); | |
166 | + } | |
167 | +#elif UDM_VERSION_ID >= 30204 | |
168 | RETURN_LONG(UdmEnvErrCode(Agent->Conf)); | |
169 | #else | |
170 | RETURN_LONG(UdmDBErrorCode(Agent->db)); | |
171 | diff -urN php-4.3.1.org/ext/mnogosearch/php_mnogo.h php-4.3.1/ext/mnogosearch/php_mnogo.h | |
172 | --- php-4.3.1.org/ext/mnogosearch/php_mnogo.h Mon Feb 24 21:42:43 2003 | |
173 | +++ php-4.3.1/ext/mnogosearch/php_mnogo.h Sun Nov 24 20:39:46 2002 | |
174 | @@ -1,5 +1,5 @@ | |
175 | /* $Source$ */ | |
176 | -/* $Id$ */ | |
177 | +/* $Id$ */ | |
178 | ||
179 | /* | |
180 | +----------------------------------------------------------------------+ | |
181 | @@ -68,6 +68,8 @@ | |
182 | #if UDM_VERSION_ID >= 30204 | |
183 | DLEXPORT PHP_FUNCTION(udm_parse_query_string); | |
184 | DLEXPORT PHP_FUNCTION(udm_make_excerpt); | |
185 | +DLEXPORT PHP_FUNCTION(udm_set_agent_param_ex); | |
186 | +DLEXPORT PHP_FUNCTION(udm_get_res_field_ex); | |
187 | #endif | |
188 | #endif | |
189 |