diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-01-15 16:11:43 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-01-15 16:11:43 +0000 |
commit | dfd33cccd5e2b4d169eb0f0ca7cccfc998b979b2 (patch) | |
tree | e48a0e99a4922bf7a8504fbbf03442c12fee49ff /local.c | |
parent | [w3m-dev 03639] Re: smb.cgi (diff) | |
download | w3m-dfd33cccd5e2b4d169eb0f0ca7cccfc998b979b2.tar.gz w3m-dfd33cccd5e2b4d169eb0f0ca7cccfc998b979b2.zip |
[w3m-dev 03640] Re: cleanup (don't close connection of news server)
* anchor.c (_put_ahchor_news): always conv_str
(_put_anchor_all): always conv_str
* etc.c (close_all_fds): deleted
(close_all_fds_except): added, except fd=f is left open
* file.c (guess_filename): added
(UFhalfclose): added
(convertLine): cleanup_line if not raw mode
check uf
(readHeader): always convertLine
(loadGeneralFile): rewrite
(loadGopherDir): return Str, args change to ParsedURL and code
rewrite
(saveBuffer): always conv_str
(_doFileCopy): close_all_fds
(doFileSave): close_all_fds_except
(uncompress_stream): dup, close_all_fds_except
* form.c (form_fputs_decode): always conv_str
(input_textarea): convertLine
* frame.c (createFrameFile): convertLine
* ftp.c (loadFTPDir): arg code
rewrite
(readFTPDir): convertLine
* html.h (UFfileno): added
* image.c (loadImage): close_all_fds
* indep.h (RAW_MODE): added
* local.c (loadLocalDir): return Str
(dirBuffer): rewrite
(localcgi_popen_r): close_all_fds
* main.c (main): check SCM_LOCAL
print err_msg
* news.c (news_command): args cmd and arg
(news_quit): news_command
(openNewsStream): news_command
(readNewsgroup): deleted
(loadNewsgroup): added
(closeNews): added
* proto.h (loadGopherDir): update
(conv_str): define for no JP_CHARSET
(readFTPDir): deleted
(loadFTPDir): added
(readNewsgroup): deleted
(loadNewsgroup): added
(dirBuffer): deleted
(loadLocalDir): added
(close_all_fds): defined by close_all_fds_except
(close_all_fds_except): added
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r-- | local.c | 41 |
1 files changed, 20 insertions, 21 deletions
@@ -1,4 +1,4 @@ -/* $Id: local.c,v 1.17 2003/01/10 16:42:50 ukai Exp $ */ +/* $Id: local.c,v 1.18 2003/01/15 16:11:43 ukai Exp $ */ #include "fm.h" #include <string.h> #include <stdio.h> @@ -34,8 +34,8 @@ setLocalCookie() set_environ("LOCAL_COOKIE", Local_cookie->ptr); } -Buffer * -dirBuffer(char *dname) +Str +loadLocalDir(char *dname) { Str tmp; DIR *d; @@ -53,17 +53,18 @@ dirBuffer(char *dname) int i, l, nrow = 0, n = 0, maxlen = 0; int nfile, nfile_max = 100; Str dirname; - Buffer *buf; d = opendir(dname); if (d == NULL) return NULL; dirname = Strnew_charp(dname); + if (Strlastchar(dirname) != '/') + Strcat_char(dirname, '/'); qdir = html_quote(Str_conv_from_system(dirname)->ptr); - tmp = - Sprintf - ("<title>Directory list of %s</title><h1>Directory list of %s</h1>\n", - qdir, qdir); + tmp = Strnew_m_charp("<HTML>\n<HEAD>\n<BASE HREF=\"file://", qdir, + "\">\n<TITLE>Directory list of ", qdir, + "</TITLE>\n</HEAD>\n<BODY>\n<H1>Directory list of ", + qdir, "</H1>\n", NULL); flist = New_N(char *, nfile_max); nfile = 0; while ((dir = readdir(d)) != NULL) { @@ -86,7 +87,7 @@ dirBuffer(char *dname) l = 1; nrow = (n + l - 1) / l; n = 1; - Strcat_charp(tmp, "<TABLE CELLPADDING=0><TR VALIGN=TOP>\n"); + Strcat_charp(tmp, "<TABLE CELLPADDING=0>\n<TR VALIGN=TOP>\n"); } qsort((void *)flist, nfile, sizeof(char *), strCmp); for (i = 0; i < nfile; i++) { @@ -108,22 +109,23 @@ dirBuffer(char *dname) Strcat_charp(tmp, "<TD><NOBR>"); } else { - if (S_ISDIR(st.st_mode)) - Strcat_charp(tmp, "[DIR] "); #ifdef HAVE_LSTAT - else if (S_ISLNK(lst.st_mode)) + if (S_ISLNK(lst.st_mode)) Strcat_charp(tmp, "[LINK] "); + else #endif /* HAVE_LSTAT */ + if (S_ISDIR(st.st_mode)) + Strcat_charp(tmp, "[DIR] "); else Strcat_charp(tmp, "[FILE] "); } - Strcat_m_charp(tmp, "<A HREF=\"", file_to_url(fbuf->ptr), NULL); + Strcat_m_charp(tmp, "<A HREF=\"", html_quote(file_quote(p)), NULL); if (S_ISDIR(st.st_mode)) Strcat_char(tmp, '/'); Strcat_m_charp(tmp, "\">", html_quote(conv_from_system(p)), NULL); if (S_ISDIR(st.st_mode)) Strcat_char(tmp, '/'); - Strcat_charp(tmp, "</a>"); + Strcat_charp(tmp, "</A>"); if (multicolList) { if (n++ == nrow) { Strcat_charp(tmp, "</NOBR></TD>\n"); @@ -149,15 +151,11 @@ dirBuffer(char *dname) } } if (multicolList) { - Strcat_charp(tmp, "</TR></TABLE>\n"); + Strcat_charp(tmp, "</TR>\n</TABLE>\n"); } + Strcat_charp(tmp, "</BODY>\n</HTML>\n"); - buf = loadHTMLString(tmp); -#ifdef JP_CHARSET - if (buf) - buf->document_code = SystemCode; -#endif - return buf; + return tmp; } static int @@ -364,6 +362,7 @@ localcgi_popen_r(FILE ** p_fp) close(fd[1]); close(fd[0]); + close_all_fds(2); } else { close(fd[1]); |