#endif
localtime_r(&timep, &tm);
#else
/* xxx Need a CreateMutex/ReleaseMutex or something here
*/
{
struct tm *tmp = NULL;
tmp = localtime(&timep);
tm = *tmp; /* struct copy */
}
#endif
swup->sw_flags = 0;
switch (swup->sw_conf.swc_file_time_type)
{
case TIME_TYPE_YEAR:
sprintf(buf,"%04d", tm.tm_year + 1900);
break;
case TIME_TYPE_MONTH:
sprintf(buf,"%04d%02d", tm.tm_year + 1900, tm.tm_mon + 1);
break;
case TIME_TYPE_DAY:
sprintf(buf,"%04d%02d%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
break;
case TIME_TYPE_HOUR:
sprintf(buf,"%04d%02d%02d%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour);
break;
default:
sprintf(buf,"%04d%02d%02d%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour);
break;
}
if (swup->sw_curfileflag == NULL)
{
timewin_copy_string(&swup->sw_curfileflag, buf);
swup->sw_flags = 1;
}
else if (strcmp(swup->sw_curfileflag, buf) != 0)
{
timewin_copy_string(&swup->sw_prefileflag, swup->sw_curfileflag);
timewin_copy_string(&swup->sw_curfileflag, buf);
swup->sw_flags = 1;
}
return swup->sw_flags;
}
/******************************************************************************/
static int timewin_copy_string(char** szDest, const char* src)
{
int len = 0;
if (src == 0)
{
return -1;
}
len = strlen(src) + 1;
if (*szDest == NULL)
{
* szDest = (char *)malloc(len);
}
else if (strlen(*szDest) < len)
{
free(*szDest);
* szDest = (char *)malloc(len);
memset(*szDest, 0, len);
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-23402-10.html
赤裸裸千里万里挑衅和侵犯别国做出愚蠢行为是要付出代价的
给观众带来更多更好的作品