diff options
author | rickard evertsson <rickard.evertsson@stericsson.com> | 2010-11-03 13:58:06 +0100 |
---|---|---|
committer | Michael BRANDT <michael.brandt@stericsson.com> | 2010-11-03 15:39:28 +0100 |
commit | c7ac92701939f1fd186711a03518bff2bc7d6bcf (patch) | |
tree | 60cdf3ef1e5d4ed054795bcde60788b2e3649eb4 /tools/mk_envimg | |
parent | 5b2813846cd986e430aad0509758a7764cee76be (diff) |
mk_envimg: Add support to have comments in input config file
Adds support to have comments in the input file to mk_envimg.
Simply start the line with # and all following characters on that
line will be treated as a comment.
Change-Id: I119be1ebf0c80a7f6056632ff56b8f91beae364f
Signed-off-by: rickard evertsson <rickard.evertsson@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/7786
Reviewed-by: Michael BRANDT <michael.brandt@stericsson.com>
Reviewed-by: Robert ROSENGREN <robert.rosengren@stericsson.com>
Diffstat (limited to 'tools/mk_envimg')
-rw-r--r-- | tools/mk_envimg/README | 11 | ||||
-rw-r--r-- | tools/mk_envimg/mk_env_img.c | 15 |
2 files changed, 20 insertions, 6 deletions
diff --git a/tools/mk_envimg/README b/tools/mk_envimg/README index 97406ab14..ae9b76462 100644 --- a/tools/mk_envimg/README +++ b/tools/mk_envimg/README @@ -20,11 +20,14 @@ If an input file is specified it will remove, modify and/or remove default environment variables. Input file examples: -* Add a new variable: +* Add a new variable -> write the new variable and its value: an_new_variable=a_new_value -* Remove the variable bootargs +* Remove the variable bootargs -> write its name without a value: bootargs -* Modify the variable bootargs -bootargs=a_new_value
\ No newline at end of file +* Modify the variable bootargs -> write its name with a new value: +bootargs=a_new_value + +* Comments -> add # at the beginning of the line +# This is a comment
\ No newline at end of file diff --git a/tools/mk_envimg/mk_env_img.c b/tools/mk_envimg/mk_env_img.c index 669e37884..ab20bc893 100644 --- a/tools/mk_envimg/mk_env_img.c +++ b/tools/mk_envimg/mk_env_img.c @@ -361,7 +361,7 @@ static char *split_name_value_pair(char *s, char *endpos) * default image. * Return values: * OK - for success - * -NOK - Text string is larger than text buffer + * -NOK - Faulty comment or Text string is larger than text buffer * -ENOENT - File or folder does not exist */ static int replace_default_values(char *file_name) @@ -380,14 +380,25 @@ static int replace_default_values(char *file_name) } while (ret != EOF) { + /* + * Each iteraction s points to beginning of s_buf. s gets + * and fills s_buf with new characters until LR or EOF is + * reached. i makes sure that the buffer isn't overflowed. + */ for (s = &s_buf[0]; i < CONFIG_BUF_SIZE; i++) { ret = fgetc(config_file); *s = (char) ret; if ((*s == '\n') || (ret == EOF)) { + i = 0; + + /* If line starts with '#' it's a comment, + * proceed to next line */ + if (s_buf[0] == '#') + break; + value = split_name_value_pair(&s_buf[0], s); replace_name_value_pair(&s_buf[0], value); - i = 0; break; } |