commit ab9c82bdc8b1b99f783e787a0373c88b312d4f95
parent b6f8ed73743c1b35697d1388ae3c38f3ea67abc3
Author: ukai <ukai>
Date: Fri, 11 Jan 2002 20:05:58 +0000
[w3m-dev 02822] Print FTP directory list for -dump_extra option
From: Fumitoshi UKAI <ukai@debian.or.jp>
Diffstat:
4 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,13 @@
+2002-01-12 Fumitoshi UKAI <ukai@debian.or.jp>
+
+ * [w3m-dev 02822] Print FTP directory list for -dump_extra option
+ * file.c (loadGeneralFile): remove FTPDIRtmp, use readFTPDir() instead
+ save to buf->sourcefile for -dump_extra
+ * ftp.c (FTPDIRtmp): deleted
+ * ftp.c (openFTP): delete readFTPDir() part
+ * ftp.c (readFTPDir): added
+ * proto.h (readFTPDir): added
+
2002-01-11 Akinori Ito <aito@fw.ipsj.or.jp>
* [w3m-dev 02819]
diff --git a/file.c b/file.c
@@ -1018,23 +1018,35 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
/* openURL failure: it means either (1) the requested URL is a directory name
* on an FTP server, or (2) is a local directory name.
*/
- extern Str FTPDIRtmp;
if (fmInitialized && prevtrap) {
term_raw();
signal(SIGINT, prevtrap);
}
switch (f.scheme) {
case SCM_FTPDIR:
- if (FTPDIRtmp->length > 0) {
- b = loadHTMLString(FTPDIRtmp);
+ {
+ Str ftpdir = readFTPDir(&pu);
+ if (ftpdir && ftpdir->length > 0) {
+ FILE *src;
+ tmp = tmpfname(TMPF_SRC, ".html");
+ pushText(fileToDelete, tmp->ptr);
+ src = fopen(tmp->ptr, "w");
+ if (src) {
+ Strfputs(ftpdir, src);
+ fclose(src);
+ }
+ b = loadHTMLString(ftpdir);
if (b) {
if (b->currentURL.host == NULL
&& b->currentURL.file == NULL)
copyParsedURL(&b->currentURL, &pu);
b->real_scheme = pu.scheme;
+ if (src)
+ b->sourcefile = tmp->ptr;
}
return b;
}
+ }
break;
case SCM_LOCAL:
{
diff --git a/ftp.c b/ftp.c
@@ -374,8 +374,6 @@ FtpBye(FTP ftp)
}
-Str FTPDIRtmp;
-
static int ex_ftpdir_name_size_date(char *, char **, char **, char **);
static int ftp_system(FTP);
@@ -392,15 +390,9 @@ openFTP(ParsedURL *pu)
{
Str tmp2 = Strnew();
Str tmp3 = Strnew();
- Str host;
STATUS s;
- Str curdir;
char *user;
char *pass;
- char *fn;
- char *qdir;
- char **flist;
- int i, nfile, nfile_max = 100;
Str pwd = NULL;
int add_auth_cookie_flag;
char *realpathname = NULL;
@@ -408,7 +400,6 @@ openFTP(ParsedURL *pu)
char code = '\0', ic;
Str pathStr;
#endif
- int sv_type;
add_auth_cookie_flag = 0;
if (pu->user)
@@ -487,7 +478,26 @@ openFTP(ParsedURL *pu)
}
ftp_dir1:
pu->scheme = SCM_FTPDIR;
- FTPDIRtmp = Strnew();
+ return NULL;
+}
+
+Str
+readFTPDir(ParsedURL *pu)
+{
+ Str FTPDIRtmp = Strnew();
+ Str host;
+ Str curdir;
+ char *fn;
+ char *qdir;
+ char **flist;
+ int i, nfile, nfile_max = 100;
+ int sv_type;
+ STATUS s;
+ char *realpathname = NULL;
+ Str tmp2 = Strnew();
+
+ if (current_ftp->data == NULL)
+ return FTPDIRtmp;
sv_type = ftp_system(current_ftp);
if (pu->file == NULL || *pu->file == '\0') {
if (sv_type == UNIXLIKE_SERVER) {
@@ -499,6 +509,7 @@ openFTP(ParsedURL *pu)
curdir = Strnew_charp("/");
}
else {
+ realpathname = file_unquote(pu->file);
if (sv_type == UNIXLIKE_SERVER) {
s = FtpCwd(current_ftp, realpathname);
if (!FtpError(s)) {
@@ -656,7 +667,7 @@ openFTP(ParsedURL *pu)
FtpClose(current_ftp);
FtpBye(current_ftp);
- return NULL;
+ return FTPDIRtmp;
}
static int
diff --git a/proto.h b/proto.h
@@ -424,6 +424,7 @@ extern char *guessContentType(char *filename);
extern TextList *make_domain_list(char *domain_list);
extern int check_no_proxy(char *domain);
extern FILE *openFTP(ParsedURL *pu);
+extern Str readFTPDir(ParsedURL *pu);
extern void closeFTP(FILE * f);
extern int Ftpfclose(FILE * f);
extern AnchorList *putAnchor(AnchorList *al, char *url, char *target,