Mercurial > gftp.yaz
diff lib/protocols.c @ 105:ae13b18c9336
2003-2-9 Brian Masney <masneyb@gftp.org>
* lib/protocols.c (parse_time) - parse more time formats. Better
error checking. If there was an error parsing this time,
skip ahead to the next token
* lib/rfc2068.c - this was completely broken. This was broken whenever
I did the conversion over to use the gftp_get_line() function.
* lib/rfc959.c - use g_strdup instead of g_malloc/strcpy
author | masneyb |
---|---|
date | Sun, 09 Feb 2003 20:05:35 +0000 |
parents | 3b573c8ef706 |
children | 982e3890e7fe |
line wrap: on
line diff
--- a/lib/protocols.c Fri Feb 07 22:02:51 2003 +0000 +++ b/lib/protocols.c Sun Feb 09 20:05:35 2003 +0000 @@ -1028,18 +1028,23 @@ parse_time (char *str, char **endpos) { struct tm curtime, *loctime; + time_t t, ret; char *tmppos; - time_t t; memset (&curtime, 0, sizeof (curtime)); curtime.tm_isdst = -1; - if (isdigit ((int) str[0]) && str[2] == '-') + if (strlen (str) > 4 && isdigit ((int) str[0]) && str[2] == '-' && isdigit ((int) str[3])) { /* This is how DOS will return the date/time */ /* 07-06-99 12:57PM */ tmppos = strptime (str, "%m-%d-%y %I:%M%p", &curtime); } + else if (strlen (str) > 4 && isdigit ((int) str[0]) && str[2] == '-' && isalpha (str[3])) + { + /* 10-Jan-2003 09:14 */ + tmppos = strptime (str, "%d-%h-%Y %H:%M", &curtime); + } else { /* This is how most UNIX, Novell, and MacOS ftp servers send their time */ @@ -1056,8 +1061,23 @@ tmppos = strptime (str, "%h %d %Y", &curtime); } + if (tmppos != NULL) + ret = mktime (&curtime); + else + ret = 0; + if (endpos != NULL) - *endpos = tmppos; + { + if (tmppos == NULL) + { + /* We cannot parse this date format. So, just skip this date field and continue to the next + token. This is mainly for the HTTP support */ + + for (*endpos = str; **endpos != ' ' && **endpos != '\t' && **endpos != '\0'; *endpos++); + } + else + *endpos = tmppos; + } return (mktime (&curtime)); }