summaryrefslogtreecommitdiff
path: root/ext/mnogosearch
diff options
context:
space:
mode:
authorSergey Kartashoff <gluke@php.net>2001-04-30 11:11:19 +0000
committerSergey Kartashoff <gluke@php.net>2001-04-30 11:11:19 +0000
commita1eee04a1b29edafe74972bb9b812a2020dcae86 (patch)
treec97f5c05ec4effe35c3f09c3bf90e04074c71c5b /ext/mnogosearch
parentb120ab3986c2ea2b7cf8ca3961b6861fb5fac287 (diff)
downloadphp-git-a1eee04a1b29edafe74972bb9b812a2020dcae86.tar.gz
Udm_Cat_List and Udm_Cat_Path functions has been added.
@ Udm_Cat_List and Udm_Cat_Path functions has been added.
Diffstat (limited to 'ext/mnogosearch')
-rw-r--r--ext/mnogosearch/php_mnogo.c101
-rw-r--r--ext/mnogosearch/php_mnogo.h3
2 files changed, 104 insertions, 0 deletions
diff --git a/ext/mnogosearch/php_mnogo.c b/ext/mnogosearch/php_mnogo.c
index 154cfe9935..61feb1c5ea 100644
--- a/ext/mnogosearch/php_mnogo.c
+++ b/ext/mnogosearch/php_mnogo.c
@@ -123,6 +123,9 @@ function_entry mnogosearch_functions[] = {
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)
@@ -1115,6 +1118,104 @@ DLEXPORT PHP_FUNCTION(udm_api_version)
/* }}} */
+/* {{{ 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;
+ }
+}
+/* }}} */
+
+
#if UDM_VERSION_ID > 30110
/* {{{ proto int udm_get_doc_count(int agent)
Get total number of documents in database */
diff --git a/ext/mnogosearch/php_mnogo.h b/ext/mnogosearch/php_mnogo.h
index 948aca9522..07238754ad 100644
--- a/ext/mnogosearch/php_mnogo.h
+++ b/ext/mnogosearch/php_mnogo.h
@@ -67,6 +67,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);