diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2005-06-26 17:51:43 +0000 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2005-06-26 17:51:43 +0000 |
commit | c60519ab50b32dc282b385b3bbb2df319279f655 (patch) | |
tree | 001c2f9653029878da1eee01d19636221a5ad268 /src/librcc.h | |
parent | 3aa2acb1aa6931d9a5cab87fe9bef94086e25d16 (diff) | |
download | librcc-c60519ab50b32dc282b385b3bbb2df319279f655.tar.gz librcc-c60519ab50b32dc282b385b3bbb2df319279f655.tar.bz2 librcc-c60519ab50b32dc282b385b3bbb2df319279f655.tar.xz librcc-c60519ab50b32dc282b385b3bbb2df319279f655.zip |
26.06.2005
Diffstat (limited to 'src/librcc.h')
-rw-r--r-- | src/librcc.h | 266 |
1 files changed, 118 insertions, 148 deletions
diff --git a/src/librcc.h b/src/librcc.h index c3d6f17..0ca55a4 100644 --- a/src/librcc.h +++ b/src/librcc.h @@ -1,11 +1,14 @@ #ifndef LIBRCC_H #define LIBRCC_H -#include <iconv.h> +/******************************************************************************* +***************************** Global Defines *********************************** +*******************************************************************************/ #define RCC_MAX_CHARSETS 16 #define RCC_MAX_ENGINES 5 #define RCC_MAX_LANGUAGES 64 +#define RCC_MAX_ALIASES 64 #define RCC_MAX_CLASSES 16 #define RCC_MAX_ERRORS 3 @@ -16,65 +19,45 @@ #define RCC_MAX_STRING_CHARS 1024 -#define RCC_STRING_MAGIC 0xFF7F01FF -/* - class = charset class - engine = auto engine - selected - which is selected - current - resolves default values -*/ +/* ID's */ +typedef char rcc_language_id; +typedef char rcc_alias_id; +typedef char rcc_charset_id; +typedef char rcc_engine_id; + +typedef int rcc_class_id; + +/* Opaque Pointer's */ +typedef struct rcc_context_t *rcc_context; +typedef struct rcc_engine_context_t *rcc_engine_context; +typedef struct rcc_language_config_t *rcc_language_config; #ifdef __cplusplus extern "C" { #endif +int rccInit(); +void rccFree(); + +/******************************************************************************* +**************************** Initialization ************************************ +*******************************************************************************/ typedef unsigned int rcc_init_flags; #define RCC_DEFAULT_CONFIGURATION 1 +rcc_context rccInitContext(rcc_init_flags flags, unsigned int max_languages, unsigned int max_classes, const char *locale); +void rccFreeContext(rcc_context ctx); -typedef int rcc_option_value; -typedef enum rcc_option_t { - RCC_LEARNING_MODE = 0, - RCC_AUTODETECT_FS_TITLES, - RCC_AUTODETECT_FS_NAMES, - RCC_USE_HEADERS, - RCC_MAX_OPTIONS -} rcc_option; - -typedef enum rcc_class_type_t { - RCC_CLASS_INVALID = 0, - RCC_CLASS_STANDARD, - RCC_CLASS_FS -} rcc_class_type; - - -struct rcc_string_header_t { - unsigned int magic; - rcc_language_id language_id; -}; -typedef struct rcc_string_header_t rcc_string_header; - -typedef char *rcc_string; -typedef char rcc_language_id; -typedef char rcc_charset_id; -typedef char rcc_engine_id; -typedef int rcc_class_id; - -typedef struct rcc_context_t rcc_context; -typedef struct rcc_engine_context_t rcc_engine_ctx; -typedef const struct rcc_class_t rcc_class; -typedef struct rcc_language_t rcc_language; -typedef struct rcc_engine_t rcc_engine; +/******************************************************************************* +******************* Altering Language Configuaration *************************** +*******************************************************************************/ typedef const char *rcc_charset; +typedef rcc_charset rcc_charset_list[RCC_MAX_CHARSETS+1]; -typedef struct rcc_language_config_t rcc_language_config; -typedef const struct rcc_language_alias_t rcc_language_alias; - +/* Engines */ typedef void *rcc_engine_internal; -typedef rcc_engine_internal (*rcc_engine_init_function)(rcc_engine_context *ctx); -typedef rcc_charset_id (*rcc_engine_function)(rcc_engine_context ctx, char *buf, int len); -typedef void (rcc_engine_free_function)(rcc_engine_context ctx); - -typedef rcc_charset rcc_charset_list[RCC_MAX_CHARSETS+1]; +typedef rcc_engine_internal (*rcc_engine_init_function)(rcc_engine_context ctx); +typedef rcc_charset_id (*rcc_engine_function)(rcc_engine_context ctx, const char *buf, int len); +typedef void (*rcc_engine_free_function)(rcc_engine_context ctx); struct rcc_engine_t { const char *title; @@ -83,22 +66,44 @@ struct rcc_engine_t { rcc_engine_function func; rcc_charset_list charsets; }; +typedef struct rcc_engine_t rcc_engine; typedef rcc_engine *rcc_engine_ptr; typedef rcc_engine_ptr rcc_engine_list[RCC_MAX_ENGINES+1]; +/* Language */ struct rcc_language_t { const char *sn; const char *name; rcc_charset_list charsets; rcc_engine_list engines; }; +typedef struct rcc_language_t rcc_language; typedef rcc_language *rcc_language_ptr; typedef rcc_language_ptr rcc_language_list[RCC_MAX_LANGUAGES+1]; +/* Alias */ struct rcc_language_alias_t { const char *alias; const char *lang; }; +typedef struct rcc_language_alias_t rcc_language_alias; +typedef rcc_language_alias *rcc_language_alias_ptr; +typedef rcc_language_alias_ptr rcc_language_alias_list[RCC_MAX_ALIASES+1]; + +rcc_language_id rccRegisterLanguage(rcc_context ctx, rcc_language *language); +rcc_charset_id rccLanguageRegisterCharset(rcc_language *language, rcc_charset charset); +rcc_engine_id rccLanguageRegisterEngine(rcc_language *language, rcc_engine *engine); +rcc_alias_id rccRegisterLanguageAlias(rcc_context ctx, rcc_language_alias *alias); + +/******************************************************************************* +************************ Altering Configuaration ******************************* +*******************************************************************************/ +typedef enum rcc_class_type_t { + RCC_CLASS_INVALID = 0, + RCC_CLASS_STANDARD, + RCC_CLASS_FS +} rcc_class_type; +typedef const struct rcc_class_t rcc_class; struct rcc_class_t { const char *name; @@ -108,94 +113,48 @@ struct rcc_class_t { typedef rcc_class *rcc_class_ptr; typedef rcc_class_ptr rcc_class_list[RCC_MAX_CLASSES+1]; -struct rcc_language_config_t { - rcc_context *ctx; - rcc_language *language; - - rcc_engine_id engine; - rcc_charset_id *charset; - rcc_option_value options[RCC_MAX_OPTIONS]; -}; - -struct rcc_engine_context_t { - rcc_context *ctx; - rcc_language *language; - - rcc_engine_function func; - rcc_engine_free_function free_func; - - rcc_engine_internal internal; -}; +rcc_class_id rccRegisterClass(rcc_context ctx, rcc_class *cl); +rcc_class_type rccGetClassType(rcc_context ctx, rcc_class_id class_id); -struct rcc_context_t { - char locale_variable[RCC_MAX_VARIABLE_CHARS+1]; - - unsigned int max_languages; - unsigned int n_languages; - rcc_language_ptr *languages; - rcc_language_config *configs; - - unsigned int max_classes; - unsigned int n_classes; - rcc_class_ptr *classes; - - rcc_engine_ctx engine_ctx; - - iconv_t *iconv_from; - iconv_t *iconv_to; - iconv_t iconv_auto[RCC_MAX_CHARSETS]; - - char tmpbuffer[RCC_MAX_STRING_CHARS+sizeof(rcc_string_footer)+1]; - iconv_t fsiconv; - - unsigned char configure; - rcc_language_config *current_config; - rcc_language_id current_language; -}; - -int rccInit(); -void rccFree(); - -rcc_context rccInitContext(rcc_init_flags flags, unsigned int max_languages, unsigned int max_classes, const char *locale); -void rccFreeContext(rcc_context *ctx); - -rcc_language_id rccRegisterLanguage(rcc_context *ctx, rcc_language *language); -rcc_charset_id rccLanguageRegisterCharset(rcc_language *language, rcc_charset charset); -rcc_engine_id rccLanguageRegisterEngine(rcc_language *language, rcc_engine *engine); -rcc_class_id rccRegisterClass(rcc_context *ctx, rcc_class *cl); - -rcc_class_type rccGetClassType(rcc_context *ctx, rcc_class_id class_id); - -int rccConfigure(rcc_context *ctx); -char *rccCreateResult(rcc_context *ctx, int len, int *rlen); +/******************************************************************************* +************************ Altering Configuaration ******************************* +*******************************************************************************/ +typedef int rcc_option_value; +typedef enum rcc_option_t { + RCC_LEARNING_MODE = 0, + RCC_AUTODETECT_FS_TITLES, + RCC_AUTODETECT_FS_NAMES, + RCC_USE_HEADERS, + RCC_MAX_OPTIONS +} rcc_option; /* lng.c */ -const char *rccGetLanguageName(rcc_context *ctx, rcc_language_id language_id); -rcc_language_id rccGetLanguageByName(rcc_context *ctx, const char *name); -rcc_language_id rccGetRealLanguage(rcc_context *ctx, rcc_language_id language_id); -const char *rccGetRealLanguageName(rcc_context *ctx, rcc_language_id language_id); -rcc_language_id rccGetSelectedLanguage(rcc_context *ctx); -const char *rccGetSelectedLanguageName(rcc_context *ctx); -rcc_language_id rccGetCurrentLanguage(rcc_context *ctx); -const char *rccGetCurrentLanguageName(rcc_context *ctx); - -int rccSetLanguage(rcc_context *ctx, rcc_language_id language_id); -int rccSetLanguageByName(rcc_context *ctx, const char *name); +const char *rccGetLanguageName(rcc_context ctx, rcc_language_id language_id); +rcc_language_id rccGetLanguageByName(rcc_context ctx, const char *name); +rcc_language_id rccGetRealLanguage(rcc_context ctx, rcc_language_id language_id); +const char *rccGetRealLanguageName(rcc_context ctx, rcc_language_id language_id); +rcc_language_id rccGetSelectedLanguage(rcc_context ctx); +const char *rccGetSelectedLanguageName(rcc_context ctx); +rcc_language_id rccGetCurrentLanguage(rcc_context ctx); +const char *rccGetCurrentLanguageName(rcc_context ctx); + +int rccSetLanguage(rcc_context ctx, rcc_language_id language_id); +int rccSetLanguageByName(rcc_context ctx, const char *name); /* lngconfig.c */ -int rccConfigInit(rcc_language_config *config, rcc_context *ctx); -int rccConfigFree(rcc_language_config *config); +int rccConfigInit(rcc_language_config config, rcc_context ctx); +int rccConfigFree(rcc_language_config config); const char *rccConfigGetEngineName(rcc_language_config config, rcc_engine_id engine_id); const char *rccConfigGetCharsetName(rcc_language_config config, rcc_charset_id charset_id); const char *rccConfigGetAutoCharsetName(rcc_language_config config, rcc_charset_id charset_id); -rcc_engine_id rccConfigGetEngineByName(rcc_language_config *config, const char *name); -rcc_charset_id rccConfigGetCharsetByName(rcc_language_config *config, const char *name); -rcc_charset_id rccConfigGetAutoCharsetByName(rcc_language_config *config, const char *name); +rcc_engine_id rccConfigGetEngineByName(rcc_language_config config, const char *name); +rcc_charset_id rccConfigGetCharsetByName(rcc_language_config config, const char *name); +rcc_charset_id rccConfigGetAutoCharsetByName(rcc_language_config config, const char *name); -rcc_language_config *rccGetConfig(rcc_context *ctx, rcc_language_id language_id); -rcc_language_config *rccGetConfigByName(rcc_context *ctx, const char *name); -rcc_language_config *rccGetCurrentConfig(rcc_context *ctx); +rcc_language_config rccGetConfig(rcc_context ctx, rcc_language_id language_id); +rcc_language_config rccGetConfigByName(rcc_context ctx, const char *name); +rcc_language_config rccGetCurrentConfig(rcc_context ctx); rcc_engine_id rccConfigGetSelectedEngine(rcc_language_config config); const char *rccConfigGetSelectedEngineName(rcc_language_config config); @@ -207,18 +166,18 @@ rcc_charset_id rccConfigGetCurrentCharset(rcc_language_config config, rcc_class_ const char *rccConfigGetCurrentCharsetName(rcc_language_config config, rcc_class_id class_id); rcc_option_value rccConfigGetOption(rcc_language_config config, rcc_option option); -int rccConfigSetEngine(rcc_language_config *config, rcc_engine_id engine_id); -int rccConfigSetCharset(rcc_language_config *config, rcc_class_id class_id, rcc_charset_id charset_id); -int rccConfigSetEngineByName(rcc_language_config *config, const char *name); -int rccConfigSetCharsetByName(rcc_language_config *config, rcc_class_id class_id, const char *name); -int rccConfigSetOption(rcc_language_config *config, rcc_option option, rcc_option_value value); +int rccConfigSetEngine(rcc_language_config config, rcc_engine_id engine_id); +int rccConfigSetCharset(rcc_language_config config, rcc_class_id class_id, rcc_charset_id charset_id); +int rccConfigSetEngineByName(rcc_language_config config, const char *name); +int rccConfigSetCharsetByName(rcc_language_config config, rcc_class_id class_id, const char *name); +int rccConfigSetOption(rcc_language_config config, rcc_option option, rcc_option_value value); -rcc_charset_id rccConfigGetLocaleCharset(rcc_language_config *config, const char *locale_variable); +rcc_charset_id rccConfigGetLocaleCharset(rcc_language_config config, const char *locale_variable); /* curconfig.c */ #define rccGetEngineName(ctx, engine_id) rccConfigGetEngineName(ctx->current_config, engine_id) #define rccGetCharsetName(ctx, charset_id) rccConfigGetCharsetName(ctx->current_config, charset_id) -#define rccGetAutoCharsetName(ctx, charset_id) rccConfGetAutoCharsetName(ctx->current_config, charset_id) +#define rccGetAutoCharsetName(ctx, charset_id) rccConfigGetAutoCharsetName(ctx->current_config, charset_id) #define rccGetEngineByName(ctx, name) rccConfigGetEngineByName(ctx->current_config, name) #define rccGetCharsetByName(ctx, name) rccConfigGetCharsetByName(ctx->current_config, name) #define rccGetAutoCharsetByName(ctx, name) rccConfigGetAutoCharsetByName(ctx->current_config, name) @@ -241,28 +200,39 @@ rcc_charset_id rccConfigGetLocaleCharset(rcc_language_config *config, const char #define rccGetLocaleCharset(ctx, locale_variable) rccConfigGetLocaleCharset(ctx->current_config, locale_variable) -/* recode.c */ -char *rccFrom(rcc_context *ctx, rcc_class_id class_id, char *buf, int len, int *rlen); -char *rccTo(rcc_context *ctx, rcc_class_id class_id, char *buf, int len, int *rlen); -char *rccRecode(rcc_context *ctx, rcc_class_id from, rcc_class_id to, char *buf, int len, int *rlen); -char *rccFS(rcc_context *ctx, char *fspath, char *path, char *filename, int len, int *rlen); - +/******************************************************************************* +************************ RCC_STRING Manipulations ****************************** +*******************************************************************************/ /* string.c */ -rcc_string rccStringInit(rcc_language_id language_id, const char *buf, int len, int *rlen); -void rccStringFree(rcc_string str); +typedef char *rcc_string; rcc_language_id rccStringCheck(const rcc_string str); const char *rccStringGet(const rcc_string str); char *rccStringExtract(const rcc_string buf, int len, int *rlen); -char *rccStringCmp(const rcc_string str1, const rcc_string str2); -char *rccStringNCmp(const rcc_string str1, const rcc_string str2, size_t n); -char *rccStringCaseCmp(const rcc_string str1, const rcc_string str2); -char *rccStringNCaseCmp(const rcc_string str1, const rcc_string str2, size_t n); +int rccStringCmp(const rcc_string str1, const rcc_string str2); +int rccStringNCmp(const rcc_string str1, const rcc_string str2, size_t n); +int rccStringCaseCmp(const rcc_string str1, const rcc_string str2); +int rccStringNCaseCmp(const rcc_string str1, const rcc_string str2, size_t n); + + +/******************************************************************************* +******************************** Recoding ************************************** +*******************************************************************************/ + +/* recode.c */ +rcc_string rccFrom(rcc_context ctx, rcc_class_id class_id, const char *buf, int len, int *rlen); +char *rccTo(rcc_context ctx, rcc_class_id class_id, const rcc_string buf, int len, int *rlen); +char *rccRecode(rcc_context ctx, rcc_class_id from, rcc_class_id to, const char *buf, int len, int *rlen); +char *rccFS(rcc_context ctx, rcc_class_id from, rcc_class_id to, const char *fspath, const char *path, const char *filename); + +/******************************************************************************* +******************************** Options *************************************** +*******************************************************************************/ /* xml.c */ -int rccSave(rcc_context *ctx); -int rccLoad(rcc_context *ctx); +int rccSave(rcc_context ctx); +int rccLoad(rcc_context ctx); #ifdef __cplusplus } |