diff options
author | Robert Kukla <roolku@rockbox.org> | 2007-10-09 21:28:51 +0000 |
---|---|---|
committer | Robert Kukla <roolku@rockbox.org> | 2007-10-09 21:28:51 +0000 |
commit | a07e93938c04d2fe2720bb032006671433719ea6 (patch) | |
tree | e2858e92ecd979749940c90a4b85449a49f7ea2b /apps/plugins/lib/configfile.c | |
parent | 8a3e141904dfa89b12dd679b3e3c3ab2086b5756 (diff) | |
download | rockbox-a07e93938c04d2fe2720bb032006671433719ea6.tar.gz rockbox-a07e93938c04d2fe2720bb032006671433719ea6.zip |
fix yellow and some house cleaning
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15056 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib/configfile.c')
-rw-r--r-- | apps/plugins/lib/configfile.c | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c index 476f776878..7c7d56e4e5 100644 --- a/apps/plugins/lib/configfile.c +++ b/apps/plugins/lib/configfile.c | |||
@@ -154,7 +154,7 @@ int configfile_get_value(const char* filename, const char* name) | |||
154 | get_cfg_filename(buf, MAX_PATH, filename); | 154 | get_cfg_filename(buf, MAX_PATH, filename); |
155 | fd = cfg_rb->open(buf, O_RDONLY); | 155 | fd = cfg_rb->open(buf, O_RDONLY); |
156 | if(fd < 0) | 156 | if(fd < 0) |
157 | return -1; | 157 | return -1; |
158 | 158 | ||
159 | while(cfg_rb->read_line(fd, buf, MAX_PATH) > 0) | 159 | while(cfg_rb->read_line(fd, buf, MAX_PATH) > 0) |
160 | { | 160 | { |
@@ -172,43 +172,42 @@ int configfile_get_value(const char* filename, const char* name) | |||
172 | 172 | ||
173 | int configfile_update_entry(const char* filename, const char* name, int val) | 173 | int configfile_update_entry(const char* filename, const char* name, int val) |
174 | { | 174 | { |
175 | int fd; | 175 | int fd; |
176 | char *pname; | 176 | char *pname; |
177 | char *pval; | 177 | char *pval; |
178 | char path[MAX_PATH]; | 178 | char path[MAX_PATH]; |
179 | char buf[256]; | 179 | char buf[256]; |
180 | int found = 0; | 180 | int found = 0; |
181 | int line_len = 0; | 181 | int line_len = 0; |
182 | int pos = 0; | 182 | int pos = 0; |
183 | 183 | ||
184 | /* open the current config file */ | 184 | /* open the current config file */ |
185 | get_cfg_filename(path, MAX_PATH, filename); | 185 | get_cfg_filename(path, MAX_PATH, filename); |
186 | fd = cfg_rb->open(path, O_RDWR); | 186 | fd = cfg_rb->open(path, O_RDWR); |
187 | if(fd < 0) | 187 | if(fd < 0) |
188 | return -1; | 188 | return -1; |
189 | 189 | ||
190 | /* read in the current stored settings */ | 190 | /* read in the current stored settings */ |
191 | while((line_len = cfg_rb->read_line(fd, buf, 256)) > 0) | 191 | while((line_len = cfg_rb->read_line(fd, buf, 256)) > 0) |
192 | { | ||
193 | cfg_rb->settings_parseline(buf, &pname, &pval); | ||
194 | |||
195 | if(!cfg_rb->strcmp(name, pname)) | ||
196 | { | 192 | { |
197 | found = 1; | 193 | cfg_rb->settings_parseline(buf, &pname, &pval); |
198 | cfg_rb->lseek(fd, pos, SEEK_SET); | 194 | if(!cfg_rb->strcmp(name, pname)) |
199 | /* pre-allocate 10 bytes for INT */ | 195 | { |
200 | cfg_rb->fdprintf(fd, "%s: %10d\n", pname, val); | 196 | found = 1; |
201 | break; | 197 | cfg_rb->lseek(fd, pos, SEEK_SET); |
198 | /* pre-allocate 10 bytes for INT */ | ||
199 | cfg_rb->fdprintf(fd, "%s: %10d\n", pname, val); | ||
200 | break; | ||
201 | } | ||
202 | pos += line_len; | ||
202 | } | 203 | } |
203 | pos += line_len; | 204 | |
204 | } | 205 | /* if (name/val) is a new entry just append to file */ |
205 | 206 | if (found == 0) | |
206 | /* if (name/val) is a new entry just append to file */ | 207 | /* pre-allocate 10 bytes for INT */ |
207 | if (found == 0) | 208 | cfg_rb->fdprintf(fd, "%s: %10d\n", name, val); |
208 | /* pre-allocate 10 bytes for INT */ | 209 | |
209 | cfg_rb->fdprintf(fd, "%s: %10d\n", name, val); | 210 | cfg_rb->close(fd); |
210 | 211 | ||
211 | cfg_rb->close(fd); | 212 | return found; |
212 | |||
213 | return found; | ||
214 | } | 213 | } |