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.tar.gz rockbox-260399ee8c44970aaa1cc9fd27db20df96604c5d.zip |
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 6cba91f34b..54939db6d2 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 * | |||
419 | 419 | ||
420 | #define INVALID_SB_SUBVERSION 0xffff | 420 | #define INVALID_SB_SUBVERSION 0xffff |
421 | 421 | ||
422 | static uint16_t parse_sb_subversion(char *str) | 422 | static const char *parse_sb_subversion(const char *str, uint16_t *v) |
423 | { | 423 | { |
424 | int len = strlen(str); | 424 | int len = 0; |
425 | uint16_t n = 0; | 425 | *v = 0; |
426 | if(len == 0 || len > 4) | 426 | while(isdigit(str[len]) && len < 3) |
427 | return INVALID_SB_SUBVERSION; | 427 | *v = (*v) << 4 | (str[len++] - '0'); |
428 | for(int i = 0; i < len; i++) | 428 | if(len == 0) |
429 | { | 429 | *v = INVALID_SB_SUBVERSION; |
430 | if(!isdigit(str[i])) | 430 | return str + len; |
431 | return INVALID_SB_SUBVERSION; | ||
432 | n = n << 4 | (str[i] - '0'); | ||
433 | } | ||
434 | return n; | ||
435 | } | 431 | } |
436 | 432 | ||
437 | bool db_parse_sb_version(struct sb_version_t *ver, char *str) | 433 | bool db_parse_sb_version(struct sb_version_t *ver, const char *str) |
438 | { | 434 | { |
439 | int len = strlen(str); | 435 | str = parse_sb_subversion(str, &ver->major); |
440 | int cnt = 0; | 436 | if(ver->major == INVALID_SB_SUBVERSION || *str != '.') |
441 | int pos[2]; | 437 | return false; |
442 | 438 | str = parse_sb_subversion(str + 1, &ver->minor); | |
443 | for(int i = 0; i < len; i++) | 439 | if(ver->minor == INVALID_SB_SUBVERSION || *str != '.') |
444 | { | ||
445 | if(str[i] != '.') | ||
446 | continue; | ||
447 | if(cnt == 2) | ||
448 | return false; | ||
449 | pos[cnt++] = i + 1; | ||
450 | str[i] = 0; | ||
451 | } | ||
452 | if(cnt != 2) | ||
453 | return false; | 440 | return false; |
454 | ver->major = parse_sb_subversion(str); | 441 | str = parse_sb_subversion(str + 1, &ver->revision); |
455 | ver->minor = parse_sb_subversion(str + pos[0]); | 442 | if(ver->revision == INVALID_SB_SUBVERSION || *str != 0) |
456 | ver->revision = parse_sb_subversion(str + pos[1]); | 443 | return false; |
457 | return ver->major != INVALID_SB_SUBVERSION && | 444 | return true; |
458 | ver->minor != INVALID_SB_SUBVERSION && | ||
459 | ver->revision != INVALID_SB_SUBVERSION; | ||
460 | } | 445 | } |
461 | 446 | ||
462 | static bool db_generate_sb_subversion(uint16_t subver, char *str) | 447 | 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) | |||
831 | return cmd_file; | 816 | return cmd_file; |
832 | } | 817 | } |
833 | 818 | ||
834 | void db_generate_default_sb_version(struct sb_version_t *ver) | ||
835 | { | ||
836 | ver->major = ver->minor = ver->revision = 0x999; | ||
837 | } | ||
838 | |||
839 | void db_free_option_list(struct cmd_option_t *opt_list) | 819 | void db_free_option_list(struct cmd_option_t *opt_list) |
840 | { | 820 | { |
841 | while(opt_list) | 821 | while(opt_list) |