void* _Locale_time_create(const char * name) { int size, month, dayofweek; char cname[_Locale_MAX_SIMPLE_NAME]; _Locale_time_t *ltime=(_Locale_time_t*)malloc(sizeof(_Locale_time_t));; if(!ltime) return ltime; memset(ltime, 0, sizeof(_Locale_time_t)); __Extract_locale_name(name, LC_TIME, cname); if(__GetLCIDFromName(cname, <ime->lcid, ltime->cp)==-1) { free(ltime); return NULL; } for(month=LOCALE_SMONTHNAME1; month<=LOCALE_SMONTHNAME12; month++) // Small hack :-) { size=GetLocaleInfoA(ltime->lcid, month, NULL, 0); ltime->month[month-LOCALE_SMONTHNAME1]=(char*)malloc(size); if(!ltime->month[month-LOCALE_SMONTHNAME1]) { _Locale_time_destroy(ltime); return NULL; } GetLocaleInfoA(ltime->lcid, month, ltime->month[month-LOCALE_SMONTHNAME1], size); __ConvertFromACP(ltime->month[month-LOCALE_SMONTHNAME1], size, ltime->cp); } for(month=LOCALE_SABBREVMONTHNAME1; month<=LOCALE_SABBREVMONTHNAME12; month++) { size=GetLocaleInfoA(ltime->lcid, month, NULL, 0); ltime->abbrev_month[month-LOCALE_SABBREVMONTHNAME1]=(char*)malloc(size); if(!ltime->abbrev_month[month-LOCALE_SABBREVMONTHNAME1]) { _Locale_time_destroy(ltime); return NULL; } GetLocaleInfoA(ltime->lcid, month, ltime->abbrev_month[month-LOCALE_SABBREVMONTHNAME1], size); __ConvertFromACP(ltime->abbrev_month[month-LOCALE_SABBREVMONTHNAME1], size, ltime->cp); } for(dayofweek=LOCALE_SDAYNAME1; dayofweek<=LOCALE_SDAYNAME7; dayofweek++) { int dayindex= ( dayofweek != LOCALE_SDAYNAME7 ) ? dayofweek-LOCALE_SDAYNAME1+1 : 0; size=GetLocaleInfoA(ltime->lcid, dayofweek, NULL, 0); ltime->dayofweek[dayindex]=(char*)malloc(size); if(!ltime->dayofweek[dayindex] ) { _Locale_time_destroy(ltime); return NULL; } GetLocaleInfoA(ltime->lcid, dayofweek, ltime->dayofweek[dayindex], size); __ConvertFromACP(ltime->dayofweek[dayindex], size, ltime->cp); } for(dayofweek=LOCALE_SABBREVDAYNAME1; dayofweek<=LOCALE_SABBREVDAYNAME7; dayofweek++) { int dayindex= ( dayofweek != LOCALE_SABBREVDAYNAME7 ) ? dayofweek-LOCALE_SABBREVDAYNAME1+1 : 0; size=GetLocaleInfoA(ltime->lcid, dayofweek, NULL, 0); ltime->abbrev_dayofweek[dayindex]=(char*)malloc(size); if(!ltime->abbrev_dayofweek[dayindex]) { _Locale_time_destroy(ltime); return NULL; } GetLocaleInfoA(ltime->lcid, dayofweek, ltime->abbrev_dayofweek[dayindex], size); __ConvertFromACP(ltime->abbrev_dayofweek[dayindex], size, ltime->cp); } return ltime; }
void _Loc_time_destroy(void* p) {_Locale_time_destroy(p);}
static void _Loc_time_destroy(void* p) {_Locale_time_destroy((_Locale_time*)p);}