X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=blobdiff_plain;f=second%2Fcfg.c;h=f23e690d4807ad0b37da58d91b9ae589d879ffa3;hp=d7f4084abb6b8e0d2e716873fda7510760f82ed2;hb=fa877515ee56ce034ee8ae0d37994d9c6957e5ad;hpb=750ce1ac64bea60a4c072373ed9661c8b180b627 diff --git a/second/cfg.c b/second/cfg.c index d7f4084..f23e690 100644 --- a/second/cfg.c +++ b/second/cfg.c @@ -41,7 +41,7 @@ typedef struct { void *data; } CONFIG; -#define MAX_TOKEN 200 +#define MAX_TOKEN 511 #define MAX_VAR_NAME MAX_TOKEN #define EOF -1 @@ -585,6 +585,43 @@ char *cfg_get_default (void) return ret; } +/* + * cfg_set_default_by_mac () + * return 1 if the default cf_option was changed to label with the MAC addr + * return 0 if not changed + */ +int cfg_set_default_by_mac (char *mac_addr) +{ + CONFIG *walk; + struct IMAGES *tmp; + char * label = NULL; + int haslabel = 0; + + /* check if there is an image label equal to mac_addr */ + for (tmp = images; tmp; tmp = tmp->next) { + label = cfg_get_strg_i (tmp->table, "label"); + if (!strcmp(label,mac_addr)){ + haslabel = 1; + } + } + + if (!haslabel) + return 0; + else { + /* + * if there is an image label equal to mac_addr, change the default + * cf_options to this image label + */ + for (walk = cf_options; walk->type != cft_end; walk++) { + if (!strcasecmp(walk->name,"default")) { + walk->data = mac_addr; + return 1; + } + } + return 0; + } +} + /* * Local variables: * c-file-style: "k&r"