static int scan_mon(char *str_mon, long *tm_monP) { static struct strlong mon_tab[] = { {"jan", 0}, {"january", 0}, {"feb", 1}, {"february", 1}, {"mar", 2}, {"march", 2}, {"apr", 3}, {"april", 3}, {"may", 4}, {"jun", 5}, {"june", 5}, {"jul", 6}, {"july", 6}, {"aug", 7}, {"august", 7}, {"sep", 8}, {"september", 8}, {"oct", 9}, {"october", 9}, {"nov", 10}, {"november", 10}, {"dec", 11}, {"december", 11}, }; static int sorted = 0; if (!sorted) { (void)qsort(mon_tab, sizeof(mon_tab) / sizeof(struct strlong), sizeof(struct strlong), strlong_compare); sorted = 1; } pound_case(str_mon); return strlong_search(str_mon, mon_tab, sizeof(mon_tab) / sizeof(struct strlong), tm_monP); }
static int scan_wday(char* str_wday, long* tm_wdayP) { static struct strlong wday_tab[] = { { "sun", 0 }, { "sunday", 0 }, { "mon", 1 }, { "monday", 1 }, { "tue", 2 }, { "tuesday", 2 }, { "wed", 3 }, { "wednesday", 3 }, { "thu", 4 }, { "thursday", 4 }, { "fri", 5 }, { "friday", 5 }, { "sat", 6 }, { "saturday", 6 }, }; static int sorted = 0; if(!sorted) { (void) qsort(wday_tab, sizeof(wday_tab) / sizeof(struct strlong), sizeof(struct strlong), (int(*)(const void*, const void*)) strlong_compare); sorted = 1; } pound_case(str_wday); return strlong_search(str_wday, wday_tab, sizeof(wday_tab) / sizeof(struct strlong), tm_wdayP); }