char * rcFile(char *base) { if (base && (base[0] == '/' || (base[0] == '.' && (base[1] == '/' || (base[1] == '.' && base[2] == '/'))) || (base[0] == '~' && base[1] == '/'))) /* /file, ./file, ../file, ~/file */ return expandPath(base); return expandPath(Strnew_m_charp(rc_dir, "/", base, NULL)->ptr); }
Str loadLocalDir(char *dname) { Str tmp; DIR *d; Directory *dir; struct stat st; char **flist; char *p, *qdir; Str fbuf = Strnew(); #ifdef HAVE_LSTAT struct stat lst; #ifdef HAVE_READLINK char lbuf[1024]; #endif /* HAVE_READLINK */ #endif /* HAVE_LSTAT */ int i, l, nrow = 0, n = 0, maxlen = 0; int nfile, nfile_max = 100; Str dirname; 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); /* FIXME: gettextize? */ tmp = Strnew_m_charp("<HTML>\n<HEAD>\n<BASE HREF=\"file://", html_quote(file_quote(dirname->ptr)), "\">\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) { flist[nfile++] = allocStr(dir->d_name, -1); if (nfile == nfile_max) { nfile_max *= 2; flist = New_Reuse(char *, flist, nfile_max); } if (multicolList) { l = strlen(dir->d_name); if (l > maxlen) maxlen = l; n++; } }
static int openImgdisplay() { Imgdisplay_pid = open_pipe_rw(&Imgdisplay_rf, &Imgdisplay_wf); if (Imgdisplay_pid < 0) goto err0; if (Imgdisplay_pid == 0) { /* child */ char *cmd; setup_child(FALSE, 2, -1); if (!strchr(Imgdisplay, '/')) cmd = Strnew_m_charp(w3m_auxbin_dir(), "/", Imgdisplay, NULL)->ptr; else cmd = Imgdisplay; myExec(cmd); /* XXX: ifdef __EMX__, use start /f ? */ } activeImage = TRUE; return TRUE; err0: Imgdisplay_pid = 0; activeImage = FALSE; return FALSE; }
Str loadNewsgroup0(ParsedURL *pu) #endif { volatile Str page; Str tmp; URLFile f; Buffer *buf; char *qgroup, *p, *q, *s, *t, *n; char *volatile scheme, *volatile group, *volatile list; int status, i, first, last; volatile int flag = 0, start = 0, end = 0; MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; #ifdef USE_M17N wc_ces doc_charset = DocumentCharset, mime_charset; *charset = WC_CES_US_ASCII; #endif if (current_news.host == NULL || !pu->file || *pu->file == '\0') return NULL; group = allocStr(pu->file, -1); if (pu->scheme == SCM_NNTP_GROUP) scheme = "/"; else scheme = "news:"; if ((list = strchr(group, '/'))) { /* <newsgroup>/<start-number>-<end-number> */ *list++ = '\0'; } if (fmInitialized) { message(Sprintf("Reading newsgroup %s...", group)->ptr, 0, 0); refresh(); } qgroup = html_quote(group); group = file_unquote(group); page = Strnew_m_charp("<html>\n<head>\n<base href=\"", parsedURL2Str(pu)->ptr, "\">\n<title>Newsgroup: ", qgroup, "</title>\n</head>\n<body>\n<h1>Newsgroup: ", qgroup, "</h1>\n<hr>\n", NULL); if (SETJMP(AbortLoading) != 0) { news_close(¤t_news); Strcat_charp(page, "</table>\n<p>Transfer Interrupted!\n"); goto news_end; } TRAP_ON; tmp = news_command(¤t_news, "GROUP", group, &status); if (status != 211) goto news_list; if (sscanf(tmp->ptr, "%d %d %d %d", &status, &i, &first, &last) != 4) goto news_list; if (list && *list) { if ((p = strchr(list, '-'))) { *p++ = '\0'; end = atoi(p); } start = atoi(list); if (start > 0) { if (start < first) start = first; if (end <= 0) end = start + MaxNewsMessage - 1; } } if (start <= 0) { start = first; end = last; if (end - start > MaxNewsMessage - 1) start = end - MaxNewsMessage + 1; } page = Sprintf("<html>\n<head>\n<base href=\"%s\">\n\ <title>Newsgroup: %s %d-%d</title>\n\ </head>\n<body>\n<h1>Newsgroup: %s %d-%d</h1>\n<hr>\n", parsedURL2Str(pu)->ptr, qgroup, start, end, qgroup, start, end); if (start > first) { i = start - MaxNewsMessage; if (i < first) i = first; Strcat(page, Sprintf("<a href=\"%s%s/%d-%d\">[%d-%d]</a>\n", scheme, qgroup, i, start - 1, i, start - 1)); } Strcat_charp(page, "<table>\n"); news_command(¤t_news, "XOVER", Sprintf("%d-%d", start, end)->ptr, &status); if (status == 224) { f.scheme = SCM_NEWS; while (true) { tmp = StrISgets(current_news.rf); if (NEWS_ENDLINE(tmp->ptr)) break; if (sscanf(tmp->ptr, "%d", &i) != 1) continue; if (!(s = strchr(tmp->ptr, '\t'))) continue; s++; if (!(n = strchr(s, '\t'))) continue; *n++ = '\0'; if (!(t = strchr(n, '\t'))) continue; *t++ = '\0'; if (!(p = strchr(t, '\t'))) continue; *p++ = '\0'; if (*p == '<') p++; if (!(q = strchr(p, '>')) && !(q = strchr(p, '\t'))) continue; *q = '\0'; tmp = decodeMIME(Strnew_charp(s), &mime_charset); s = convertLine(&f, tmp, HEADER_MODE, mime_charset ? &mime_charset : charset, mime_charset ? mime_charset : doc_charset)->ptr; tmp = decodeMIME(Strnew_charp(n), &mime_charset); n = convertLine(&f, tmp, HEADER_MODE, mime_charset ? &mime_charset : charset, mime_charset ? mime_charset : doc_charset)->ptr; add_news_message(page, i, t, n, s, p, scheme, pu->scheme == SCM_NNTP_GROUP ? qgroup : NULL); } } else { init_stream(&f, SCM_NEWS, current_news.rf); buf = newBuffer(INIT_BUFFER_WIDTH); for (i = start; i <= end && i <= last; i++) { news_command(¤t_news, "HEAD", Sprintf("%d", i)->ptr, &status); if (status != 221) continue; readHeader(&f, buf, FALSE, NULL); if (!(p = checkHeader(buf, "Message-ID:"))) continue; if (*p == '<') p++; if (!(q = strchr(p, '>')) && !(q = strchr(p, '\t'))) *q = '\0'; if (!(s = checkHeader(buf, "Subject:"))) continue; if (!(n = checkHeader(buf, "From:"))) continue; if (!(t = checkHeader(buf, "Date:"))) continue; add_news_message(page, i, t, n, s, p, scheme, pu->scheme == SCM_NNTP_GROUP ? qgroup : NULL); } } Strcat_charp(page, "</table>\n"); if (end < last) { i = end + MaxNewsMessage; if (i > last) i = last; Strcat(page, Sprintf("<a href=\"%s%s/%d-%d\">[%d-%d]</a>\n", scheme, qgroup, end + 1, i, end + 1, i)); } flag = 1; news_list: tmp = Sprintf("ACTIVE %s", group); if (!strchr(group, '*')) Strcat_charp(tmp, ".*"); news_command(¤t_news, "LIST", tmp->ptr, &status); if (status != 215) goto news_end; while (true) { tmp = StrISgets(current_news.rf); if (NEWS_ENDLINE(tmp->ptr)) break; if (flag < 2) { if (flag == 1) Strcat_charp(page, "<hr>\n"); Strcat_charp(page, "<table>\n"); flag = 2; } p = tmp->ptr; for (q = p; *q && !IS_SPACE(*q); q++) ; *(q++) = '\0'; if (sscanf(q, "%d %d", &last, &first) == 2 && last >= first) i = last - first + 1; else i = 0; Strcat(page, Sprintf ("<tr><td align=right>%d<td><a href=\"%s%s\">%s</a>\n", i, scheme, html_quote(file_quote(p)), html_quote(p))); } if (flag == 2) Strcat_charp(page, "</table>\n"); news_end: Strcat_charp(page, "</body>\n</html>\n"); TRAP_OFF; return page; }
static int createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, int force_reload) { int r, c, t_stack; URLFile f2; #ifdef USE_M17N wc_ces charset, doc_charset; #endif char *d_target, *p_target, *s_target, *t_target; ParsedURL *currentURL, base; MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; int flag; if (f == NULL) return -1; if (level == 0) { if (SETJMP(AbortLoading) != 0) { TRAP_OFF; return -1; } TRAP_ON; f->name = "_top"; } if (level > 7) { fputs("Too many frameset tasked.\n", f1); return -1; } if (level == 0) { fprintf(f1, "<html><head><title>%s</title></head><body>\n", html_quote(current->buffername)); fputs("<table hborder width=\"100%\">\n", f1); } else fputs("<table hborder>\n", f1); currentURL = f->currentURL ? f->currentURL : ¤t->currentURL; for (r = 0; r < f->row; r++) { fputs("<tr valign=top>\n", f1); for (c = 0; c < f->col; c++) { union frameset_element frame; struct frameset *f_frameset; int i = c + r * f->col; char *p = ""; int status = R_ST_NORMAL; Str tok = Strnew(); int pre_mode = 0; int end_tag = 0; frame = f->frame[i]; if (frame.element == NULL) { fputs("<td>\n</td>\n", f1); continue; } fputs("<td", f1); if (frame.element->name) fprintf(f1, " id=\"_%s\"", html_quote(frame.element->name)); if (!r) fprintf(f1, " width=\"%s\"", f->width[c]); fputs(">\n", f1); flag = 0; if (force_reload) { flag |= RG_NOCACHE; if (frame.element->attr == F_BODY) unloadFrame(frame.body); } switch (frame.element->attr) { default: /* FIXME: gettextize? */ fprintf(f1, "Frameset \"%s\" frame %d: type unrecognized", html_quote(f->name), i + 1); break; case F_UNLOADED: if (!frame.body->name && f->name) { frame.body->name = Sprintf("%s_%d", f->name, i)->ptr; } fflush(f1); f_frameset = frame_download_source(frame.body, currentURL, current->baseURL, flag); if (f_frameset) { deleteFrame(frame.body); f->frame[i].set = frame.set = f_frameset; goto render_frameset; } /* fall through */ case F_BODY: init_stream(&f2, SCM_LOCAL, NULL); if (frame.body->source) { fflush(f1); examineFile(frame.body->source, &f2); } if (f2.stream == NULL) { frame.body->attr = F_UNLOADED; if (frame.body->flags & FB_NO_BUFFER) /* FIXME: gettextize? */ fprintf(f1, "Open %s with other method", html_quote(frame.body->url)); else if (frame.body->url) /* FIXME: gettextize? */ fprintf(f1, "Can't open %s", html_quote(frame.body->url)); else /* FIXME: gettextize? */ fprintf(f1, "This frame (%s) contains no src attribute", frame.body->name ? html_quote(frame.body->name) : "(no name)"); break; } parseURL2(frame.body->url, &base, currentURL); p_target = f->name; s_target = frame.body->name; t_target = "_blank"; d_target = TargetSelf ? s_target : t_target; #ifdef USE_M17N charset = WC_CES_US_ASCII; if (current->document_charset != WC_CES_US_ASCII) doc_charset = current->document_charset; else doc_charset = DocumentCharset; #endif t_stack = 0; if (frame.body->type && !strcasecmp(frame.body->type, "text/plain")) { Str tmp; fprintf(f1, "<pre>\n"); while ((tmp = StrmyUFgets(&f2))->length) { tmp = convertLine(NULL, tmp, HTML_MODE, &charset, doc_charset); fprintf(f1, "%s", html_quote(tmp->ptr)); } fprintf(f1, "</pre>\n"); UFclose(&f2); break; } do { int is_tag = FALSE; char *q; struct parsed_tag *tag; do { if (*p == '\0') { Str tmp = StrmyUFgets(&f2); if (tmp->length == 0) break; tmp = convertLine(NULL, tmp, HTML_MODE, &charset, doc_charset); p = tmp->ptr; } read_token(tok, &p, &status, 1, status != R_ST_NORMAL); } while (status != R_ST_NORMAL); if (tok->length == 0) continue; if (tok->ptr[0] == '<') { if (tok->ptr[1] && REALLY_THE_BEGINNING_OF_A_TAG(tok->ptr)) is_tag = TRUE; else if (!(pre_mode & (RB_PLAIN | RB_INTXTA | RB_SCRIPT | RB_STYLE))) { p = Strnew_m_charp(tok->ptr + 1, p, NULL)->ptr; tok = Strnew_charp("<"); } } if (is_tag) { if (pre_mode & (RB_PLAIN | RB_INTXTA | RB_SCRIPT | RB_STYLE)) { q = tok->ptr; if ((tag = parse_tag(&q, FALSE)) && tag->tagid == end_tag) { if (pre_mode & RB_PLAIN) { fputs("</PRE_PLAIN>", f1); pre_mode = 0; end_tag = 0; goto token_end; } pre_mode = 0; end_tag = 0; goto proc_normal; } if (strncmp(tok->ptr, "<!--", 4) && (q = strchr(tok->ptr + 1, '<'))) { tok = Strnew_charp_n(tok->ptr, q - tok->ptr); p = Strnew_m_charp(q, p, NULL)->ptr; status = R_ST_NORMAL; } is_tag = FALSE; } else if (pre_mode & RB_INSELECT) { q = tok->ptr; if ((tag = parse_tag(&q, FALSE))) { if ((tag->tagid == end_tag) || (tag->tagid == HTML_N_FORM)) { if (tag->tagid == HTML_N_FORM) fputs("</SELECT>", f1); pre_mode = 0; end_tag = 0; goto proc_normal; } if (t_stack) { switch (tag->tagid) { case HTML_TABLE: case HTML_N_TABLE: CASE_TABLE_TAG: fputs("</SELECT>", f1); pre_mode = 0; end_tag = 0; goto proc_normal; } } } } } proc_normal: if (is_tag) { char *q = tok->ptr; int j, a_target = 0; ParsedURL url; if (!(tag = parse_tag(&q, FALSE))) goto token_end; switch (tag->tagid) { case HTML_TITLE: fputs("<!-- title:", f1); goto token_end; case HTML_N_TITLE: fputs("-->", f1); goto token_end; case HTML_BASE: /* "BASE" is prohibit tag */ if (parsedtag_get_value(tag, ATTR_HREF, &q)) { q = url_encode(remove_space(q), NULL, charset); parseURL(q, &base, NULL); } if (parsedtag_get_value(tag, ATTR_TARGET, &q)) { if (!strcasecmp(q, "_self")) d_target = s_target; else if (!strcasecmp(q, "_parent")) d_target = p_target; else d_target = url_quote_conv(q, charset); } Strshrinkfirst(tok, 1); Strshrink(tok, 1); fprintf(f1, "<!-- %s -->", html_quote(tok->ptr)); goto token_end; case HTML_META: if (parsedtag_get_value(tag, ATTR_HTTP_EQUIV, &q) && !strcasecmp(q, "refresh")) { if (parsedtag_get_value(tag, ATTR_CONTENT, &q) ) { Str s_tmp = NULL; int refresh_interval = getMetaRefreshParam(q, &s_tmp); if (s_tmp) { q = html_quote(s_tmp->ptr); fprintf(f1, "Refresh (%d sec) <a href=\"%s\">%s</a>\n", refresh_interval, q, q); } } } #ifdef USE_M17N if (UseContentCharset && parsedtag_get_value(tag, ATTR_HTTP_EQUIV, &q) && !strcasecmp(q, "Content-Type") && parsedtag_get_value(tag, ATTR_CONTENT, &q) && (q = strcasestr(q, "charset")) != NULL) { q += 7; SKIP_BLANKS(q); if (*q == '=') { wc_ces c; q++; SKIP_BLANKS(q); if ((c = wc_guess_charset(q, 0)) != 0) { doc_charset = c; charset = WC_CES_US_ASCII; } } } #endif /* fall thru, "META" is prohibit tag */ case HTML_HEAD: case HTML_N_HEAD: case HTML_BODY: case HTML_N_BODY: case HTML_DOCTYPE: /* prohibit_tags */ Strshrinkfirst(tok, 1); Strshrink(tok, 1); fprintf(f1, "<!-- %s -->", html_quote(tok->ptr)); goto token_end; case HTML_TABLE: t_stack++; break; case HTML_N_TABLE: t_stack--; if (t_stack < 0) { t_stack = 0; Strshrinkfirst(tok, 1); Strshrink(tok, 1); fprintf(f1, "<!-- table stack underflow: %s -->", html_quote(tok->ptr)); goto token_end; } break; CASE_TABLE_TAG: /* table_tags MUST be in table stack */ if (!t_stack) { Strshrinkfirst(tok, 1); Strshrink(tok, 1); fprintf(f1, "<!-- %s -->", html_quote(tok->ptr)); goto token_end; } break; case HTML_SELECT: pre_mode = RB_INSELECT; end_tag = HTML_N_SELECT; break; case HTML_TEXTAREA: pre_mode = RB_INTXTA; end_tag = HTML_N_TEXTAREA; break; case HTML_SCRIPT: pre_mode = RB_SCRIPT; end_tag = HTML_N_SCRIPT; break; case HTML_STYLE: pre_mode = RB_STYLE; end_tag = HTML_N_STYLE; break; case HTML_LISTING: pre_mode = RB_PLAIN; end_tag = HTML_N_LISTING; fputs("<PRE_PLAIN>", f1); goto token_end; case HTML_XMP: pre_mode = RB_PLAIN; end_tag = HTML_N_XMP; fputs("<PRE_PLAIN>", f1); goto token_end; case HTML_PLAINTEXT: pre_mode = RB_PLAIN; end_tag = MAX_HTMLTAG; fputs("<PRE_PLAIN>", f1); goto token_end; default: break; } for (j = 0; j < TagMAP[tag->tagid].max_attribute; j++) { switch (tag->attrid[j]) { case ATTR_SRC: case ATTR_HREF: case ATTR_ACTION: if (!tag->value[j]) break; tag->value[j] = url_encode(remove_space(tag->value[j]), &base, charset); tag->need_reconstruct = TRUE; parseURL2(tag->value[j], &url, &base); if (url.scheme == SCM_UNKNOWN || #ifndef USE_W3MMAILER url.scheme == SCM_MAILTO || #endif url.scheme == SCM_MISSING) break; a_target |= 1; tag->value[j] = parsedURL2Str(&url)->ptr; parsedtag_set_value(tag, ATTR_REFERER, parsedURL2Str(&base)->ptr); #ifdef USE_M17N if (tag->attrid[j] == ATTR_ACTION && charset != WC_CES_US_ASCII) parsedtag_set_value(tag, ATTR_CHARSET, wc_ces_to_charset (charset)); #endif break; case ATTR_TARGET: if (!tag->value[j]) break; a_target |= 2; if (!strcasecmp(tag->value[j], "_self")) { parsedtag_set_value(tag, ATTR_TARGET, s_target); } else if (!strcasecmp(tag->value[j], "_parent")) { parsedtag_set_value(tag, ATTR_TARGET, p_target); } break; case ATTR_NAME: case ATTR_ID: if (!tag->value[j]) break; parsedtag_set_value(tag, ATTR_FRAMENAME, s_target); break; } } if (a_target == 1) { /* there is HREF attribute and no TARGET * attribute */ parsedtag_set_value(tag, ATTR_TARGET, d_target); } if (parsedtag_need_reconstruct(tag)) tok = parsedtag2str(tag); Strfputs(tok, f1); } else { if (pre_mode & RB_PLAIN) fprintf(f1, "%s", html_quote(tok->ptr)); else if (pre_mode & RB_INTXTA) fprintf(f1, "%s", html_quote(html_unquote(tok->ptr))); else Strfputs(tok, f1); } token_end: Strclear(tok); } while (*p != '\0' || !iseos(f2.stream)); if (pre_mode & RB_PLAIN) fputs("</PRE_PLAIN>\n", f1); else if (pre_mode & RB_INTXTA) fputs("</TEXTAREA></FORM>\n", f1); else if (pre_mode & RB_INSELECT) fputs("</SELECT></FORM>\n", f1); else if (pre_mode & (RB_SCRIPT | RB_STYLE)) { if (status != R_ST_NORMAL) fputs(correct_irrtag(status)->ptr, f1); if (pre_mode & RB_SCRIPT) fputs("</SCRIPT>\n", f1); else if (pre_mode & RB_STYLE) fputs("</STYLE>\n", f1); } while (t_stack--) fputs("</TABLE>\n", f1); UFclose(&f2); break; case F_FRAMESET: render_frameset: if (!frame.set->name && f->name) { frame.set->name = Sprintf("%s_%d", f->name, i)->ptr; } createFrameFile(frame.set, f1, current, level + 1, force_reload); break; } fputs("</td>\n", f1); } fputs("</tr>\n", f1); } fputs("</table>\n", f1); if (level == 0) { fputs("</body></html>\n", f1); TRAP_OFF; } return 0; }
char * helpFile(char *base) { return expandPath(Strnew_m_charp(w3m_help_dir(), "/", base, NULL)->ptr); }
char * confFile(char *base) { return expandPath(Strnew_m_charp(w3m_conf_dir(), "/", base, NULL)->ptr); }
char * auxbinFile(char *base) { return expandPath(Strnew_m_charp(w3m_auxbin_dir(), "/", base, NULL)->ptr); }
Str loadFTPDir0(ParsedURL *pu) #endif { Str FTPDIRtmp; Str tmp; int status; volatile int sv_type; char *realpathname, *fn, *q; char **flist; int i, nfile, nfile_max; MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; #ifdef USE_M17N wc_ces doc_charset = DocumentCharset; *charset = WC_CES_US_ASCII; #endif if (current_ftp.data == NULL) return NULL; tmp = ftp_command(¤t_ftp, "SYST", NULL, &status); if (strstr(tmp->ptr, "UNIX") != NULL || !strncmp(tmp->ptr + 4, "Windows_NT", 10)) /* :-) */ sv_type = UNIXLIKE_SERVER; else sv_type = SERVER_NONE; if (pu->file == NULL || *pu->file == '\0') { if (sv_type == UNIXLIKE_SERVER) ftp_command(¤t_ftp, "LIST", NULL, &status); else ftp_command(¤t_ftp, "NLST", NULL, &status); pu->file = "/"; } else { realpathname = file_unquote(pu->file); if (*realpathname == '/' && *(realpathname + 1) == '~') realpathname++; if (sv_type == UNIXLIKE_SERVER) { ftp_command(¤t_ftp, "CWD", realpathname, &status); if (status == 250) ftp_command(¤t_ftp, "LIST", NULL, &status); } else ftp_command(¤t_ftp, "NLST", realpathname, &status); } if (status != 125 && status != 150) { fclose(current_ftp.data); current_ftp.data = NULL; return NULL; } tmp = parsedURL2Str(pu); if (Strlastchar(tmp) != '/') Strcat_char(tmp, '/'); fn = html_quote(tmp->ptr); tmp = convertLine(NULL, Strnew_charp(file_unquote(tmp->ptr)), RAW_MODE, charset, doc_charset); q = html_quote(tmp->ptr); FTPDIRtmp = Strnew_m_charp("<html>\n<head>\n<base href=\"", fn, "\">\n<title>", q, "</title>\n</head>\n<body>\n<h1>Index of ", q, "</h1>\n", NULL); if (SETJMP(AbortLoading) != 0) { if (sv_type == UNIXLIKE_SERVER) Strcat_charp(FTPDIRtmp, "</a></pre>\n"); else Strcat_charp(FTPDIRtmp, "</a></ul>\n"); Strcat_charp(FTPDIRtmp, "<p>Transfer Interrupted!\n"); goto ftp_end; } TRAP_ON; if (sv_type == UNIXLIKE_SERVER) Strcat_charp(FTPDIRtmp, "<pre>\n"); else Strcat_charp(FTPDIRtmp, "<ul>\n<li>"); Strcat_charp(FTPDIRtmp, "<a href=\"..\">[Upper Directory]</a>\n"); nfile_max = 100; flist = New_N(char *, nfile_max); nfile = 0; if (sv_type == UNIXLIKE_SERVER) { char *name, *link, *date, *size, *type_str; int ftype, max_len, len, j; max_len = 20; while (tmp = Strfgets(current_ftp.data), tmp->length > 0) { Strchop(tmp); if ((ftype = ex_ftpdir_name_size_date(tmp->ptr, &name, &link, &date, &size)) == FTPDIR_NONE) continue; if (!strcmp(".", name) || !strcmp("..", name)) continue; len = strlen(name); if (!len) continue; if (ftype == FTPDIR_DIR) { len++; type_str = "/"; } else if (ftype == FTPDIR_LINK) { len++; type_str = "@"; } else { type_str = " "; } if (max_len < len) max_len = len; flist[nfile++] = Sprintf("%s%s\n%s %5s%s", name, type_str, date, size, link)->ptr; if (nfile == nfile_max) { nfile_max *= 2; flist = New_Reuse(char *, flist, nfile_max); } }