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

From: Date: Mon, 30 Apr 2001 11:11:19 +0000
Subject: cvs: php4 /ext/mnogosearch php_mnogo.c php_mnogo.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5382@lists.php.net to get a copy of this message
gluke Mon Apr 30 04:11:19 2001 EDT Modified files: /php4/ext/mnogosearch php_mnogo.c php_mnogo.h Log: Udm_Cat_List and Udm_Cat_Path functions has been added. @ Udm_Cat_List and Udm_Cat_Path functions has been added. Index: php4/ext/mnogosearch/php_mnogo.c diff -u php4/ext/mnogosearch/php_mnogo.c:1.24 php4/ext/mnogosearch/php_mnogo.c:1.25 --- php4/ext/mnogosearch/php_mnogo.c:1.24 Mon Apr 30 01:57:40 2001 +++ php4/ext/mnogosearch/php_mnogo.c Mon Apr 30 04:11:17 2001 @@ -1,5 +1,5 @@ /* $Source: /local/repository/php4/ext/mnogosearch/php_mnogo.c,v $ */ -/* $Id: php_mnogo.c,v 1.24 2001/04/30 08:57:40 gluke Exp $ */ +/* $Id: php_mnogo.c,v 1.25 2001/04/30 11:11:17 gluke Exp $ */ /* +----------------------------------------------------------------------+ @@ -123,6 +123,9 @@ PHP_FE(udm_get_res_param, NULL) PHP_FE(udm_get_res_field, NULL) + PHP_FE(udm_cat_list, NULL) + PHP_FE(udm_cat_path, NULL) + PHP_FE(udm_free_res, NULL) PHP_FE(udm_free_agent, NULL) @@ -1111,6 +1114,104 @@ DLEXPORT PHP_FUNCTION(udm_api_version) { RETURN_LONG(UDM_VERSION_ID); +} +/* }}} */ + + +/* {{{ proto array udm_cat_list(int agent, string category) + Get mnoGoSearch categories list with the same root */ +DLEXPORT PHP_FUNCTION(udm_cat_list) +{ + pval ** yycat, ** yyagent; + UDM_AGENT * Agent; + char *cat; + UDM_CATEGORY *c=NULL; + char *buf=NULL; + int id=-1; + + switch(ZEND_NUM_ARGS()){ + case 2: { + if (zend_get_parameters_ex(2, &yyagent,&yycat)==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(yycat); + cat = (*yycat)->value.str.val; + + if((c=UdmCatList(Agent,cat))){ + if (array_init(return_value)==FAILURE) { + RETURN_FALSE; + } + + if (!(buf=calloc(1,UDMSTRSIZ+1))) { + RETURN_FALSE; + } + + while(c->rec_id){ + snprintf(buf, UDMSTRSIZ, "%s%s",c->link[0]?"@ ":"", c->name); + add_assoc_string(return_value, c->link[0]?c->link:c->path, buf, 1); + c++; + } + + free(buf); + } else { + RETURN_FALSE; + } +} +/* }}} */ + + +/* {{{ proto array udm_cat_path(int agent, string category) + Get mnoGoSearch categories path from the root to the given catgory */ +DLEXPORT PHP_FUNCTION(udm_cat_path) +{ + pval ** yycat, ** yyagent; + UDM_AGENT * Agent; + char *cat; + UDM_CATEGORY *c=NULL; + char *buf=NULL; + int id=-1; + + switch(ZEND_NUM_ARGS()){ + case 2: { + if (zend_get_parameters_ex(2, &yyagent,&yycat)==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(yycat); + cat = (*yycat)->value.str.val; + + if((c=UdmCatPath(Agent,cat))){ + if (array_init(return_value)==FAILURE) { + RETURN_FALSE; + } + + if (!(buf=calloc(1,UDMSTRSIZ+1))) { + RETURN_FALSE; + } + + while(c->rec_id){ + snprintf(buf, UDMSTRSIZ, "%s%s",c->link[0]?"@ ":"", c->name); + add_assoc_string(return_value, c->link[0]?c->link:c->path, buf, 1); + c++; + } + + free(buf); + } else { + RETURN_FALSE; + } } /* }}} */ Index: php4/ext/mnogosearch/php_mnogo.h diff -u php4/ext/mnogosearch/php_mnogo.h:1.8 php4/ext/mnogosearch/php_mnogo.h:1.9 --- php4/ext/mnogosearch/php_mnogo.h:1.8 Thu Mar 1 05:38:38 2001 +++ php4/ext/mnogosearch/php_mnogo.h Mon Apr 30 04:11:18 2001 @@ -1,5 +1,5 @@ /* $Source: /local/repository/php4/ext/mnogosearch/php_mnogo.h,v $ */ -/* $Id: php_mnogo.h,v 1.8 2001/03/01 13:38:38 gluke Exp $ */ +/* $Id: php_mnogo.h,v 1.9 2001/04/30 11:11:18 gluke Exp $ */ /* +----------------------------------------------------------------------+ @@ -66,6 +66,9 @@ DLEXPORT PHP_FUNCTION(udm_find); DLEXPORT PHP_FUNCTION(udm_get_res_field); DLEXPORT PHP_FUNCTION(udm_get_res_param); + +DLEXPORT PHP_FUNCTION(udm_cat_list); +DLEXPORT PHP_FUNCTION(udm_cat_path); DLEXPORT PHP_FUNCTION(udm_free_res); DLEXPORT PHP_FUNCTION(udm_free_agent);

« previous php.cvs (#5382) next »