/rusxmms/librcc

To get this branch, use:
bzr branch http://suren.me/webbzr/rusxmms/librcc

« back to all changes in this revision

Viewing changes to src/librcc.c

  • Committer: Suren A. Chilingaryan
  • Date: 2005-07-02 05:08:36 UTC
  • Revision ID: Arch-1:ds@dside.dyndns.org--darksoft-2004%librcc--main--0.1--patch-3
02.07.2005

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#include "internal.h"
7
7
#include "rccconfig.h"
8
8
#include "rccenca.h"
 
9
#include "rcclist.h"
9
10
 
10
11
 
11
12
int rccInit() {
 
13
    /*DS: Load addition languages from config! */
12
14
    return rccEncaInit();
13
15
}
14
16
 
16
18
    rccEncaFree();
17
19
}
18
20
 
19
 
rcc_context rccInitContext(rcc_init_flags flags, unsigned int max_languages, unsigned int max_classes, const char *locale) {
 
21
rcc_context rccCreateContext(rcc_init_flags flags, unsigned int max_languages, unsigned int max_classes, const char *locale) {
20
22
    int err;
21
23
    unsigned int i;
22
24
    
109
111
        rccRegisterLanguage(ctx, rcc_default_languages);
110
112
        ctx->current_config = NULL;
111
113
    } 
112
 
    
 
114
 
 
115
    for (i=0;i<RCC_MAX_OPTIONS;i++)
 
116
        ctx->options[i] = 0;    
 
117
 
 
118
    ctx->configuration_lock = 0;
113
119
    ctx->configure = 1;
114
120
    
115
121
    return ctx;
163
169
    }
164
170
}
165
171
 
 
172
int rccLockConfiguration(rcc_context ctx, unsigned int lock_code) {
 
173
    if (!ctx) return -1;
 
174
    if (ctx->configuration_lock) return -3;
 
175
    ctx->configuration_lock = lock_code;
 
176
    return 0;
 
177
}
 
178
 
 
179
int rccUnlockConfiguration(rcc_context ctx, unsigned int lock_code) {
 
180
    if (!ctx) return -1;
 
181
    if (ctx->configuration_lock != lock_code) return -3;
 
182
    ctx->configuration_lock = 0;
 
183
    return 0;    
 
184
}
 
185
 
166
186
rcc_language_id rccRegisterLanguage(rcc_context ctx, rcc_language *language) {
167
187
    if ((!ctx)||(!language)) return -1;
 
188
    if (ctx->configuration_lock) return -3;
 
189
    
168
190
    if (ctx->n_languages == ctx->max_languages) return -2;
169
191
    ctx->languages[ctx->n_languages++] = language;
170
192
    ctx->languages[ctx->n_languages] = NULL;
213
235
 
214
236
rcc_class_id rccRegisterClass(rcc_context ctx, rcc_class *cl) {
215
237
    if ((!ctx)||(!cl)) return -1;
 
238
    if (ctx->configuration_lock) return -3;
216
239
    if (ctx->n_classes == ctx->max_classes) return -2;
 
240
 
217
241
    ctx->configure = 1;
218
242
    ctx->classes[ctx->n_languages++] = cl;
219
243
    ctx->classes[ctx->n_languages] = NULL;
227
251
    return ctx->classes[class_id]->class_type;
228
252
}
229
253
 
230
 
static rcc_language_ptr *rccGetLanguageList(rcc_context ctx) {
231
 
    if (!ctx) return NULL;
232
 
    return ctx->languages;
233
 
}
234
 
 
235
 
static rcc_charset *rccGetCharsetList(rcc_context ctx, rcc_language_id language_id) {
236
 
    if ((!ctx)||(language_id<0)||(language_id>=ctx->n_languages)) return NULL;
237
 
    return ctx->languages[language_id]->charsets;
238
 
}
239
 
 
240
 
static rcc_engine_ptr *rccGetEngineList(rcc_context ctx, rcc_language_id language_id) {
241
 
    if ((!ctx)||(language_id<0)||(language_id>=ctx->n_languages)) return NULL;
242
 
    return ctx->languages[language_id]->engines;
243
 
}
244
 
 
245
 
static rcc_charset *rccGetCurrentCharsetList(rcc_context ctx) {
246
 
    rcc_language_id language_id;
247
 
 
248
 
    if (!ctx) return NULL;
249
 
 
250
 
    language_id = rccGetCurrentLanguage(ctx);
251
 
    if (language_id<0) return NULL;
252
 
 
253
 
    return rccGetCharsetList(ctx, language_id);
254
 
}
255
 
 
256
 
static rcc_engine_ptr *rccGetCurrentEngineList(rcc_context ctx) {
257
 
    rcc_language_id language_id;
258
 
 
259
 
    if (!ctx) return NULL;
260
 
 
261
 
    language_id = rccGetCurrentLanguage(ctx);
262
 
    if (language_id<0) return NULL;
263
 
 
264
 
    return rccGetEngineList(ctx, language_id); 
265
 
}
266
 
 
267
 
static rcc_charset *rccGetCurrentAutoCharsetList(rcc_context ctx) {
268
 
    rcc_language_id language_id;
269
 
    rcc_engine_id engine_id;
270
 
 
271
 
    if (!ctx) return NULL;
272
 
 
273
 
    language_id = rccGetCurrentLanguage(ctx);
274
 
    engine_id = rccGetCurrentEngine(ctx);
275
 
    if ((language_id<0)||(engine_id<0)) return NULL;
276
 
    
277
 
    
278
 
    return ctx->languages[language_id]->engines[engine_id]->charsets;
279
 
}
280
 
 
281
254
 
282
255
int rccConfigure(rcc_context ctx) {
283
256
    unsigned int i;