gluke Fri Feb 2 04:54:15 2001 EDT
Modified files:
/php4/ext/mnogosearch README php_mnogo.c test.php
Log:
Added new UDM_PARAM_STOPTABLE and UDM_PARAM_STOPFILE parameters
for Udm_Set_Agent_Params mnoGoSearch module. Now it can use stopwords
stored either in database or in the plain text files. Added php warnings.
Test example updated.
@- Added new UDM_PARAM_STOPTABLE and UDM_PARAM_STOPFILE parameters
@ for Udm_Set_Agent_Params mnoGoSearch module. Now it can use stopwords
@ stored either in database or in the plain text files. Added php warnings.
@ Test example updated. (gluke)
Index: php4/ext/mnogosearch/README
diff -u php4/ext/mnogosearch/README:1.2 php4/ext/mnogosearch/README:1.3
--- php4/ext/mnogosearch/README:1.2 Wed Jan 31 06:04:29 2001
+++ php4/ext/mnogosearch/README Fri Feb 2 04:54:14 2001
@@ -1,7 +1,7 @@
$Source: /local/repository/php4/ext/mnogosearch/README,v $
-$Id: README,v 1.2 2001/01/31 14:04:29 gluke Exp $
+$Id: README,v 1.3 2001/02/02 12:54:14 gluke Exp $
-mnoGoSearch extension module version 0.3 for PHP4.
+mnoGoSearch extension module for PHP4.
Basic mnoGoSearch function implementation.
If used with mysql you should not use bundled mysql library
@@ -12,8 +12,7 @@
TODO
----
-1. Implement more UdmSearch functions. Only basic minimal functions
-set is implemented for now.
+1. Implement more UdmSearch functions.
2. Fix config.m4 to detect whether UdmSearch is actually installed.
Currently there is no any checking. ./configure just trust that UdmSearch
@@ -24,6 +23,3 @@
Actually it should work fine with other supported database.
4. Write PHP interface documentation.
-
-5. Add nice warnings when unknown parameters are passed to PHP functions.
-Those places are marked with FIXME is php_udm.c
Index: php4/ext/mnogosearch/php_mnogo.c
diff -u php4/ext/mnogosearch/php_mnogo.c:1.3 php4/ext/mnogosearch/php_mnogo.c:1.4
--- php4/ext/mnogosearch/php_mnogo.c:1.3 Thu Feb 1 05:06:25 2001
+++ php4/ext/mnogosearch/php_mnogo.c Fri Feb 2 04:54:14 2001
@@ -1,5 +1,5 @@
/* $Source: /local/repository/php4/ext/mnogosearch/php_mnogo.c,v $ */
-/* $Id: php_mnogo.c,v 1.3 2001/02/01 13:06:25 gluke Exp $ */
+/* $Id: php_mnogo.c,v 1.4 2001/02/02 12:54:14 gluke Exp $ */
/*
+----------------------------------------------------------------------+
@@ -48,6 +48,8 @@
#define UDM_PARAM_CACHE_MODE 4
#define UDM_PARAM_TRACK_MODE 5
#define UDM_PARAM_CHARSET 6
+#define UDM_PARAM_STOPTABLE 7
+#define UDM_PARAM_STOPFILE 8
#define UDM_TRACK_ENABLED 1
#define UDM_TRACK_DISABLED 0
@@ -128,6 +130,8 @@
REGISTER_LONG_CONSTANT("UDM_PARAM_CACHE_MODE",UDM_PARAM_CACHE_MODE,CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_TRACK_MODE",UDM_PARAM_TRACK_MODE,CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_CHARSET",UDM_PARAM_CHARSET,CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_PARAM_STOPTABLE",UDM_PARAM_STOPTABLE,CONST_CS |
+CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_PARAM_STOPFILE",UDM_PARAM_STOPFILE,CONST_CS |
+CONST_PERSISTENT);
/* udm_get_res_param constants */
REGISTER_LONG_CONSTANT("UDM_PARAM_FOUND",UDM_PARAM_FOUND,CONST_CS |
CONST_PERSISTENT);
@@ -285,7 +289,8 @@
break;
default:
- RETURN_STRING("<Udm_Set_Agent_Param:
Unknown search mode>",1);
+
+php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown search mode");
+ RETURN_FALSE;
break;
}
@@ -303,7 +308,8 @@
default:
Agent->cache_mode=UDM_CACHE_DISABLED;
- RETURN_STRING("<Udm_Set_Agent_Param: Unknown
cache mode>",1);
+ php_error(E_WARNING,"Udm_Set_Agent_Param:
+Unknown cache mode");
+ RETURN_FALSE;
break;
}
@@ -320,7 +326,8 @@
break;
default:
- RETURN_STRING("<Udm_Set_Agent_Param: Unknown
track_mode>",1);
+ php_error(E_WARNING,"Udm_Set_Agent_Param:
+Unknown track mode");
+ RETURN_FALSE;
break;
}
@@ -332,34 +339,26 @@
break;
- default:
- RETURN_STRING("<Udm_Set_Agent_Param: Unknown agent
parameter>",1);
- break;
- }
-}
-/* }}} */
+ case UDM_PARAM_STOPTABLE:
+ strcat(Agent->Conf->stop_tables," ");
+ strcat(Agent->Conf->stop_tables,val);
-
+ break;
-/* {{{ proto int udm_free_agent(int agent_identifier)
- Free mnoGoSearch session */
-DLEXPORT PHP_FUNCTION(udm_free_agent)
-{
- pval ** yyagent;
- UDM_RESULT * Agent;
- switch(ZEND_NUM_ARGS()){
- case 1: {
- if (zend_get_parameters_ex(1, &yyagent)==FAILURE) {
- RETURN_FALSE;
- }
+ case UDM_PARAM_STOPFILE:
+ if (UdmFileLoadStopList(Agent->Conf,val)) {
+ php_error(E_WARNING,Agent->Conf->errstr);
+ RETURN_FALSE;
}
+
break;
+
default:
- WRONG_PARAM_COUNT;
+ php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown agent
+parameter");
+ RETURN_FALSE;
break;
}
- ZEND_FETCH_RESOURCE(Agent, UDM_RESULT *, yyagent, -1, "mnoGoSearch-agent",
le_link);
- zend_list_delete((*yyagent)->value.lval);
+ RETURN_TRUE;
}
/* }}} */
@@ -429,15 +428,51 @@
case UDM_FIELD_SCORE:
RETURN_LONG((Res->Doc[row].rating));break;
case UDM_FIELD_MODIFIED:
RETURN_LONG((Res->Doc[row].last_mod_time));break;
default:
- RETURN_STRING("<Udm_Get_Res_Field: Unknown mnoGoSearch
field name>",1);break;
+ php_error(E_WARNING,"Udm_Get_Res_Field: Unknown
+mnoGoSearch field name");
+ RETURN_FALSE;
+ break;
}
}else{
- RETURN_STRING("<Udm_Get_Res_Field: row number too large>",1);
+ php_error(E_WARNING,"Udm_Get_Res_Field: row number too large");
+ RETURN_FALSE;
}
}
/* }}} */
+/* {{{ proto int udm_get_res_param(int res_identifier, const int param_id)
+ mnoGoSearch result parameters */
+DLEXPORT PHP_FUNCTION(udm_get_res_param)
+{
+ pval ** yyres, ** yyparam;
+ int param;
+ UDM_RESULT * Res;
+ switch(ZEND_NUM_ARGS()){
+ case 2: {
+ if (zend_get_parameters_ex(2, &yyres,
+&yyparam)==FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_long_ex(yyparam);
+ param=((*yyparam)->value.lval);
+ }
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+ ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result",
+le_res);
+ switch(param){
+ case UDM_PARAM_NUM_ROWS: RETURN_LONG(Res->num_rows);break;
+ case UDM_PARAM_FOUND: RETURN_LONG(Res->total_found);break;
+ default:
+ php_error(E_WARNING,"Udm_Get_Res_Param: Unknown mnoGoSearch
+param name");
+ RETURN_FALSE;
+ break;
+ }
+}
+/* }}} */
+
+
/* {{{ proto int udm_free_res(int res_identifier)
mnoGoSearch free result */
DLEXPORT PHP_FUNCTION(udm_free_res)
@@ -462,13 +497,12 @@
/* }}} */
-/* {{{ proto int udm_error(int agent_identifier)
- mnoGoSearch error message */
-DLEXPORT PHP_FUNCTION(udm_error)
+/* {{{ proto int udm_errno(int agent_identifier)
+ mnoGoSearch error number */
+DLEXPORT PHP_FUNCTION(udm_errno)
{
pval ** yyagent;
UDM_AGENT * Agent;
-
switch(ZEND_NUM_ARGS()){
case 1: {
if (zend_get_parameters_ex(1, &yyagent)==FAILURE) {
@@ -481,16 +515,18 @@
break;
}
ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent",
le_link);
- RETURN_STRING(UdmDBErrorMsg(Agent->db),1);
+ RETURN_LONG(UdmDBErrorCode(Agent->db));
}
/* }}} */
-/* {{{ proto int udm_errno(int agent_identifier)
- mnoGoSearch error number */
-DLEXPORT PHP_FUNCTION(udm_errno)
+
+/* {{{ proto int udm_error(int agent_identifier)
+ mnoGoSearch error message */
+DLEXPORT PHP_FUNCTION(udm_error)
{
pval ** yyagent;
UDM_AGENT * Agent;
+
switch(ZEND_NUM_ARGS()){
case 1: {
if (zend_get_parameters_ex(1, &yyagent)==FAILURE) {
@@ -503,42 +539,33 @@
break;
}
ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent",
le_link);
- RETURN_LONG(UdmDBErrorCode(Agent->db));
+ RETURN_STRING(UdmDBErrorMsg(Agent->db),1);
}
/* }}} */
-/* {{{ proto int udm_get_res_param(int res_identifier, const int param_id)
- mnoGoSearch result parameters */
-DLEXPORT PHP_FUNCTION(udm_get_res_param)
+/* {{{ proto int udm_free_agent(int agent_identifier)
+ Free mnoGoSearch session */
+DLEXPORT PHP_FUNCTION(udm_free_agent)
{
- pval ** yyres, ** yyparam;
- int param;
- UDM_RESULT * Res;
+ pval ** yyagent;
+ UDM_RESULT * Agent;
switch(ZEND_NUM_ARGS()){
- case 2: {
- if (zend_get_parameters_ex(2, &yyres,
&yyparam)==FAILURE) {
+ case 1: {
+ if (zend_get_parameters_ex(1, &yyagent)==FAILURE) {
RETURN_FALSE;
}
- convert_to_long_ex(yyparam);
- param=((*yyparam)->value.lval);
}
break;
default:
WRONG_PARAM_COUNT;
break;
- }
- ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result",
le_res);
- switch(param){
- case UDM_PARAM_NUM_ROWS: RETURN_LONG(Res->num_rows);break;
- case UDM_PARAM_FOUND: RETURN_LONG(Res->total_found);break;
- default:
- /* FIXME: unknown parameter */
- RETURN_STRING("<Udm_Get_Res_Param: Unknown mnoGoSearch param
name>",1);
- break;
}
+ ZEND_FETCH_RESOURCE(Agent, UDM_RESULT *, yyagent, -1, "mnoGoSearch-agent",
+le_link);
+ zend_list_delete((*yyagent)->value.lval);
}
/* }}} */
+
#endif
Index: php4/ext/mnogosearch/test.php
diff -u php4/ext/mnogosearch/test.php:1.3 php4/ext/mnogosearch/test.php:1.4
--- php4/ext/mnogosearch/test.php:1.3 Thu Feb 1 05:06:25 2001
+++ php4/ext/mnogosearch/test.php Fri Feb 2 04:54:14 2001
@@ -1,6 +1,6 @@
<!--
$Source: /local/repository/php4/ext/mnogosearch/test.php,v $
- $Id: test.php,v 1.3 2001/02/01 13:06:25 gluke Exp $
+ $Id: test.php,v 1.4 2001/02/02 12:54:14 gluke Exp $
-->
<html>
@@ -35,6 +35,8 @@
Udm_Set_Agent_Param($udm,UDM_PARAM_CACHE_MODE,UDM_CACHE_DISABLED);
Udm_Set_Agent_Param($udm,UDM_PARAM_TRACK_MODE,UDM_TRACK_DISABLED);
Udm_Set_Agent_Param($udm,UDM_PARAM_CHARSET,"koi8-r");
+ Udm_Set_Agent_Param($udm,UDM_PARAM_STOPTABLE,"stopwords");
+// Udm_Set_Agent_Param($udm,UDM_PARAM_STOPFILE,"stop.txt");
// Stage 3: perform search
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]