version 1.7, 2004/07/27 13:55:00 |
version 1.8, 2004/07/27 16:16:19 |
|
|
static char *cvs_mt_stack[CVS_MTSTK_MAXDEPTH]; |
static char *cvs_mt_stack[CVS_MTSTK_MAXDEPTH]; |
static u_int cvs_mtstk_depth = 0; |
static u_int cvs_mtstk_depth = 0; |
|
|
static struct tm cvs_modtime; |
static time_t cvs_modtime = 0; |
|
|
|
|
#define CVS_NBREQ (sizeof(cvs_requests)/sizeof(cvs_requests[0])) |
#define CVS_NBREQ (sizeof(cvs_requests)/sizeof(cvs_requests[0])) |
|
|
static int |
static int |
cvs_resp_modtime(int type, char *line) |
cvs_resp_modtime(int type, char *line) |
{ |
{ |
u_int i; |
int i; |
char mon[8]; |
long off; |
|
char sign, mon[8], gmt[8], hr[4], min[4], *ep; |
|
struct tm cvs_tm; |
|
|
cvs_modtime.tm_yday = 0; |
memset(&cvs_tm, 0, sizeof(cvs_tm)); |
cvs_modtime.tm_wday = 0; |
sscanf(line, "%d %8s %d %2d:%2d:%2d %5s", &cvs_tm.tm_mday, mon, |
|
&cvs_tm.tm_year, &cvs_tm.tm_hour, &cvs_tm.tm_min, |
|
&cvs_tm.tm_sec, gmt); |
|
cvs_tm.tm_year -= 1900; |
|
|
sscanf(line, "%d %8s %d %2d:%2d:%2d", &cvs_modtime.tm_mday, mon, |
if (*gmt == '-') { |
&cvs_modtime.tm_year, &cvs_modtime.tm_hour, &cvs_modtime.tm_min, |
sscanf("%c%2s%2s", &sign, hr, min); |
&cvs_modtime.tm_sec); |
cvs_tm.tm_gmtoff = strtol(hr, &ep, 10); |
cvs_modtime.tm_year -= 1900; |
if ((cvs_tm.tm_gmtoff == LONG_MIN) || |
|
(cvs_tm.tm_gmtoff == LONG_MAX) || |
|
(*ep != '\0')) { |
|
cvs_log(LP_ERR, |
|
"parse error in GMT hours specification `%s'", hr); |
|
cvs_tm.tm_gmtoff = 0; |
|
} |
|
else { |
|
/* get seconds */ |
|
cvs_tm.tm_gmtoff *= 3600; |
|
|
for (i = 0; i < sizeof(cvs_months)/sizeof(cvs_months[0]); i++) { |
/* add the minutes */ |
if (strcmp(cvs_months[i], mon) == 0) |
off = strtol(min, &ep, 10); |
cvs_modtime.tm_mon = (int)i; |
if ((cvs_tm.tm_gmtoff == LONG_MIN) || |
|
(cvs_tm.tm_gmtoff == LONG_MAX) || |
|
(*ep != '\0')) { |
|
cvs_log(LP_ERR, |
|
"parse error in GMT minutes " |
|
"specification `%s'", min); |
|
} |
|
else |
|
cvs_tm.tm_gmtoff += off * 60; |
|
} |
} |
} |
|
if (sign == '-') |
|
cvs_tm.tm_gmtoff = -cvs_tm.tm_gmtoff; |
|
|
|
for (i = 0; i < (int)(sizeof(cvs_months)/sizeof(cvs_months[0])); i++) { |
|
if (strcmp(cvs_months[i], mon) == 0) { |
|
cvs_tm.tm_mon = i; |
|
break; |
|
} |
|
} |
|
|
|
cvs_modtime = mktime(&cvs_tm); |
return (0); |
return (0); |
} |
} |
|
|
|
|
return (-1); |
return (-1); |
|
|
/* set the timestamp as the last one received from Mod-time */ |
/* set the timestamp as the last one received from Mod-time */ |
ep->ce_timestamp = asctime_r(&cvs_modtime, tbuf); |
ep->ce_timestamp = ctime_r(&cvs_modtime, tbuf); |
len = strlen(tbuf); |
len = strlen(tbuf); |
if ((len > 0) && (tbuf[len - 1] == '\n')) |
if ((len > 0) && (tbuf[len - 1] == '\n')) |
tbuf[--len] = '\0'; |
tbuf[--len] = '\0'; |