gluke           Sat May  8 07:50:37 2004 EDT

  Modified files:              
    /php-src/ext/mnogosearch    php_mnogo.c php_mnogo.h 
  Log:
  - mnoGoSearch extension was updated to support CachedCopies of 
    mnogosearch-3.2.16 or later. Udm_Get_Agent_Param and
    Udm_Store_Doc_Cgi functions were added. MnoGoSearch-3.2.3 stored API
    was removed.
  
  
http://cvs.php.net/diff.php/php-src/ext/mnogosearch/php_mnogo.c?r1=1.87&r2=1.88&ty=u
Index: php-src/ext/mnogosearch/php_mnogo.c
diff -u php-src/ext/mnogosearch/php_mnogo.c:1.87 
php-src/ext/mnogosearch/php_mnogo.c:1.88
--- php-src/ext/mnogosearch/php_mnogo.c:1.87    Mon Feb 16 11:11:55 2004
+++ php-src/ext/mnogosearch/php_mnogo.c Sat May  8 07:50:36 2004
@@ -1,11 +1,11 @@
 /* $Source: /repository/php-src/ext/mnogosearch/php_mnogo.c,v $ */
-/* $Id: php_mnogo.c,v 1.87 2004/02/16 16:11:55 gluke Exp $ */
+/* $Id: php_mnogo.c,v 1.88 2004/05/08 11:50:36 gluke Exp $ */
 
 /*
    +----------------------------------------------------------------------+
-   | PHP Version 5                                                        |
+   | PHP Version 4                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2004 The PHP Group                                |
+   | Copyright (c) 1997-2003 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.0 of the PHP license,       |
    | that is bundled with this package in the file LICENSE, and is        |
@@ -77,7 +77,7 @@
 #define UDM_PARAM_HLBEG                        19
 #define UDM_PARAM_HLEND                        20
 #define UDM_PARAM_SYNONYM              21
-#define UDM_PARAM_SEARCHD              22
+#define UDM_PARAM_SEARCHD              22      /* unused */
 #define UDM_PARAM_QSTRING              23
 #define UDM_PARAM_REMOTE_ADDR          24
 #define UDM_PARAM_QUERY                        25
@@ -156,11 +156,6 @@
 
 #if UDM_VERSION_ID >= 30200                    
        PHP_FE(udm_check_charset,       NULL)
-#if UDM_VERSION_ID == 30203
-       PHP_FE(udm_open_stored, NULL)
-       PHP_FE(udm_check_stored,NULL)
-       PHP_FE(udm_close_stored,NULL)
-#endif
 #if UDM_VERSION_ID >= 30203
        PHP_FE(udm_crc32,       NULL)
 #endif
@@ -168,12 +163,16 @@
        PHP_FE(udm_parse_query_string,  NULL)
        PHP_FE(udm_make_excerpt,        NULL)
        PHP_FE(udm_set_agent_param_ex,  NULL)
+       PHP_FE(udm_get_agent_param_ex,  NULL)
        PHP_FE(udm_get_res_field_ex,    NULL)
 #endif
 #if UDM_VERSION_ID >= 30211
        PHP_FE(udm_hash32,              NULL)
        PHP_FE(udm_alloc_agent_array,   NULL)
 #endif
+#if UDM_VERSION_ID >= 30216
+       PHP_FE(udm_store_doc_cgi,       NULL)
+#endif
 #endif
 
        PHP_FE(udm_alloc_agent,         NULL)
@@ -317,7 +316,6 @@
        REGISTER_LONG_CONSTANT("UDM_PARAM_HLEND",       UDM_PARAM_HLEND,CONST_CS | 
CONST_PERSISTENT);   
        
        REGISTER_LONG_CONSTANT("UDM_PARAM_SYNONYM",     UDM_PARAM_SYNONYM,CONST_CS | 
CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("UDM_PARAM_SEARCHD",     UDM_PARAM_SEARCHD,CONST_CS | 
CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("UDM_PARAM_STORED",      UDM_PARAM_STORED,CONST_CS | 
CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("UDM_PARAM_GROUPBYSITE", UDM_PARAM_GROUPBYSITE,CONST_CS 
| CONST_PERSISTENT);
        
@@ -908,18 +906,6 @@
 #endif                 
                        break;
                        
-               case UDM_PARAM_SEARCHD:
-#if UDM_VERSION_ID <= 30203
-                       UdmSDCLientListAdd(&(Agent->Conf->sdcl),val);
-                       {
-                               size_t i;
-                               for(i=0;i<Agent->Conf->sdcl.nclients;i++){
-                                       
UdmSDCLientListAdd(&Agent->sdcl,Agent->Conf->sdcl.Clients[i].addr);
-                               }
-                       }
-#endif                 
-                       break;
-
                case UDM_PARAM_QSTRING:
 #if UDM_VERSION_ID >= 30204
                        UdmVarListReplaceStr(&Agent->Conf->Vars,"QUERY_STRING",val);
@@ -1472,6 +1458,7 @@
                if ((!strcasecmp("ul",Agent->Conf->Vars.Var[i].name))||
                    (!strcasecmp("cat",Agent->Conf->Vars.Var[i].name))||
                    (!strcasecmp("t",Agent->Conf->Vars.Var[i].name))||
+                   (!strcasecmp("type",Agent->Conf->Vars.Var[i].name))||
                    (!strcasecmp("lang",Agent->Conf->Vars.Var[i].name))) {
                    UDM_FREE(Agent->Conf->Vars.Var[i].name);
                    UDM_FREE(Agent->Conf->Vars.Var[i].val);
@@ -1553,136 +1540,6 @@
 /* }}} */
 #endif
 
-#if UDM_VERSION_ID == 30203
-
-static ssize_t UdmRecvAll(int s, void *buf, size_t len, int flags) {
-  size_t received = 0, r;
-  char *b = buf;
-  while ( (received < len) && ((r = recv(s, &b[received], len - received, flags)) >= 
0 ) ) {
-    received += r;
-  }
-  return received;
-}
-
-
-/* {{{ proto int udm_open_stored(int agent, string storedaddr)
-   Open connection to stored  */
-DLEXPORT PHP_FUNCTION(udm_open_stored)
-{
-       pval ** yyagent, ** yyaddr;
-       
-       int s;
-       char * addr;
-       const char *hello = "F\0";
-       
-       UDM_AGENT * Agent;
-       int id=-1;
-
-       switch(ZEND_NUM_ARGS()){
-               case 2: {
-                               if (zend_get_parameters_ex(2, &yyagent, 
&yyaddr)==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(yyaddr);
-       addr = Z_STRVAL_PP(yyaddr);
-
-       UdmReplaceStrVar(Agent->Conf->vars,"StoredAddr",addr,UDM_VARSRC_GLOBAL);
-       Agent->Conf->stored_addr = strdup(UdmFindStrVar(Agent->Conf->vars, 
"StoredAddr", "localhost"));
-       
-       s = UdmStoreOpen(Agent->Conf);
-       
-       if (s >= 0) {
-           send(s, hello, 1, 0);
-           RETURN_LONG(s);
-       } else RETURN_FALSE;    
-}
-/* }}} */
-
-/* {{{ proto int udm_close_stored(int agent, int link)
-   Open connection to stored  */
-DLEXPORT PHP_FUNCTION(udm_close_stored)
-{
-       pval ** yylink, ** yyagent;
-       
-       int s;
-       unsigned int rec_id = 0;
-       
-       UDM_AGENT * Agent;
-       int id=-1;
-
-       switch(ZEND_NUM_ARGS()){
-               case 2: {
-                               if (zend_get_parameters_ex(2, &yyagent, 
&yylink)==FAILURE) {
-                                       RETURN_FALSE;
-                               }
-                       }
-                       break;
-               default:                                
-                       WRONG_PARAM_COUNT;
-                       break;
-       }
-       ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", 
le_link);
-       
-       convert_to_long_ex(yylink);
-       s = Z_LVAL_PP(yylink);
-
-       
-       send(s, &rec_id, sizeof(rec_id), 0);
-       closesocket(s);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int udm_check_stored(int agent, int link, string doc_id)
-   Open connection to stored  */
-DLEXPORT PHP_FUNCTION(udm_check_stored)
-{
-       pval ** yyid, ** yylink, ** yyagent;
-       
-       int s;
-       unsigned int rec_id = 0;
-       int store_found;
-       
-       UDM_AGENT * Agent;
-       int id=-1;
-
-       switch(ZEND_NUM_ARGS()){
-               case 3: {
-                               if (zend_get_parameters_ex(3, &yyagent, &yylink, 
&yyid)==FAILURE) {
-                                       RETURN_FALSE;
-                               }
-                       }
-                       break;
-               default:                                
-                       WRONG_PARAM_COUNT;
-                       break;
-       }
-       ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", 
le_link);
-       
-       convert_to_long_ex(yylink);
-       s = Z_LVAL_PP(yylink);
-       
-       convert_to_string_ex(yyid);
-       
-       rec_id=strtoul(Z_STRVAL_PP(yyid),NULL,10);
-
-       send(s, &rec_id, sizeof(rec_id), 0);
-       if (UdmRecvAll(s, &store_found, sizeof(store_found), MSG_WAITALL) < 0) {
-           RETURN_LONG(store_found);
-       } else RETURN_FALSE;
-}
-/* }}} */
-#endif
-
 #if UDM_VERSION_ID >= 30204
 /* {{{ proto int udm_parse_query_string(int agent, string str)
    Parses query string, initialises variables and search limits taken from it */
@@ -1838,6 +1695,36 @@
        RETURN_TRUE;
 }
 
+/* {{{ proto string udm_get_agent_param_ex(int agent, string field)
+   Fetch mnoGoSearch environment parameters */
+DLEXPORT PHP_FUNCTION(udm_get_agent_param_ex)
+{
+       pval **yyagent, **yyfield_name;
+
+       UDM_AGENT * Agent;
+       int row;
+       char *field;
+       
+       switch(ZEND_NUM_ARGS()){
+               case 2: {
+                               if (zend_get_parameters_ex(2, 
&yyagent,&yyfield_name)==FAILURE){
+                                       RETURN_FALSE;
+                               }
+                               convert_to_string_ex(yyfield_name);
+                               field = Z_STRVAL_PP(yyfield_name);
+                       }
+                       break;
+               default:
+                       WRONG_PARAM_COUNT;
+                       break;
+       }
+       
+       ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", 
le_link);
+       
+       RETURN_STRING((char *)UdmVarListFindStr(&Agent->Conf->Vars,field,""),1);
+}
+/* }}} */
+
 /* {{{ proto string udm_get_res_field_ex(int res, int row, string field)
    Fetch mnoGoSearch result field */
 DLEXPORT PHP_FUNCTION(udm_get_res_field_ex)
@@ -1881,6 +1768,110 @@
 /* }}} */
 #endif
 
+#if UDM_VERSION_ID >= 30216
+/* {{{ proto int udm_store_doc_cgi(int agent)
+   Get CachedCopy of document and return TRUE if cached copy found */
+DLEXPORT PHP_FUNCTION(udm_store_doc_cgi)
+{
+       pval ** yyagent;
+       UDM_AGENT * Agent;
+       int id=-1;
+       
+       const char      *htok;
+       char            *last = NULL;
+       UDM_DOCUMENT    *Doc;
+       UDM_RESULT      *Res;
+       UDM_HTMLTOK     tag;
+       char            *HDoc=NULL;
+       char            *HEnd=NULL;
+       char            ch;
+       const char      *content_type, *charset;
+       UDM_CHARSET     *cs;
+
+       switch(ZEND_NUM_ARGS()){
+               case 1: {
+                               if (zend_get_parameters_ex(1, &yyagent)==FAILURE) {
+                                       RETURN_FALSE;
+                               }
+                       }
+                       break;
+               default:                                
+                       WRONG_PARAM_COUNT;
+                       break;
+       }
+       ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", 
le_link);
+       
+       Doc=UdmDocInit(NULL);
+       Res=UdmResultInit(NULL);
+       
+       UdmPrepare(Agent,Res);
+       UdmVarListReplaceStr(&Doc->Sections, "URL", 
UdmVarListFindStr(&Agent->Conf->Vars, "URL", "0"));
+       UdmURLAction(Agent, Doc, UDM_URL_ACTION_GET_CACHED_COPY);
+       UdmVarListReplaceLst(&Agent->Conf->Vars, &Doc->Sections, NULL, "*");
+
+       charset = UdmVarListFindStr(&Agent->Conf->Vars,"Charset","iso-8859-1");
+       cs = UdmGetCharSet(charset);
+       
+       /* UnStore Doc, Highlight and Display */
+       
+       content_type = UdmVarListFindStr(&Agent->Conf->Vars, "Content-Type", 
"text/html");
+
+       if(!Doc->Buf.content) {
+           UdmResultFree(Res);
+           UdmDocFree(Doc);
+           UDM_FREE(HDoc);
+       
+           RETURN_FALSE;
+       }
+       
+       HEnd=HDoc = (char*)UdmMalloc(UDM_MAXDOCSIZE + 32);
+       *HEnd='\0';
+       
+       if (strncasecmp(content_type, "text/plain", 10) == 0) {
+         sprintf(HEnd, "<pre>\n");
+         HEnd += strlen(HEnd);
+       }
+
+       UdmHTMLTOKInit(&tag);
+       for(htok = UdmHTMLToken(Doc->Buf.content, (const char **)&last, &tag) ; htok 
;) {
+               switch(tag.type) {
+               case UDM_HTML_COM:
+               case UDM_HTML_TAG:
+                       memcpy(HEnd,htok,(size_t)(last-htok));
+                       HEnd+=last-htok;
+                       HEnd[0]='\0';
+                               UdmHTMLParseTag(&tag,Doc);
+                       break;
+               case UDM_HTML_TXT:
+                       ch = *last; *last = '\0';
+                       if (tag.title || tag.script) {
+                         sprintf(HEnd, "%s", UdmHlConvert(NULL, htok, cs, cs));
+                       } else {
+                         sprintf(HEnd, "%s", UdmHlConvert(&Res->WWList, htok, cs, 
cs));
+                       }
+                       HEnd=UDM_STREND(HEnd);
+                       *last = ch;
+                       break;
+               }
+               htok = UdmHTMLToken(NULL, (const char **)&last, &tag);
+       }
+
+       if (strncasecmp(content_type, "text/plain", 10) == 0) {
+         sprintf(HEnd, "</pre>\n");
+         HEnd += strlen(HEnd);
+       }
+
+       UdmVarListAddStr(&Agent->Conf->Vars, "document", HDoc);
+       
+       UdmResultFree(Res);
+       UdmDocFree(Doc);
+       UDM_FREE(HDoc);
+       
+       RETURN_TRUE;
+}
+/* }}} */
+#endif
+
 #if UDM_VERSION_ID >= 30211
 /* {{{ proto int udm_alloc_agent_array(array dbaddr)
    Allocate mnoGoSearch session */
@@ -2152,7 +2143,7 @@
 #endif
                                break;
                                
-                       case UDM_FIELD_CATEGORY:                
+                       case UDM_FIELD_CATEGORY:
 #if UDM_VERSION_ID >= 30204
                                RETURN_STRING((char 
*)UdmVarListFindStr(&(Res->Doc[row].Sections),"Category",""),1);
 #else
@@ -2161,7 +2152,7 @@
                                break;
 
 #if UDM_VERSION_ID >= 30203            
-                       case UDM_FIELD_LANG:            
+                       case UDM_FIELD_LANG:
 #if UDM_VERSION_ID >= 30204
                                RETURN_STRING((char 
*)UdmVarListFindStr(&(Res->Doc[row].Sections),"Content-Language",""),1);
 #else
http://cvs.php.net/diff.php/php-src/ext/mnogosearch/php_mnogo.h?r1=1.24&r2=1.25&ty=u
Index: php-src/ext/mnogosearch/php_mnogo.h
diff -u php-src/ext/mnogosearch/php_mnogo.h:1.24 
php-src/ext/mnogosearch/php_mnogo.h:1.25
--- php-src/ext/mnogosearch/php_mnogo.h:1.24    Thu Jan  8 12:32:25 2004
+++ php-src/ext/mnogosearch/php_mnogo.h Sat May  8 07:50:36 2004
@@ -1,16 +1,16 @@
 /* $Source: /repository/php-src/ext/mnogosearch/php_mnogo.h,v $ */
-/* $Id: php_mnogo.h,v 1.24 2004/01/08 17:32:25 sniper Exp $ */
+/* $Id: php_mnogo.h,v 1.25 2004/05/08 11:50:36 gluke Exp $ */
 
 /* 
    +----------------------------------------------------------------------+
-   | PHP Version 5                                                        |
+   | PHP Version 4                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2004 The PHP Group                                |
+   | Copyright (c) 1997-2003 The PHP Group                                |
    +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
+   | This source file is subject to version 2.02 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
+   | available at through the world-wide-web at                           |
+   | http://www.php.net/license/2_02.txt.                                 |
    | If you did not receive a copy of the PHP license and are unable to   |
    | obtain it through the world-wide-web, please send a note to          |
    | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
@@ -57,11 +57,6 @@
 DLEXPORT PHP_FUNCTION(udm_api_version);
 #if UDM_VERSION_ID >= 30200
 DLEXPORT PHP_FUNCTION(udm_check_charset);
-#if UDM_VERSION_ID == 30203
-DLEXPORT PHP_FUNCTION(udm_open_stored);
-DLEXPORT PHP_FUNCTION(udm_check_stored);
-DLEXPORT PHP_FUNCTION(udm_close_stored);
-#endif
 #if UDM_VERSION_ID >= 30203
 DLEXPORT PHP_FUNCTION(udm_crc32);
 #endif
@@ -69,12 +64,16 @@
 DLEXPORT PHP_FUNCTION(udm_parse_query_string);
 DLEXPORT PHP_FUNCTION(udm_make_excerpt);
 DLEXPORT PHP_FUNCTION(udm_set_agent_param_ex);
+DLEXPORT PHP_FUNCTION(udm_get_agent_param_ex);
 DLEXPORT PHP_FUNCTION(udm_get_res_field_ex);
 #endif
 #if UDM_VERSION_ID >= 30211
 DLEXPORT PHP_FUNCTION(udm_hash32);
 DLEXPORT PHP_FUNCTION(udm_alloc_agent_array);
 #endif
+#if UDM_VERSION_ID >= 30216
+DLEXPORT PHP_FUNCTION(udm_store_doc_cgi);
+#endif
 #endif
 
 DLEXPORT PHP_FUNCTION(udm_alloc_agent);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to