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

📄 lymail.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 3 页
字号:
	cp = (cp1 + 1);    }    if (*cp) {	addstr(cp);    }#ifdef VMS    if ((isPMDF == TRUE) &&	(cp = ccaddr) != NULL)#else    if ((cp = ccaddr) != NULL)#endif /* VMS */    {	if (strchr(cp, ',') != NULL) {	    addstr(WITH_COPIES_TO);	} else {	    addstr(WITH_COPY_TO);	}	while ((cp1 = strchr(cp, ',')) != NULL) {	    *cp1 = '\0';	    while (*cp == ' ')		cp++;	    if (*cp) {		addstr(cp);		addstr(",\n  ");	    }	    *cp1 = ',';	    cp = (cp1 + 1);	}	if (*cp) {	    addstr(cp);	}    }    addstr(CTRL_G_TO_CANCEL_SEND);#ifdef VMS    if (isPMDF || !body) {#endif /* VMS */#ifndef NO_ANONYMOUS_EMAIL    /*     *	Get the user's personal name.     */    addstr(ENTER_NAME_OR_BLANK);    if (personal_name == NULL)	*user_input = '\0';    else {	addstr(CTRL_U_TO_ERASE);	strcpy(user_input, personal_name);    }#ifdef VMS    if (isPMDF) {	addstr("Personal_name: ");    } else {	addstr("X_Personal_name: ");    }#else    addstr("Personal Name: ");#endif /* VMS */    if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 ||	term_letter) {	addstr("\n");	_statusline(COMMENT_REQUEST_CANCELLED);	sleep(InfoSecs);	fclose(fd);		/* Close the tmpfile. */	scrollok(stdscr,FALSE); /* Stop scrolling.    */	goto cleanup;    }    addstr("\n");    remove_tildes(user_input);    StrAllocCopy(personal_name, user_input);    term_letter = FALSE;    if (*user_input) {#ifdef VMS	fprintf((isPMDF ? hfd : fd),		"X-Personal_name: %s\n",user_input);#else	sprintf(buf, "X-Personal_name: %s\n", user_input);	StrAllocCat(header, buf);#endif /* VMS */    }    /*     *	Get the user's return address.     */    addstr(ENTER_MAIL_ADDRESS_OR_OTHER);    addstr(MEANS_TO_CONTACT_FOR_RESPONSE);    if (personal_mail_address)	addstr(CTRL_U_TO_ERASE);#ifdef VMS    if (isPMDF) {	addstr("From: ");    } else {	addstr("X-From: ");    }#else    addstr("From: ");#endif /* VMS */    /* Add the personal mail address if there is one. */    sprintf(user_input, "%s", (personal_mail_address ?			       personal_mail_address : ""));    if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 ||	term_letter) {	addstr("\n");	_statusline(COMMENT_REQUEST_CANCELLED);	sleep(InfoSecs);	fclose(fd);		/* Close the tmpfile. */	scrollok(stdscr,FALSE); /* Stop scrolling.    */	goto cleanup;    }    addstr("\n");    remove_tildes(user_input);#ifdef VMS    if (*user_input) {	if (isPMDF) {	    fprintf(hfd, "From: %s\n", user_input);	} else {	    fprintf(fd, "X-From: %s\n\n", user_input);	}    } else if (!isPMDF) {	fprintf(fd, "\n");    }#else    sprintf(buf, "From: %s\n", user_input);    StrAllocCat(header, buf);#endif /* VMS */#endif /* !NO_ANONYMOUS_EMAIL */#ifdef VMS    }#endif /* VMS */    /*     *	Get the subject line.     */    addstr(ENTER_SUBJECT_LINE);    addstr(CTRL_U_TO_ERASE);    addstr("Subject: ");    /* Add the default subject. */    sprintf(user_input, "%.70s%.63s",			(subject[0] != '\0') ?				     subject :		    ((filename && *filename) ?				    filename : "mailto:"),			(subject[0] != '\0') ?					  "" :		    ((filename && *filename) ?					  "" : address));    if (LYgetstr(user_input, VISIBLE, 71, NORECALL) < 0 ||	term_letter) {	addstr("\n");	_statusline(COMMENT_REQUEST_CANCELLED);	sleep(InfoSecs);	fclose(fd);		/* Close the tmpfile. */	scrollok(stdscr,FALSE); /* Stop scrolling.    */	goto cleanup;    }    addstr("\n");    remove_tildes(user_input);#ifdef VMS    sprintf(subject, "%.70s", user_input);#else    sprintf(buf, "Subject: %s\n", user_input);    StrAllocCat(header, buf);#endif /* VMS */    /*     *	Offer a CC line, if permitted. - FM     */    user_input[0] = '\0';    if (!LYNoCc) {	addstr(ENTER_ADDRESS_FOR_CC);	if (personal_mail_address)	    addstr(CTRL_U_TO_ERASE);	addstr(BLANK_FOR_NO_COPY);	addstr("Cc: ");	/*	 *  Add the mail address if there is one.	 */	sprintf(user_input, "%s", (personal_mail_address ?				   personal_mail_address : ""));	if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 ||	    term_letter) {	    addstr("\n");	    _statusline(COMMENT_REQUEST_CANCELLED);	    sleep(InfoSecs);	    fclose(fd); 		/* Close the tmpfile. */	    scrollok(stdscr, FALSE);	/* Stop scrolling.    */	    goto cleanup;	}	addstr("\n");    }    remove_tildes(user_input);#if defined (VMS) || defined (DOSPATH)    if (*user_input) {	cp = user_input;	while (*cp == ',' || isspace((unsigned char)*cp))	    cp++;	if (*cp) {	    if (ccaddr == NULL) {		StrAllocCopy(ccaddr, cp);	    } else {		StrAllocCat(ccaddr, ",");		StrAllocCat(ccaddr, cp);	    }	}    }#endif#ifdef DOSPATH    if (*address) {	sprintf(buf, "To: %s\n", address);	StrAllocCat(header, buf);    }#endif#ifndef VMS    /*    **	Add the Cc: header. - FM    */    if (ccaddr != NULL && *ccaddr != '\0') {	StrAllocCat(header, "Cc: ");	StrAllocCat(header, ccaddr);	StrAllocCat(header, "\n");    }    /*    **	Add the Keywords: header. - FM    */    if (keywords != NULL && *keywords != '\0') {	StrAllocCat(header, "Keywords: ");	StrAllocCat(header, keywords);	StrAllocCat(header, "\n");    }    /*     *	Terminate the header.     */    sprintf(buf, "\n");    StrAllocCat(header, buf);#endif /* !VMS */    if (!no_editor && editor && *editor != '\0') {	/*	 *  Use an external editor for the message.	 */	char *editor_arg = "";	if (body) {	    cp1 = body;	    while((cp = strchr(cp1, '\n')) != NULL) {		*cp++ = '\0';		fprintf(fd, "%s\n", cp1);		cp1 = cp;	    }	} else if (strcmp(HTLoadedDocumentURL(), "")) {	    /*	     *	Ask if the user wants to include the original message.	     */	    BOOLEAN is_preparsed = (LYPreparsedSource &&				    HTisDocumentSource());	    if (is_preparsed)		_statusline(INC_PREPARSED_MSG_PROMPT);	    else		_statusline(INC_ORIG_MSG_PROMPT);	    c = 0;	    while (TOUPPER(c) != 'Y' && TOUPPER(c) != 'N' &&		   !term_letter && c != 7   && c != 3)		c = LYgetch();	    if (TOUPPER(c) == 'Y') {		/*		 *  The 1 will add the reply "> " in front of every line.		 */		if (is_preparsed)		    print_wwwfile_to_fd(fd, 0);		else		    print_wwwfile_to_fd(fd, 1);	    }	}	fclose(fd);		/* Close the tmpfile. */	scrollok(stdscr,FALSE); /* Stop scrolling.    */	if (term_letter || c == 7 || c == 3)	    goto cleanup;	/*	 *  Spawn the users editor on the mail file	 */	if (strstr(editor, "pico")) {	    editor_arg = " -t"; /* No prompt for filename to use */	}	sprintf(user_input, "%s%s %s", editor, editor_arg, my_tmpfile);	_statusline(SPAWNING_EDITOR_FOR_MAIL);	stop_curses();	if (system(user_input)) {	    start_curses();	    _statusline(ERROR_SPAWNING_EDITOR);	    sleep(AlertSecs);	} else {	    start_curses();	}    } else if (body) {	/*	 *  Let user review the body. - FM	 */	clear();	move(0,0);	addstr(REVIEW_MESSAGE_BODY);	refresh();	cp1 = body;	i = (LYlines - 5);	while((cp = strchr(cp1, '\n')) != NULL) {	    if (i <= 0) {		addstr(RETURN_TO_CONTINUE);		refresh();		c = LYgetch();		addstr("\n");		if (term_letter || c == 7 || c == 3) {		    addstr(CANCELLED);		    sleep(InfoSecs);		    fclose(fd); 		/* Close the tmpfile. */		    scrollok(stdscr, FALSE);	/* Stop scrolling.    */		    goto cleanup;		}		i = (LYlines - 2);	    }	    *cp++ = '\0';	    sprintf(cmd, "%s\n", cp1);	    fprintf(fd, cmd);	    addstr(cmd);	    cp1 = cp;	    i--;	}	while (i >= 0) {	    addstr("\n");	    i--;	}	refresh();	fclose(fd);		/* Close the tmpfile.	  */	scrollok(stdscr,FALSE); /* Stop scrolling.	  */    } else {	/*	 *  Use the internal line editor for the message.	 */	addstr(ENTER_MESSAGE_BELOW);	addstr(ENTER_PERIOD_WHEN_DONE_A);	addstr(ENTER_PERIOD_WHEN_DONE_B);	addstr("\n\n");	refresh();	*user_input = '\0';	if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 ||	    term_letter || STREQ(user_input, ".")) {	    _statusline(COMMENT_REQUEST_CANCELLED);	    sleep(InfoSecs);	    fclose(fd); 		/* Close the tmpfile. */	    scrollok(stdscr,FALSE);	/* Stop scrolling.    */	    goto cleanup;	}	while (!STREQ(user_input, ".") && !term_letter) {	    addstr("\n");	    remove_tildes(user_input);	    fprintf(fd, "%s\n", user_input);	    *user_input = '\0';	    if (LYgetstr(user_input, VISIBLE,			 sizeof(user_input), NORECALL) < 0) {		_statusline(COMMENT_REQUEST_CANCELLED);		sleep(InfoSecs);		fclose(fd);		/* Close the tmpfile. */		scrollok(stdscr,FALSE); /* Stop scrolling.    */		goto cleanup;	    }	}	fprintf(fd, "\n");	/* Terminate the message. */	fclose(fd);		/* Close the tmpfile.	  */	scrollok(stdscr,FALSE); /* Stop scrolling.	  */    }#ifndef VMS    /*     *	Ignore CTRL-C on this last question.     */    signal(SIGINT, SIG_IGN);#endif /* !VMS */    LYStatusLine = (LYlines - 1);    if (body)	_statusline(SEND_MESSAGE_PROMPT);    else	_statusline(SEND_COMMENT_PROMPT);    LYStatusLine = -1;    c = 0;    while (TOUPPER(c) != 'Y' && TOUPPER(c) != 'N' &&	   !term_letter && c != 7   && c != 3)	c = LYgetch();    if (TOUPPER(c) != 'Y') {	clear();  /* clear the screen */	goto cleanup;    }    if ((body == NULL && LynxSigFile != NULL) &&	(fp = fopen(LynxSigFile, "r")) != NULL) {	LYStatusLine = (LYlines - 1);	_user_message(APPEND_SIG_FILE, LynxSigFile);	c = 0;	LYStatusLine = -1;	while (TOUPPER(c) != 'Y' && TOUPPER(c) != 'N' &&	       !term_letter && c != 7	&& c != 3)	    c = LYgetch();	if (TOUPPER(c) == 'Y') {	    if ((fd = fopen(my_tmpfile, "a")) != NULL) {		fputs("-- \n", fd);		while (fgets(user_input, sizeof(user_input), fp) != NULL) {		    fputs(user_input, fd);		}		fclose(fd);	    }	}	fclose(fp);    }    clear();  /* Clear the screen. */    /*     *	Send the message.     */#ifdef VMS    /*     *	Set the mail command. - FM     */    if (isPMDF) {	/*	 *  For PMDF, put any keywords and the subject	 *  in the header file and close it. - FM	 */	if (keywords != NULL && *keywords != '\0') {	    fprintf(hfd, "Keywords: %s\n", keywords);	}	fprintf(hfd, "Subject: %s\n\n", subject);	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, and ignore any keywords to minimize risk	 *  of them making the line too long or having problem	 *  characters. - FM	 */	sprintf(cmd,		"%s %s%s/subject=\"%s\" %s ",		system_mail,		system_mail_flags,		(strncasecomp(system_mail, "MAIL", 4) ? "" : "/noself"),		subject,		my_tmpfile);    }    StrAllocCopy(command, cmd);    /*     *	Now add all the people in the address field. - FM     */    address_ptr1 = address;    do {	if ((cp = strchr(address_ptr1, ',')) != NULL) {	    address_ptr2 = (cp+1);	    *cp = '\0';	} else {	    address_ptr2 = NULL;	}	/*	 *  4 letters is arbitrarily the smallest possible mail	 *  address, at least for lynx.  That way extra spaces	 *  won't confuse the mailer and give a blank address.	 */	if (strlen(address_ptr1) > 3) {	    if (!first) {		StrAllocCat(command, ",");	    }	    sprintf(cmd, mail_adrs, address_ptr1);	    StrAllocCat(command, cmd);	    first = FALSE;	}	address_ptr1 = address_ptr2;    } while (address_ptr1 != NULL);    /*     *	Now add all the people in the CC field. - FM     */    if (ccaddr != NULL && *ccaddr != '\0') {	address_ptr1 = ccaddr;	do {	    if ((cp = strchr(address_ptr1, ',')) != NULL) {		address_ptr2 = (cp+1);		*cp = '\0';	    } else {		address_ptr2 = NULL;	    }	    /*	     *	4 letters is arbitrarily the smallest possible mail	     *	address, at least for lynx.  That way extra spaces	     *	won't confuse the mailer and give a blank address.	     */	    if (strlen(address_ptr1) > 3) {		StrAllocCat(command, ",");		sprintf(cmd, mail_adrs, address_ptr1);		if (isPMDF) {		    strcat(cmd, "/CC");		}		StrAllocCat(command, cmd);	    }	    address_ptr1 = address_ptr2;	} while (address_ptr1 != NULL);    }    stop_curses();    printf("Sending your comment:\n\n$ %s\n\nPlease wait...", command);    system(command);    FREE(command);    sleep(AlertSecs);    start_curses();    goto cleandown;#else /* Unix: */    /*     *	Send the tmpfile into sendmail.     */    _statusline(SENDING_YOUR_MSG);    sprintf(cmd, "%s %s", system_mail, system_mail_flags);#ifdef DOSPATH    tempname(tmpfile2, NEW_FILE);    if (((cp = strrchr(tmpfile2, '.')) != NULL) &&	NULL == strchr(cp, '/')) {	*cp = '\0';	strcat(tmpfile2, ".txt");    }    if ((fp = LYNewTxtFile(tmpfile2)) == NULL) {	HTAlert(MAILTO_URL_TEMPOPEN_FAILED);	return;    }#else    signal(SIGINT, SIG_IGN);    fp = popen(cmd, "w");    if (fp == NULL) {	_statusline(COMMENT_REQUEST_CANCELLED);	sleep(InfoSecs);	goto cleanup;    }#endif /* DOSPATH */    fd = fopen(my_tmpfile, "r");    if (fd == NULL) {	_statusline(COMMENT_REQUEST_CANCELLED);	sleep(InfoSecs);	pclose(fp);	goto cleanup;    }    fputs(header, fp);    while ((n = fread(buf, 1, sizeof(buf), fd)) != 0)	fwrite(buf, 1, n, fp);#ifdef DOSPATH	sprintf(cmd, "%s -t \"%s\" -F %s", system_mail, address, tmpfile2);	fclose(fp);		/* Close the tmpfile. */	stop_curses();	printf("Sending your comment:\n\n$ %s\n\nPlease wait...", cmd);	system(cmd);	sleep(MessageSecs);	start_curses();	remove(tmpfile2);	/* Delete the tmpfile. */#else    pclose(fp);#endif    fclose(fd); /* Close the tmpfile. */    if (TRACE)	printf("%s\n", cmd);#endif /* VMS */    /*     *	Come here to cleanup and exit.     */cleanup:    signal(SIGINT, cleanup_sig);#if !defined(VMS) && !defined(DOSPATH)    FREE(header);#endif /* !VMS */#if defined(VMS) || defined(DOSPATH)cleandown:#endif /* VMS */    term_letter = FALSE;#ifdef VMS    FREE(command);    while (remove(my_tmpfile) == 0)	;		 /* Delete the tmpfile(s). */    if (isPMDF) {	remove(hdrfile); /* Delete the hdrfile. */    }#else    remove(my_tmpfile);  /* Delete the tmpfile. */#endif /* VMS */    FREE(address);    FREE(ccaddr);    FREE(keywords);    FREE(body);    return;}PRIVATE void terminate_letter ARGS1(int,sig GCC_UNUSED){    term_letter = TRUE;    /* Reassert the AST */    signal(SIGINT, terminate_letter);#if defined(VMS) || defined(DOSPATH)    /*     *	Refresh the screen to get rid of the "interrupt" message.     */    if (!dump_output_immediately) {	lynx_force_repaint();	refresh();    }#endif /* VMS */}PRIVATE void remove_tildes ARGS1(char *,string){   /*    *  Change the first character to    *  a space if it is a '~'.    */    if (*string == '~')	*string = ' ';}

⌨️ 快捷键说明

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