IDZEBRA 2.2.11
charmap.c File Reference

character conversions (.chr) More...

#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <charmap.h>
#include <yaz/yaz-util.h>

Go to the source code of this file.

Data Structures

struct  chrmaptab_info
struct  chr_t_entry
struct  chrwork
struct  chr_equiv_work

Macros

#define CHR_MAXSTR   1024
#define CHR_MAXEQUIV   32

Typedefs

typedef unsigned ucs4_t
typedef struct chrwork chrwork

Functions

static chr_t_entry * set_map_string (chr_t_entry *root, NMEM nmem, const char *from, int len, char *to, const char *from_0)
static chr_t_entry * find_entry_x (chr_t_entry *t, const char **from, int *len, int first)
const char ** chr_map_input_x (chrmaptab maptab, const char **from, int *len, int first)
const char ** chr_map_input (chrmaptab maptab, const char **from, int len, int first)
const char ** chr_map_q_input (chrmaptab maptab, const char **from, int len, int first)
const char * chr_map_output (chrmaptab maptab, const char **from, int len)
static int zebra_ucs4_strlen (ucs4_t *s)
ucs4_t zebra_prim_w (ucs4_t **s)
static void fun_addentry (const char *s, void *data, int num)
static void fun_addspace (const char *s, void *data, int num)
static void fun_addcut (const char *s, void *data, int num)
static void fun_mkstring (const char *s, void *data, int num)
static void fun_add_equivalent_string (const char *s, void *data, int num)
static void fun_add_map (const char *s, void *data, int num)
static int scan_to_utf8 (yaz_iconv_t t, ucs4_t *from, size_t inlen, char *outbuf, size_t outbytesleft)
static int scan_string (char *s_native, yaz_iconv_t t_unicode, yaz_iconv_t t_utf8, void(*fun)(const char *c, void *data, int num), void *data, int *num)
chrmaptab chrmaptab_create (const char *tabpath, const char *name, const char *tabroot)
void chrmaptab_destroy (chrmaptab tab)

Variables

const unsigned char CHR_FIELD_BEGIN = '^'
const char * CHR_UNKNOWN = "\001"
const char * CHR_SPACE = "\002"
const char * CHR_CUT = "\003"
const char * CHR_BASE = "\005"

Detailed Description

character conversions (.chr)

Support module to handle character-conversions into and out of the Zebra dictionary.

Definition in file charmap.c.

Macro Definition Documentation

◆ CHR_MAXEQUIV

#define CHR_MAXEQUIV   32

Definition at line 44 of file charmap.c.

Referenced by fun_add_equivalent_string().

◆ CHR_MAXSTR

#define CHR_MAXSTR   1024

Definition at line 43 of file charmap.c.

Referenced by fun_mkstring().

Typedef Documentation

◆ chrwork

typedef struct chrwork chrwork

◆ ucs4_t

typedef unsigned ucs4_t

Definition at line 37 of file charmap.c.

Function Documentation

◆ chr_map_input()

const char ** chr_map_input ( chrmaptab maptab,
const char ** from,
int len,
int first )

◆ chr_map_input_x()

const char ** chr_map_input_x ( chrmaptab maptab,
const char ** from,
int * len,
int first )

Definition at line 184 of file charmap.c.

References find_entry_x(), chrmaptab_info::input, and chr_t_entry::target.

Referenced by tst_string().

◆ chr_map_output()

const char * chr_map_output ( chrmaptab maptab,
const char ** from,
int len )

Definition at line 221 of file charmap.c.

References chrmaptab_info::output.

Referenced by zebra_maps_output().

◆ chr_map_q_input()

const char ** chr_map_q_input ( chrmaptab maptab,
const char ** from,
int len,
int first )

Definition at line 207 of file charmap.c.

References find_entry_x(), chrmaptab_info::q_input, and chr_t_entry::target.

Referenced by zebra_maps_search().

◆ chrmaptab_create()

◆ chrmaptab_destroy()

void chrmaptab_destroy ( chrmaptab tab)

Definition at line 748 of file charmap.c.

References chrmaptab_info::nmem.

Referenced by chrmaptab_create(), tst2(), tst3(), tst_latin1(), tst_utf8(), and zebra_maps_close().

◆ find_entry_x()

chr_t_entry * find_entry_x ( chr_t_entry * t,
const char ** from,
int * len,
int first )
static

◆ fun_add_equivalent_string()

void fun_add_equivalent_string ( const char * s,
void * data,
int num )
static

Definition at line 369 of file charmap.c.

References CHR_MAXEQUIV, chr_equiv_work::eq, chr_equiv_work::nmem, and chr_equiv_work::no_eq.

Referenced by chrmaptab_create().

◆ fun_add_map()

void fun_add_map ( const char * s,
void * data,
int num )
static

◆ fun_addcut()

void fun_addcut ( const char * s,
void * data,
int num )
static

Definition at line 344 of file charmap.c.

References CHR_CUT, chrmaptab_info::input, chrmaptab_info::nmem, and set_map_string().

Referenced by chrmaptab_create().

◆ fun_addentry()

void fun_addentry ( const char * s,
void * data,
int num )
static

◆ fun_addspace()

void fun_addspace ( const char * s,
void * data,
int num )
static

Definition at line 333 of file charmap.c.

References CHR_SPACE, chrmaptab_info::input, chrmaptab_info::nmem, and set_map_string().

Referenced by chrmaptab_create().

◆ fun_mkstring()

void fun_mkstring ( const char * s,
void * data,
int num )
static

Definition at line 354 of file charmap.c.

References chr_map_input(), CHR_MAXSTR, CHR_UNKNOWN, chrwork::map, and chrwork::string.

Referenced by chrmaptab_create().

◆ scan_string()

int scan_string ( char * s_native,
yaz_iconv_t t_unicode,
yaz_iconv_t t_utf8,
void(* fun )(const char *c, void *data, int num),
void * data,
int * num )
static

Definition at line 421 of file charmap.c.

References begin(), end(), scan_to_utf8(), zebra_prim_w(), and zebra_ucs4_strlen().

Referenced by chrmaptab_create().

◆ scan_to_utf8()

int scan_to_utf8 ( yaz_iconv_t t,
ucs4_t * from,
size_t inlen,
char * outbuf,
size_t outbytesleft )
static

Definition at line 393 of file charmap.c.

Referenced by scan_string().

◆ set_map_string()

chr_t_entry * set_map_string ( chr_t_entry * root,
NMEM nmem,
const char * from,
int len,
char * to,
const char * from_0 )
static

◆ zebra_prim_w()

ucs4_t zebra_prim_w ( ucs4_t ** s)

Definition at line 239 of file charmap.c.

References zebra_ucs4_strlen().

Referenced by scan_string().

◆ zebra_ucs4_strlen()

int zebra_ucs4_strlen ( ucs4_t * s)
static

Definition at line 231 of file charmap.c.

Referenced by scan_string(), and zebra_prim_w().

Variable Documentation

◆ CHR_BASE

const char* CHR_BASE = "\005"

Definition at line 51 of file charmap.c.

Referenced by chrmaptab_create().

◆ CHR_CUT

const char* CHR_CUT = "\003"

Definition at line 50 of file charmap.c.

Referenced by fun_addcut(), and parse_complete_field().

◆ CHR_FIELD_BEGIN

const unsigned char CHR_FIELD_BEGIN = '^'

Definition at line 46 of file charmap.c.

Referenced by find_entry_x().

◆ CHR_SPACE

◆ CHR_UNKNOWN

const char* CHR_UNKNOWN = "\001"

Definition at line 48 of file charmap.c.

Referenced by chrmaptab_create(), fun_mkstring(), set_map_string(), and zebra_it_key_str_dump().