break;
default:
cur.type = FT_UNKNOWN;
- DEBUGP (("UNKOWN; "));
+ DEBUGP (("UNKNOWN; "));
break;
}
switch (cur.type)
{
case FT_PLAINFILE:
- cur.perms = 420;
+ cur.perms = 0644;
break;
case FT_DIRECTORY:
- cur.perms = 493;
+ cur.perms = 0755;
break;
default:
- cur.perms = 1023;
+ /*cur.perms = 1023;*/ /* #### What is this? --hniksic */
+ cur.perms = 0644;
}
- DEBUGP (("implicite perms %0o; ", cur.perms));
+ DEBUGP (("implicit perms %0o; ", cur.perms));
}
else
{
FILE *fp;
int len;
int year, month, day; /* for time analysis */
- int hour, min, sec;
+ int hour, min;
struct tm timestruct;
char *line, *tok; /* tokenizer */
cur.name = xstrdup(tok);
DEBUGP(("Name: '%s'\n", cur.name));
- /* First column: mm-dd-yy */
+ /* First column: mm-dd-yy. Should atoi() on the month fail, january
+ will be assumed. */
tok = strtok(line, "-");
- month = atoi(tok);
+ month = atoi(tok) - 1;
+ if (month < 0) month = 0;
tok = strtok(NULL, "-");
day = atoi(tok);
tok = strtok(NULL, " ");
/* Assuming the epoch starting at 1.1.1970 */
if (year <= 70) year += 100;
- /* Second column: hh:mm[AP]M */
+ /* Second column: hh:mm[AP]M, listing does not contain value for
+ seconds */
tok = strtok(NULL, ":");
hour = atoi(tok);
tok = strtok(NULL, "M");
min = atoi(tok);
- /* Adjust hour from AM/PM */
+ /* Adjust hour from AM/PM. Just for the record, the sequence goes
+ 11:00AM, 12:00PM, 01:00PM ... 11:00PM, 12:00AM, 01:00AM . */
tok+=2;
+ if (hour == 12) hour = 0;
if (*tok == 'P') hour += 12;
- /* Listing does not contain value for seconds */
- sec = 0;
DEBUGP(("YYYY/MM/DD HH:MM - %d/%02d/%02d %02d:%02d\n",
year+1900, month, day, hour, min));
/* Build the time-stamp (copy & paste from above) */
- timestruct.tm_sec = sec;
+ timestruct.tm_sec = 0;
timestruct.tm_min = min;
timestruct.tm_hour = hour;
timestruct.tm_mday = day;
{
cur.type = FT_DIRECTORY;
cur.size = 0;
- cur.perms = 493; /* my gcc does not like 0755 ?? */
+ cur.perms = 0755;
DEBUGP(("Directory\n"));
}
else
{
cur.type = FT_PLAINFILE;
cur.size = atoi(tok);
- cur.perms = 420; /* 0664 octal */
+ cur.perms = 0644;
DEBUGP(("File, size %ld bytes\n", cur.size));
}
int hour, min, sec;
struct tm timestruct;
- char *line, *tok, *p; /* tokenizer */
+ char *line, *tok; /* tokenizer */
struct fileinfo *dir, *l, cur; /* list creation */
fp = fopen (file, "rb");
/* Line loop to end of file: */
while ((line = read_whole_line (fp)))
{
+ char *p;
i = clean_line (line);
if (!i) break;
}
for (i=0; i<12; i++) if (!strcmp(tok,months[i])) break;
/* Uknown months are mapped to January */
- month = (i%12)+1;
- tok = strtok(NULL, " ");
- year = atoi(tok)-1900;
+ month = i % 12 ;
+ tok = strtok (NULL, " ");
+ year = atoi (tok) - 1900;
DEBUGP(("date parsed\n"));
- /* Fourth/Third column: Time hh:mm:ss */
- tok = strtok(NULL, ":");
- hour = atoi(tok);
- tok = strtok(NULL, ":");
- min = atoi(tok);
- tok = strtok(NULL, " ");
- sec = atoi(tok);
+ /* Fourth/Third column: Time hh:mm[:ss] */
+ tok = strtok (NULL, " ");
+ hour = min = sec = 0;
+ p = tok;
+ hour = atoi (p);
+ for (; *p && *p != ':'; ++p);
+ if (*p)
+ min = atoi (++p);
+ for (; *p && *p != ':'; ++p);
+ if (*p)
+ sec = atoi (++p);
DEBUGP(("YYYY/MM/DD HH:MM:SS - %d/%02d/%02d %02d:%02d:%02d\n",
year+1900, month, day, hour, min, sec));
{
char *tmpu, *tmpp; /* temporary, clean user and passwd */
- tmpu = CLEANDUP (u->user);
- tmpp = u->passwd ? CLEANDUP (u->passwd) : NULL;
+ tmpu = encode_string (u->user);
+ tmpp = u->passwd ? encode_string (u->passwd) : NULL;
upwd = (char *)xmalloc (strlen (tmpu)
+ (tmpp ? (1 + strlen (tmpp)) : 0) + 2);
sprintf (upwd, "%s%s%s@", tmpu, tmpp ? ":" : "", tmpp ? tmpp : "");