#ifndef	V_UCODE_H
#define V_UCODE_H

#define	ASCII_LIMIT	0x80

/* FIXME: move to v_config.h */
#define	CONFIG_KOI8R_TABLE
#define	CONFIG_CP866_TABLE
#define	CONFIG_WIN1251_TABLE

/*
 * Character description: ascii and unicode codes, name.
 */
typedef struct uc_char_desc_s
{
	u32_t acode;
	u32_t ucode;
	char *name;
} uc_char_desc_t, *uc_char_desc_p;

/*
 * Character map contains variable number of uc_char_desc_t entries.
 * All maps except 'latin1' contain only upper part (from 0x80).
 * The last entry should be {0, 0, NULL}.
 */
typedef struct uc_charmap_desc_s
{
	char *name;
	uc_char_desc_p desc;
} uc_charmap_desc_t, *uc_charmap_desc_p;

/*
 * If current LibV locale doesn't contain ASCII code for some character,
 * it is possible to substitute the character by another one with similar
 * glyph and/or reading. For example, "HORIZONTAL ELLIPSIS" can be
 * replaced by "LOW LINE", "CYRILLIC SMALL LETTER A" can be replced by
 * "LATIN SMALL LETTER A", etc.
 */

#define	MAX_ALIASES		16

typedef struct uc_alias_list_s
{
	u32_t ucode;
	u32_t num_alias;
	u32_t alias[MAX_ALIASES];
} uc_alias_list_t, *uc_alias_list_p;

#ifdef	__cplusplus
extern "C" {
#endif	/* __cplusplus */
	/* Returns charmap description or NULL if no more descriptions */
	uc_charmap_desc_p	V_GLOBAL ucGetCharmap(int cmap_num);
	/* Searches for character with ASCII 'acode' in 'cmap' */
	uc_char_desc_p	V_GLOBAL ucFindAscii(uc_charmap_desc_p cmap,u32_t acode);
	/* Searches for character with UNICODE 'ucode' in 'cmap' */
	uc_char_desc_p	V_GLOBAL ucFindUnicode(uc_charmap_desc_p cmap,u32_t ucode);
	/* Same as above, but also searches for alias(es). */
	uc_char_desc_p	V_GLOBAL ucFindUnicodeOrAlias(uc_charmap_desc_p target_cmap,u32_t uc_orig);
	/* Returns name of character with UNICODE 'ucode' or "UNKNOWN" */
	char_p	V_GLOBAL ucCharName(u32_t ucode);
	/* Makes translation table (of 256-entries) from one locale to other */
	vboolean	V_GLOBAL ucAscii2AsciiTable(char_p src_cmap_name,
		char_p dst_cmap_name, u8_t transtab_ret[]);
	/*
	 * Conversion between scancodes and their names.
	 * The name formed by striping "sc_" prefix.
	 */
	char_p		V_GLOBAL	uiKeyscan2Name(unsigned scan);
	unsigned	V_GLOBAL	uiName2Keyscan(char *name);
#ifdef	__cplusplus
}
#endif	/* __cplusplus */

#endif	/* !V_UCODE_H */
