void HTFWriter_abort( HTStream *me, HTError e ) { if ( WWW_TraceFlag ) { fprintf( TraceFP( ), "HTFWriter_abort called\n" ); } LYCloseTempFP( &me->fp ); if ( me->viewer_command ) { free( &me->viewer_command ); *(int*)&me->viewer_command = 0; } if ( me->end_command ) { if ( WWW_TraceFlag ) { fprintf( TraceFP( ), "HTFWriter: Aborting: file not executed or saved.\n" ); } if ( me->end_command ) { free( &me->end_command ); *(int*)&me->end_command = 0; } if ( me->remove_command ) { chmod( &me->remove_command, 384 ); if ( unlink( &me->remove_command ) ) { char buf[560]; sprintf( buf, "%.60s '%.400s': %.60s", gettext( "Error deleting file" ), &me->remove_command, strerror( *(int*)(__errno_location( )) ) ); HTAlert( buf ); } if ( me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } } } if ( WWW_Download_File ) { free( WWW_Download_File ); WWW_Download_File = 0; } if ( me ) { free( me ); me = 0; } return; }
int LYUpload_options( char **newfile, char *directory ) { static char tempfile[256]; static char curloc[256]; FILE *fp0 = InternalPageFP( tempfile, 1 ); lynx_list_item_type *cur_upload; int count; char *cp; if ( fp0 == 0 ) { return -1; } cp = HTnameOfFile_WWW( directory, 0, 1 ); strcpy( curloc, cp ); LYTrimPathSep( curloc ); if ( cp != 0 ) { free( cp ); cp = 0; } LYLocalFileToURL( newfile, tempfile ); LYRegisterUIPage( newfile, 10 ); BeginInternalPage( fp0, gettext( "Upload Options" ), "Lynx_users_guide.html.gz#DirEd" ); fwrite( "<pre>\n", 1, 6, fp0 ); fprintf( fp0, " <em>%s</em> %s\n", gettext( "Upload To:" ), curloc ); fprintf( fp0, "\n%s\n", gettext( "Upload options:" ) ); if ( uploaders != 0 ) { count = 0; cur_upload = uploaders; for ( ; cur_upload != 0; count++ ) { fprintf( fp0, " <a href=\"LYNXDIRED://UPLOAD=%d/TO=%s\">", count, curloc ); fputs( cur_upload->name == 0 ? gettext( "No Name Given" ) : cur_upload->name, fp0 ); fwrite( "</a>\n", 1, 5, fp0 ); cur_upload = &cur_upload; //count++; } } else fwrite( " <NONE>\n", 1, 16, fp0 ); fwrite( "</pre>\n", 1, 7, fp0 ); EndInternalPage( fp0 ); LYCloseTempFP( fp0 ); LYforce_no_cache = 1; return 0; }
/* ** mailmsg() sends a message to the owner of the file, if one is defined, ** telling of errors (i.e., link not available). */ PUBLIC void mailmsg ARGS4( int, cur, char *, owner_address, char *, filename, char *, linkname) { FILE *fd, *fp; char *address = NULL; char *searchpart = NULL; char *cmd = NULL, *cp; #ifdef ALERTMAIL BOOLEAN skip_parsing = FALSE; #endif #if !CAN_PIPE_TO_MAILER char *ccaddr; char subject[128]; char my_tmpfile[LY_MAXPATH]; #endif #if USE_VMS_MAILER BOOLEAN isPMDF = LYMailPMDF(); char hdrfile[LY_MAXPATH]; char *command = NULL; CTRACE((tfp, "mailmsg(%d, \"%s\", \"%s\", \"%s\")\n", cur, NONNULL(owner_address), NONNULL(filename), NONNULL(linkname))); #endif /* VMS */ if (!LYSystemMail()) return; #ifdef ALERTMAIL if (owner_address == NULL) { owner_address = ALERTMAIL; skip_parsing = TRUE; } #endif if (isEmpty(owner_address)) return; if ((cp = (char *)strchr(owner_address,'\n')) != NULL) { #ifdef ALERTMAIL if (skip_parsing) return; /* invalidly defined - ignore - kw */ #else *cp = '\0'; #endif } if (!strncasecomp(owner_address, "lynx-dev@", 9)) { /* * Silently refuse sending bad link messages to lynx-dev. */ return; } StrAllocCopy(address, owner_address); #ifdef ALERTMAIL /* * If we are using a fixed address given by ALERTMAIL, it is * supposed to already be in usable form, without URL-isms like * ?-searchpart and URL-escaping. So skip some code. - kw */ if (!skip_parsing) #endif { /* * Check for a ?searchpart. - FM */ if ((cp = strchr(address, '?')) != NULL) { StrAllocCopy(searchpart, cp); *cp = '\0'; cp = (searchpart + 1); if (*cp != '\0') { /* * Seek and handle to=address(es) fields. * Appends to address. We ignore any other * headers in the ?searchpart. - FM */ extract_field(&address, searchpart, "to="); } } convert_explorer(address); /* * Unescape the address field. - FM */ SafeHTUnEscape(address); } if (trim_comma(address)) { FREE(address); CTRACE((tfp, "mailmsg: No address in '%s'.\n", owner_address)); return; } #if CAN_PIPE_TO_MAILER if ((fd = LYPipeToMailer()) == 0) { FREE(address); CTRACE((tfp, "mailmsg: '%s' failed.\n", cmd)); return; } fprintf(fd, "To: %s\n", address); fprintf(fd, "Subject: Lynx Error in %s\n", filename); if (!isEmpty(personal_mail_address)) { fprintf(fd, "Cc: %s\n", personal_mail_address); } fprintf(fd, "X-URL: %s\n", filename); fprintf(fd, "X-Mailer: %s, Version %s\n\n", LYNX_NAME, LYNX_VERSION); #else if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { CTRACE((tfp, "mailmsg: Could not fopen '%s'.\n", my_tmpfile)); FREE(address); return; } sprintf(subject, "Lynx Error in %.56s", filename); ccaddr = personal_mail_address; #if USE_VMS_MAILER if (isPMDF) { FILE *hfd; if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { CTRACE((tfp, "mailmsg: Could not fopen '%s'.\n", hdrfile)); FREE(address); return; } if (!isEmpty(personal_mail_address)) { fprintf(fd, "Cc: %s\n", personal_mail_address); } fprintf(fd, "X-URL: %s\n", filename); fprintf(fd, "X-Mailer: %s, Version %s\n\n", LYNX_NAME, LYNX_VERSION); /* * For PMDF, put the subject in the * header file and close it. - FM */ fprintf(hfd, "Subject: Lynx Error in %.56s\n\n", filename); LYCloseTempFP(hfd); } #endif /* USE_VMS_MAILER */ #endif /* CAN_PIPE_TO_MAILER */ fprintf(fd, gettext("The link %s :?: %s \n"), links[cur].lname, links[cur].target); fprintf(fd, gettext("called \"%s\"\n"), LYGetHiliteStr(cur, 0)); fprintf(fd, gettext("in the file \"%s\" called \"%s\"\n"), filename, linkname); fprintf(fd, "%s\n\n", gettext("was requested but was not available.")); fprintf(fd, "%s\n\n", gettext("Thought you might want to know.")); fprintf(fd, "%s\n", gettext("This message was automatically generated by")); fprintf(fd, "%s %s", LYNX_NAME, LYNX_VERSION); if ((LynxSigFile != NULL) && (fp = fopen(LynxSigFile, TXT_R)) != NULL) { fputs("-- \n", fd); while (LYSafeGets(&cmd, fp) != NULL) fputs(cmd, fd); LYCloseInput(fp); } #if CAN_PIPE_TO_MAILER pclose(fd); #else LYCloseTempFP(fd); #if USE_VMS_MAILER if (isPMDF) { /* * Now set up the command. - FM */ HTSprintf0(&command, "%s %s %s,%s ", system_mail, system_mail_flags, hdrfile, my_tmpfile); } else { /* * For "generic" VMS MAIL, include the * subject in the command. - FM */ HTSprintf0(&command, "%s %s/self/subject=\"Lynx Error in %.56s\" %s ", system_mail, system_mail_flags, filename, my_tmpfile); } vms_append_addrs(&command, address, ""); LYSystem(command); /* VMS */ FREE(command); FREE(cmd); LYRemoveTemp(my_tmpfile); if (isPMDF) { LYRemoveTemp(hdrfile); } #else /* DOS */ LYSendMailFile ( address, my_tmpfile, subject, ccaddr, ""); LYRemoveTemp(my_tmpfile); #endif /* USE_VMS_MAILER */ #endif /* CAN_PIPE_TO_MAILER */ if (traversal) { FILE *ofp; if ((ofp = LYAppendToTxtFile(TRAVERSE_ERRORS)) == NULL) { if ((ofp = LYNewTxtFile(TRAVERSE_ERRORS)) == NULL) { perror(NOOPEN_TRAV_ERR_FILE); exit_immediately(EXIT_FAILURE); } } fprintf(ofp, "%s\t%s \tin %s\n", links[cur].lname, links[cur].target, filename); LYCloseOutput(ofp); } FREE(address); return; }
/* ** mailform() sends form content to the mailto address(es). - FM */ PUBLIC void mailform ARGS4( CONST char *, mailto_address, CONST char *, mailto_subject, CONST char *, mailto_content, CONST char *, mailto_type) { FILE *fd; char *address = NULL; char *ccaddr = NULL; char *keywords = NULL; char *cp = NULL; char self[MAX_SUBJECT + 10]; char subject[MAX_SUBJECT + 10]; char *searchpart = NULL; char buf[512]; int ch, len, i; #if USE_VMS_MAILER static char *cmd; char *command = NULL; BOOLEAN isPMDF = LYMailPMDF(); char hdrfile[LY_MAXPATH]; #endif #if !CAN_PIPE_TO_MAILER char my_tmpfile[LY_MAXPATH]; #endif CTRACE((tfp, "mailto_address: \"%s\"\n", NONNULL(mailto_address))); CTRACE((tfp, "mailto_subject: \"%s\"\n", NONNULL(mailto_subject))); CTRACE((tfp, "mailto_content: \"%s\"\n", NONNULL(mailto_content))); CTRACE((tfp, "mailto_type: \"%s\"\n", NONNULL(mailto_type))); if (!LYSystemMail()) return; if (!mailto_address || !mailto_content) { HTAlert(BAD_FORM_MAILTO); return; } subject[0] = '\0'; self[0] = '\0'; if ((cp = (char *)strchr(mailto_address,'\n')) != NULL) *cp = '\0'; StrAllocCopy(address, mailto_address); /* * 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 */ extract_subject(subject, searchpart); /* * Seek and handle to=address(es) fields. * Appends to address. - FM */ extract_field(&address, searchpart, "to="); /* * 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 */ extract_field(&ccaddr, searchpart, "cc="); /* * Seek and handle keywords=term(s) fields. - FM */ extract_field(&keywords, searchpart, "keywords="); if (keywords != NULL) { if (*keywords != '\0') { SafeHTUnEscape(keywords); } else { FREE(keywords); } } FREE(searchpart); } } if (convert_explorer(address)) { HTAlert(BAD_FORM_MAILTO); goto cleanup; } if (ccaddr != NULL) { if (convert_explorer(ccaddr)) { FREE(ccaddr); } } /* * Unescape the address and ccaddr fields. - FM */ SafeHTUnEscape(address); if (ccaddr != NULL) { SafeHTUnEscape(ccaddr); } /* * Allow user to edit the default Subject - FM */ if (isEmpty(subject)) { if (!isEmpty(mailto_subject)) { LYstrncpy(subject, mailto_subject, MAX_SUBJECT); } else { sprintf(subject, "mailto:%.63s", address); } } _statusline(SUBJECT_PROMPT); if ((ch = LYgetstr(subject, VISIBLE, MAX_SUBJECT, NORECALL)) < 0) { /* * User cancelled via ^G. - FM */ HTInfoMsg(FORM_MAILTO_CANCELLED); goto cleanup; } /* * Allow user to specify a self copy via a CC: * entry, if permitted. - FM */ if (!LYNoCc) { sprintf(self, "%.*s", MAX_SUBJECT, isEmpty(personal_mail_address) ? "" : personal_mail_address); _statusline("Cc: "); if ((ch = LYgetstr(self, VISIBLE, MAX_SUBJECT, NORECALL)) < 0) { /* * User cancelled via ^G. - FM */ HTInfoMsg(FORM_MAILTO_CANCELLED); goto cleanup; } remove_tildes(self); if (ccaddr == NULL) { StrAllocCopy(ccaddr, self); } else { StrAllocCat(ccaddr, ","); StrAllocCat(ccaddr, self); } } #if CAN_PIPE_TO_MAILER if ((fd = LYPipeToMailer()) == 0) { HTAlert(FORM_MAILTO_FAILED); goto cleanup; } if (!isEmpty(mailto_type)) { fprintf(fd, "Mime-Version: 1.0\n"); fprintf(fd, "Content-Type: %s\n", mailto_type); } fprintf(fd, "To: %s\n", address); if (!isEmpty(personal_mail_address)) fprintf(fd, "From: %s\n", personal_mail_address); if (!isEmpty(ccaddr)) fprintf(fd, "Cc: %s\n", ccaddr); fprintf(fd, "Subject: %s\n\n", subject); if (!isEmpty(keywords)) fprintf(fd, "Keywords: %s\n", keywords); _statusline(SENDING_FORM_CONTENT); #else /* e.g., VMS, DOS */ if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { HTAlert(FORM_MAILTO_FAILED); goto cleanup; } #if USE_VMS_MAILER if (isPMDF) { FILE *hfd; if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { HTAlert(FORM_MAILTO_FAILED); LYCloseTempFP(fd); goto cleanup; } if (!isEmpty(mailto_type)) { fprintf(hfd, "Mime-Version: 1.0\n"); fprintf(hfd, "Content-Type: %s\n", mailto_type); if (!isEmpty(personal_mail_address)) fprintf(hfd, "From: %s\n", personal_mail_address); } /* * For PMDF, put any keywords and the subject * in the header file and close it. - FM */ if (!isEmpty(keywords)) { fprintf(hfd, "Keywords: %s\n", keywords); } fprintf(hfd, "Subject: %s\n\n", subject); LYCloseTempFP(hfd); } else if (mailto_type && !strncasecomp(mailto_type, "multipart/form-data", 19)) { /* * Ugh! There's no good way to include headers while * we're still using "generic" VMS MAIL, so we'll put * this in the body of the message. - FM */ fprintf(fd, "X-Content-Type: %s\n\n", mailto_type); } #else /* !VMS (DOS) */ #if USE_BLAT_MAILER if (mail_is_blat) { if (strlen(subject) > MAX_SUBJECT) subject[MAX_SUBJECT] = '\0'; } else #endif { if (!isEmpty(mailto_type)) { fprintf(fd, "Mime-Version: 1.0\n"); fprintf(fd, "Content-Type: %s\n", mailto_type); } fprintf(fd,"To: %s\n", address); if (!isEmpty(personal_mail_address)) fprintf(fd,"From: %s\n", personal_mail_address); fprintf(fd,"Subject: %.70s\n\n", subject); } #endif /* VMS */ #endif /* CAN_PIPE_TO_MAILER */ /* * Break up the content into lines with a maximum length of 78. * If the ENCTYPE was text/plain, we have physical newlines and * should take them into account. Otherwise, the actual newline * characters in the content are hex escaped. - FM */ while((cp = strchr(mailto_content, '\n')) != NULL) { *cp = '\0'; i = 0; len = strlen(mailto_content); while (len > 78) { strncpy(buf, &mailto_content[i], 78); buf[78] = '\0'; fprintf(fd, "%s\n", buf); i += 78; len = strlen(&mailto_content[i]); } fprintf(fd, "%s\n", &mailto_content[i]); mailto_content = (cp+1); } i = 0; len = strlen(mailto_content); while (len > 78) { strncpy(buf, &mailto_content[i], 78); buf[78] = '\0'; fprintf(fd, "%s\n", buf); i += 78; len = strlen(&mailto_content[i]); } if (len) fprintf(fd, "%s\n", &mailto_content[i]); #if CAN_PIPE_TO_MAILER pclose(fd); LYSleepMsg(); #else LYCloseTempFP(fd); #if USE_VMS_MAILER /* * Set the mail command. - FM */ if (isPMDF) { /* * Now set up the command. - FM */ HTSprintf0(&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 */ HTSprintf0(&cmd, "%s %s%s/subject=\"%s\" %s ", system_mail, system_mail_flags, (strncasecomp(system_mail, "MAIL", 4) ? "" : "/noself"), subject, my_tmpfile); } StrAllocCopy(command, cmd); vms_append_addrs(&command, address, ""); if (!isEmpty(ccaddr)) { vms_append_addrs(&command, ccaddr, "/CC"); } stop_curses(); printf("%s\n\n$ %s\n\n%s", SENDING_FORM_CONTENT, command, PLEASE_WAIT); LYSystem(command); /* Mail (VMS) */ FREE(command); LYSleepAlert(); start_curses(); LYRemoveTemp(my_tmpfile); if (isPMDF) LYRemoveTemp(hdrfile); #else /* DOS */ LYSendMailFile ( address, my_tmpfile, subject, ccaddr, SENDING_FORM_CONTENT); LYRemoveTemp(my_tmpfile); #endif /* USE_VMS_MAILER */ #endif /* CAN_PIPE_TO_MAILER */ cleanup: FREE(address); FREE(ccaddr); FREE(keywords); 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 ARGS4( char *, mail_address, char *, filename, CONST char *, title, CONST char *, refid) { #ifndef NO_ANONYMOUS_EMAIL static char *personal_name = NULL; #endif char user_input[LINESIZE]; FILE *fd, *fp; char *label = NULL; char *from_address = NULL; char *cc_address = NULL; char *to_address = NULL; char *the_subject = NULL; char *ccaddr = NULL; char *keywords = NULL; char *searchpart = NULL; char *body = NULL; char *cp = NULL, *cp1 = NULL; int i; int c = 0; /* user input */ char my_tmpfile[LY_MAXPATH]; char default_subject[MAX_SUBJECT + 10]; #if USE_VMS_MAILER char *command = NULL; BOOLEAN isPMDF = LYMailPMDF(); char hdrfile[LY_MAXPATH]; FILE *hfd = 0; #else #if !CAN_PIPE_TO_MAILER char tmpfile2[LY_MAXPATH]; #endif char buf[4096]; /* 512 */ char *header = NULL; int n; #endif /* USE_VMS_MAILER */ CTRACE((tfp, "reply_by_mail(\"%s\", \"%s\", \"%s\", \"%s\")\n", NONNULL(mail_address), NONNULL(filename), NONNULL(title), NONNULL(refid))); term_letter = FALSE; if (!LYSystemMail()) return; if (isEmpty(mail_address)) { HTAlert(NO_ADDRESS_IN_MAILTO_URL); return; } StrAllocCopy(to_address, mail_address); if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } #if USE_VMS_MAILER if (isPMDF) { if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } } #endif /* VMS */ default_subject[0] = '\0'; /* * Check for a ?searchpart. - FM */ if ((cp = strchr(to_address, '?')) != NULL) { StrAllocCopy(searchpart, cp); *cp = '\0'; cp = (searchpart + 1); if (*cp != '\0') { /* * Seek and handle a subject=foo. - FM */ extract_subject(default_subject, searchpart); /* * Seek and handle to=address(es) fields. * Appends to address. - FM */ extract_field(&to_address, searchpart, "to="); /* * 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 */ extract_field(&ccaddr, searchpart, "cc="); /* * Seek and handle keywords=term(s) fields. - FM */ extract_field(&keywords, searchpart, "keywords="); if (keywords != NULL) { if (*keywords != '\0') { SafeHTUnEscape(keywords); } else { FREE(keywords); } } /* * Seek and handle body=foo fields. - FM */ extract_body(&body, searchpart); FREE(searchpart); } } if (convert_explorer(to_address)) { HTAlert(NO_ADDRESS_IN_MAILTO_URL); goto cancelled; } if (ccaddr != NULL) { if (convert_explorer(ccaddr)) { FREE(ccaddr); } } /* * Unescape the address and ccaddr fields. - FM */ SafeHTUnEscape(to_address); if (ccaddr != NULL) { SafeHTUnEscape(ccaddr); } /* * Set the default subject. - FM */ if (isEmpty(default_subject) && !isEmpty(title)) { strncpy(default_subject, title, MAX_SUBJECT); default_subject[MAX_SUBJECT] = '\0'; } /* * Use ^G to cancel mailing of comment * and don't let SIGINTs exit lynx. */ signal(SIGINT, terminate_letter); #if USE_VMS_MAILER 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", isEmpty(filename) ? STR_MAILTO_URL : filename, isEmpty(filename) ? to_address : ""); fprintf((isPMDF ? hfd : fd), "X-Mailer: %s, Version %s\n", LYNX_NAME, LYNX_VERSION); #ifdef NO_ANONYMOUS_EMAIL if (!isPMDF) { fprintf(fd, "\n"); } #endif /* NO_ANONYMOUS_EMAIL */ } #else /* Unix/DOS/Windows */ /* * Put the To: line in the header. */ #ifndef DOSPATH asprintf(&header, "To: %s\n", to_address); if (!header) { fprintf(stderr, "Out of memory, you lose!\n"); exit(1); } #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) { HTSprintf(&header, "Content-Type: text/plain; charset=%s\n", LYCharSet_UC[current_char_set].MIMEname); } StrAllocCat(header, "Content-Transfer-Encoding: 8bit\n"); } /* * Put the X-URL and X-Mailer lines in the header. */ if (!isEmpty(filename)) { HTSprintf(&header, "X-URL: %s\n", filename); } else { HTSprintf(&header, "X-URL: mailto:%s\n", to_address); } HTSprintf(&header, "X-Mailer: %s, Version %s\n", LYNX_NAME, LYNX_VERSION); if (!isEmpty(refid)) { HTSprintf(&header, "In-Reply-To: <%s>\n", refid); } #endif /* VMS */ /* * Clear the screen and inform the user. */ LYclear(); LYmove(2,0); scrollok(LYwin, TRUE); /* Enable scrolling. */ if (body) LYaddstr(SENDING_MESSAGE_WITH_BODY_TO); else LYaddstr(SENDING_COMMENT_TO); show_addresses(to_address); if ( #if USE_VMS_MAILER (isPMDF == TRUE) && #endif /* VMS */ (cp = ccaddr) != NULL) { if (strchr(cp, ',') != NULL) { LYaddstr(WITH_COPIES_TO); } else { LYaddstr(WITH_COPY_TO); } show_addresses(ccaddr); } LYaddstr(CTRL_G_TO_CANCEL_SEND); #if USE_VMS_MAILER if (isPMDF || !body) { #endif /* USE_VMS_MAILER */ #ifndef NO_ANONYMOUS_EMAIL /* * Get the user's personal name. */ LYaddstr(ENTER_NAME_OR_BLANK); #if USE_VMS_MAILER if (isPMDF) { label = "Personal_name: "; } else { label = "X-Personal_name: "; } #else label = "X-Personal_Name: "; #endif /* USE_VMS_MAILER */ if (!header_prompt(label, &personal_name, LINESIZE)) { goto cancelled; } if (*personal_name) { #if USE_VMS_MAILER fprintf((isPMDF ? hfd : fd), "%s: %s\n", label, personal_name); #else HTSprintf(&header, "%s: %s\n", label, personal_name); #endif /* VMS */ } /* * Get the user's return address. */ LYaddstr(ENTER_MAIL_ADDRESS_OR_OTHER); LYaddstr(MEANS_TO_CONTACT_FOR_RESPONSE); #if USE_VMS_MAILER if (isPMDF) { label = "From"; } else { label = "X-From"; } #else label = "From"; #endif /* VMS */ /* Add the personal mail address if there is one. */ if (personal_mail_address) StrAllocCopy(from_address, personal_mail_address); if (!header_prompt(label, &from_address, LINESIZE)) { goto cancelled; } #if USE_VMS_MAILER if (*from_address) { fprintf(isPMDF ? hfd : fd, "%s: %s\n", label, from_address); } if (!isPMDF) { fprintf(fd, "\n"); } #else HTSprintf(&header, "%s: %s\n", label, from_address); #endif /* USE_VMS_MAILER */ #endif /* !NO_ANONYMOUS_EMAIL */ #if USE_VMS_MAILER } #endif /* USE_VMS_MAILER */ /* * Get the subject line. */ LYaddstr(ENTER_SUBJECT_LINE); label = "Subject"; if (*default_subject) { StrAllocCopy(the_subject, default_subject); } else if (!isEmpty(filename)) { HTSprintf(&the_subject, "%s", filename); } else { HTSprintf(&the_subject, "mailto:%s", to_address); } if (!header_prompt(label, &the_subject, MAX_SUBJECT)) { goto cancelled; } /* * Offer a CC line, if permitted. - FM */ if (!LYNoCc) { LYaddstr(ENTER_ADDRESS_FOR_CC); LYaddstr(BLANK_FOR_NO_COPY); if (personal_mail_address) StrAllocCopy(cc_address, personal_mail_address); if (!header_prompt("Cc", &cc_address, LINESIZE)) { goto cancelled; } comma_append(&ccaddr, cc_address); } #if !USE_VMS_MAILER HTSprintf(&header, "%s: %s\n", label, the_subject); #if !CAN_PIPE_TO_MAILER if (*to_address) { HTSprintf(&header, "To: %s\n", to_address); } #endif /* ** Add the Cc: header. - FM */ if (!isEmpty(ccaddr)) { HTSprintf(&header, "Cc: %s\n", ccaddr); } /* ** Add the Keywords: header. - FM */ if (!isEmpty(keywords)) { HTSprintf(&header, "Keywords: %s\n", keywords); } /* * Terminate the header. */ StrAllocCat(header, "\n"); CTRACE((tfp,"**header==\n%s",header)); #endif /* !VMS */ if (!no_editor && !isEmpty(editor)) { 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 = (BOOL) (LYPreparsedSource && HTisDocumentSource()); if (HTConfirm(is_preparsed ? INC_PREPARSED_MSG_PROMPT : INC_ORIG_MSG_PROMPT) == YES) { print_wwwfile_to_fd(fd, (BOOL) !is_preparsed); } } LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(LYwin,FALSE); /* Stop scrolling. */ if (term_letter || LYCharIsINTERRUPT(c)) goto cleanup; /* * Spawn the users editor on the mail file */ edit_temporary_file(my_tmpfile, "", SPAWNING_EDITOR_FOR_MAIL); } else if (body) { /* * Let user review the body. - FM */ LYclear(); LYmove(0,0); LYaddstr(REVIEW_MESSAGE_BODY); LYrefresh(); cp1 = body; i = (LYlines - 5); while((cp = strchr(cp1, '\n')) != NULL) { if (i <= 0) { LYaddstr(RETURN_TO_CONTINUE); LYrefresh(); c = LYgetch(); LYaddstr("\n"); if (term_letter || LYCharIsINTERRUPT(c)) { goto cancelled; } i = (LYlines - 2); } *cp++ = '\0'; fprintf(fd, "%s\n", cp1); LYaddstr(cp1); LYaddstr("\n"); cp1 = cp; i--; } while (i >= 0) { LYaddstr("\n"); i--; } LYrefresh(); LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(LYwin,FALSE); /* Stop scrolling. */ } else { /* * Use the internal line editor for the message. */ LYaddstr(ENTER_MESSAGE_BELOW); LYaddstr(ENTER_PERIOD_WHEN_DONE_A); LYaddstr(ENTER_PERIOD_WHEN_DONE_B); LYaddstr("\n\n"); LYrefresh(); *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter || STREQ(user_input, ".")) { goto cancelled; } while (!STREQ(user_input, ".") && !term_letter) { LYaddstr("\n"); remove_tildes(user_input); fprintf(fd, "%s\n", user_input); *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0) { goto cancelled; } } fprintf(fd, "\n"); /* Terminate the message. */ LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(LYwin,FALSE); /* Stop scrolling. */ } #if !USE_VMS_MAILER /* * Ignore CTRL-C on this last question. */ signal(SIGINT, SIG_IGN); #endif /* !VMS */ LYStatusLine = (LYlines - 1); c = HTConfirm (body ? SEND_MESSAGE_PROMPT : SEND_COMMENT_PROMPT); LYStatusLine = -1; if (c != YES) { LYclear(); /* clear the screen */ goto cleanup; } if ((body == NULL && LynxSigFile != NULL) && (fp = fopen(LynxSigFile, TXT_R)) != NULL) { LYStatusLine = (LYlines - 1); if (term_letter) { _user_message(APPEND_SIG_FILE, LynxSigFile); c = 0; } else { char *msg = NULL; HTSprintf0(&msg, APPEND_SIG_FILE, LynxSigFile); c = HTConfirm(msg); FREE(msg); } LYStatusLine = -1; if (c == YES) { if ((fd = fopen(my_tmpfile, TXT_A)) != NULL) { char *buffer = NULL; fputs("-- \n", fd); while (LYSafeGets(&buffer, fp) != NULL) { fputs(buffer, fd); } LYCloseOutput(fd); FREE(buffer); } } LYCloseInput(fp); } LYclear(); /* Clear the screen. */ /* * Send the message. */ #if USE_VMS_MAILER /* * Set the mail command. - FM */ if (isPMDF) { /* * For PMDF, put any keywords and the subject * in the header file and close it. - FM */ if (!isEmpty(keywords)) { fprintf(hfd, "Keywords: %s\n", keywords); } fprintf(hfd, "Subject: %s\n\n", the_subject); LYCloseTempFP(hfd); /* * Now set up the command. - FM */ HTSprintf0(&command, "%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 */ HTSprintf0(&command, "%s %s%s/subject=\"%s\" %s ", system_mail, system_mail_flags, (strncasecomp(system_mail, "MAIL", 4) ? "" : "/noself"), the_subject, my_tmpfile); } vms_append_addrs(&command, to_address, ""); if (!isEmpty(ccaddr)) { vms_append_addrs(&command, ccaddr, "/CC"); } stop_curses(); printf("%s\n\n$ %s\n\n%s", SENDING_COMMENT, command, PLEASE_WAIT); LYSystem(command); /* SENDING COMMENT (VMS) */ FREE(command); LYSleepAlert(); start_curses(); #else /* Unix/DOS/Windows */ /* * Send the tmpfile into sendmail. */ _statusline(SENDING_YOUR_MSG); #if CAN_PIPE_TO_MAILER signal(SIGINT, SIG_IGN); if ((fp = LYPipeToMailer()) == 0) { HTInfoMsg(CANCELLED); } #else if ((fp = LYOpenTemp(tmpfile2, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); } #endif /* CAN_PIPE_TO_MAILER */ if (fp != 0) { fd = fopen(my_tmpfile, TXT_R); if (fd == NULL) { HTInfoMsg(CANCELLED); #if CAN_PIPE_TO_MAILER pclose(fp); #else LYCloseTempFP(fp); #endif /* CAN_PIPE_TO_MAILER */ } else { #if USE_BLAT_MAILER if (!mail_is_blat) fputs(header, fp); #else fputs(header, fp); #endif while ((n = fread(buf, 1, sizeof(buf), fd)) != 0) { fwrite(buf, 1, n, fp); } #if CAN_PIPE_TO_MAILER pclose(fp); #else LYCloseTempFP(fp); /* Close the tmpfile. */ LYSendMailFile ( to_address, tmpfile2, the_subject, ccaddr, SENDING_COMMENT); LYRemoveTemp(tmpfile2); /* Delete the tmpfile. */ #endif /* CAN_PIPE_TO_MAILER */ LYCloseInput(fd); /* Close the tmpfile. */ } } #endif /* USE_VMS_MAILER */ goto cleanup; /* * Come here to cleanup and exit. */ cancelled: HTInfoMsg(CANCELLED); LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(LYwin,FALSE); /* Stop scrolling. */ cleanup: signal(SIGINT, cleanup_sig); term_letter = FALSE; #if USE_VMS_MAILER while (LYRemoveTemp(my_tmpfile) == 0) ; /* Delete the tmpfile(s). */ if (isPMDF) { LYRemoveTemp(hdrfile); /* Delete the hdrfile. */ } #else FREE(header); LYRemoveTemp(my_tmpfile); /* Delete the tmpfile. */ #endif /* VMS */ FREE(from_address); FREE(the_subject); FREE(cc_address); FREE(to_address); FREE(ccaddr); FREE(keywords); FREE(body); return; }
/* * LYdownload_options writes out the current download choices to a file so that * the user can select downloaders in the same way that they select all other * links. Download links look like: * LYNXDOWNLOAD://Method=<#>/File=<STRING>/SugFile=<STRING> */ int LYdownload_options(char **newfile, char *data_file) { static char tempfile[LY_MAXPATH] = "\0"; char *downloaded_url = NULL; char *sug_filename = NULL; FILE *fp0; lynx_list_item_type *cur_download; int count; /* * Get a suggested filename. */ StrAllocCopy(sug_filename, *newfile); change_sug_filename(sug_filename); if ((fp0 = InternalPageFP(tempfile, TRUE)) == 0) return (-1); StrAllocCopy(downloaded_url, *newfile); LYLocalFileToURL(newfile, tempfile); LYStrNCpy(LYValidDownloadFile, data_file, (sizeof(LYValidDownloadFile) - 1)); LYforce_no_cache = TRUE; /* don't cache this doc */ BeginInternalPage(fp0, DOWNLOAD_OPTIONS_TITLE, DOWNLOAD_OPTIONS_HELP); fprintf(fp0, "<pre>\n"); fprintf(fp0, "<em>%s</em> %s\n", gettext("Downloaded link:"), downloaded_url); FREE(downloaded_url); fprintf(fp0, "<em>%s</em> %s\n", gettext("Suggested file name:"), sug_filename); fprintf(fp0, "\n%s\n", (user_mode == NOVICE_MODE) ? gettext("Standard download options:") : gettext("Download options:")); if (!no_disk_save) { #if defined(DIRED_SUPPORT) /* * Disable save to disk option for local files. */ if (!lynx_edit_mode) #endif /* DIRED_SUPPORT */ { fprintf(fp0, " <a href=\"%s//Method=-1/File=%s/SugFile=%s%s\">%s</a>\n", STR_LYNXDOWNLOAD, data_file, NonNull(lynx_save_space), sug_filename, gettext("Save to disk")); /* * If it is not a binary file, offer the opportunity to view the * downloaded temporary file (see HTSaveToFile). */ if (SuffixIs(data_file, HTML_SUFFIX) || SuffixIs(data_file, TEXT_SUFFIX)) { char *target = NULL; char *source = LYAddPathToSave(data_file); LYLocalFileToURL(&target, source); fprintf(fp0, " <a href=\"%s\">%s</a>\n", target, gettext("View temporary file")); FREE(source); FREE(target); } } } else { fprintf(fp0, " <em>%s</em>\n", gettext("Save to disk disabled.")); } if (user_mode == NOVICE_MODE) fprintf(fp0, "\n%s\n", gettext("Local additions:")); if (downloaders != NULL) { for (count = 0, cur_download = downloaders; cur_download != NULL; cur_download = cur_download->next, count++) { if (!no_download || cur_download->always_enabled) { fprintf(fp0, " <a href=\"%s//Method=%d/File=%s/SugFile=%s\">", STR_LYNXDOWNLOAD, count, data_file, sug_filename); fprintf(fp0, "%s", (cur_download->name ? cur_download->name : gettext("No Name Given"))); fprintf(fp0, "</a>\n"); } } } fprintf(fp0, "</pre>\n"); EndInternalPage(fp0); LYCloseTempFP(fp0); LYRegisterUIPage(*newfile, UIP_DOWNLOAD_OPTIONS); /* * Free off temp copy. */ FREE(sug_filename); return (0); }
/* * This procedure outputs the Visited Links list into a temporary file. - FM * Returns links's number to make active (1-based), or 0 if not required. */ int LYShowVisitedLinks(char **newfile) { static char tempfile[LY_MAXPATH] = "\0"; char *Title = NULL; char *Address = NULL; int x, tot; FILE *fp0; VisitedLink *vl; HTList *cur = Visited_Links; int offset; int ret = 0; const char *arrow, *post_arrow; if (!cur) return (-1); if ((fp0 = InternalPageFP(tempfile, TRUE)) == 0) return (-1); LYLocalFileToURL(newfile, tempfile); LYRegisterUIPage(*newfile, UIP_VLINKS); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ BeginInternalPage(fp0, VISITED_LINKS_TITLE, VISITED_LINKS_HELP); #ifndef NO_OPTION_FORMS fprintf(fp0, "<form action=\"%s\" method=\"post\">\n", STR_LYNXOPTIONS); LYMenuVisitedLinks(fp0, FALSE); fprintf(fp0, "<input type=\"submit\" value=\"Accept Changes\">\n"); fprintf(fp0, "</form>\n"); fprintf(fp0, "<P>\n"); #endif fprintf(fp0, "<pre>\n"); fprintf(fp0, "<em>%s</em>\n", gettext("You visited (POSTs, bookmark, menu and list files excluded):")); if (Visited_Links_As & VISITED_LINKS_REVERSE) tot = x = HTList_count(Visited_Links); else tot = x = -1; if (Visited_Links_As & VISITED_LINKS_AS_TREE) { vl = First_tree; } else if (Visited_Links_As & VISITED_LINKS_AS_LATEST) { if (Visited_Links_As & VISITED_LINKS_REVERSE) vl = Latest_last.prev_latest; else vl = Latest_first.next_latest; if (vl == &Latest_last || vl == &Latest_first) vl = NULL; } else { if (Visited_Links_As & VISITED_LINKS_REVERSE) vl = Last_by_first; else vl = (VisitedLink *) HTList_nextObject(cur); } while (NULL != vl) { /* * The number of the document (most recent highest), its title in a * link, and its address. - FM */ post_arrow = arrow = ""; if (Visited_Links_As & VISITED_LINKS_REVERSE) x--; else x++; if (vl == PrevActiveVisitedLink) { if (Visited_Links_As & VISITED_LINKS_REVERSE) ret = tot - x + 2; else ret = x + 3; } if (vl == PrevActiveVisitedLink) { post_arrow = "<A NAME=current></A>"; /* Otherwise levels 0 and 1 look the same when with arrow: */ arrow = (vl->level && (Visited_Links_As & VISITED_LINKS_AS_TREE)) ? "==>" : "=>"; StrAllocCat(*newfile, "#current"); } if (Visited_Links_As & VISITED_LINKS_AS_TREE) { offset = 2 * vl->level; if (offset > 24) offset = (offset + 24) / 2; if (offset > LYcols * 3 / 4) offset = LYcols * 3 / 4; } else offset = (x > 99 ? 0 : x < 10 ? 2 : 1); if (non_empty(vl->title)) { StrAllocCopy(Title, vl->title); LYEntify(&Title, TRUE); LYTrimLeading(Title); LYTrimTrailing(Title); if (*Title == '\0') StrAllocCopy(Title, NO_TITLE); } else { StrAllocCopy(Title, NO_TITLE); } if (non_empty(vl->address)) { StrAllocCopy(Address, vl->address); LYEntify(&Address, FALSE); fprintf(fp0, "%-*s%s<em>%d</em>. <tab id=t%d><a href=\"%s\">%s</a>\n", offset, arrow, post_arrow, x, x, Address, Title); } else { fprintf(fp0, "%-*s%s<em>%d</em>. <tab id=t%d><em>%s</em>\n", offset, arrow, post_arrow, x, x, Title); } if (Address != NULL) { StrAllocCopy(Address, vl->address); LYEntify(&Address, TRUE); } fprintf(fp0, "<tab to=t%d>%s\n", x, ((Address != NULL) ? Address : gettext("(no address)"))); if (Visited_Links_As & VISITED_LINKS_AS_TREE) vl = vl->next_tree; else if (Visited_Links_As & VISITED_LINKS_AS_LATEST) { if (Visited_Links_As & VISITED_LINKS_REVERSE) vl = vl->prev_latest; else vl = vl->next_latest; if (vl == &Latest_last || vl == &Latest_first) vl = NULL; } else { if (Visited_Links_As & VISITED_LINKS_REVERSE) vl = vl->prev_first; else vl = (VisitedLink *) HTList_nextObject(cur); } } fprintf(fp0, "</pre>\n"); EndInternalPage(fp0); LYCloseTempFP(fp0); FREE(Title); FREE(Address); return (ret); }
/* * This procedure outputs the history buffer into a temporary file. */ int showhistory(char **newfile) { static char tempfile[LY_MAXPATH] = "\0"; char *Title = NULL; int x = 0; FILE *fp0; if ((fp0 = InternalPageFP(tempfile, TRUE)) == 0) return (-1); LYLocalFileToURL(newfile, tempfile); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ BeginInternalPage(fp0, HISTORY_PAGE_TITLE, HISTORY_PAGE_HELP); fprintf(fp0, "<p align=right> <a href=\"%s\">[%s]</a>\n", STR_LYNXMESSAGES, STATUSLINES_TITLE); fprintf(fp0, "<pre>\n"); fprintf(fp0, "<em>%s</em>\n", gettext("You selected:")); for (x = nhist + nhist_extra - 1; x >= 0; x--) { /* * The number of the document in the hist stack, its title in a link, * and its address. - FM */ if (HDOC(x).title != NULL) { StrAllocCopy(Title, HDOC(x).title); LYEntify(&Title, TRUE); LYTrimLeading(Title); LYTrimTrailing(Title); if (*Title == '\0') StrAllocCopy(Title, NO_TITLE); } else { StrAllocCopy(Title, NO_TITLE); } fprintf(fp0, "%s<em>%d</em>. <tab id=t%d><a href=\"%s%d\">%s</a>\n", (x > 99 ? "" : x < 10 ? " " : " "), x, x, STR_LYNXHIST, x, Title); if (HDOC(x).address != NULL) { StrAllocCopy(Title, HDOC(x).address); LYEntify(&Title, TRUE); } else { StrAllocCopy(Title, gettext("(no address)")); } if (HDOC(x).internal_link) { if (history[x].intern_seq_start == history[nhist - 1].intern_seq_start) StrAllocCat(Title, gettext(" (internal)")); else StrAllocCat(Title, gettext(" (was internal)")); } fprintf(fp0, "<tab to=t%d>%s\n", x, Title); } fprintf(fp0, "</pre>\n"); EndInternalPage(fp0); LYCloseTempFP(fp0); FREE(Title); return (0); }
/* * This function is called from HTLoadNews() to have the user * create a file with news headers and a body for posting of * a new message (based on a newspost://nntp_host/newsgroups * or snewspost://secure_nntp_host/newsgroups URL), or to post * a followup (based on a newsreply://nntp_host/newsgroups or * snewsreply://secure_nntp_host/newsgroups URL). The group * or comma-separated list of newsgroups is passed without * a lead slash, and followup is TRUE for newsreply or * snewsreply URLs. - FM */ char *LYNewsPost(char *newsgroups, BOOLEAN followup) { char user_input[MAX_LINE]; char CJKinput[MAX_LINE]; char *cp = NULL; const char *kp = NULL; int c = 0; /* user input */ int len; FILE *fd = NULL; char my_tempfile[LY_MAXPATH]; FILE *fc = NULL; char CJKfile[LY_MAXPATH]; char *postfile = NULL; char *NewsGroups = NULL; char *References = NULL; char *org = NULL; FILE *fp = NULL; BOOLEAN nonempty = FALSE; BOOLEAN nonspaces = FALSE; /* * Make sure a non-zero length newspost, newsreply, snewspost or snewsreply * path was sent to us. - FM */ if (isEmpty(newsgroups)) return (postfile); /* * Return immediately if we do get called, maybe by some quirk of HTNews.c, * when we shouldn't. - kw */ if (no_newspost) return (postfile); /* * Open a temporary file for the headers and message body. - FM */ #ifdef __DJGPP__ if ((fd = LYOpenTemp(my_tempfile, HTML_SUFFIX, BIN_W)) == NULL) #else if ((fd = LYOpenTemp(my_tempfile, HTML_SUFFIX, "w")) == NULL) #endif /* __DJGPP__ */ { HTAlert(CANNOT_OPEN_TEMP); return (postfile); } /* * If we're using a Japanese display character set, open a temporary file * for a conversion to JIS. - FM */ CJKfile[0] = '\0'; if (current_char_set == UCGetLYhndl_byMIME("euc-jp") || current_char_set == UCGetLYhndl_byMIME("shift_jis")) { if ((fc = LYOpenTemp(CJKfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(CANNOT_OPEN_TEMP); LYRemoveTemp(my_tempfile); return (postfile); } } /* * The newsgroups could be a comma-seperated list. It need not have * spaces, but deal with any that may also have been hex escaped. - FM */ StrAllocCopy(NewsGroups, newsgroups); if ((cp = strstr(NewsGroups, ";ref="))) { *cp = '\0'; cp += 5; if (*cp == '<') { StrAllocCopy(References, cp); } else { StrAllocCopy(References, "<"); StrAllocCat(References, cp); StrAllocCat(References, ">"); } HTUnEscape(References); if (!((cp = strchr(References, '@')) && cp > References + 1 && isalnum(UCH(cp[1])))) { FREE(References); } } HTUnEscape(NewsGroups); if (!*NewsGroups) { LYCloseTempFP(fd); /* Close the temp file. */ goto cleanup; } /* * Allow ^C to cancel the posting, i.e., don't let SIGINTs exit Lynx. */ signal(SIGINT, terminate_message); term_message = FALSE; /* * Show the list of newsgroups. - FM */ LYclear(); LYmove(2, 0); scrollok(LYwin, TRUE); /* Enable scrolling. */ LYaddstr(gettext("You will be posting to:")); LYaddstr("\n\t"); LYaddstr(NewsGroups); LYaddch('\n'); /* * Get the mail address for the From header, offering personal_mail_address * as default. */ LYaddstr(gettext("\n\n Please provide your mail address for the From: header\n")); sprintf(user_input, "From: %.*s", (int) sizeof(user_input) - 8, NonNull(personal_mail_address)); if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { HTInfoMsg(NEWS_POST_CANCELLED); LYCloseTempFP(fd); /* Close the temp file. */ scrollok(LYwin, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd, "%s\n", user_input); /* * Get the Subject header, offering the current document's title as the * default if this is a followup rather than a new post. - FM */ LYaddstr(gettext("\n\n Please provide or edit the Subject: header\n")); strcpy(user_input, "Subject: "); if ((followup == TRUE && nhist > 0) && (kp = HText_getTitle()) != NULL) { /* * Add the default subject. */ kp = LYSkipCBlanks(kp); #ifdef CJK_EX /* 1998/05/15 (Fri) 09:10:38 */ if (HTCJK == JAPANESE) { CJKinput[0] = '\0'; switch (kanji_code) { case EUC: TO_EUC((const unsigned char *) kp, (unsigned char *) CJKinput); kp = CJKinput; break; case SJIS: TO_SJIS((const unsigned char *) kp, (unsigned char *) CJKinput); kp = CJKinput; break; default: break; } } #endif if (strncasecomp(kp, "Re:", 3)) { strcat(user_input, "Re: "); } len = (int) strlen(user_input); LYstrncpy(user_input + len, kp, (int) sizeof(user_input) - len - 1); } cp = NULL; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { HTInfoMsg(NEWS_POST_CANCELLED); LYCloseTempFP(fd); /* Close the temp file. */ scrollok(LYwin, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd, "%s\n", user_input); /* * Add Organization: header. */ StrAllocCopy(cp, "Organization: "); if ((org = LYGetEnv("ORGANIZATION")) != NULL) { StrAllocCat(cp, org); } else if ((org = LYGetEnv("NEWS_ORGANIZATION")) != NULL) { StrAllocCat(cp, org); } #ifdef UNIX else if ((fp = fopen("/etc/organization", TXT_R)) != NULL) { char *buffer = 0; if (LYSafeGets(&buffer, fp) != NULL) { if (user_input[0] != '\0') { LYTrimNewline(buffer); StrAllocCat(cp, buffer); } } FREE(buffer); LYCloseInput(fp); } #else #ifdef _WINDOWS /* 1998/05/14 (Thu) 17:47:01 */ else { char *p, fname[LY_MAXPATH]; strcpy(fname, LynxSigFile); p = strrchr(fname, '/'); if (p != 0 && (p - fname) < sizeof(fname) - 15) { strcpy(p + 1, "LYNX_ETC.TXT"); if ((fp = fopen(fname, TXT_R)) != NULL) { if (fgets(user_input, sizeof(user_input), fp) != NULL) { if ((org = strchr(user_input, '\n')) != NULL) { *org = '\0'; } if (user_input[0] != '\0') { StrAllocCat(cp, user_input); } } LYCloseInput(fp); } } } #endif /* _WINDOWS */ #endif /* !UNIX */ LYstrncpy(user_input, cp, (sizeof(user_input) - 16)); FREE(cp); LYaddstr(gettext("\n\n Please provide or edit the Organization: header\n")); if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { HTInfoMsg(NEWS_POST_CANCELLED); LYCloseTempFP(fd); /* Close the temp file. */ scrollok(LYwin, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd, "%s\n", user_input); if (References) { fprintf(fd, "References: %s\n", References); } /* * Add Newsgroups Summary and Keywords headers. */ fprintf(fd, "Newsgroups: %s\nSummary: \nKeywords: \n\n", NewsGroups); /* * Have the user create the message body. */ if (!no_editor && non_empty(editor)) { if (followup && nhist > 0) { /* * Ask if the user wants to include the original message. */ if (term_message) { _statusline(INC_ORIG_MSG_PROMPT); } else if (HTConfirm(INC_ORIG_MSG_PROMPT) == YES) { /* * The 'TRUE' will add the reply ">" in front of every line. * We're assuming that if the display character set is Japanese * and the document did not have a CJK charset, any non-EUC or * non-SJIS 8-bit characters in it where converted to 7-bit * equivalents. - FM */ print_wwwfile_to_fd(fd, FALSE, TRUE); } } LYCloseTempFP(fd); /* Close the temp file. */ scrollok(LYwin, FALSE); /* Stop scrolling. */ if (term_message || LYCharIsINTERRUPT(c)) goto cleanup; /* * Spawn the user's editor on the news file. */ edit_temporary_file(my_tempfile, "", SPAWNING_EDITOR_FOR_NEWS); nonempty = message_has_content(my_tempfile, &nonspaces); } else { /* * Use the built in line editior. */ LYaddstr(gettext("\n\n Please enter your message below.")); LYaddstr(gettext("\n When you are done, press enter and put a single period (.)")); LYaddstr(gettext("\n on a line and press enter again.")); LYaddstr("\n\n"); LYrefresh(); *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { HTInfoMsg(NEWS_POST_CANCELLED); LYCloseTempFP(fd); /* Close the temp file. */ scrollok(LYwin, FALSE); /* Stop scrolling. */ goto cleanup; } while (!STREQ(user_input, ".") && !term_message) { LYaddch('\n'); fprintf(fd, "%s\n", user_input); if (!nonempty && strlen(user_input)) nonempty = TRUE; *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0) { HTInfoMsg(NEWS_POST_CANCELLED); LYCloseTempFP(fd); /* Close the temp file. */ scrollok(LYwin, FALSE); /* Stop scrolling. */ goto cleanup; } } fprintf(fd, "\n"); LYCloseTempFP(fd); /* Close the temp file. */ scrollok(LYwin, FALSE); /* Stop scrolling. */ } if (nonempty) { /* * Confirm whether to post, and if so, whether to append the sig file. * - FM */ LYStatusLine = (LYlines - 1); c = HTConfirm(POST_MSG_PROMPT); LYStatusLine = -1; if (c != YES) { LYclear(); /* clear the screen */ goto cleanup; } } else { HTAlert(gettext("Message has no original text!")); if (!nonspaces || HTConfirmDefault(POST_MSG_PROMPT, NO) != YES) goto cleanup; } if ((LynxSigFile != NULL) && (fp = fopen(LynxSigFile, TXT_R)) != NULL) { char *msg = NULL; HTSprintf0(&msg, APPEND_SIG_FILE, LynxSigFile); LYStatusLine = (LYlines - 1); if (term_message) { _user_message(APPEND_SIG_FILE, LynxSigFile); } else if (HTConfirm(msg) == YES) { if ((fd = LYAppendToTxtFile(my_tempfile)) != NULL) { char *buffer = NULL; fputs("-- \n", fd); while (LYSafeGets(&buffer, fp) != NULL) { fputs(buffer, fd); } LYCloseOutput(fd); } } LYCloseInput(fp); FREE(msg); LYStatusLine = -1; } LYclear(); /* clear the screen */ /* * If we are using a Japanese display character set, convert the contents * of the temp file to JIS (nothing should change if it does not, in fact, * contain EUC or SJIS di-bytes). Otherwise, use the temp file as is. - * FM */ if (CJKfile[0] != '\0') { if ((fd = fopen(my_tempfile, TXT_R)) != NULL) { char *buffer = NULL; while (LYSafeGets(&buffer, fd) != NULL) { TO_JIS((unsigned char *) buffer, (unsigned char *) CJKinput); fputs(CJKinput, fc); } LYCloseTempFP(fc); StrAllocCopy(postfile, CJKfile); LYCloseInput(fd); LYRemoveTemp(my_tempfile); strcpy(my_tempfile, CJKfile); CJKfile[0] = '\0'; } else { StrAllocCopy(postfile, my_tempfile); } } else { StrAllocCopy(postfile, my_tempfile); } if (!followup) { /* * If it's not a followup, the current document most likely is the * group listing, so force a to have the article show up in the list * after the posting. Note, that if it's a followup via a link in a * news article, the user must do a reload manually on returning to the * group listing. - FM */ LYforce_no_cache = TRUE; } LYStatusLine = (LYlines - 1); HTUserMsg(POSTING_TO_NEWS); LYStatusLine = -1; /* * Come here to cleanup and exit. */ cleanup: #ifndef VMS signal(SIGINT, cleanup_sig); #endif /* !VMS */ term_message = FALSE; if (!postfile) LYRemoveTemp(my_tempfile); LYRemoveTemp(CJKfile); FREE(NewsGroups); FREE(References); return (postfile); }
void HTFWriter_free( HTStream *me ) { int len; char *path = 0; char *addr = 0; int status; BOOLEAN use_zread = 0; BOOLEAN found = 0; if ( me->fp ) fflush( &me->fp ); if ( me->end_command ) { LYCloseTempFP( &me->fp ); if ( me->input_format == HTAtom_for( "www/compressed" ) ) { if ( me->anchor->FileCache ) { BOOLEAN skip_loadfile = me->viewer_command != 0; HTSACopy( &path, &me->anchor->FileCache ); len = strlen( path ); if ( len > 3 && ( strcasecomp( &path[ len + -2 ], "gz" ) == 0 || strcasecomp( &path[ len + -2 ], "zz" ) == 0 ) ) { if ( skip_loadfile == 0 ) use_zread = 1; else { path[ len + -3 ] = 0; remove( path ); } } else if ( len > 4 && strcasecomp( &path[ len + -3 ], "bz2" ) == 0 ) { path[ len + -4 ] = 0; remove( path ); } else if ( len > 2 && strcasecomp( &path[ len + -1 ], "Z" ) == 0 ) { path[ len + -2 ] = 0; remove( path ); } if ( use_zread == 0 ) { if ( dump_output_immediately == 0 ) { mustshow = 1; HTProgress( &me->end_command ); } if ( me->end_command && me->end_command[0] ) LYSystem( &me->end_command ); found = LYCanReadFile( &me->anchor->FileCache ); } if ( found ) { if ( dump_output_immediately == 0 ) { lynx_force_repaint( ); LYrefresh( ); } HTAlert( gettext( "Error uncompressing temporary file!" ) ); LYRemoveTemp( &me->anchor->FileCache ); if ( me->anchor->FileCache ) { free( &me->anchor->FileCache ); me->anchor->FileCache = 0; } } else { LYLocalFileToURL( &addr, path ); if ( use_zread == 0 ) { LYRenamedTemp( &me->anchor->FileCache, path ); HTSACopy( &me->anchor->FileCache, path ); HTSACopy( &me->anchor->content_encoding, "binary" ); } if ( path ) { free( path ); path = 0; } if ( skip_loadfile == 0 ) { if ( HTAnchor_getUCLYhndl( &me->anchor, 1 ) < 0 ) HTAnchor_copyUCInfoStage( &me->anchor, 1, 0, 2 ); HTAnchor_copyUCInfoStage( &me->anchor, 1, 0, -1 ); } if ( dump_output_immediately == 0 ) { LYstore_message2( gettext( "Using %s" ), addr ); } if ( skip_loadfile ) { if ( me->end_command ) { free( &me->end_command ); *(int*)&me->end_command = 0; } HTAddParam( &me->end_command, &me->viewer_command, 1, &me->anchor->FileCache ); HTEndParam( &me->end_command, &me->viewer_command, 1 ); if ( dump_output_immediately == 0 ) { HTProgress( &me->end_command ); stop_curses( ); } LYSystem( &me->end_command ); if ( me->remove_command && me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } if ( dump_output_immediately == 0 ) start_curses( ); } else { status = HTLoadFile( addr, &me->anchor, &me->output_format, &me->sink ); } if ( dump_output_immediately && me->output_format == HTAtom_for( "www/present" ) ) { if ( addr ) { free( addr ); addr = 0; } remove( &me->anchor->FileCache ); if ( me->anchor->FileCache ) { free( &me->anchor->FileCache ); me->anchor->FileCache = 0; } if ( me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } if ( me->end_command ) { free( &me->end_command ); *(int*)&me->end_command = 0; } if ( me->viewer_command ) { free( &me->viewer_command ); *(int*)&me->viewer_command = 0; } if ( me == 0 ) { return; } free( me ); me = 0; return; } } if ( addr ) { free( addr ); addr = 0; } } if ( me->remove_command && me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } } else { if ( strcmp( &me->end_command, "SaveToFile" ) ) { if ( dump_output_immediately == 0 ) { mustshow = 1; HTProgress( &me->end_command ); stop_curses( ); } LYSystem( &me->end_command ); if ( me->remove_command && me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } if ( dump_output_immediately == 0 ) start_curses( ); } else { if ( me->remove_command && me->remove_command ) { free( &me->remove_command ); *(int*)&me->remove_command = 0; } if ( dump_output_immediately == 0 ) start_curses( ); } } if ( me->end_command ) { free( &me->end_command ); *(int*)&me->end_command = 0; } } if ( me->viewer_command ) { free( &me->viewer_command ); *(int*)&me->viewer_command = 0; } if ( dump_output_immediately ) { if ( me->anchor->FileCache ) remove( &me->anchor->FileCache ); if ( me ) { free( me ); me = 0; } if ( persistent_cookies ) LYStoreCookies( LYCookieSaveFile ); exit_immediately( 0 ); } if ( me == 0 ) { return; } free( me ); me = 0; return; }
static void send_file_to_printer(DocInfo *newdoc, char *content_base, char *sug_filename, int printer_number) { BOOLEAN FirstRecall = TRUE; FILE *outfile_fp; char *the_command = 0; bstring *my_file = NULL; char my_temp[LY_MAXPATH]; int FnameTotal, FnameNum = -1; lynx_list_item_type *cur_printer; outfile_fp = LYOpenTemp(my_temp, (HTisDocumentSource()) ? HTML_SUFFIX : TEXT_SUFFIX, "w"); if (outfile_fp == NULL) { CannotPrint(FILE_ALLOC_FAILED); } if (LYPrependBaseToSource && HTisDocumentSource()) { /* * Added the document's base as a BASE tag to the top of the file. 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, FALSE, FALSE); /* PRINTER */ if (keypad_mode) printlist(outfile_fp, FALSE); LYCloseTempFP(outfile_fp); /* find the right printer number */ { int count = 0; for (cur_printer = printers; count < printer_number; count++, cur_printer = cur_printer->next) ; /* null body */ } /* * Commands have the form "command %s [%s] [etc]" where %s is the filename * and the second optional %s is the suggested filename. */ if (cur_printer->command == NULL) { CannotPrint(PRINTER_MISCONF_ERROR); } /* * Check for two '%s' and ask for the second filename argument if there * is. */ BStrCopy0(my_file, ""); if (HTCountCommandArgs(cur_printer->command) >= 2) { _statusline(FILENAME_PROMPT); again: SetupFilename(&my_file, sug_filename); check_again: switch (RecallFilename(&my_file, &FirstRecall, &FnameNum, &FnameTotal, PRINT_FLAG)) { case FN_INIT: goto again; case FN_READ: goto check_again; case FN_QUIT: goto done; default: break; } if (no_dotfiles || !show_dotfiles) { if (*LYPathLeaf(my_file->str) == '.') { HTAlert(FILENAME_CANNOT_BE_DOT); _statusline(NEW_FILENAME_PROMPT); FirstRecall = TRUE; FnameNum = FnameTotal; goto again; } } /* * Cancel if the user entered "/dev/null" on Unix, or an "nl:" path * on VMS. - FM */ if (LYIsNullDevice(my_file->str)) { CancelPrint(PRINT_REQUEST_CANCELLED); } HTAddSugFilename(my_file->str); } #ifdef SH_EX /* 1999/01/04 (Mon) 09:37:03 */ HTAddParam(&the_command, cur_printer->command, 1, my_temp); if (!isBEmpty(my_file)) { HTAddParam(&the_command, cur_printer->command, 2, my_file->str); HTEndParam(&the_command, cur_printer->command, 3); } else { HTEndParam(&the_command, cur_printer->command, 2); } #else HTAddParam(&the_command, cur_printer->command, 1, my_temp); HTAddParam(&the_command, cur_printer->command, 2, my_file->str); HTEndParam(&the_command, cur_printer->command, 2); #endif /* * Move the cursor to the top of the screen so that output from system'd * commands don't scroll up the screen. */ LYmove(1, 1); stop_curses(); CTRACE((tfp, "command: %s\n", the_command)); SetOutputMode(O_TEXT); printf(PRINTING_FILE); /* * Set various bits of document information as environment variables, for * use by external print scripts/etc. On UNIX, We assume there are values, * and leave NULL value checking up to the external PRINTER: cmd/script - * KED */ SET_ENVIRON(LYNX_PRINT_TITLE, HText_getTitle(), "No Title"); SET_ENVIRON(LYNX_PRINT_URL, newdoc->address, "No URL"); SET_ENVIRON(LYNX_PRINT_DATE, HText_getDate(), "No Date"); SET_ENVIRON(LYNX_PRINT_LASTMOD, HText_getLastModified(), "No LastMod"); LYSystem(the_command); FREE(the_command); (void) LYRemoveTemp(my_temp); /* * Remove the various LYNX_PRINT_xxxx logicals. - KED * [could use unsetenv(), but it's not portable] */ SET_ENVIRON(LYNX_PRINT_TITLE, "", ""); SET_ENVIRON(LYNX_PRINT_URL, "", ""); SET_ENVIRON(LYNX_PRINT_DATE, "", ""); SET_ENVIRON(LYNX_PRINT_LASTMOD, "", ""); fflush(stdout); #ifndef VMS signal(SIGINT, cleanup_sig); #endif /* !VMS */ #ifdef SH_EX fprintf(stdout, gettext(" Print job complete.\n")); fflush(stdout); #endif SetOutputMode(O_BINARY); LYSleepMsg(); start_curses(); done: /* send_file_to_printer() */ BStrFree(my_file); return; }
static void send_file_to_mail(DocInfo *newdoc, char *content_base, char *content_location) { static BOOLEAN first_mail_preparsed = TRUE; #if USE_VMS_MAILER BOOLEAN isPMDF = LYMailPMDF(); FILE *hfd; char hdrfile[LY_MAXPATH]; #endif BOOL use_mime; #if !CAN_PIPE_TO_MAILER char my_temp[LY_MAXPATH]; #endif BOOL use_cte; BOOL use_type; const char *disp_charset; FILE *outfile_fp; char *buffer = NULL; char *subject = NULL; bstring *user_response = NULL; if (!LYSystemMail()) return; if (LYPreparsedSource && first_mail_preparsed && HTisDocumentSource()) { if (HTConfirmDefault(CONFIRM_MAIL_SOURCE_PREPARSED, NO) == YES) { LYaddstr(" Ok..."); first_mail_preparsed = FALSE; } else { CancelPrint(MAIL_REQUEST_CANCELLED); } } _statusline(MAIL_ADDRESS_PROMPT); BStrCopy0(user_response, NonNull(personal_mail_address)); if (LYgetBString(&user_response, FALSE, 0, RECALL_MAIL) < 0 || isBEmpty(user_response)) { 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; #if USE_VMS_MAILER use_cte = FALSE; #endif } #if USE_VMS_MAILER use_type = (BOOL) (disp_charset || HTisDocumentSource()); #endif /* * 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); } #if USE_VMS_MAILER if (StrChr(user_response->str, '@') && !StrChr(user_response->str, ':') && !StrChr(user_response->str, '%') && !StrChr(user_response->str, '"')) { char *temp = 0; HTSprintf0(&temp, mail_adrs, user_response->str); BStrCopy0(user_response, temp); FREE(temp); } outfile_fp = LYOpenTemp(my_temp, (HTisDocumentSource()) ? HTML_SUFFIX : TEXT_SUFFIX, "w"); if (outfile_fp == NULL) { CannotPrint(UNABLE_TO_OPEN_TEMPFILE); } if (isPMDF) { if ((hfd = LYOpenTemp(hdrfile, TEXT_SUFFIX, "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); /* * For PMDF, put the subject in the header file and close it. - FM */ fprintf(hfd, "Subject: %.70s\n\n", subject); LYCloseTempFP(hfd); } /* * 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, TRUE, FALSE); /* MAIL */ if (keypad_mode) printlist(outfile_fp, FALSE); LYCloseTempFP(outfile_fp); buffer = NULL; if (isPMDF) { /* * Now set up the command. - FM */ HTSprintf0(&buffer, "%s %s %s,%s %s", system_mail, system_mail_flags, hdrfile, my_temp, user_response->str); } 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->str); } stop_curses(); SetOutputMode(O_TEXT); printf(MAILING_FILE); LYSystem(buffer); LYSleepAlert(); start_curses(); SetOutputMode(O_BINARY); if (isPMDF) (void) LYRemoveTemp(hdrfile); (void) LYRemoveTemp(my_temp); #else /* !VMS (Unix or DOS) */ #if CAN_PIPE_TO_MAILER outfile_fp = LYPipeToMailer(); #else outfile_fp = LYOpenTemp(my_temp, TEXT_SUFFIX, "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 = (BOOL) (disp_charset || HTisDocumentSource()); use_mime = (BOOL) (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->str, 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, TRUE, FALSE); /* MAIL */ if (keypad_mode) printlist(outfile_fp, FALSE); #if CAN_PIPE_TO_MAILER pclose(outfile_fp); #else LYCloseOutput(outfile_fp); LYSendMailFile(user_response->str, my_temp, subject, "", ""); (void) LYRemoveTemp(my_temp); /* Delete the tmpfile. */ #endif /* CAN_PIPE_TO_MAILER */ #endif /* USE_VMS_MAILER */ done: /* send_file_to_mail() */ BStrFree(user_response); FREE(buffer); FREE(subject); return; }
/* * print_options writes out the current printer choices to a file * so that the user can select printers in the same way that * they select all other links * printer links look like * * LYNXPRINT://LOCAL_FILE/lines=# print to a local file * LYNXPRINT://TO_SCREEN/lines=# print to the screen * LYNXPRINT://LPANSI/lines=# print to the local terminal * LYNXPRINT://MAIL_FILE/lines=# mail the file * LYNXPRINT://PRINTER/lines=#/number=# print to printer number # */ int print_options(char **newfile, const char *printed_url, int lines_in_file) { static char my_temp[LY_MAXPATH] = "\0"; char *buffer = 0; int count; int pages; FILE *fp0; lynx_list_item_type *cur_printer; if ((fp0 = InternalPageFP(my_temp, TRUE)) == 0) return (-1); LYLocalFileToURL(newfile, my_temp); BeginInternalPage(fp0, PRINT_OPTIONS_TITLE, PRINT_OPTIONS_HELP); fprintf(fp0, "<pre>\n"); /* pages = lines_in_file/66 + 1; */ pages = (lines_in_file + 65) / 66; HTSprintf0(&buffer, " <em>%s</em> %s\n <em>%s</em> %d\n <em>%s</em> %d %s %s\n", gettext("Document:"), printed_url, gettext("Number of lines:"), lines_in_file, gettext("Number of pages:"), pages, (pages > 1 ? gettext("pages") : gettext("page")), gettext("(approximately)")); fputs(buffer, fp0); FREE(buffer); if (no_print || no_disk_save || no_mail) fprintf(fp0, " <em>%s</em>\n", gettext("Some print functions have been disabled!")); fprintf(fp0, "\n%s\n", (user_mode == NOVICE_MODE) ? gettext("Standard print options:") : gettext("Print options:")); if (no_disk_save == FALSE && no_print == FALSE) { fprintf(fp0, " <a href=\"%s//LOCAL_FILE/lines=%d\">%s</a>\n", STR_LYNXPRINT, lines_in_file, gettext("Save to a local file")); } else { fprintf(fp0, " <em>%s</em>\n", gettext("Save to disk disabled")); } if (no_mail == FALSE && local_host_only == FALSE) fprintf(fp0, " <a href=\"%s//MAIL_FILE/lines=%d\">%s</a>\n", STR_LYNXPRINT, lines_in_file, gettext("Mail the file")); #if defined(UNIX) || defined(VMS) fprintf(fp0, " <a href=\"%s//TO_SCREEN/lines=%d\">%s</a>\n", STR_LYNXPRINT, lines_in_file, gettext("Print to the screen")); fprintf(fp0, " <a href=\"%s//LPANSI/lines=%d\">%s</a>\n", STR_LYNXPRINT, lines_in_file, gettext("Print out on a printer attached to your vt100 terminal")); #endif if (user_mode == NOVICE_MODE) fprintf(fp0, "\n%s\n", gettext("Local additions:")); for (count = 0, cur_printer = printers; cur_printer != NULL; cur_printer = cur_printer->next, count++) if (no_print == FALSE || cur_printer->always_enabled) { fprintf(fp0, " <a href=\"%s//PRINTER/number=%d/pagelen=%d/lines=%d\">", STR_LYNXPRINT, count, cur_printer->pagelen, lines_in_file); fprintf(fp0, "%s", (cur_printer->name ? cur_printer->name : "No Name Given")); fprintf(fp0, "</a>\n"); } fprintf(fp0, "</pre>\n"); EndInternalPage(fp0); LYCloseTempFP(fp0); LYforce_no_cache = TRUE; return (0); }
int showlist(DocInfo *newdoc, BOOLEAN titles) { int cnt; int refs, hidden_links; static char tempfile[LY_MAXPATH]; static BOOLEAN last_titles = TRUE; FILE *fp0; char *Address = NULL, *Title = NULL, *cp = NULL; char *LinkTitle = NULL; /* Rel stored as property of link, not of dest */ BOOLEAN intern_w_post = FALSE; const char *desc = "unknown field or link"; void *helper; refs = HText_sourceAnchors(HTMainText); hidden_links = HText_HiddenLinkCount(HTMainText); if (refs <= 0 && hidden_links > 0 && LYHiddenLinks != HIDDENLINKS_SEPARATE) { HTUserMsg(NO_VISIBLE_REFS_FROM_DOC); return (-1); } if (refs <= 0 && hidden_links <= 0) { HTUserMsg(NO_REFS_FROM_DOC); return (-1); } if ((fp0 = InternalPageFP(tempfile, titles == last_titles)) == 0) return (-1); LYLocalFileToURL(&(newdoc->address), tempfile); LYRegisterUIPage(newdoc->address, titles ? UIP_LIST_PAGE : UIP_ADDRLIST_PAGE); last_titles = titles; LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ #ifdef EXP_ADDRLIST_PAGE if (titles != TRUE) BeginInternalPage(fp0, ADDRLIST_PAGE_TITLE, LIST_PAGE_HELP); else #endif BeginInternalPage(fp0, LIST_PAGE_TITLE, LIST_PAGE_HELP); StrAllocCopy(Address, HTLoadedDocumentURL()); LYEntify(&Address, FALSE); fprintf(fp0, "%s%s<p>\n", gettext("References in "), (non_empty(Address) ? Address : gettext("this document:"))); FREE(Address); if (refs > 0) { fprintf(fp0, "<%s compact>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol" : "ul")); if (hidden_links > 0) fprintf(fp0, "<lh><em>%s</em>\n", gettext("Visible links:")); } if (hidden_links > 0) { if (LYHiddenLinks == HIDDENLINKS_IGNORE) hidden_links = 0; } helper = NULL; /* init */ for (cnt = 1; cnt <= refs; cnt++) { HTChildAnchor *child = HText_childNextNumber(cnt, &helper); HTAnchor *dest_intl = NULL; HTAnchor *dest; HTParentAnchor *parent; char *address; const char *title; if (child == 0) { /* * child should not be 0 unless form field numbering is on and cnt * is the number of a form input field. HText_FormDescNumber() * will set desc to a description of what type of input field this * is. We'll list it to ensure that the link numbers on the list * page match the numbering in the original document, but won't * create a forward link to the form. - FM && LE * * Changed to create a fake hidden link, to get the numbering right * in connection with always treating this file as * HIDDENLINKS_MERGE in GridText.c - kw */ if (fields_are_numbered()) { HText_FormDescNumber(cnt, &desc); fprintf(fp0, "<li><a id=%d href=\"#%d\">form field</a> = <em>%s</em>\n", cnt, cnt, desc); } continue; } #ifndef DONT_TRACK_INTERNAL_LINKS dest_intl = HTAnchor_followTypedLink(child, HTInternalLink); #endif dest = dest_intl ? dest_intl : HTAnchor_followLink(child); parent = HTAnchor_parent(dest); if (!intern_w_post && dest_intl && HTMainAnchor && HTMainAnchor->post_data && parent->post_data && BINEQ(HTMainAnchor->post_data, parent->post_data)) { /* * Set flag to note that we had at least one internal link, if the * document from which we are generating the list has associated * POST data; after an extra check that the link destination really * has the same POST data so that we can believe it is an internal * link. */ intern_w_post = TRUE; } address = HTAnchor_address(dest); title = titles ? HTAnchor_title(parent) : NULL; if (dest_intl) { HTSprintf0(&LinkTitle, "(internal)"); } else if (titles && child->type && dest == child->dest && !strncmp(HTAtom_name(child->type), "RelTitle: ", 10)) { HTSprintf0(&LinkTitle, "(%s)", HTAtom_name(child->type) + 10); } else { FREE(LinkTitle); } StrAllocCopy(Address, address); FREE(address); LYEntify(&Address, TRUE); if (non_empty(title)) { LYformTitle(&Title, title); LYEntify(&Title, TRUE); if (*Title) { cp = findPoundSelector(Address); } else { FREE(Title); } } fprintf(fp0, "<li><a href=\"%s\"%s>%s%s%s%s%s</a>\n", Address, dest_intl ? " TYPE=\"internal link\"" : "", NonNull(LinkTitle), ((HTAnchor *) parent != dest) && Title ? "in " : "", (char *) (Title ? Title : Address), (Title && cp) ? " - " : "", (Title && cp) ? (cp + 1) : ""); FREE(Address); FREE(Title); } FREE(LinkTitle); if (hidden_links > 0) { if (refs > 0) fprintf(fp0, "\n</%s>\n\n<p>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol" : "ul")); fprintf(fp0, "<%s compact>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol continue" : "ul")); fprintf(fp0, "<lh><em>%s</em>\n", gettext("Hidden links:")); } for (cnt = 0; cnt < hidden_links; cnt++) { StrAllocCopy(Address, HText_HiddenLinkAt(HTMainText, cnt)); LYEntify(&Address, FALSE); if (isEmpty(Address)) { FREE(Address); continue; } fprintf(fp0, "<li><a href=\"%s\">%s</a>\n", Address, Address); FREE(Address); } fprintf(fp0, "\n</%s>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol" : "ul")); EndInternalPage(fp0); LYCloseTempFP(fp0); /* * Make necessary changes to newdoc before returning to caller. If the * intern_w_post flag is set, we keep the POST data in newdoc that have * been passed in. They should be the same as in the loaded document for * which we generated the list. In that case the file we have written will * be associated with the same POST data when it is loaded after we are * done here, so that following one of the links we have marked as * "internal link" can lead back to the underlying document with the right * address+post_data combination. - kw */ if (intern_w_post) { newdoc->internal_link = TRUE; } else { LYFreePostData(newdoc); newdoc->internal_link = FALSE; } newdoc->isHEAD = FALSE; newdoc->safe = FALSE; return (0); }