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 | |
| parent | 8a3e141904dfa89b12dd679b3e3c3ab2086b5756 (diff) | |
| download | rockbox-a07e93938c04d2fe2720bb032006671433719ea6.zip rockbox-a07e93938c04d2fe2720bb032006671433719ea6.tar.gz rockbox-a07e93938c04d2fe2720bb032006671433719ea6.tar.bz2 rockbox-a07e93938c04d2fe2720bb032006671433719ea6.tar.xz | |
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')
| -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 476f776..7c7d56e 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) get_cfg_filename(buf, MAX_PATH, filename); fd = cfg_rb->open(buf, O_RDONLY); if(fd < 0) - return -1; + return -1; while(cfg_rb->read_line(fd, buf, MAX_PATH) > 0) { @@ -172,43 +172,42 @@ int configfile_get_value(const char* filename, const char* name) int configfile_update_entry(const char* filename, const char* name, int val) { - int fd; - char *pname; - char *pval; - char path[MAX_PATH]; - char buf[256]; - int found = 0; - int line_len = 0; - int pos = 0; - - /* open the current config file */ - get_cfg_filename(path, MAX_PATH, filename); - fd = cfg_rb->open(path, O_RDWR); - if(fd < 0) - return -1; - - /* read in the current stored settings */ - while((line_len = cfg_rb->read_line(fd, buf, 256)) > 0) - { - cfg_rb->settings_parseline(buf, &pname, &pval); - - if(!cfg_rb->strcmp(name, pname)) + int fd; + char *pname; + char *pval; + char path[MAX_PATH]; + char buf[256]; + int found = 0; + int line_len = 0; + int pos = 0; + + /* open the current config file */ + get_cfg_filename(path, MAX_PATH, filename); + fd = cfg_rb->open(path, O_RDWR); + if(fd < 0) + return -1; + + /* read in the current stored settings */ + while((line_len = cfg_rb->read_line(fd, buf, 256)) > 0) { - found = 1; - cfg_rb->lseek(fd, pos, SEEK_SET); - /* pre-allocate 10 bytes for INT */ - cfg_rb->fdprintf(fd, "%s: %10d\n", pname, val); - break; + cfg_rb->settings_parseline(buf, &pname, &pval); + if(!cfg_rb->strcmp(name, pname)) + { + found = 1; + cfg_rb->lseek(fd, pos, SEEK_SET); + /* pre-allocate 10 bytes for INT */ + cfg_rb->fdprintf(fd, "%s: %10d\n", pname, val); + break; + } + pos += line_len; } - pos += line_len; - } - - /* if (name/val) is a new entry just append to file */ - if (found == 0) - /* pre-allocate 10 bytes for INT */ - cfg_rb->fdprintf(fd, "%s: %10d\n", name, val); - - cfg_rb->close(fd); - - return found; + + /* if (name/val) is a new entry just append to file */ + if (found == 0) + /* pre-allocate 10 bytes for INT */ + cfg_rb->fdprintf(fd, "%s: %10d\n", name, val); + + cfg_rb->close(fd); + + return found; } |