ftp: display hour:minute information if it is available.

This commit is contained in:
John Trengrove 2010-08-01 22:55:53 +02:00 committed by Giuseppe Scrivano
parent 0055a98eb1
commit e6b486fd93
3 changed files with 25 additions and 2 deletions

View File

@ -1,3 +1,13 @@
2010-07-25 John Trengrove <jtrengrove@gmail.com> (tiny change)
* ftp.h: Added enum `parsetype'. Modified struct to hold parsetype.
* ftp-ls.c (ftp_parse_unix_ls): Default to TT_DAY. Change to TT_HOUR_MIN
if hours/minutes parsed.
(ftp_parse_winnt_ls): Default to TT_HOUR_MIN.
(ftp_parse_vms_ls): Default to TT_HOUR_MIN.
(ftp_index): Print only if fileinfo struct value ttype set to TT_HOUR_MIN.
2010-07-30 Giuseppe Scrivano <gscrivano@gnu.org> 2010-07-30 Giuseppe Scrivano <gscrivano@gnu.org>
* html-url.h (struct map_context): Remove member `tail'. * html-url.h (struct map_context): Remove member `tail'.

View File

@ -100,7 +100,7 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
}; };
int next, len, i, error, ignore; int next, len, i, error, ignore;
int year, month, day; /* for time analysis */ int year, month, day; /* for time analysis */
int hour, min, sec; int hour, min, sec, ptype;
struct tm timestruct, *tnow; struct tm timestruct, *tnow;
time_t timenow; time_t timenow;
@ -183,6 +183,7 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
treated equally for now. */ treated equally for now. */
year = hour = min = sec = 0; /* Silence the compiler. */ year = hour = min = sec = 0; /* Silence the compiler. */
month = day = 0; month = day = 0;
ptype = TT_DAY;
next = -1; next = -1;
/* While there are tokens on the line, parse them. Next is the /* While there are tokens on the line, parse them. Next is the
number of tokens left until the filename. number of tokens left until the filename.
@ -262,6 +263,7 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
/* This means these were hours! */ /* This means these were hours! */
hour = year; hour = year;
year = 0; year = 0;
ptype = TT_HOUR_MIN;
++tok; ++tok;
/* Get the minutes... */ /* Get the minutes... */
for (; c_isdigit (*tok); tok++) for (; c_isdigit (*tok); tok++)
@ -414,6 +416,7 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
timestruct.tm_yday = 0; timestruct.tm_yday = 0;
timestruct.tm_isdst = -1; timestruct.tm_isdst = -1;
l->tstamp = mktime (&timestruct); /* store the time-stamp */ l->tstamp = mktime (&timestruct); /* store the time-stamp */
l->ptype = ptype;
xfree (line); xfree (line);
} }
@ -501,6 +504,7 @@ ftp_parse_winnt_ls (const char *file)
timestruct.tm_yday = 0; timestruct.tm_yday = 0;
timestruct.tm_isdst = -1; timestruct.tm_isdst = -1;
cur.tstamp = mktime (&timestruct); /* store the time-stamp */ cur.tstamp = mktime (&timestruct); /* store the time-stamp */
cur.ptype = TT_HOUR_MIN;
DEBUGP(("Timestamp: %ld\n", cur.tstamp)); DEBUGP(("Timestamp: %ld\n", cur.tstamp));
@ -987,6 +991,7 @@ ftp_parse_vms_ls (const char *file)
} }
cur.tstamp = timenow; /* Store the time-stamp. */ cur.tstamp = timenow; /* Store the time-stamp. */
DEBUGP(("Timestamp: %ld\n", cur.tstamp)); DEBUGP(("Timestamp: %ld\n", cur.tstamp));
cur.ptype = TT_HOUR_MIN;
/* Add the data for this item to the linked list, */ /* Add the data for this item to the linked list, */
if (!dir) if (!dir)
@ -1134,7 +1139,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
fprintf (fp, "%d %s %02d ", ptm->tm_year + 1900, months[ptm->tm_mon], fprintf (fp, "%d %s %02d ", ptm->tm_year + 1900, months[ptm->tm_mon],
ptm->tm_mday); ptm->tm_mday);
if (ptm->tm_hour) if (f->ptype == TT_HOUR_MIN)
fprintf (fp, "%02d:%02d ", ptm->tm_hour, ptm->tm_min); fprintf (fp, "%02d:%02d ", ptm->tm_hour, ptm->tm_min);
else else
fprintf (fp, " "); fprintf (fp, " ");

View File

@ -87,6 +87,13 @@ enum
GLOB_GLOBALL, GLOB_GETALL, GLOB_GETONE GLOB_GLOBALL, GLOB_GETALL, GLOB_GETONE
}; };
/* Used by to test if time parsed includes hours and minutes. */
enum parsetype
{
TT_HOUR_MIN, TT_DAY
};
/* Information about one filename in a linked list. */ /* Information about one filename in a linked list. */
struct fileinfo struct fileinfo
{ {
@ -94,6 +101,7 @@ struct fileinfo
char *name; /* file name */ char *name; /* file name */
wgint size; /* file size */ wgint size; /* file size */
long tstamp; /* time-stamp */ long tstamp; /* time-stamp */
enum parsetype ptype; /* time parsing */
int perms; /* file permissions */ int perms; /* file permissions */
char *linkto; /* link to which file points */ char *linkto; /* link to which file points */
struct fileinfo *prev; /* previous... */ struct fileinfo *prev; /* previous... */