use_type =  (disp_charset || HTisDocumentSource());
use_type = (BOOL) (disp_charset || HTisDocumentSource());
PRIVATE void send_file_to_mail ARGS3(	document *,	newdoc,	char *,		content_base,	char *,		content_location){    static BOOLEAN first_mail_preparsed = TRUE;#ifdef VMS    BOOLEAN isPMDF = !strncasecomp(system_mail, "PMDF SEND", 9);    FILE *hfd;    char hdrfile[LY_MAXPATH];    char my_temp[LY_MAXPATH];#endif#ifdef DOSPATH    char my_temp[LY_MAXPATH];#endif    BOOL use_cte;    BOOL use_mime;    BOOL use_type;    CONST char *disp_charset;    FILE *outfile_fp;    char *buffer = NULL;    char *subject = NULL;    char user_response[LINESIZE];    if (LYPreparsedSource && first_mail_preparsed &&	HTisDocumentSource()) {	if (HTConfirmDefault(CONFIRM_MAIL_SOURCE_PREPARSED, NO) == YES) {	    addstr("   Ok...");	    first_mail_preparsed = FALSE;	} else	{	    CancelPrint(MAIL_REQUEST_CANCELLED);	}    }    _statusline(MAIL_ADDRESS_PROMPT);    LYstrncpy(user_response, personal_mail_address, sizeof(user_response)-1);    if (LYgetstr(user_response, VISIBLE, sizeof(user_response), NORECALL) < 0 ||	*user_response == '\0') {	CancelPrint(MAIL_REQUEST_CANCELLED);    }    /*     * Determine which mail headers should be sent.  Use Content-Type and     * MIME-Version headers only if needed.  We need them if we are mailing     * HTML source, or if we have 8-bit characters and will be sending     * Content-Transfer-Encoding to indicate this.  We will append a charset     * parameter to the Content-Type if we do not have an "x-" charset, and we     * will include the Content-Transfer-Encoding only if we are appending the     * charset parameter, because indicating an 8-bit transfer without also     * indicating the charset can cause problems with many mailers.  - FM & KW     */    disp_charset = LYCharSet_UC[current_char_set].MIMEname;    use_cte = HTLoadedDocumentEightbit();    if (!(use_cte && strncasecomp(disp_charset, "x-", 2))) {	disp_charset = NULL;	use_cte = FALSE;    }    use_type =  (disp_charset || HTisDocumentSource());    /*     * Use newdoc->title as a subject instead of sug_filename:  MORE readable     * and 8-bit letters shouldn't be a problem - LP     */    /* change_sug_filename(sug_filename); */   subject = subject_translate8bit(newdoc->title);   if (newdoc->isHEAD) {	   /*	    * Special case for mailing HEAD responce:  this is rather technical	    * information, show URL.	    */	   FREE(subject);	   StrAllocCopy(subject, "HEAD  ");	   StrAllocCat(subject, newdoc->address);    }#ifdef VMS    if (strchr(user_response,'@') && !strchr(user_response,':') &&       !strchr(user_response,'%') && !strchr(user_response,'"')) {	char *temp = 0;	HTSprintf0(&temp, mail_adrs, user_response);	LYstrncpy(user_response, temp, sizeof(user_response)-1);	FREE(temp);    }    outfile_fp = LYOpenTemp(my_temp,			    (HTisDocumentSource())				    ? HTML_SUFFIX				    : ".txt",			    "w");    if (outfile_fp == NULL) {	CannotPrint(UNABLE_TO_OPEN_TEMPFILE);    }    if (isPMDF) {	if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) {	    CannotPrint(UNABLE_TO_OPEN_TEMPFILE);	}	if (use_type) {	    fprintf(hfd, "Mime-Version: 1.0\n");	    if (use_cte) {		fprintf(hfd, "Content-Transfer-Encoding: 8bit\n");	    }	}	if (HTisDocumentSource()) {	    /*	     * Add Content-Type, Content-Location, and Content-Base headers for	     * HTML source.  - FM	     */	    fprintf(hfd, "Content-Type: text/html");	    if (disp_charset != NULL) {		fprintf(hfd, "; charset=%s\n", disp_charset);	    } else {		fprintf(hfd, "\n");	    }	    fprintf(hfd, "Content-Base: %s\n", content_base);	    fprintf(hfd, "Content-Location: %s\n", content_location);	} else {	    /*	     * Add Content-Type:  text/plain if we have 8-bit characters and a	     * valid charset for non-source documents.  - FM	     */	    if (disp_charset != NULL) {		fprintf(hfd,			"Content-Type: text/plain; charset=%s\n",			disp_charset);	    }	}	/*	 *	X-URL header. - FM	 */	fprintf(hfd, "X-URL: %s\n", newdoc->address);    }    /*     *  Write the contents to a temp file.     */    if (LYPrependBaseToSource && HTisDocumentSource()) {	/*	 * Added the document's base as a BASE tag to the top of the message	 * body.  May create technically invalid HTML, but will help get any	 * partial or relative URLs resolved properly if no BASE tag is present	 * to replace it.  - FM	 */	fprintf(outfile_fp,		"<!-- X-URL: %s -->\n<BASE HREF=\"%s\">\n\n",		newdoc->address, content_base);    } else if (!isPMDF) {	fprintf(outfile_fp, "X-URL: %s\n\n", newdoc->address);    }    print_wwwfile_to_fd(outfile_fp, 0);    if (keypad_mode)	printlist(outfile_fp, FALSE);    LYCloseTempFP(outfile_fp);    if (isPMDF) {	/*	 * For PMDF, put the subject in the header file and close it.  - FM	 */	fprintf(hfd, "Subject: %.70s\n\n", subject);	LYCloseTempFP(hfd);	/*	 * Now set up the command.  - FM	 */	HTSprintf0(&buffer,		"%s %s %s,%s %s",		system_mail,		system_mail_flags,		hdrfile,		my_temp,		user_response);    } else {	/*	 * For "generic" VMS MAIL, include the subject in the command.  - FM	 */	remove_quotes(subject);	HTSprintf0(&buffer,		"%s %s/subject=\"%.70s\" %s %s",		system_mail,		system_mail_flags,		subject,		my_temp,		user_response);    }    stop_curses();    printf(MAILING_FILE);    LYSystem(buffer);    sleep(AlertSecs);    start_curses();    if (isPMDF)	LYRemoveTemp(hdrfile);    LYRemoveTemp(my_temp);#else /* Unix or DOS */#ifdef DOSPATH    outfile_fp = LYOpenTemp(my_temp, ".txt", "w");#else    HTSprintf0(&buffer, "%s %s", system_mail, system_mail_flags);    outfile_fp = popen(buffer, "w");#endif    if (outfile_fp == NULL) {	CannotPrint(MAIL_REQUEST_FAILED);    }    /*     * Determine which mail headers should be sent.  Use Content-Type and     * MIME-Version headers only if needed.  We need them if we are mailing     * HTML source, or if we have 8-bit characters and will be sending     * Content-Transfer-Encoding to indicate this.     *     * Send Content-Transfer-Encoding only if the document has 8-bit     * characters.  Send a charset parameter only if the document has 8-bit     * characters and we seem to have a valid charset.  - kw     */    use_cte = HTLoadedDocumentEightbit();    disp_charset = LYCharSet_UC[current_char_set].MIMEname;    /*     * 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.  - kw     */    if (!use_cte || LYHaveCJKCharacterSet ||	strncasecomp(disp_charset, "x-", 2) == 0) {	disp_charset = NULL;    }#ifdef NOTDEFINED    /*  Enable this if indicating an 8-bit transfer without     *  also indicating the charset causes problems. - kw */    if (use_cte && !disp_charset)	use_cte = FALSE;#endif /* NOTDEFINED */    use_type = (disp_charset || HTisDocumentSource());    use_mime = (use_cte || use_type);    if (use_mime) {	fprintf(outfile_fp, "Mime-Version: 1.0\n");	if (use_cte) {	    fprintf(outfile_fp, "Content-Transfer-Encoding: 8bit\n");	}    }    if (HTisDocumentSource()) {	/*	 * Add Content-Type, Content-Location, and Content-Base headers for	 * HTML source.  - FM	 */	fprintf(outfile_fp, "Content-Type: text/html");	if (disp_charset != NULL) {	    fprintf(outfile_fp, "; charset=%s\n", disp_charset);	} else {	    fprintf(outfile_fp, "\n");	}    } else {	/*	 * Add Content-Type:  text/plain if we have 8-bit characters and a	 * valid charset for non-source documents.  - KW	 */	if (disp_charset != NULL) {	    fprintf(outfile_fp,		    "Content-Type: text/plain; charset=%s\n",		    disp_charset);	}    }    /*     * If we are using MIME headers, add content-base and content-location if     * we have them.  This will always be the case if the document is source.     * - kw     */    if (use_mime) {	if (content_base)	    fprintf(outfile_fp, "Content-Base: %s\n", content_base);	if (content_location)	    fprintf(outfile_fp, "Content-Location: %s\n", content_location);    }    /*     *  Add the To, Subject, and X-URL headers. - FM     */    fprintf(outfile_fp, "To: %s\nSubject: %s\n", user_response, subject);    fprintf(outfile_fp, "X-URL: %s\n\n", newdoc->address);    if (LYPrependBaseToSource && HTisDocumentSource()) {	/*	 * Added the document's base as a BASE tag to the top of the message	 * body.  May create technically invalid HTML, but will help get any	 * partial or relative URLs resolved properly if no BASE tag is present	 * to replace it.  - FM	 */	fprintf(outfile_fp,		"<!-- X-URL: %s -->\n<BASE HREF=\"%s\">\n\n",		newdoc->address, content_base);    }    print_wwwfile_to_fd(outfile_fp, 0);    if (keypad_mode)	printlist(outfile_fp, FALSE);#ifdef DOSPATH    HTSprintf0(&buffer, "%s -t \"%s\" -F %s", system_mail, user_response, my_temp);    LYCloseTempFP(outfile_fp);	/* Close the tmpfile. */    stop_curses();    printf("%s\n\n$ %s\n\n%s", gettext("Sending"), buffer, PLEASE_WAIT);    LYSystem(buffer);    sleep(MessageSecs);    start_curses();    LYRemoveTemp(my_temp); /* Delete the tmpfile. */#else    pclose(outfile_fp);#endif#endif /* VMS */done:    FREE(buffer);    FREE(subject);    return;}