From: Adam Dickmeiss Date: Thu, 24 Feb 2000 12:31:17 +0000 (+0000) Subject: Added zebra_string_norm. X-Git-Tag: ZEBRA.1.1~99 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=d82a3109cb3fcc56fd613b71a3a48d5ec72146f8 Added zebra_string_norm. --- diff --git a/index/apitest.c b/index/apitest.c index 88c9e6b..69574e4 100644 --- a/index/apitest.c +++ b/index/apitest.c @@ -147,7 +147,25 @@ int main (int argc, char **argv) odr_reset (odr_input); continue; } + else + { + char out_str[100]; + int r; +#if 1 + r = zebra_string_norm (zh, 'w', + argv[argno], strlen(argv[argno]), + out_str, sizeof(out_str)); + if (r >= 0) + { + printf ("norm: '%s'\n", out_str); + } + else + { + printf ("norm fail: %d\n", r); + } +#endif + } /* result set name will be called 1,2, etc */ sprintf (setname, "%d", argno); diff --git a/index/zebraapi.c b/index/zebraapi.c index a740d57..fa596e4 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebraapi.c,v $ - * Revision 1.26 1999-11-30 13:48:03 adam + * Revision 1.27 2000-02-24 12:31:17 adam + * Added zebra_string_norm. + * + * Revision 1.26 1999/11/30 13:48:03 adam * Improved installation. Updated for inclusion of YAZ header files. * * Revision 1.25 1999/11/04 15:00:45 adam @@ -600,3 +603,22 @@ void zebra_admin (ZebraHandle zh, const char *command) { } + +int zebra_string_norm (ZebraHandle zh, unsigned reg_id, + const char *input_str, int input_len, + char *output_str, int output_len) +{ + WRBUF wrbuf; + if (!zh->zebra_maps) + return -1; + wrbuf = zebra_replace(zh->zebra_maps, reg_id, "", + input_str, input_len); + if (!wrbuf) + return -2; + if (wrbuf_len(wrbuf) >= output_len) + return -3; + if (wrbuf_len(wrbuf)) + memcpy (output_str, wrbuf_buf(wrbuf), wrbuf_len(wrbuf)); + output_str[wrbuf_len(wrbuf)] = '\0'; + return wrbuf_len(wrbuf); +} diff --git a/index/zebraapi.h b/index/zebraapi.h index 0aae163..b8ab5bf 100644 --- a/index/zebraapi.h +++ b/index/zebraapi.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebraapi.h,v $ - * Revision 1.8 1999-11-30 13:48:03 adam + * Revision 1.9 2000-02-24 12:31:17 adam + * Added zebra_string_norm. + * + * Revision 1.8 1999/11/30 13:48:03 adam * Improved installation. Updated for inclusion of YAZ header files. * * Revision 1.7 1999/11/04 15:00:45 adam @@ -103,6 +106,12 @@ YAZ_EXPORT int zebra_hits (ZebraHandle zh); /* do authentication */ YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass); +/* Character normalisation on specific register . + This routine is subject to change - do not use. */ +YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id, + const char *input_str, int input_len, + char *output_str, int output_len); + #ifdef __cplusplus } #endif