static void build_tab_list(void) { struct widget_config *wcfg = &config.widgets[0]; unsigned char *p = &tab_list[1]; /* build tab list */ tab_list[0] = 0; while (wcfg->tab != TABS_END) { if (!search_on_list(tab_list, wcfg->tab)) { *p++ = wcfg->tab; tab_list[0]++; } wcfg++; if (tab_list[0] > (MAX_TABS-2)) break; } /* add an empty tab (tab 255) at the end */ *p++ = 255; tab_list[0]++; #if 0 DTABS("found %d tabs\n", tab_list[0]); int i; for (i = 0; i < tab_list[0]; i++) DTABS(" tab%d = %d\n", i, tab_list[i+1]); #endif /* load first tab */ load_tab(tab_list[1]); }
/* returns a pointer to the list */ static unsigned char* init_tab_list(void) { struct widget_config *addr = 0x00, cfg; unsigned char tlist[CONF_MAX_TABS+1]; unsigned char *cnt = &tlist[0]; unsigned char *p = &tlist[1]; /* first element of the list is the length */ *cnt = 0; while ((unsigned int) addr < (0x400 - 0x10)) { eeprom_read_block(&cfg, (const void*) addr++, sizeof(struct widget_config)); if (cfg.tab == TAB_TABLE_END) break; if (cfg.tab == ALL_TABS) continue; if (!search_on_list(tlist, cfg.tab)) { (*cnt)++; *p++ = cfg.tab; if (*cnt == CONF_MAX_TABS) break; } }; tab_list = malloc((*cnt) + 1); if (tab_list != NULL) memcpy(tab_list, tlist, (*cnt) + 1); return tab_list; }