]> granicus.if.org Git - php/commitdiff
Udm_Cat_List and Udm_Cat_Path functions has been added.
authorSergey Kartashoff <gluke@php.net>
Mon, 30 Apr 2001 11:11:19 +0000 (11:11 +0000)
committerSergey Kartashoff <gluke@php.net>
Mon, 30 Apr 2001 11:11:19 +0000 (11:11 +0000)
@ Udm_Cat_List and Udm_Cat_Path functions has been added.

ext/mnogosearch/php_mnogo.c
ext/mnogosearch/php_mnogo.h

index 154cfe9935b066192dfb0dfeaedd6b0c9d1e975e..61feb1c5eaa4fea0c7675fd350d624831e2586b6 100644 (file)
@@ -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 */
index 948aca95229a24d719fa679928d558f8cd2c9745..07238754ad2926889d8a6b3334e68acbbf80bac5 100644 (file)
@@ -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);