gluke Mon Feb 5 05:12:15 2001 EDT Modified files: /php4/ext/mnogosearch README php_mnogo.c php_mnogo.h test.php Log: Added new Udm_Add_Search_Limit mnoGoSearch extension function. Some bugfixes and example update. @- Added new Udm_Add_Search_Limit mnoGoSearch extension function. @ Some bugfixes and example update. (gluke) Index: php4/ext/mnogosearch/README diff -u php4/ext/mnogosearch/README:1.4 php4/ext/mnogosearch/README:1.5 --- php4/ext/mnogosearch/README:1.4 Mon Feb 5 00:42:53 2001 +++ php4/ext/mnogosearch/README Mon Feb 5 05:12:15 2001 @@ -1,8 +1,8 @@ $Source: /local/repository/php4/ext/mnogosearch/README,v $ -$Id: README,v 1.4 2001/02/05 08:42:53 gluke Exp $ +$Id: README,v 1.5 2001/02/05 13:12:15 gluke Exp $ mnoGoSearch extension module for PHP4. -Basic mnoGoSearch function implementation. +mnoGoSearch function implementation. If used with mysql you should not use bundled mysql library in the php distribution. You should use native mysql @@ -12,7 +12,7 @@ TODO ---- -1. Implement more mnoGoSearch functions. +1. Implement all mnoGoSearch functions. 2. Fix config.m4 to detect whether mnoGoSearch is actually installed. Currently there is no any checking. ./configure just trust that mnoGoSearch Index: php4/ext/mnogosearch/php_mnogo.c diff -u php4/ext/mnogosearch/php_mnogo.c:1.6 php4/ext/mnogosearch/php_mnogo.c:1.7 --- php4/ext/mnogosearch/php_mnogo.c:1.6 Mon Feb 5 00:42:53 2001 +++ php4/ext/mnogosearch/php_mnogo.c Mon Feb 5 05:12:15 2001 @@ -1,5 +1,5 @@ /* $Source: /local/repository/php4/ext/mnogosearch/php_mnogo.c,v $ */ -/* $Id: php_mnogo.c,v 1.6 2001/02/05 08:42:53 gluke Exp $ */ +/* $Id: php_mnogo.c,v 1.7 2001/02/05 13:12:15 gluke Exp $ */ /* +----------------------------------------------------------------------+ @@ -51,6 +51,12 @@ #define UDM_PARAM_STOPTABLE 7 #define UDM_PARAM_STOPFILE 8 +/* udm_add_search_limit constants */ +#define UDM_LIMIT_URL 1 +#define UDM_LIMIT_TAG 2 +#define UDM_LIMIT_LANG 3 +#define UDM_LIMIT_CAT 4 + #define UDM_TRACK_ENABLED 1 #define UDM_TRACK_DISABLED 0 @@ -66,6 +72,7 @@ function_entry mnogosearch_functions[] = { PHP_FE(udm_alloc_agent, NULL) PHP_FE(udm_set_agent_param, NULL) + PHP_FE(udm_add_search_limit, NULL) PHP_FE(udm_free_agent, NULL) PHP_FE(udm_errno, NULL) @@ -133,6 +140,12 @@ 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_add_search_limit constants */ + REGISTER_LONG_CONSTANT("UDM_LIMIT_CAT",UDM_LIMIT_CAT,CONST_CS | +CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("UDM_LIMIT_URL",UDM_LIMIT_URL,CONST_CS | +CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("UDM_LIMIT_TAG",UDM_LIMIT_TAG,CONST_CS | +CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("UDM_LIMIT_LANG",UDM_LIMIT_LANG,CONST_CS | +CONST_PERSISTENT); + /* udm_get_res_param constants */ REGISTER_LONG_CONSTANT("UDM_PARAM_FOUND",UDM_PARAM_FOUND,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("UDM_PARAM_NUM_ROWS",UDM_PARAM_NUM_ROWS,CONST_CS | CONST_PERSISTENT); @@ -353,8 +366,67 @@ break; + default: + php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown agent +session parameter"); + RETURN_FALSE; + break; + } + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int udm_add_search_limit(int agent, int var, string val) + Add mnoGoSearch search restrictions */ +DLEXPORT PHP_FUNCTION(udm_add_search_limit) +{ + pval **yyagent, **yyvar, **yyval; + char *val; + int var; + UDM_AGENT * Agent; + + switch(ZEND_NUM_ARGS()){ + + case 3: + if(zend_get_parameters_ex(3,&yyagent,&yyvar,&yyval)==FAILURE){ + RETURN_FALSE; + } + convert_to_long_ex(yyvar); + convert_to_string_ex(yyval); + ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, +"mnoGoSearch-agent", le_link); + var = (*yyvar)->value.lval; + val = (*yyval)->value.str.val; + + break; + + default: + WRONG_PARAM_COUNT; + break; + } + + switch(var){ + case UDM_LIMIT_URL: + UdmAddURLLimit(Agent->Conf,val); + + break; + + case UDM_LIMIT_TAG: + UdmAddTagLimit(Agent->Conf,val); + + break; + + case UDM_LIMIT_LANG: + UdmAddLangLimit(Agent->Conf,val); + + break; + + case UDM_LIMIT_CAT: + UdmAddCatLimit(Agent->Conf,val); + + break; + default: - php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown agent parameter"); + php_error(E_WARNING,"Udm_Add_Search_Limit: Unknown search +limit parameter"); RETURN_FALSE; break; } Index: php4/ext/mnogosearch/php_mnogo.h diff -u php4/ext/mnogosearch/php_mnogo.h:1.3 php4/ext/mnogosearch/php_mnogo.h:1.4 --- php4/ext/mnogosearch/php_mnogo.h:1.3 Mon Feb 5 00:42:53 2001 +++ php4/ext/mnogosearch/php_mnogo.h Mon Feb 5 05:12:15 2001 @@ -1,5 +1,5 @@ /* $Source: /local/repository/php4/ext/mnogosearch/php_mnogo.h,v $ */ -/* $Id: php_mnogo.h,v 1.3 2001/02/05 08:42:53 gluke Exp $ */ +/* $Id: php_mnogo.h,v 1.4 2001/02/05 13:12:15 gluke Exp $ */ /* +----------------------------------------------------------------------+ @@ -48,6 +48,7 @@ DLEXPORT PHP_FUNCTION(udm_alloc_agent); DLEXPORT PHP_FUNCTION(udm_set_agent_param); +DLEXPORT PHP_FUNCTION(udm_add_search_limit); DLEXPORT PHP_FUNCTION(udm_free_agent); DLEXPORT PHP_FUNCTION(udm_error); Index: php4/ext/mnogosearch/test.php diff -u php4/ext/mnogosearch/test.php:1.4 php4/ext/mnogosearch/test.php:1.5 --- php4/ext/mnogosearch/test.php:1.4 Fri Feb 2 04:54:14 2001 +++ php4/ext/mnogosearch/test.php Mon Feb 5 05:12:15 2001 @@ -1,6 +1,6 @@ <!-- $Source: /local/repository/php4/ext/mnogosearch/test.php,v $ - $Id: test.php,v 1.4 2001/02/02 12:54:14 gluke Exp $ + $Id: test.php,v 1.5 2001/02/05 13:12:15 gluke Exp $ --> <html> @@ -35,14 +35,20 @@ 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_STOPTABLE,"stopword"); // Udm_Set_Agent_Param($udm,UDM_PARAM_STOPFILE,"stop.txt"); + +// Stage 3: add search limits +// Udm_Add_Search_Limit($udm,UDM_LIMIT_URL,"http://www.mydomain.com/%"); +// Udm_Add_Search_Limit($udm,UDM_LIMIT_TAG,"01"); +// Udm_Add_Search_Limit($udm,UDM_LIMIT_CAT,"01"); +// Udm_Add_Search_Limit($udm,UDM_LIMIT_LANG,"en"); -// Stage 3: perform search +// Stage 4: perform search $res=Udm_Find($udm,$q); -// Stage 4: display results +// Stage 5: display results // Check error code if(($errno=Udm_Errno($udm))>0){ @@ -77,7 +83,7 @@ Udm_Free_Res($res); } -//Stage 5: free UdmSearch agent +//Stage 6: free UdmSearch agent Udm_Free_Agent($udm); ?> -- 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]