cvs: php4 /ext/mnogosearch php_mnogo.c php_mnogo.h

From: Date: Mon, 05 Nov 2001 19:07:24 +0000
Subject: cvs: php4 /ext/mnogosearch php_mnogo.c php_mnogo.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8085@lists.php.net to get a copy of this message
gluke Mon Nov 5 14:07:24 2001 EDT Modified files: /php4/ext/mnogosearch php_mnogo.c php_mnogo.h Log: @- Added Udm_Check_Charset function (gluke) - Added Udm_Check_Charset function (gluke) Index: php4/ext/mnogosearch/php_mnogo.c diff -u php4/ext/mnogosearch/php_mnogo.c:1.42 php4/ext/mnogosearch/php_mnogo.c:1.43 --- php4/ext/mnogosearch/php_mnogo.c:1.42 Sat Nov 3 16:45:49 2001 +++ php4/ext/mnogosearch/php_mnogo.c Mon Nov 5 14:07:24 2001 @@ -1,5 +1,5 @@ /* $Source: /usr/repository/php4/ext/mnogosearch/php_mnogo.c,v $ */ -/* $Id: php_mnogo.c,v 1.42 2001/11/03 21:45:49 gluke Exp $ */ +/* $Id: php_mnogo.c,v 1.43 2001/11/05 19:07:24 gluke Exp $ */ /* +----------------------------------------------------------------------+ @@ -129,6 +129,9 @@ */ function_entry mnogosearch_functions[] = { PHP_FE(udm_api_version, NULL) +#if UDM_VERSION_ID >= 30200 + PHP_FE(udm_check_charset, NULL) +#endif PHP_FE(udm_alloc_agent, NULL) PHP_FE(udm_set_agent_param, NULL) @@ -753,12 +756,12 @@ } /* }}} */ -/* {{{ proto int udm_load_ispell_data(int agent, int var, string val1, string val2, int flag) +/* {{{ proto int udm_load_ispell_data(int agent, int var, string val1, [string charset], string val2, int flag) Load ispell data */ DLEXPORT PHP_FUNCTION(udm_load_ispell_data) { - pval **yyagent, **yyvar, **yyval1, **yyval2, **yyflag; - char *val1, *val2; + pval **yyagent, **yyvar, **yyval1, **yyval2, **yyflag, **yycharset ; + char *val1, *val2, *charset; int var, flag; UDM_AGENT * Agent; @@ -777,6 +780,25 @@ flag = Z_LVAL_PP(yyflag); val1 = Z_STRVAL_PP(yyval1); val2 = Z_STRVAL_PP(yyval2); + charset = "us-ascii"; + + break; + + case 6: + if(zend_get_parameters_ex(6,&yyagent,&yyvar,&yyval1,&yycharset,&yyval2,&yyflag)==FAILURE){ + RETURN_FALSE; + } + convert_to_long_ex(yyvar); + convert_to_long_ex(yyflag); + convert_to_string_ex(yyval1); + convert_to_string_ex(yyval2); + convert_to_string_ex(yycharset); + ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); + var = Z_LVAL_PP(yyvar); + flag = Z_LVAL_PP(yyflag); + val1 = Z_STRVAL_PP(yyval1); + val2 = Z_STRVAL_PP(yyval2); + charset = Z_STRVAL_PP(yycharset); break; @@ -785,8 +807,9 @@ break; } -#if UDM_VERSION_ID < 30200 + switch(var){ +#if UDM_VERSION_ID < 30200 case UDM_ISPELL_TYPE_DB: Agent->Conf->ispell_mode |= UDM_ISPELL_MODE_DB; @@ -794,10 +817,24 @@ UdmImportDictionaryFromDB(Agent)) { RETURN_FALSE; } - + break; +#if UDM_VERSION_ID > 30111 + + case UDM_ISPELL_TYPE_SERVER: + Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_DB; + Agent->Conf->ispell_mode |= UDM_ISPELL_MODE_SERVER; + + Agent->Conf->spellhost = strdup(val1); + + break; + +#endif +#endif + case UDM_ISPELL_TYPE_AFFIX: +#if UDM_VERSION_ID < 30200 Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_DB; #if UDM_VERSION_ID > 30111 @@ -808,10 +845,17 @@ php_error(E_WARNING,"Udm_Load_Ispell_Data: Cannot load affix file %s",val2); RETURN_FALSE; } - +#else + if (UdmImportAffixes(Agent->Conf,val1,charset,val2)) { + php_error(E_WARNING,"Udm_Load_Ispell_Data: Cannot load affix file %s",val2); + RETURN_FALSE; + } + +#endif break; case UDM_ISPELL_TYPE_SPELL: +#if UDM_VERSION_ID < 30200 Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_DB; #if UDM_VERSION_ID > 30111 @@ -822,20 +866,14 @@ php_error(E_WARNING,"Udm_Load_Ispell_Data: Cannot load spell file %s",val2); RETURN_FALSE; } - +#else + if (UdmImportDictionary(Agent->Conf,val1,charset,val2,0,"")) { + php_error(E_WARNING,"Udm_Load_Ispell_Data: Cannot load spell file %s",val2); + RETURN_FALSE; + } +#endif break; -#if UDM_VERSION_ID > 30111 - - case UDM_ISPELL_TYPE_SERVER: - Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_DB; - Agent->Conf->ispell_mode |= UDM_ISPELL_MODE_SERVER; - - Agent->Conf->spellhost = strdup(val1); - - break; - -#endif default: php_error(E_WARNING,"Udm_Load_Ispell_Data: Unknown ispell type parameter"); @@ -849,7 +887,6 @@ UdmSortAffixes(Agent->Conf); } } -#endif RETURN_TRUE; } @@ -981,6 +1018,39 @@ RETURN_TRUE; } /* }}} */ + +#if UDM_VERSION_ID >= 30200 +/* {{{ proto int udm_check_charset(int agent, string charset) + Check if the given charset is known to mnogosearch */ +DLEXPORT PHP_FUNCTION(udm_check_charset) +{ + pval ** yycharset, ** yyagent; + UDM_AGENT * Agent; + int id=-1; + + switch(ZEND_NUM_ARGS()){ + case 2: { + if (zend_get_parameters_ex(2, &yyagent,&yycharset)==FAILURE) { + RETURN_FALSE; + } + } + break; + default: + WRONG_PARAM_COUNT; + break; + } + ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); + convert_to_string_ex(yycharset); + + + if (UdmGetCharSet(Z_STRVAL_PP(yycharset))) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ +#endif /* {{{ proto int udm_find(int agent, string query) Perform search */ Index: php4/ext/mnogosearch/php_mnogo.h diff -u php4/ext/mnogosearch/php_mnogo.h:1.10 php4/ext/mnogosearch/php_mnogo.h:1.11 --- php4/ext/mnogosearch/php_mnogo.h:1.10 Mon Aug 20 04:31:29 2001 +++ php4/ext/mnogosearch/php_mnogo.h Mon Nov 5 14:07:24 2001 @@ -1,5 +1,5 @@ /* $Source: /usr/repository/php4/ext/mnogosearch/php_mnogo.h,v $ */ -/* $Id: php_mnogo.h,v 1.10 2001/08/20 08:31:29 gluke Exp $ */ +/* $Id: php_mnogo.h,v 1.11 2001/11/05 19:07:24 gluke Exp $ */ /* +----------------------------------------------------------------------+ @@ -50,6 +50,9 @@ DLEXPORT PHP_MINFO_FUNCTION(mnogosearch); DLEXPORT PHP_FUNCTION(udm_api_version); +#if UDM_VERSION_ID >= 30200 +DLEXPORT PHP_FUNCTION(udm_check_charset); +#endif DLEXPORT PHP_FUNCTION(udm_alloc_agent); DLEXPORT PHP_FUNCTION(udm_set_agent_param);

« previous php.cvs (#8085) next »