/*
- * $Id: ftp.cc,v 1.233 1998/07/02 16:53:39 wessels Exp $
+ * $Id: ftp.cc,v 1.234 1998/07/14 22:59:15 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
static void ftpUnhack(FtpStateData * ftpState);
static void ftpScheduleReadControlReply(FtpStateData *, int);
static void ftpHandleControlReply(FtpStateData *);
+static char *ftpHtmlifyListEntry(char *line, FtpStateData * ftpState);
/* State machine functions
* send == state transition
if ((s = strchr(ftpState->user, ':'))) {
*s = 0;
xstrncpy(ftpState->password, s + 1, MAX_URL);
- rfc1738_unescape(ftpState->password);
+ rfc1738_unescape(ftpState->password);
} else {
xstrncpy(ftpState->password, null_string, MAX_URL);
}
{
StoreEntry *e = ftpState->entry;
wordlist *w;
+ char *dirup;
storeBuffer(e);
storeAppendPrintf(e, "<!-- HTML listing generated by Squid %s -->\n",
version_string);
storeAppendPrintf(e, "FTP Directory: %s\n", ftpState->title_url);
storeAppendPrintf(e, "</H2>\n");
storeAppendPrintf(e, "<PRE>\n");
+ dirup = ftpHtmlifyListEntry("<internal-dirup>", ftpState);
+ storeAppend(e, dirup, strlen(dirup));
storeBufferFlush(e);
ftpState->flags.html_header_sent = 1;
}
snprintf(html, 8192, "%s\n", line);
return html;
}
- if ((parts = ftpListParseParts(line, ftpState->flags)) == NULL) {
- char *p;
- snprintf(html, 8192, "%s\n", line);
- for (p = line; *p && isspace(*p); p++);
- if (*p && !isspace(*p))
- ftpState->flags.listformat_unknown = 1;
- return html;
- }
- /* check .. as special case */
- if (!strcmp(parts->name, "..")) {
+ /* Handle builtin <dirup> */
+ if (!strcmp(line, "<internal-dirup>")) {
snprintf(icon, 2048, "<IMG BORDER=0 SRC=\"%s\" ALT=\"%-6s\">",
mimeGetIconURL("internal-dirup"),
"[DIRUP]");
"Home Directory");
}
snprintf(html, 8192, "%s %s\n", icon, link);
- ftpListPartsFree(&parts);
+ return html;
+ }
+ if ((parts = ftpListParseParts(line, ftpState->flags)) == NULL) {
+ char *p;
+ snprintf(html, 8192, "%s\n", line);
+ for (p = line; *p && isspace(*p); p++);
+ if (*p && !isspace(*p))
+ ftpState->flags.listformat_unknown = 1;
return html;
}
if (!strcmp(parts->name, ".") || !strcmp(parts->name, "..")) {
j >>= 1;
IOStats.Ftp.read_hist[bin]++;
}
+ if (ftpState->flags.isdir && !ftpState->flags.html_header_sent && len >= 0) {
+ ftpListingStart(ftpState);
+ }
if (len < 0) {
debug(50, 1) ("ftpDataRead: read error: %s\n", xstrerror());
if (ignoreErrno(errno)) {
ftpReadComplete(ftpState);
} else {
if (ftpState->flags.isdir) {
- if (!ftpState->flags.html_header_sent)
- ftpListingStart(ftpState);
ftpParseListing(ftpState);
} else {
storeAppend(entry, ftpState->data.buf, len);