From dfd33cccd5e2b4d169eb0f0ca7cccfc998b979b2 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 15 Jan 2003 16:11:43 +0000 Subject: [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 --- local.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'local.c') diff --git a/local.c b/local.c index 018a98c..17e1b64 100644 --- a/local.c +++ b/local.c @@ -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 #include @@ -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 - ("Directory list of %s

Directory list of %s

\n", - qdir, qdir); + tmp = Strnew_m_charp("\n\n\nDirectory list of ", qdir, + "\n\n\n

Directory list of ", + qdir, "

\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, "\n"); + Strcat_charp(tmp, "
\n\n"); } qsort((void *)flist, nfile, sizeof(char *), strCmp); for (i = 0; i < nfile; i++) { @@ -108,22 +109,23 @@ dirBuffer(char *dname) Strcat_charp(tmp, "\n"); @@ -149,15 +151,11 @@ dirBuffer(char *dname) } } if (multicolList) { - Strcat_charp(tmp, "
"); } 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, "ptr), NULL); + Strcat_m_charp(tmp, "", html_quote(conv_from_system(p)), NULL); if (S_ISDIR(st.st_mode)) Strcat_char(tmp, '/'); - Strcat_charp(tmp, ""); + Strcat_charp(tmp, ""); if (multicolList) { if (n++ == nrow) { Strcat_charp(tmp, "
\n"); + Strcat_charp(tmp, "\n\n"); } + Strcat_charp(tmp, "\n\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]); -- cgit v1.2.3