/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/rccdb4.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:
4
4
 
5
5
#include "../config.h"
6
6
 
7
 
#ifdef HAVE_SYS_TYPES_H
8
 
# include <sys/types.h>
9
 
#endif /* HAVE_SYS_TYPES_H */
10
 
 
11
 
#ifdef HAVE_SYS_STAT_H
12
 
# include <sys/stat.h>
13
 
#endif /* HAVE_SYS_STAT_H */
14
 
 
15
7
#include "internal.h"
16
8
#include "rccdb4.h"
17
9
 
18
10
#define DATABASE "autolearn.db"
19
11
 
20
 
int rccInitDb4(rcc_context ctx, const char *name, rcc_db4_flags flags) {
21
 
    size_t size;
22
 
    char *dbname;
23
 
    
24
 
    if (!ctx) {
25
 
        if (rcc_default_ctx) ctx = rcc_default_ctx;
26
 
        else return -1;
27
 
    }
28
 
 
29
 
    if (!name) name = "default";
30
 
 
31
 
    size = strlen(rcc_home_dir) + strlen(name) + 32;
32
 
    dbname = (char*)malloc(size*sizeof(char));
33
 
    if (!dbname) return -1;
34
 
 
35
 
    sprintf(dbname,"%s/.rcc/",rcc_home_dir);
36
 
    mkdir(dbname, 00644);
37
 
    
38
 
    sprintf(dbname,"%s/.rcc/%s.db/",rcc_home_dir,name);
39
 
    mkdir(dbname, 00644);
40
 
 
41
 
    ctx->db4ctx = rccDb4CreateContext(dbname, flags);
42
 
    free(dbname);       
43
 
    
44
 
    if (!ctx->db4ctx) return -1;
45
 
 
46
 
    return 0;
47
 
}
48
 
 
49
12
db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) {
50
13
    int err;
51
14
    db4_context ctx;
124
87
}
125
88
#endif /* HAVE_DB_H */
126
89
 
127
 
int rccDb4SetKey(db4_context ctx, const char *orig, size_t olen, const rcc_string string) {
 
90
int rccDb4SetKey(db4_context ctx, const char *orig, size_t olen, const char *string) {
128
91
#ifdef HAVE_DB_H
129
92
    DBT key, data;
130
93
#endif /* HAVE_DB_H */
149
112
    return 1;
150
113
}
151
114
 
152
 
rcc_string rccDb4GetKey(db4_context ctx, const char *orig, size_t olen) {
 
115
char *rccDb4GetKey(db4_context ctx, const char *orig, size_t olen) {
153
116
#ifdef HAVE_DB_H
154
117
    DBT key, data;
155
118
#endif /* HAVE_DB_H */