⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htftp.c

📁 elinks下lynx是最重要的二个文本浏览器, 在linux下非常实用, lynx比elinks早的多, 目前好像停止开发, 这是lynx源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
		size = 0;		while (*(++cp) && (*cp != ','))		    size = (size * 10) + (*cp - '0');		info->size = size;		break;	    case 'm':		secs = 0;		while (*(++cp) && (*cp != ','))		    secs = (secs * 10) + (*cp - '0');		secs += base; /* assumes that time_t is #seconds */		strcpy(ct, ctime(&secs));		ct[24] = 0;		StrAllocCopy(info->date, ct);		break;	    case '/':		StrAllocCopy(info->type, ENTRY_IS_DIRECTORY);		/* FALLTHRU */	    default:		while (*cp) {		    if (*cp++ == ',')		      break;		}		break;	}    }} /* parse_eplf_line *//* * parse_ls_line() -- *	Extract the name, size, and date from an ls -l line. */PRIVATE void parse_ls_line ARGS2(	char *,		line,	EntryInfo *,	entry_info){    int    i, j;    int    base=1;    int    size_num=0;    for (i = strlen(line) - 1;	 (i > 13) && (!isspace(UCH(line[i])) || !is_ls_date(&line[i-12])); i--)	; /* null body */    line[i] = '\0';    if (i > 13) {	StrAllocCopy(entry_info->date, &line[i-12]);	/* replace the 4th location with nbsp if it is a space or zero */	if (entry_info->date[4] == ' ' || entry_info->date[4] == '0')	    entry_info->date[4] = HT_NON_BREAK_SPACE;	/* make sure year or time is flush right */	if (entry_info->date[11] == ' ') {	    for (j = 11; j > 6; j--) {		entry_info->date[j] = entry_info->date[j-1];	    }	}    }    j = i - 14;    while (isdigit(UCH(line[j]))) {	size_num += (line[j] - '0') * base;	base *= 10;	j--;    }    entry_info->size = size_num;    StrAllocCopy(entry_info->filename, &line[i + 1]);} /* parse_ls_line() *//* * parse_dls_line() -- *	Extract the name and size info and whether it refers to a *      directory from a LIST line in "dls" format. */PRIVATE void parse_dls_line ARGS3(	char *,		line,	EntryInfo *,	entry_info,	char **,	pspilledname){    short  j;    int    base=1;    int    size_num=0;    int    len;    char *cps = NULL;    /* README		   763	Information about this server\0       bin/		     -	\0       etc/		     =	\0       ls-lR		     0	\0       ls-lR.Z		     3	\0       pub/		     =	Public area\0       usr/		     -	\0       morgan		    14	-> ../real/morgan\0       TIMIT.mostlikely.Z\0			 79215	\0	*/    len = strlen(line);    if (len == 0) {	FREE(*pspilledname);	entry_info->display = FALSE;	return;    }    cps = LYSkipNonBlanks(line);    if (*cps == '\0') {		/* only a filename, save it and return. */	StrAllocCopy(*pspilledname, line);	entry_info->display = FALSE;	return;    }    if (len < 24 || line[23] != ' ' ||	(isspace(UCH(line[0])) && !*pspilledname)) {	/* this isn't the expected "dls" format! */	if (!isspace(UCH(line[0])))	    *cps = '\0';	if (*pspilledname && !*line) {	    entry_info->filename = *pspilledname;	    *pspilledname = NULL;	    if (entry_info->filename[strlen(entry_info->filename)-1] == '/')		StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);	    else		StrAllocCopy(entry_info->type, "");	} else {	    StrAllocCopy(entry_info->filename, line);	    if (cps && cps != line && *(cps-1) == '/')		StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);	    else		StrAllocCopy(entry_info->type, "");	    FREE(*pspilledname);	}	return;    }    j = 22;    if (line[j] == '=' || line[j] == '-') {	StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);    } else {	while (isdigit(UCH(line[j]))) {	    size_num += (line[j] - '0') * base;	    base *= 10;	    j--;	}    }    entry_info->size = size_num;    cps = LYSkipBlanks(&line[23]);    if (!strncmp(cps, "-> ", 3) && cps[3] != '\0' && cps[3] != ' ') {	StrAllocCopy(entry_info->type, gettext("Symbolic Link"));	entry_info->size = 0;	/* don't display size */    }    if (j > 0)	line[j] = '\0';    LYTrimTrailing(line);    len = strlen(line);    if (len == 0 && *pspilledname && **pspilledname) {	line = *pspilledname;	len = strlen(*pspilledname);    }    if (len > 0 && line[len-1] == '/') {		/*		**  It's a dir, remove / and mark it as such.		*/	if (len > 1)	    line[len-1] = '\0';	if (!entry_info->type)	    StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);    }    StrAllocCopy(entry_info->filename, line);    FREE(*pspilledname);} /* parse_dls_line() *//* * parse_vms_dir_entry() *	Format the name, date, and size from a VMS LIST line *	into the EntryInfo structure - FM */PRIVATE void parse_vms_dir_entry ARGS2(	char *,		line,	EntryInfo *,	entry_info){    int i, j;    unsigned int ialloc;    char *cp, *cpd, *cps, date[16], *sp = " ";    /**  Get rid of blank lines, and information lines.  **/    /**  Valid lines have the ';' version number token.  **/    if (!strlen(line) || (cp = strchr(line, ';')) == NULL) {	entry_info->display = FALSE;	return;    }    /** Cut out file or directory name at VMS version number. **/    *cp++ ='\0';    StrAllocCopy(entry_info->filename,line);    /** Cast VMS non-README file and directory names to lowercase. **/    if (strstr(entry_info->filename, "READ") == NULL) {	LYLowerCase(entry_info->filename);	i = strlen(entry_info->filename);    } else {	i = ((strstr(entry_info->filename, "READ") - entry_info->filename) + 4);	if (!strncmp(&entry_info->filename[i], "ME", 2)) {	    i += 2;	    while (entry_info->filename[i] && entry_info->filename[i] != '.') {		i++;	    }	} else if (!strncmp(&entry_info->filename[i], ".ME", 3)) {	    i = strlen(entry_info->filename);	} else {	    i = 0;	}	LYLowerCase(entry_info->filename + i);    }    /** Uppercase terminal .z's or _z's. **/    if ((--i > 2) &&	entry_info->filename[i] == 'z' &&	(entry_info->filename[i-1] == '.' ||	 entry_info->filename[i-1] == '_'))	entry_info->filename[i] = 'Z';    /** Convert any tabs in rest of line to spaces. **/    cps = cp-1;    while ((cps=strchr(cps+1, '\t')) != NULL)	*cps = ' ';    /** Collapse serial spaces. **/    i = 0; j = 1;    cps = cp;    while (cps[j] != '\0') {	if (cps[i] == ' ' && cps[j] == ' ')	    j++;	else	    cps[++i] = cps[j++];    }    cps[++i] = '\0';    /* Set the years and date, if we don't have them yet. **/    if (!HaveYears) {	set_years_and_date();    }    /** Track down the date. **/    if ((cpd=strchr(cp, '-')) != NULL &&	strlen(cpd) > 9 && isdigit(UCH(*(cpd-1))) &&	isalpha(UCH(*(cpd+1))) && *(cpd+4) == '-') {	/** Month **/	*(cpd+2) = (char) TOLOWER(*(cpd+2));	*(cpd+3) = (char) TOLOWER(*(cpd+3));	sprintf(date, "%.3s ", cpd+1);	/** Day **/	if (isdigit(UCH(*(cpd-2))))	    sprintf(date+4, "%.2s ", cpd-2);	else	    sprintf(date+4, "%c%.1s ", HT_NON_BREAK_SPACE, cpd-1);	/** Time or Year **/	if (!strncmp(ThisYear, cpd+5, 4) &&	    strlen(cpd) > 15 && *(cpd+12) == ':') {	    sprintf(date+7, "%.5s", cpd+10);	} else {	    sprintf(date+7, " %.4s", cpd+5);	}	StrAllocCopy(entry_info->date, date);    }    /** Track down the size **/    if ((cpd=strchr(cp, '/')) != NULL) {	/* Appears be in used/allocated format */	cps = cpd;	while (isdigit(UCH(*(cps-1))))	    cps--;	if (cps < cpd)	    *cpd = '\0';	entry_info->size = atoi(cps);	cps = cpd+1;	while (isdigit(UCH(*cps)))	    cps++;	*cps = '\0';	ialloc = atoi(cpd+1);	/* Check if used is in blocks or bytes */	if (entry_info->size <= ialloc)	    entry_info->size *= 512;    } else if ((cps=strtok(cp, sp)) != NULL) {	/* We just initialized on the version number */	/* Now let's hunt for a lone, size number    */	while ((cps=strtok(NULL, sp)) != NULL) {	    cpd = cps;	    while (isdigit(UCH(*cpd)))		cpd++;	    if (*cpd == '\0') {		/* Assume it's blocks */		entry_info->size = atoi(cps) * 512;		break;	    }	}    }    /** Wrap it up **/    CTRACE((tfp, "HTFTP: VMS filename: %s  date: %s  size: %d\n",		entry_info->filename,		NonNull(entry_info->date),		entry_info->size));    return;} /* parse_vms_dir_entry() *//* * parse_ms_windows_dir_entry() -- *	Format the name, date, and size from an MS_WINDOWS LIST line into *	the EntryInfo structure (assumes Chameleon NEWT format). - FM */PRIVATE void parse_ms_windows_dir_entry ARGS2(	char *,		line,	EntryInfo *,	entry_info){    char *cp = line;    char *cps, *cpd, date[16];    char *end = line + strlen(line);    /**  Get rid of blank or junk lines.  **/    cp = LYSkipBlanks(cp);    if (!(*cp)) {	entry_info->display = FALSE;	return;    }    /** Cut out file or directory name. **/    cps = LYSkipNonBlanks(cp);    *cps++ ='\0';    cpd = cps;    StrAllocCopy(entry_info->filename, cp);    /** Track down the size **/    if (cps < end) {	cps = LYSkipBlanks(cps);	cpd = LYSkipNonBlanks(cps);	*cpd++ = '\0';	if (isdigit(UCH(*cps))) {	    entry_info->size = atoi(cps);	} else {	    StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);	}    } else {	StrAllocCopy(entry_info->type, "");    }    /* Set the years and date, if we don't have them yet. **/    if (!HaveYears) {	set_years_and_date();    }    /** Track down the date. **/    if (cpd < end) {	cpd = LYSkipBlanks(cpd);	if (strlen(cpd) > 17) {	    *(cpd+6)  = '\0';  /* Month and Day */	    *(cpd+11) = '\0';  /* Year */	    *(cpd+17) = '\0';  /* Time */	    if (strcmp(ThisYear, cpd+7))		/* Not this year, so show the year */		sprintf(date, "%.6s  %.4s", cpd, (cpd+7));	    else		/* Is this year, so show the time */		sprintf(date, "%.6s %.5s", cpd, (cpd+12));	    StrAllocCopy(entry_info->date, date);	    if (entry_info->date[4] == ' '|| entry_info->date[4] == '0') {		entry_info->date[4] = HT_NON_BREAK_SPACE;	    }	}    }    /** Wrap it up **/    CTRACE((tfp, "HTFTP: MS Windows filename: %s  date: %s  size: %d\n",		entry_info->filename,		NonNull(entry_info->date),		entry_info->size));    return;} /* parse_ms_windows_dir_entry *//* * parse_windows_nt_dir_entry() -- *	Format the name, date, and size from a WINDOWS_NT LIST line into *	the EntryInfo structure (assumes Chameleon NEWT format). - FM */#ifdef NOTDEFINEDPRIVATE void parse_windows_nt_dir_entry ARGS2(	char *,		line,	EntryInfo *,	entry_info){    char *cp = line;    char *cps, *cpd, date[16];    char *end = line + strlen(line);    int i;    /**  Get rid of blank or junk lines.  **/    cp = LYSkipBlanks(cp);    if (!(*cp)) {	entry_info->display = FALSE;	return;    }    /** Cut out file or directory name. **/    cpd = cp;    cps = LYSkipNonBlanks(end-1);    cp = (cps+1);    if (!strcmp(cp, ".") || !strcmp(cp, "..")) {	entry_info->display = FALSE;	return;    }    StrAllocCopy(entry_info->filename, cp);    if (cps < cpd)	return;    *cp = '\0';    end = cp;    /* Set the years and date, if we don't have them yet. **/    if (!HaveYears) {	set_years_and_date();    }    /** Cut out the date. **/    cp = cps = cpd;    cps = LYSkipNonBlanks(cps);    *cps++ ='\0';    if (cps > end) {	entry_info->display = FALSE;	return;    }    cps = LYSkipBlanks(cps);    cpd = LYSkipNonBlanks(cps);    *cps++ ='\0';    if (cps > end || cpd == cps || strlen(cpd) < 7) {	entry_info->display = FALSE;	return;    }    if (strlen(cp) == 8 &&	isdigit(*cp) && isdigit(*(cp+1)) && *(cp+2) == '-' &&	isdigit(*(cp+3)) && isdigit(*(cp+4)) && *(cp+5) == '-') {	*(cp+2)  = '\0';	/* Month */	i = atoi(cp) - 1;	*(cp+5) = '\0';		/* Day */	sprintf(date, "%.3s %.2s", months[i], (cp+3));	if (date[4] == '0')	    date[4] = ' ';	cp += 6;			/* Year */	if (strcmp((ThisYear+2), cp)) {	    /* Not this year, so show the year */	    if (atoi(cp) < 70) {		sprintf(&date[6], "  20%.2s", cp);	    } else {		sprintf(&date[6], "  19%.2s", cp);	    }	} else {	    /* Is this year, so show the time */	    *(cpd+2) = '\0';	/* Hour */	    i = atoi(cpd);	    if (*(cpd+5) == 'P' || *(cpd+5) == 'p')		i += 12;	    sprintf(&date[6], " %02d:%.2s", i, (cpd+3));	}	StrAllocCopy(entry_info->date, date);	if (entry_info->date[4] == ' '|| entry_info->date[4] == '0') {	    entry_info->date[4] = HT_NON_BREAK_SPACE;	}    }    /** Track down the size **/    if (cps < end) {	cps = LYSkipBlanks(cps);	cpd = LYSkipNonBlanks(cps);	*cpd = '\0';	if (isdigit(*cps)) {	    entry_info->size = atoi(cps);	} else {	    StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);	}    } else {	StrAllocCopy(entry_info->type, "");    }    /** Wrap it up **/    CTRACE((tfp, "HTFTP: Windows NT filename: %s  date: %s  size: %d\n",		entry_info->filename,		NonNull(entry_info->date),		entry_info->size));    return;} /* parse_windows_nt_dir_entry */#endif /* NOTDEFINED *//* * parse_cms_dir_entry() -- *	Format the name, date, and size from a VM/CMS line into *	the EntryInfo structure. - FM */PRIVATE void parse_cms_dir_entry ARGS2(	char *,		line,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -