/* ** 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; }
/* Telnet or "rlogin" access ** ------------------------- */ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) { char * user = host; char * password = NULL; char * cp; char * hostname; char * port; char command[256]; enum _login_protocol { telnet, rlogin, tn3270 } login_protocol = strcmp(acc_method, "rlogin") == 0 ? rlogin : strcmp(acc_method, "tn3270") == 0 ? tn3270 : telnet; #ifdef VMS extern int DCLsystem PARAMS((char *command)); #define system(a) DCLsystem(a) /* use LYCurses.c routines for spawns */ #endif /* VMS */ /* * Modified to allow for odd chars in a username only if exists. * 05-28-94 Lynx 2-3-1 Garrett Arch Blythe */ /* prevent telnet://hostname;rm -rf * URL's (VERY BAD) * *cp=0; / * terminate at any ;,<,>,`,|,",' or space or return * or tab to prevent security whole */ for(cp = (strchr(host, '@') ? strchr(host, '@') : host); *cp != '\0'; cp++) { if(!isalnum(*cp) && *cp != '_' && *cp != '-' && *cp != ':' && *cp != '.' && *cp != '@') { *cp = '\0'; break; } } hostname = strchr(host, '@'); if (hostname) { *hostname++ = '\0'; /* Split */ } else { hostname = host; user = NULL; /* No user specified */ } port = strchr(hostname, ':'); if (port) *port++ = '\0'; /* Split */ if (!hostname || *hostname == '\0') { CTRACE(tfp, "HTTelnet: No host specified!\n"); return HT_NO_DATA; } if (user) { password = strchr(user, ':'); if (password) { *password++ = '\0'; } } /* If the person is already telnetting etc, forbid hopping */ /* This is a security precaution, for us and remote site */ if (HTSecure) { #ifdef TELNETHOPPER_MAIL sprintf(command, "finger @%s | mail -s \"**telnethopper %s\" [email protected]", HTClientHost, HTClientHost); system(command); #endif printf("\n\nSorry, but the service you have selected is one\n"); printf("to which you have to log in. If you were running www\n"); printf("on your own computer, you would be automatically connected.\n"); printf("For security reasons, this is not allowed when\n"); printf("you log in to this information service remotely.\n\n"); printf("You can manually connect to this service using %s\n", acc_method); printf("to host %s", hostname); if (user) printf(", user name %s", user); if (password) printf(", password %s", password); if (port) printf(", port %s", port); printf(".\n\n"); return HT_NO_DATA; } /* Not all telnet servers get it even if user name is specified ** so we always tell the guy what to log in as */ if (user && login_protocol != rlogin) printf("When you are connected, log in as: %s\n", user); if (password && login_protocol != rlogin) printf(" The password is: %s\n", password); /* * NeXTSTEP is the implied version of the NeXT operating system. * You may need to define this yourself. */ #if defined(NeXT) && defined(NeXTSTEP) && NeXTSTEP<=20100 sprintf(command, "%s%s%s %s %s", TELNET_COMMAND, user ? " -l " : "", user ? user : "", hostname, port ? port : ""); CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ #define TELNET_DONE #endif /* Most unix machines suppport username only with rlogin */ #if defined(unix) || defined(DOSPATH) #ifndef TELNET_DONE if (login_protocol == rlogin) { sprintf(command, "%s %s%s%s", RLOGIN_COMMAND, hostname, user ? " -l " : "", user ? user : ""); } else if (login_protocol == tn3270) { sprintf(command, "%s %s %s", TN3270_COMMAND, hostname, port ? port : ""); } else { /* TELNET */ sprintf(command, "%s %s %s", TELNET_COMMAND, hostname, port ? port : ""); } CTRACE(tfp, "HTTelnet: Normal: Command is: %s\n\n", command); #ifdef __DJGPP__ __djgpp_set_ctrl_c(0); _go32_want_ctrl_break(1); #endif /* __DJGPP__ */ system(command); #ifdef __DJGPP__ __djgpp_set_ctrl_c(1); _go32_want_ctrl_break(0); #endif /* __DJGPP__ */ return HT_NO_DATA; /* Ok - it was done but no data */ #define TELNET_DONE #endif /* !TELNET_DONE */ #endif /* unix */ /* VMS varieties */ #if defined(MULTINET) if (login_protocol == rlogin) { sprintf(command, "RLOGIN%s%s%s%s%s %s", /*lm 930713 */ user ? "/USERNAME=\"" : "", user ? user : "", user ? "\"" : "", port ? "/PORT=" : "", port ? port : "", hostname); } else if (login_protocol == tn3270) { sprintf(command, "TELNET/TN3270 %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); } else { /* TELNET */ sprintf(command, "TELNET %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); } CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ #define TELNET_DONE #endif /* MULTINET */ #if defined(WIN_TCP) { char *cp; if ((cp=getenv("WINTCP_COMMAND_STYLE")) != NULL && 0==strncasecomp(cp, "VMS", 3)) { /* VMS command syntax */ if (login_protocol == rlogin) { sprintf(command, "RLOGIN%s%s%s%s%s %s", /*lm 930713 */ user ? "/USERNAME=\"" : "", user ? user : "", user ? "\"" : "", port ? "/PORT=" : "", port ? port : "", hostname); } else if (login_protocol == tn3270) { sprintf(command, "TELNET/TN3270 %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); } else { /* TELNET */ sprintf(command, "TELNET %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); } } else { /* UNIX command syntax */ if (login_protocol == rlogin) { sprintf(command, "RLOGIN %s%s%s%s%s", hostname, user ? " -l " : "", user ? "\"" : "", user ? user : "", user ? "\"" : ""); } else if (login_protocol == tn3270) { sprintf(command, "TN3270 %s %s", hostname, port ? port : ""); } else { /* TELNET */ sprintf(command, "TELNET %s %s", hostname, port ? port : ""); } } CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } #define TELNET_DONE #endif /* WIN_TCP */ #ifdef UCX if (login_protocol == rlogin) { sprintf(command, "RLOGIN%s%s%s %s %s", user ? "/USERNAME=\"" : "", user ? user : "", user ? "\"" : "", hostname, port ? port : ""); } else if (login_protocol == tn3270) { sprintf(command, "TN3270 %s %s", hostname, port ? port : ""); } else { /* TELNET */ sprintf(command, "TELNET %s %s", hostname, port ? port : ""); } CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ #define TELNET_DONE #endif /* UCX */ #ifdef CMU_TCP if (login_protocol == telnet) { sprintf(command, "TELNET %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); } else { extern int LYgetch NOPARAMS; extern BOOLEAN HadVMSInterrupt; printf( "\nSorry, this browser was compiled without the %s access option.\n", acc_method); printf("\nPress <return> to return to Lynx."); LYgetch(); HadVMSInterrupt = FALSE; } return HT_NO_DATA; /* Ok - it was done but no data */ #define TELNET_DONE #endif /* CMU_TCP */ #ifdef SOCKETSHR_TCP { char *cp; if (getenv("MULTINET_SOCKET_LIBRARY") != NULL) { if (login_protocol == rlogin) { sprintf(command, "MULTINET RLOGIN%s%s%s%s %s", /*lm 930713 */ user ? "/USERNAME="******"", user ? user : "", port ? "/PORT=" : "", port ? port : "", hostname); } else if (login_protocol == tn3270) { sprintf(command, "MULTINET TELNET/TN3270 %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); } else { /* TELNET */ sprintf(command, "MULTINET TELNET %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); } CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } else if ((cp=getenv("WINTCP_COMMAND_STYLE")) != NULL) { if (0==strncasecomp(cp, "VMS", 3)) { /* VMS command syntax */ if (login_protocol == rlogin) { sprintf(command, "RLOGIN%s%s%s%s %s", /*lm 930713 */ user ? "/USERNAME="******"", user ? user : "", port ? "/PORT=" : "", port ? port : "", hostname); } else if (login_protocol == tn3270) { sprintf(command, "TELNET/TN3270 %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); } else { /* TELNET */ sprintf(command, "TELNET %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); } } else { /* UNIX command syntax */ if (login_protocol == rlogin) { sprintf(command, "RLOGIN %s%s%s", hostname, user ? " -l " : "", user ? user : ""); } else if (login_protocol == tn3270) { sprintf(command, "TN3270 %s %s", hostname, port ? port : ""); } else { /* TELNET */ sprintf(command, "TELNET %s %s", hostname, port ? port : ""); } } CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } else if (getenv("UCX$DEVICE") != NULL) { if (login_protocol == rlogin) { sprintf(command, "RLOGIN%s%s %s %s", user ? "/USERNAME="******"", user ? user : "", hostname, port ? port : ""); } else if (login_protocol == tn3270) { sprintf(command, "TN3270 %s %s", hostname, port ? port : ""); } else { /* TELNET */ sprintf(command, "TELNET %s %s", hostname, port ? port : ""); } CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } else if (getenv("CMUTEK_ROOT") != NULL) { if (login_protocol == telnet) { sprintf(command, "TELNET %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); } else { extern int LYgetch NOPARAMS; extern BOOLEAN HadVMSInterrupt; printf( "\nSorry, this browser was compiled without the %s access option.\n", acc_method); printf("\nPress <return> to return to Lynx."); LYgetch(); HadVMSInterrupt = FALSE; } return HT_NO_DATA; /* Ok - it was done but no data */ } else { if (login_protocol == telnet) { sprintf(command, "TELNET %s%s %s", port ? "/PORT=" : "", port ? port : "", hostname); CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); } else { extern int LYgetch NOPARAMS; extern BOOLEAN HadVMSInterrupt; printf( "\nSorry, this browser was compiled without the %s access option.\n", acc_method); printf("\nPress <return> to return to Lynx."); LYgetch(); HadVMSInterrupt = FALSE; } return HT_NO_DATA; /* Ok - it was done but no data */ } } #define TELNET_DONE #endif /* SOCKETSHR_TCP */ #ifdef VM #define SIMPLE_TELNET #endif #ifdef SIMPLE_TELNET if (login_protocol == telnet) { /* telnet only */ sprintf(command, "TELNET %s", /* @@ Bug: port ignored */ hostname); CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } #endif #ifndef TELNET_DONE printf( "\nSorry, this browser was compiled without the %s access option.\n", acc_method); printf( "\nTo access the information you must %s to %s", acc_method, hostname); if (port) printf(" (port %s)", port); if (user) printf("\nlogging in with username %s", user); printf(".\n"); { extern int LYgetch NOPARAMS; printf("\nPress <return> to return to Lynx."); fflush(stdout); LYgetch(); #ifdef VMS { extern BOOLEAN HadVMSInterrupt; HadVMSInterrupt = FALSE; } #endif /* VMS */ } return HT_NO_DATA; #endif /* !TELNET_DONE */ }
PUBLIC int LYNewsPost ARGS1(document *,newdoc) { char *newsgroups = strchr(newdoc->address,':')+1; char user_input[1024]; FILE *fd; char *tmptr; char c; /* user input */ char tmpfile[100]; char cmd[130]; DocAddress WWWDoc; term_message=FALSE; /* pop previous document off of stack and load into main memory */ pop(newdoc); WWWDoc.address = newdoc->address; WWWDoc.post_data = newdoc->post_data; WWWDoc.post_content_type = newdoc->post_content_type; if(!HTLoadAbsolute(&WWWDoc)) return(NOT_FOUND); clear(); move(2,0); tempname(tmpfile,NEW_FILE); if((fd = fopen(tmpfile,"w")) == NULL) { statusline("Unable to open temp file"); sleep(2); return(NORMAL); } addstr("You will be posting to:"); addstr("\n "); addstr(newsgroups); addch('\n'); /* Use ^C to cancel mailing of comment */ /* and don't let sigints exit lynx */ signal(SIGINT, terminate_message); term_message=FALSE; addstr("\n\n Please enter your mail address\n"); strcpy(user_input,"From: "); /* add the mail address if there is one */ if(personal_mail_address) strcat(user_input,personal_mail_address); if (LYgetstr(user_input, VISIBLE) < 0 || term_message) { statusline("News Post Cancelled!!!"); sleep(1); fclose(fd); /* close the temp file */ goto cleanup; } fprintf(fd,"%s\n",user_input); addstr("\n\n Please enter a subject line\n"); strcpy(user_input,"Subject: "); /* add the default subject */ tmptr = newdoc->title; while(isspace(*tmptr)) tmptr++; if(strncasecomp(tmptr, "Re:",3)) strcat(user_input, "Re: "); strcat(user_input, newdoc->title); if (LYgetstr(user_input, VISIBLE) < 0 || term_message) { statusline("News Post Cancelled!!!"); sleep(1); fclose(fd); /* close the temp file */ goto cleanup; } fprintf(fd,"%s\n",user_input); /* add Newsgroups: summary: and Keywords: */ fprintf(fd,"Newsgroups: %s\nSummary: \nKeywords: \n\n",newsgroups); if(!no_editor && editor && *editor != '\0') { /* ask if the user wants to include the original message */ statusline("Do you wish to inlude the original message? (y/n) "); c=0; while((c = toupper(LYgetch())) != 'Y' && c != 'N') ; /* null body */ if(toupper(c) == 'Y') /* the 1 will add the reply ">" in front of every line */ print_wwwfile_to_fd(fd,1); fclose(fd); /* spawn the users editor on the news file */ sprintf(user_input,"%s %s",editor,tmpfile); statusline("Spawning your selected editor to edit mail message"); stop_curses(); if(system(user_input)) { statusline("Error spawning editor, check your editor definition in the options menu"); sleep(1); } start_curses(); } else { addstr("\n\n Please enter your message below."); addstr("\n When you are done, press enter and put a single period (.)"); addstr("\n on a line and press enter again."); addstr("\n\n"); scrollok(stdscr,TRUE); refresh(); *user_input = '\0'; if (LYgetstr(user_input, VISIBLE) < 0 || term_message) { statusline("News Post Cancelled!!!"); sleep(1); fclose(fd); /* close the temp file */ goto cleanup; } while(!STREQ(user_input,".") && !term_message) { addch('\n'); fprintf(fd,"%s\n",user_input); *user_input = '\0'; if (LYgetstr(user_input, VISIBLE) < 0) { statusline("News Post Cancelled!!!"); sleep(1); fclose(fd); /* close the temp file */ goto cleanup; } } fprintf(fd,"\n"); fclose(fd); /* close the temp file */ scrollok(stdscr,FALSE); /* stop scrolling */ } statusline("Post this message? (y/n) "); while((c = toupper(LYgetch())) != 'Y' && c != 'N') ; /* null body */ clear(); /* clear the screen */ if(c == 'N') { goto cleanup; } sprintf(cmd,"%s %s",INEWS,tmpfile); stop_curses(); printf("Posting your message:\n\n%s\n\nPlease wait...", cmd); #ifndef VMS signal(SIGINT, SIG_IGN); #endif /* not VMS */ system(cmd); start_curses(); #ifdef VMS goto cleandown; #endif /* VMS */ /* come here to cleanup and exit */ cleanup: signal(SIGINT, cleanup_sig); cleandown: term_message = FALSE; scrollok(stdscr,FALSE); /* stop scrolling */ remove(tmpfile); return(NORMAL); }
static void send_file_to_screen(DocInfo *newdoc, char *content_base, int Lpansi) { FILE *outfile_fp; bstring *prompt = NULL; if (Lpansi) { _statusline(CHECK_PRINTER); } else { _statusline(PRESS_RETURN_TO_BEGIN); } BStrCopy0(prompt, ""); if (LYgetBString(&prompt, FALSE, 0, NORECALL) < 0) { CancelPrint(PRINT_REQUEST_CANCELLED); } else { outfile_fp = stdout; stop_curses(); SetOutputMode(O_TEXT); #ifndef VMS signal(SIGINT, SIG_IGN); #endif /* !VMS */ 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); } if (Lpansi) printf("\033[5i"); print_wwwfile_to_fd(outfile_fp, FALSE, FALSE); /* SCREEN */ if (keypad_mode) printlist(outfile_fp, FALSE); #ifdef VMS if (HadVMSInterrupt) { HadVMSInterrupt = FALSE; start_curses(); CancelPrint(PRINT_REQUEST_CANCELLED); } #endif /* VMS */ if (Lpansi) { printf("\n\014"); /* Form feed */ printf("\033[4i"); fflush(stdout); /* refresh to screen */ } else { fprintf(stdout, "\n\n%s", PRESS_RETURN_TO_FINISH); fflush(stdout); /* refresh to screen */ (void) LYgetch(); /* grab some user input to pause */ #ifdef VMS HadVMSInterrupt = FALSE; #endif /* VMS */ } #ifdef SH_EX fprintf(stdout, "\n"); #endif SetOutputMode(O_BINARY); start_curses(); } done: /* send_file_to_screen() */ BStrFree(prompt); return; }