author | mickeyl <mickeyl> | 2003-03-30 01:51:14 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-30 01:51:14 (UTC) |
commit | d11a0154e2d9732854c9a3d598857bc20f359849 (patch) (unidiff) | |
tree | af0e0273d01f4f6c64c9f230f22bb91a7a8a21d8 /noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc | |
parent | 99899abc80a8aa05044eeecd8a061b0a8efaa713 (diff) | |
download | opie-d11a0154e2d9732854c9a3d598857bc20f359849.zip opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.gz opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.bz2 |
- the network work for libopie2 pays off...
- good bye to wellenreiterd, t'was fun but always too unstable and too hard to maintain
- good bye to libwellenreiter
Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc deleted file mode 100644 index ba56754..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc +++ b/dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | /* | ||
2 | * Configfile operations for wellenreiter | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "wl_conf.hh" | ||
8 | #include "wl_log.hh" | ||
9 | #include "wl_types.hh" | ||
10 | |||
11 | /* Check whether configfile exists and is readable */ | ||
12 | int wl_checkcfg(void) | ||
13 | { | ||
14 | FILE *wl_config; | ||
15 | |||
16 | if((wl_config = fopen(WL_CONFFILE, "r")) == NULL) | ||
17 | { | ||
18 | wl_logerr("Cannot open configfile: %s", strerror(errno)); | ||
19 | return 0; | ||
20 | } | ||
21 | else | ||
22 | { | ||
23 | fclose(wl_config); | ||
24 | return 1; | ||
25 | } | ||
26 | |||
27 | } | ||
28 | |||
29 | /* Get value for given token from config file */ | ||
30 | int wl_cfgvalue(const char *token, char *out, int maxlen) | ||
31 | { | ||
32 | FILE *wl_config; | ||
33 | char *ptr, *ptr2; | ||
34 | char confbuf[WL_CONFBUFF]; | ||
35 | |||
36 | if(token == NULL) | ||
37 | return -1; | ||
38 | |||
39 | if((wl_config = fopen(WL_CONFFILE, "r")) == NULL) | ||
40 | { | ||
41 | wl_logerr("Cannot open configfile: %s", strerror(errno)); | ||
42 | return -1; | ||
43 | } | ||
44 | |||
45 | /* Clear buffers */ | ||
46 | memset(out, 0, maxlen); | ||
47 | memset(confbuf, 0, sizeof(confbuf)); | ||
48 | |||
49 | while((fgets(confbuf, sizeof(confbuf) - 1, wl_config)) != NULL) | ||
50 | { | ||
51 | |||
52 | /* Ignore comments */ | ||
53 | if(confbuf[0] == '#') continue; | ||
54 | |||
55 | /* Search for token, if found check whether next character | ||
56 | * is a '=' or a ' ' | ||
57 | */ | ||
58 | if(strstr(confbuf, token) != NULL && | ||
59 | (confbuf[strlen(token)] == '=' || confbuf[strlen(token)] == ' ')) | ||
60 | { | ||
61 | |||
62 | /* Get value between quotes */ | ||
63 | if((ptr = strstr(confbuf, "\"")) == NULL) | ||
64 | break; | ||
65 | ++ptr; | ||
66 | if((ptr2 = strstr(ptr, "\"")) == NULL) | ||
67 | break; | ||
68 | ptr2[0] = '\0'; | ||
69 | |||
70 | memcpy(out, ptr, maxlen - 1); | ||
71 | break; | ||
72 | |||
73 | } | ||
74 | memset(confbuf, 0, sizeof(confbuf)); | ||
75 | } | ||
76 | |||
77 | fclose(wl_config); | ||
78 | |||
79 | return (out[0] == '\0' ? 0 : 1); | ||
80 | } | ||
81 | |||