mirror of
https://github.com/linux-msm/cdba.git
synced 2026-02-25 13:11:56 -08:00
device_parser: Fall back to read /etc/cdba
After attempting to read .cdba, fall back to read /etc/cdba - to make it possible to provide system wide configuration for a multiple users. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
@@ -287,7 +287,14 @@ int main(int argc, char **argv)
|
||||
|
||||
signal(SIGPIPE, sigpipe_handler);
|
||||
|
||||
device_parser(".cdba");
|
||||
ret = device_parser(".cdba");
|
||||
if (ret) {
|
||||
ret = device_parser("/etc/cdba");
|
||||
if (ret) {
|
||||
fprintf(stderr, "device parser: unable to open config file\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
watch_add_readfd(STDIN_FILENO, handle_stdin, NULL);
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ static void parse_board(struct device_parser *dp)
|
||||
device_add(dev);
|
||||
}
|
||||
|
||||
void device_parser(const char *path)
|
||||
int device_parser(const char *path)
|
||||
{
|
||||
struct device_parser dp;
|
||||
char key[TOKEN_LENGTH];
|
||||
@@ -154,11 +154,13 @@ void device_parser(const char *path)
|
||||
fh = fopen(path, "r");
|
||||
if (!fh) {
|
||||
fprintf(stderr, "device parser: unable to open %s\n", path);
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!yaml_parser_initialize(&dp.parser))
|
||||
if(!yaml_parser_initialize(&dp.parser)) {
|
||||
fprintf(stderr, "device parser: failed to initialize parser\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
yaml_parser_set_input_file(&dp.parser, fh);
|
||||
|
||||
@@ -188,4 +190,6 @@ void device_parser(const char *path)
|
||||
yaml_parser_delete(&dp.parser);
|
||||
|
||||
fclose(fh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef __DEVICE_PARSER_H__
|
||||
#define __DEVICE_PARSER_H__
|
||||
|
||||
void device_parser(const char *path);
|
||||
int device_parser(const char *path);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user