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

📄 lymail.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 3 页
字号:
	    *cp0 = ',';	    cp1 = cp0 + 1;	}	cp = cp1;    }    /*     *	Unescape the address field. - FM     */    HTUnEscape(address);    if (address[(strlen(address) - 1)] == ',')	address[(strlen(address) - 1)] = '\0';    if (*address == '\0') {	FREE(address);	if (TRACE) {	    fprintf(stderr,		    "mailmsg: No address in '%s'.\n",		    owner_address);	}	return;    }#ifdef UNIX    sprintf(cmd, "%s %s", system_mail, system_mail_flags);    if ((fd = popen(cmd, "w")) == NULL) {	FREE(address);	if (TRACE) {	    fprintf(stderr,		    "mailmsg: '%s' failed.\n",		    cmd);	}	return;    }    fprintf(fd, "To: %s\n", address);    fprintf(fd, "Subject: Lynx Error in %s\n", filename);    if (personal_mail_address != NULL && *personal_mail_address != '\0') {	fprintf(fd, "Cc: %s\n", personal_mail_address);    }    fprintf(fd, "X-URL: %s\n", filename);    fprintf(fd, "X-Mailer: Lynx, Version %s\n\n", LYNX_VERSION);#endif /* UNIX */#if defined(VMS) || defined(DOSPATH)    tempname(my_tmpfile, NEW_FILE);    if (((cp = strrchr(my_tmpfile, '.')) != NULL) &&	NULL == strchr(cp, ']') &&	NULL == strchr(cp, '/')) {	*cp = '\0';	strcat(my_tmpfile, ".txt");    }    if ((fd = LYNewTxtFile(my_tmpfile)) == NULL) {	if (TRACE) {	    fprintf(stderr,		    "mailmsg: Could not fopen '%s'.\n",		    my_tmpfile);	}	FREE(address);	return;    }    if (isPMDF) {	tempname(hdrfile, NEW_FILE);	if (((cp = strrchr(hdrfile, '.')) != NULL) &&	    NULL == strchr(cp, ']') &&	    NULL == strchr(cp, '/')) {	    *cp = '\0';	    strcat(hdrfile, ".txt");	}	if ((hfd = LYNewTxtFile(hdrfile)) == NULL) {	    if (TRACE) {		fprintf(stderr,			"mailmsg: Could not fopen '%s'.\n",			hdrfile);	    }	    FREE(address);	    return;	}	if (personal_mail_address != NULL && *personal_mail_address != '\0') {	    fprintf(fd, "Cc: %s\n", personal_mail_address);	}	fprintf(fd, "X-URL: %s\n", filename);	fprintf(fd, "X-Mailer: Lynx, Version %s\n\n", LYNX_VERSION);    }#endif /* VMS */    fprintf(fd, "The link   %s :?: %s \n",		links[cur].lname, links[cur].target);    fprintf(fd, "called \"%s\"\n", links[cur].hightext);    fprintf(fd, "in the file \"%s\" called \"%s\"", filename, linkname);    fputs("\nwas requested but was not available.", fd);    fputs("\n\nThought you might want to know.", fd);    fputs("\n\nThis message was automatically generated by\n", fd);    fprintf(fd, "Lynx ver. %s", LYNX_VERSION);    if ((LynxSigFile != NULL) &&	(fp = fopen(LynxSigFile, "r")) != NULL) {	fputs("-- \n", fd);	while (fgets(cmd, sizeof(cmd), fp) != NULL)	    fputs(cmd, fd);	fclose(fp);    }#ifdef UNIX    pclose(fd);#endif /* UNIX */#if defined(VMS) || defined(DOSPATH)    fclose(fd);#ifdef VMS    if (isPMDF) {	/*	 *  For PMDF, put the subject in the	 *  header file and close it. - FM	 */	fprintf(hfd, "Subject: Lynx Error in %.56s\n\n", filename);	fclose(hfd);	/*	 *  Now set up the command. - FM	 */	sprintf(cmd,		"%s %s %s,%s ",		system_mail,		system_mail_flags,		hdrfile,		my_tmpfile);    } else {	/*	 *  For "generic" VMS MAIL, include the	 *  subject in the command. - FM	 */	sprintf(cmd,		"%s %s/self/subject=\"Lynx Error in %.56s\" %s ",		system_mail,		system_mail_flags,		filename,		my_tmpfile);    }    StrAllocCopy(command, cmd);    address_ptr1 = address;    do {	if ((cp = strchr(address_ptr1, ',')) != NULL) {	    address_ptr2 = (cp+1);	    *cp = '\0';	} else	    address_ptr2 = NULL;	if (strlen(address) > 3) {	    if (!first) {		StrAllocCat(command, ",");	    }	    sprintf(cmd, mail_adrs, address_ptr1);	    StrAllocCat(command, cmd);	    first = FALSE;	}	address_ptr1 = address_ptr2;    } while (address_ptr1 != NULL);    system(command);    FREE(command);    remove(my_tmpfile);    if (isPMDF) {	remove(hdrfile);    }#else /* DOSPATH */    sprintf(cmd, "%s -t \"%s\" -F %s", system_mail, address, my_tmpfile);    system(cmd);    remove(my_tmpfile);#endif#endif /* VMS */    if (traversal) {	FILE *ofp;	if ((ofp = LYAppendToTxtFile(TRAVERSE_ERRORS)) == NULL) {	    if ((ofp = LYNewTxtFile(TRAVERSE_ERRORS)) == NULL) {		perror(NOOPEN_TRAV_ERR_FILE);#ifndef NOSIGHUP		(void) signal(SIGHUP, SIG_DFL);#endif /* NOSIGHUP */		(void) signal(SIGTERM, SIG_DFL);#ifndef VMS		(void) signal(SIGINT, SIG_DFL);#endif /* !VMS */#ifdef SIGTSTP		if (no_suspend)		    (void) signal(SIGTSTP,SIG_DFL);#endif /* SIGTSTP */		exit(-1);	    }	}	fprintf(ofp, "%s\t%s \tin %s\n",		     links[cur].lname, links[cur].target, filename);	fclose(ofp);    }    FREE(address);    return;}/***  reply_by_mail() invokes sendmail on Unix or mail on VMS to send**  a comment  from the users to the owner*/PUBLIC void reply_by_mail ARGS3(	char *, 	mail_address,	char *, 	filename,	CONST char *,	title){    char user_input[1000];    FILE *fd, *fp;    char *address = NULL;    char *ccaddr = NULL;    char *keywords = NULL;    char *searchpart = NULL;    char *body = NULL;    char *cp = NULL, *cp0 = NULL, *cp1 = NULL;    char *temp = NULL;    int i, len;    int c = 0;	/* user input */    char my_tmpfile[256], cmd[512];#ifdef DOSPATH    char tmpfile2[256];#endif    static char *personal_name = NULL;    char subject[80];#ifdef VMS    char *address_ptr1 = NULL, *address_ptr2 = NULL;    char *command = NULL;    BOOLEAN first = TRUE;    BOOLEAN isPMDF = FALSE;    char hdrfile[256];    FILE *hfd;    if (!strncasecomp(system_mail, "PMDF SEND", 9)) {	isPMDF = TRUE;    }#else    char buf[512];    char *header = NULL;    int n;#endif /* VMS */    term_letter = FALSE;    if (mail_address && *mail_address) {	StrAllocCopy(address, mail_address);    } else {	HTAlert(NO_ADDRESS_IN_MAILTO_URL);	return;    }    tempname(my_tmpfile, NEW_FILE);    if (((cp = strrchr(my_tmpfile, '.')) != NULL) &&#ifdef VMS	NULL == strchr(cp, ']') &&#endif /* VMS */	NULL == strchr(cp, '/')) {	*cp = '\0';	strcat(my_tmpfile, ".txt");    }    if ((fd = LYNewTxtFile(my_tmpfile)) == NULL) {	HTAlert(MAILTO_URL_TEMPOPEN_FAILED);	return;    }#ifdef VMS    if (isPMDF) {	tempname(hdrfile, NEW_FILE);	if (((cp = strrchr(hdrfile, '.')) != NULL) &&	    NULL == strchr(cp, ']') &&	    NULL == strchr(cp, '/')) {	    *cp = '\0';	    strcat(hdrfile, ".txt");	}	if ((hfd = LYNewTxtFile(hdrfile)) == NULL) {	    HTAlert(MAILTO_URL_TEMPOPEN_FAILED);	    return;	}    }#endif /* VMS */    subject[0] = '\0';    /*     *	Check for a ?searchpart. - FM     */    if ((cp = strchr(address, '?')) != NULL) {	StrAllocCopy(searchpart, cp);	*cp = '\0';	cp = (searchpart + 1);	if (*cp != '\0') {	    /*	     *	Seek and handle a subject=foo. - FM	     */	    while (*cp != '\0') {		if ((*(cp - 1) == '?' || *(cp - 1) == '&') &&		    !strncasecomp(cp, "subject=", 8))		    break;		cp++;	    }	    if (*cp) {		cp += 8;		if ((cp1 = strchr(cp, '&')) != NULL) {		    *cp1 = '\0';		}		if (*cp) {		    strncpy(subject, cp, 70);		    subject[70] = '\0';		    HTUnEscape(subject);		}		if (cp1) {		    *cp1 = '&';		    cp1 = NULL;		}	    }	    /*	     *	Seek and handle to=address(es) fields.	     *	Appends to address. - FM	     */	    cp = (searchpart + 1);	    while (*cp != '\0') {		if ((*(cp - 1) == '?' || *(cp - 1) == '&') &&		    !strncasecomp(cp, "to=", 3)) {		    cp += 3;		    if ((cp1 = strchr(cp, '&')) != NULL) {			*cp1 = '\0';		    }		    while (*cp == ',' || isspace((unsigned char)*cp))			cp++;		    if (*cp) {			if (*address) {			    StrAllocCat(address, ",");			}			StrAllocCat(address, cp);		    }		    if (cp1) {			*cp1 = '&';			cp = cp1;			cp1 = NULL;		    } else {			break;		    }		}		cp++;	    }	    /*	     *	Seek and handle cc=address(es) fields.	Excludes	     *	Bcc=address(es) as unsafe.  We may append our own	     *	cc (below) as a list for the actual mailing. - FM	     */	    cp = (searchpart + 1);	    while (*cp != '\0') {		if ((*(cp - 1) == '?' || *(cp - 1) == '&') &&		    !strncasecomp(cp, "cc=", 3)) {		    cp += 3;		    if ((cp1 = strchr(cp, '&')) != NULL) {			*cp1 = '\0';		    }		    while (*cp == ',' || isspace((unsigned char)*cp))			cp++;		    if (*cp) {			if (ccaddr == NULL) {			    StrAllocCopy(ccaddr, cp);			} else {			    StrAllocCat(ccaddr, ",");			    StrAllocCat(ccaddr, cp);			}		    }		    if (cp1) {			*cp1 = '&';			cp = cp1;			cp1 = NULL;		    } else {			break;		    }		}		cp++;	    }	    /*	     *	Seek and handle keywords=term(s) fields. - FM	     */	    cp = (searchpart + 1);	    while (*cp != '\0') {		if ((*(cp - 1) == '?' || *(cp - 1) == '&') &&		    !strncasecomp(cp, "keywords=", 9)) {		    cp += 9;		    if ((cp1 = strchr(cp, '&')) != NULL) {			*cp1 = '\0';		    }		    while (*cp == ',' || isspace((unsigned char)*cp))			cp++;		    if (*cp) {			if (keywords == NULL) {			    StrAllocCopy(keywords, cp);			} else {			    StrAllocCat(keywords, cp);			    StrAllocCat(keywords, ", ");			}			StrAllocCat(keywords, cp);		    }		    if (cp1) {			*cp1 = '&';			cp = cp1;			cp1 = NULL;		    } else {			break;		    }		}		cp++;	    }	    if (keywords != NULL) {		if (*keywords != '\0') {		    HTUnEscape(keywords);		} else {		    FREE(keywords);		}	    }	    /*	     *	Seek and handle body=foo fields. - FM	     */	    cp = (searchpart + 1);	    while (*cp != '\0') {		if ((*(cp - 1) == '?' || *(cp - 1) == '&') &&		    !strncasecomp(cp, "body=", 5)) {		    cp += 5;		    if ((cp1 = strchr(cp, '&')) != NULL) {			*cp1 = '\0';		    }		    if (*cp) {			/*			 *  Break up the value into lines with			 *  a maximum length of 78. - FM			 */			StrAllocCopy(temp, cp);			HTUnEscape(temp);			cp0 = temp;			while((cp = strchr(cp0, '\n')) != NULL) {			    *cp = '\0';			    if (cp > cp0) {				if (*(cp - 1) == '\r') {				    *(cp - 1) = '\0';				}			    }			    i = 0;			    len = strlen(cp0);			    while (len > 78) {				strncpy(cmd, (char *)&cp0[i], 78);				cmd[78] = '\0';				strcat(cmd, "\n");				StrAllocCat(body, cmd);				i += 78;				len = strlen((char *)&cp0[i]);			    }			    sprintf(cmd, "%s\n", (char *)&cp0[i]);			    StrAllocCat(body, cmd);			    cp0 = (cp + 1);			}			i = 0;			len = strlen(cp0);			while (len > 78) {			    strncpy(cmd, (char *)&cp0[i], 78);			    cmd[78] = '\0';			    strcat(cmd, "\n");			    StrAllocCat(body, cmd);			    i += 78;			    len = strlen((char *)&cp0[i]);			}			if (len) {			    sprintf(cmd, "%s\n", (char *)&cp0[i]);			    StrAllocCat(body, cmd);			}			FREE(temp);		    }		    if (cp1) {			*cp1 = '&';			cp = cp1;			cp1 = NULL;		    } else {			break;		    }		}		cp++;	    }	    FREE(searchpart);	}    }    /*     *	Convert any Explorer semi-colon Internet address     *	separators to commas. - FM     */    cp = address;    while ((cp1 = strchr(cp, '@')) != NULL) {	cp1++;	if ((cp0 = strchr(cp1, ';')) != NULL) {	    *cp0 = ',';	    cp1 = cp0 + 1;	}	cp = cp1;    }    if (address[(strlen(address) - 1)] == ',')	address[(strlen(address) - 1)] = '\0';    if (*address == '\0') {	FREE(address);	FREE(ccaddr);	FREE(keywords);	FREE(body);	fclose(fd);		/* Close the tmpfile.  */	remove(my_tmpfile);	/* Delete the tmpfile. */	HTAlert(NO_ADDRESS_IN_MAILTO_URL);	return;    }    if (ccaddr != NULL) {	cp = ccaddr;	while ((cp1 = strchr(cp, '@')) != NULL) {	    cp1++;	    if ((cp0 = strchr(cp1, ';')) != NULL) {		*cp0 = ',';		cp1 = cp0 + 1;	    }	    cp = cp1;	}	if (ccaddr[(strlen(ccaddr) - 1)] == ',') {	    ccaddr[(strlen(ccaddr) - 1)] = '\0';	}	if (*ccaddr == '\0') {	    FREE(ccaddr);	}    }    /*     *	Unescape the address and ccaddr fields. - FM     */    HTUnEscape(address);    if (ccaddr != NULL) {	HTUnEscape(ccaddr);    }    /*     *	Set the default subject. - FM     */    if (subject[0] == '\0' && title && *title) {	strncpy(subject, title, 70);	subject[70] = '\0';    }    /*     *	Use ^G to cancel mailing of comment     *	and don't let SIGINTs exit lynx.     */    signal(SIGINT, terminate_letter);#ifdef VMS    if (isPMDF || !body) {	/*	 *  Put the X-URL and X-Mailer lines in the hdrfile	 *  for PMDF or my_tmpfile for VMS MAIL. - FM	 */	fprintf((isPMDF ? hfd : fd),		"X-URL: %s%s\n",		(filename && *filename) ? filename : "mailto:",		(filename && *filename) ? "" : address);	fprintf((isPMDF ? hfd : fd),		"X-Mailer: Lynx, Version %s\n",LYNX_VERSION);#ifdef NO_ANONYMOUS_MAIL	if (!isPMDF) {	    fprintf(fd, "\n");	}#endif /* NO_ANONYMOUS_MAIL */    }#else /* Unix: */    /*     *	Put the To: line in the header.     */#ifndef DOSPATH    sprintf(buf, "To: %s\n", address);    StrAllocCopy(header, buf);#endif    /*     *	Put the Mime-Version, Content-Type and     *	Content-Transfer-Encoding in the header.     *	This assumes that the same character set is used     *	for composing the mail which is currently selected     *	as display character set...     *	Don't send a charset if we have a CJK character set     *	selected, since it may not be appropriate for mail...     *	Also don't use an unofficial "x-" charset.     *	Also if the charset would be "us-ascii" (7-bit replacements     *	selected, don't send any MIME headers. - kw     */    if (strncasecomp(LYCharSet_UC[current_char_set].MIMEname,		     "us-ascii", 8) != 0) {	StrAllocCat(header, "Mime-Version: 1.0\n");	if (!LYHaveCJKCharacterSet &&	    strncasecomp(LYCharSet_UC[current_char_set].MIMEname, "x-", 2)	    != 0) {	    sprintf(buf,"Content-Type: text/plain; charset=%s\n",		    LYCharSet_UC[current_char_set].MIMEname);	    StrAllocCat(header, buf);	}	StrAllocCat(header, "Content-Transfer-Encoding: 8bit\n");    }    /*     *	Put the X-URL and X-Mailer lines in the header.     */    sprintf(buf,	    "X-URL: %s%s\n",	    (filename && *filename) ? filename : "mailto:",	    (filename && *filename) ? "" : address);    StrAllocCat(header, buf);    sprintf(buf, "X-Mailer: Lynx, Version %s\n", LYNX_VERSION);    StrAllocCat(header, buf);#endif /* VMS */    /*     *	Clear the screen and inform the user.     */    clear();    move(2,0);    scrollok(stdscr, TRUE);	/* Enable scrolling. */    if (body)	addstr(SENDING_MESSAGE_WITH_BODY_TO);    else	addstr(SENDING_COMMENT_TO);    cp = address;    while ((cp1 = strchr(cp, ',')) != NULL) {	*cp1 = '\0';	while (*cp == ' ')	    cp++;	if (*cp) {	    addstr(cp);	    addstr(",\n  ");	}	*cp1 = ',';

⌨️ 快捷键说明

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