diff options
| author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-08-22 14:39:46 +0200 |
|---|---|---|
| committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-08-22 14:39:46 +0200 |
| commit | 260399ee8c44970aaa1cc9fd27db20df96604c5d (patch) | |
| tree | a0e9ae8de0de9c8f656d7a64759209e4183fd747 /utils/imxtools/sbtools/dbparser.c | |
| parent | a122b52d66464db7310022872e9eed1e55ea980c (diff) | |
| download | rockbox-260399ee8c44970aaa1cc9fd27db20df96604c5d.zip rockbox-260399ee8c44970aaa1cc9fd27db20df96604c5d.tar.gz rockbox-260399ee8c44970aaa1cc9fd27db20df96604c5d.tar.bz2 rockbox-260399ee8c44970aaa1cc9fd27db20df96604c5d.tar.xz | |
sbtools: more work on sbtoelf and elftosb, support more attributes
Now handle timestamp, sb minor version, component/product versions,
section flags.
Change-Id: I35313efe60c28f04ea3732b36e5e01be3213cf9e
Diffstat (limited to 'utils/imxtools/sbtools/dbparser.c')
| -rw-r--r-- | utils/imxtools/sbtools/dbparser.c | 56 |
1 files changed, 18 insertions, 38 deletions
diff --git a/utils/imxtools/sbtools/dbparser.c b/utils/imxtools/sbtools/dbparser.c index 6cba91f..54939db 100644 --- a/utils/imxtools/sbtools/dbparser.c +++ b/utils/imxtools/sbtools/dbparser.c @@ -419,44 +419,29 @@ struct cmd_option_t *db_find_option_by_id(struct cmd_option_t *opt, const char * #define INVALID_SB_SUBVERSION 0xffff -static uint16_t parse_sb_subversion(char *str) +static const char *parse_sb_subversion(const char *str, uint16_t *v) { - int len = strlen(str); - uint16_t n = 0; - if(len == 0 || len > 4) - return INVALID_SB_SUBVERSION; - for(int i = 0; i < len; i++) - { - if(!isdigit(str[i])) - return INVALID_SB_SUBVERSION; - n = n << 4 | (str[i] - '0'); - } - return n; + int len = 0; + *v = 0; + while(isdigit(str[len]) && len < 3) + *v = (*v) << 4 | (str[len++] - '0'); + if(len == 0) + *v = INVALID_SB_SUBVERSION; + return str + len; } -bool db_parse_sb_version(struct sb_version_t *ver, char *str) +bool db_parse_sb_version(struct sb_version_t *ver, const char *str) { - int len = strlen(str); - int cnt = 0; - int pos[2]; - - for(int i = 0; i < len; i++) - { - if(str[i] != '.') - continue; - if(cnt == 2) - return false; - pos[cnt++] = i + 1; - str[i] = 0; - } - if(cnt != 2) + str = parse_sb_subversion(str, &ver->major); + if(ver->major == INVALID_SB_SUBVERSION || *str != '.') + return false; + str = parse_sb_subversion(str + 1, &ver->minor); + if(ver->minor == INVALID_SB_SUBVERSION || *str != '.') return false; - ver->major = parse_sb_subversion(str); - ver->minor = parse_sb_subversion(str + pos[0]); - ver->revision = parse_sb_subversion(str + pos[1]); - return ver->major != INVALID_SB_SUBVERSION && - ver->minor != INVALID_SB_SUBVERSION && - ver->revision != INVALID_SB_SUBVERSION; + str = parse_sb_subversion(str + 1, &ver->revision); + if(ver->revision == INVALID_SB_SUBVERSION || *str != 0) + return false; + return true; } static bool db_generate_sb_subversion(uint16_t subver, char *str) @@ -831,11 +816,6 @@ struct cmd_file_t *db_parse_file(const char *file) return cmd_file; } -void db_generate_default_sb_version(struct sb_version_t *ver) -{ - ver->major = ver->minor = ver->revision = 0x999; -} - void db_free_option_list(struct cmd_option_t *opt_list) { while(opt_list) |