1 /*
2   LibRCC - various definitions used internally
3 
4   Copyright (C) 2005-2008 Suren A. Chilingaryan <csa@dside.dyndns.org>
5 
6   This library is free software; you can redistribute it and/or modify it
7   under the terms of the GNU Lesser General Public License version 2.1 or later
8   as published by the Free Software Foundation.
9 
10   This library is distributed in the hope that it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
13   for more details.
14 
15   You should have received a copy of the GNU Lesser General Public License
16   along with this program; if not, write to the Free Software Foundation, Inc.,
17   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #ifndef _RCC_INTERNAL_H
21 #define _RCC_INTERNAL_H
22 
23 #ifndef LIBRCC_DATA_DIR
24 # define LIBRCC_DATA_DIR "/usr/lib/rcc"
25 #endif /* LIBRCC_DATA_DIR */
26 
27 #define RCC_MAX_LANGUAGE_PARENTS 4
28 #define RCC_MAX_RELATIONS RCC_MAX_LANGUAGES
29 
30 #ifdef HAVE_STRNLEN
31 #define STRNLEN(str,n) (n?strnlen(str,n):strlen(str))
32 #else
33 #define STRNLEN(str,n) (n?rccStrnlen(str,n):strlen(str))
34 #endif /* !strnlen */
35 
36 #define RCC_MAX_PLUGINS 32
37 #define RCC_MAX_STRING_CHARS 1024
38 #define RCC_MAX_PREFIX_CHARS 32
39 #define RCC_MIN_DB4_CHARS 3
40 
41 #include "librcc.h"
42 #include "recode.h"
43 #include "engine.h"
44 #include "lngconfig.h"
45 #include "rccstring.h"
46 #include "rccdb4.h"
47 #include "rcciconv.h"
48 #include "rccstring.h"
49 #include "rccmutex.h"
50 #include "rcclocale.h"
51 
52 #define RCC_MAX_ADDITION_CHARSETS	8
53 #define RCC_MAX_DISABLED_CHARSETS	64
54 
55 
56 typedef rcc_language_id rcc_language_parent_list[RCC_MAX_LANGUAGE_PARENTS];
57 
58 struct rcc_language_internal_t {
59     rcc_language language;
60     rcc_language_id parents[RCC_MAX_LANGUAGE_PARENTS + 1];
61     unsigned char latin;
62 };
63 typedef struct rcc_language_internal_t rcc_language_internal;
64 typedef rcc_language_internal *rcc_language_internal_ptr;
65 
66 struct rcc_class_internal_t {
67     rcc_class cl;
68     rcc_charset *additional;
69     rcc_charset *disabled;
70 };
71 typedef struct rcc_class_internal_t rcc_class_internal;
72 
73 struct rcc_context_t {
74     char locale_variable[RCC_MAX_VARIABLE_CHARS+1];
75 
76     rcc_language_alias_list aliases;
77 
78     rcc_option_value options[RCC_MAX_OPTIONS];
79     unsigned char default_options[RCC_MAX_OPTIONS];
80 
81     unsigned int max_languages;
82     unsigned int n_languages;
83     rcc_language_internal *ilang;
84     rcc_language_ptr *languages;
85     rcc_language_config configs;
86 
87     unsigned int max_classes;
88     unsigned int n_classes;
89     rcc_class_internal *iclass;
90     rcc_class_ptr *classes;
91 
92     rcc_iconv *iconv_from;
93     rcc_iconv iconv_auto[RCC_MAX_CHARSETS];
94 
95     rcc_iconv fsiconv;
96 
97     char tmpbuffer[RCC_MAX_STRING_CHARS+sizeof(rcc_string_header)+9];
98     char lastprefix[RCC_MAX_PREFIX_CHARS+1];
99 
100     unsigned char configure;
101     rcc_language_config current_config;
102     rcc_language_id current_language;
103 
104     rcc_language_id default_language;
105 
106     db4_context db4ctx;
107 
108     rcc_mutex mutex;
109     unsigned int configuration_lock;
110 };
111 typedef struct rcc_context_t rcc_context_s;
112 
113 int rccLock();
114 void rccUnLock();
115 
116 int rccConfigure(rcc_context ctx);
117 char *rccCreateResult(rcc_context ctx, size_t len);
118 
119 extern rcc_context rcc_default_ctx;
120 
121 #endif /* _RCC_INTERNAL_H */
122