summaryrefslogtreecommitdiff
path: root/ext/mnogosearch
diff options
context:
space:
mode:
authorSergey Kartashoff <gluke@php.net>2001-12-01 14:05:13 +0000
committerSergey Kartashoff <gluke@php.net>2001-12-01 14:05:13 +0000
commitf70e998794f5d3f9a0681b219f3748c49b867ed1 (patch)
tree8073d218a991cd4816648daed943d829f92e821a /ext/mnogosearch
parent94cfe03da5dca388ff51cf90d99e40804923860e (diff)
downloadphp-git-f70e998794f5d3f9a0681b219f3748c49b867ed1.tar.gz
- StoreDOC support has been added to mnogoSearch module.
Diffstat (limited to 'ext/mnogosearch')
-rw-r--r--ext/mnogosearch/php_mnogo.c56
-rw-r--r--ext/mnogosearch/php_mnogo.h8
2 files changed, 63 insertions, 1 deletions
diff --git a/ext/mnogosearch/php_mnogo.c b/ext/mnogosearch/php_mnogo.c
index aa1c9d8b2d..fb0ffc7b55 100644
--- a/ext/mnogosearch/php_mnogo.c
+++ b/ext/mnogosearch/php_mnogo.c
@@ -49,6 +49,8 @@
#define UDM_FIELD_ORDER 11
#define UDM_FIELD_CRC 12
#define UDM_FIELD_CATEGORY 13
+#define UDM_FIELD_LANG 14
+#define UDM_FIELD_CHARSET 15
/* udm_set_agent_param constants */
#define UDM_PARAM_PAGE_SIZE 1
@@ -133,6 +135,10 @@ function_entry mnogosearch_functions[] = {
PHP_FE(udm_check_charset, NULL)
#endif
+#if UDM_VERSION_ID >= 30203
+ PHP_FE(udm_crc32, NULL)
+#endif
+
PHP_FE(udm_alloc_agent, NULL)
PHP_FE(udm_set_agent_param, NULL)
@@ -217,6 +223,8 @@ DLEXPORT PHP_MINIT_FUNCTION(mnogosearch)
REGISTER_LONG_CONSTANT("UDM_FIELD_ORDER", UDM_FIELD_ORDER,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_FIELD_CRC", UDM_FIELD_CRC,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_FIELD_CATEGORY", UDM_FIELD_CATEGORY,CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_FIELD_LANG", UDM_FIELD_LANG,CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_FIELD_CHARSET", UDM_FIELD_CHARSET,CONST_CS | CONST_PERSISTENT);
/* udm_set_agent_param constants */
REGISTER_LONG_CONSTANT("UDM_PARAM_PAGE_SIZE", UDM_PARAM_PAGE_SIZE,CONST_CS | CONST_PERSISTENT);
@@ -1019,7 +1027,7 @@ DLEXPORT PHP_FUNCTION(udm_clear_search_limits)
}
/* }}} */
-#if UDM_VERSION_ID >= 30200
+#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)
@@ -1052,6 +1060,42 @@ DLEXPORT PHP_FUNCTION(udm_check_charset)
/* }}} */
#endif
+#if UDM_VERSION_ID >= 30203
+/* {{{ proto int udm_crc32(int agent, string str)
+ Return CRC32 checksum of gived string */
+DLEXPORT PHP_FUNCTION(udm_crc32)
+{
+ pval ** yystr, ** yyagent;
+ char *str;
+ int crc32;
+ char buf[32];
+ UDM_AGENT * Agent;
+ int id=-1;
+
+ switch(ZEND_NUM_ARGS()){
+ case 2: {
+ if (zend_get_parameters_ex(2, &yyagent,&yystr)==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(yystr);
+ str = Z_STRVAL_PP(yystr);
+
+ crc32=UdmCRC32((str),strlen(str));
+ snprintf(buf,sizeof(buf)-1,"%u",crc32);
+
+ RETURN_STRING(buf,1);
+}
+/* }}} */
+#endif
+
+
/* {{{ proto int udm_find(int agent, string query)
Perform search */
DLEXPORT PHP_FUNCTION(udm_find)
@@ -1165,6 +1209,16 @@ DLEXPORT PHP_FUNCTION(udm_get_res_field)
case UDM_FIELD_CATEGORY:
RETURN_STRING((Res->Doc[row].category)?(Res->Doc[row].category):"",1);
break;
+
+#if UDM_VERSION_ID >= 30203
+ case UDM_FIELD_LANG:
+ RETURN_STRING((Res->Doc[row].lang)?(Res->Doc[row].lang):"",1);
+ break;
+
+ case UDM_FIELD_CHARSET:
+ RETURN_STRING((Res->Doc[row].charset)?(Res->Doc[row].charset):"",1);
+ break;
+#endif
default:
php_error(E_WARNING,"Udm_Get_Res_Field: Unknown mnoGoSearch field name");
diff --git a/ext/mnogosearch/php_mnogo.h b/ext/mnogosearch/php_mnogo.h
index b5e4480321..c5da3be499 100644
--- a/ext/mnogosearch/php_mnogo.h
+++ b/ext/mnogosearch/php_mnogo.h
@@ -30,6 +30,10 @@
#include <udm_config.h>
#include <udmsearch.h>
+#if UDM_VERSION_ID >= 30203
+#include <udm_crc32.h>
+#endif
+
extern zend_module_entry mnogosearch_module_entry;
#define mnogosearch_module_ptr &mnogosearch_module_entry
@@ -54,6 +58,10 @@ DLEXPORT PHP_FUNCTION(udm_api_version);
DLEXPORT PHP_FUNCTION(udm_check_charset);
#endif
+#if UDM_VERSION_ID >= 30203
+DLEXPORT PHP_FUNCTION(udm_crc32);
+#endif
+
DLEXPORT PHP_FUNCTION(udm_alloc_agent);
DLEXPORT PHP_FUNCTION(udm_set_agent_param);