更高MAAT_SET_SCAN_DISTRICT选项的参数要求,不再要求‘\0’结束。

This commit is contained in:
zhengchao
2016-09-18 12:44:00 +08:00
parent f646921a97
commit bdca633bbd
6 changed files with 23 additions and 4 deletions

View File

@@ -161,7 +161,7 @@ int Maat_table_callback_register(Maat_feather_t feather,short table_id,
enum MAAT_SCAN_OPT enum MAAT_SCAN_OPT
{ {
MAAT_SET_SCAN_DISTRICT=1 //VALUE is a const char*,MUST end with '\0',SIZE= strlen(string+'\0')+1.DEFAULT: no default. MAAT_SET_SCAN_DISTRICT=1 //VALUE is a const char*,SIZE= strlen(string).DEFAULT: no default.
}; };
//return 0 if success, return -1 when failed; //return 0 if success, return -1 when failed;
int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCAN_OPT type,const void* value,int size); int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCAN_OPT type,const void* value,int size);

View File

@@ -1491,7 +1491,7 @@ int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCA
{ {
return -1; return -1;
} }
map_ret=map_str2int(_feather->scanner->district_map,(const char*)value,&(_mid->district_id)); map_ret=map_unNullstr2int(_feather->scanner->district_map,(const char*)value,size,&(_mid->district_id));
if(map_ret<0) if(map_ret<0)
{ {
//May be the district is not effected yet. //May be the district is not effected yet.

View File

@@ -26,7 +26,7 @@
#include "mesa_fuzzy.h" #include "mesa_fuzzy.h"
#include "great_index_engine.h" #include "great_index_engine.h"
int MAAT_FRAME_VERSION_1_8_20160909_TABLE_CONJ=1; int MAAT_FRAME_VERSION_1_8_20160918_TABLE_CONJ=1;
const char *maat_module="MAAT Frame"; const char *maat_module="MAAT Frame";
const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin", const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin",

View File

@@ -75,6 +75,24 @@ int map_str2int(MESA_htable_handle handle,const char* string,int* value)
return -1; return -1;
} }
} }
int map_unNullstr2int(MESA_htable_handle handle,const char* string,int len,int* value)
{
int *data=NULL;
long cb_ret=0;
data=(int*)MESA_htable_search_cb(handle,(unsigned char*)string,len,
read_map_val,value,&cb_ret);
// data=(int*)MESA_htable_search(handle,(unsigned char*)string,len);
if(cb_ret>0)
{
return 1;
}
else
{
return -1;
}
}
void duplicate_func(const uchar * key, uint size, void * data, void * user) void duplicate_func(const uchar * key, uint size, void * data, void * user)
{ {
MESA_htable_handle target=(MESA_htable_handle)user; MESA_htable_handle target=(MESA_htable_handle)user;

View File

@@ -4,6 +4,7 @@ MESA_htable_handle map_create(void);
void map_destroy(MESA_htable_handle p); void map_destroy(MESA_htable_handle p);
int map_register(MESA_htable_handle handle,const char* string,int value); int map_register(MESA_htable_handle handle,const char* string,int value);
int map_str2int(MESA_htable_handle handle,const char* string,int* value); int map_str2int(MESA_htable_handle handle,const char* string,int* value);
int map_unNullstr2int(MESA_htable_handle handle,const char* string,int size,int* value);
MESA_htable_handle map_duplicate(MESA_htable_handle origin_map); MESA_htable_handle map_duplicate(MESA_htable_handle origin_map);
#endif #endif

View File

@@ -415,7 +415,7 @@ int test_expr_plus(Maat_feather_t feather,const char* table_name,scan_status_t*
printf("Should not hit without setting district.\n"); printf("Should not hit without setting district.\n");
return -1; return -1;
} }
ret=Maat_set_scan_status(feather, mid, MAAT_SET_SCAN_DISTRICT,region_name,strlen(region_name)+1); ret=Maat_set_scan_status(feather, mid, MAAT_SET_SCAN_DISTRICT,region_name,strlen(region_name));
if(ret<0) if(ret<0)
{ {
printf("set MAAT_SET_SCAN_DISTRICT failed.\n"); printf("set MAAT_SET_SCAN_DISTRICT failed.\n");