/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-29 03:26:28 UTC
  • Revision ID: Arch-1:ds@dside.dyndns.org--darksoft-2004%librcc--main--0.1--patch-23
Translation
    - Language Translation using libtranslate is implemented
    - Autoengine sets current charset (option)

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#ifdef HAVE_SYS_TYPES_H
12
12
# include <sys/types.h>
13
13
#endif /* HAVE_SYS_TYPES_H */
 
14
#ifdef HAVE_SYS_STAT_H
 
15
# include <sys/stat.h>
 
16
#endif /* HAVE_SYS_STAT_H */
14
17
 
15
18
#ifdef HAVE_PWD_H
16
19
# include <pwd.h>
23
26
#include "plugin.h"
24
27
#include "engine.h"
25
28
#include "rccxml.h"
 
29
#include "rccexternal.h"
 
30
#include "rcctranslate.h"
26
31
 
27
32
static int initialized = 0;
28
33
char *rcc_home_dir = NULL;
43
48
#ifdef HAVE_DB_H
44
49
    compiled_configuration.flags|=RCC_CC_FLAG_HAVE_BERKLEY_DB;
45
50
#endif /* HAVE_DB_H */
 
51
#ifdef HAVE_LIBTRANSLATE
 
52
    compiled_configuration.flags|=RCC_CC_FLAG_HAVE_LIBTRANSLATE;
 
53
#endif /* HAVE_LIBTRANSLATE */
46
54
 
47
55
    return &compiled_configuration;
48
56
}
72
80
    memcpy(rcc_default_languages, rcc_default_languages_embeded, (RCC_MAX_LANGUAGES + 1)*sizeof(rcc_language));
73
81
    memcpy(rcc_option_descriptions, rcc_option_descriptions_embeded, (RCC_MAX_OPTIONS + 1)*sizeof(rcc_option_description));
74
82
 
 
83
#ifdef HAVE_LIBTRANSLATE
 
84
    rccExternalInit();
 
85
#endif /* HAVE_LIBTRANSLATE */    
 
86
 
75
87
    err = rccPluginInit();
 
88
    if (!err) err = rccTranslateInit();
76
89
    if (!err) err = rccXmlInit(1);
77
90
    if (!err) err = rccEngineInit();
78
91
 
94
107
    
95
108
    rccEngineFree();
96
109
    rccXmlFree();
 
110
    rccTranslateFree();
97
111
    rccPluginFree();
98
112
 
 
113
    rccExternalFree();
 
114
 
99
115
    if (rcc_home_dir) {
100
116
        free(rcc_home_dir);
101
117
        rcc_home_dir = NULL;
274
290
    }
275
291
}
276
292
 
 
293
int rccInitDb4(rcc_context ctx, const char *name, rcc_db4_flags flags) {
 
294
    size_t size;
 
295
    char *dbname;
 
296
    
 
297
    if (!ctx) {
 
298
        if (rcc_default_ctx) ctx = rcc_default_ctx;
 
299
        else return -1;
 
300
    }
 
301
 
 
302
    if (!name) name = "default";
 
303
 
 
304
    size = strlen(rcc_home_dir) + strlen(name) + 32;
 
305
    dbname = (char*)malloc(size*sizeof(char));
 
306
    if (!dbname) return -1;
 
307
 
 
308
    sprintf(dbname,"%s/.rcc/",rcc_home_dir);
 
309
    mkdir(dbname, 00644);
 
310
    
 
311
    sprintf(dbname,"%s/.rcc/%s.db/",rcc_home_dir,name);
 
312
    mkdir(dbname, 00644);
 
313
 
 
314
    ctx->db4ctx = rccDb4CreateContext(dbname, flags);
 
315
    free(dbname);       
 
316
    
 
317
    if (!ctx->db4ctx) return -1;
 
318
 
 
319
    return 0;
 
320
}
 
321
 
277
322
int rccLockConfiguration(rcc_context ctx, unsigned int lock_code) {
278
323
    if (!ctx) {
279
324
        if (rcc_default_ctx) ctx = rcc_default_ctx;