/* * reply_by_mail() prompts line-by-line for header information, allowing * scrolling of the screen. */ PRIVATE int header_prompt ARGS3( char *, label, char **, result, unsigned, limit) { char buffer[LINESIZE]; int ok; if (*result != 0) { LYaddstr(CTRL_U_TO_ERASE); LYstrncpy(buffer, *result, sizeof(buffer)-1); } else *buffer = 0; if (limit > sizeof(buffer)) limit = sizeof(buffer); LYaddstr(gettext(label)); LYaddstr(": "); ok = (LYgetstr(buffer, VISIBLE, limit, NORECALL) >= 0 && !term_letter); LYaddstr("\n"); if (ok) { remove_tildes(buffer); StrAllocCopy(*result, buffer); } term_letter = FALSE; return ok; }
void HTMLSRC_init_caches( BOOLEAN dont_exit ) { int i; char *p; char buf[1000]; if ( WWW_TraceFlag && ( WWW_TraceMask & 8 ) ) { fprintf( TraceFP( ), "HTMLSRC_init_caches(%d tagspecs)\n", 12 ); } i = 0; for ( ; i <= 11; i++ ) { LYstrncpy( buf, HTL_tagspecs_defaults[ i ], 999 ); HTSACopy( &HTL_tagspecs[ i ], buf ); if ( WWW_TraceFlag && ( WWW_TraceMask & 8 ) ) { fprintf( TraceFP( ), "parsing lexeme %d: %s\n", i + 1, buf ); } p = strchr( buf, ':' ); if ( p ) p = 0; if ( html_src_parse_tagspec( buf, i, 0, 1 ) == 0 && dont_exit == 0 ) failed_init( "1st", i ); if ( html_src_parse_tagspec( 0, i, 0, 0 ) == 0 && dont_exit == 0 ) failed_init( "2nd", i ); // i++; } return; }
PUBLIC void HTMLSRC_init_caches ARGS1( BOOL, dont_exit) { int i; char* p; char buf[1000]; for (i = 0; i < HTL_num_lexemes; ++i) { /*we assume that HT_tagspecs was NULLs at when program started*/ LYstrncpy(buf, HTL_tagspecs[i] ? HTL_tagspecs[i] : HTL_tagspecs_defaults[i], sizeof(buf) - 1); StrAllocCopy(HTL_tagspecs[i], buf); if ((p = strchr(buf, ':')) != 0) *p = '\0'; if (html_src_parse_tagspec(buf, i, FALSE, TRUE) && !dont_exit ) { fprintf(stderr, "internal error while caching 1st tagspec of %d lexeme", i); exit_immediately(EXIT_FAILURE); } if (html_src_parse_tagspec( p ? p+1 : NULL , i, FALSE, FALSE) && !dont_exit) { fprintf(stderr, "internal error while caching 2nd tagspec of %d lexeme", i); exit_immediately(EXIT_FAILURE); } } }
/* ** 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; }
/* * Format the given command into a buffer, returning the resulting string. * * It is too dangerous to leave any URL that may come along unquoted. They * often contain '&', ';', and '?' chars, and who knows what else may occur. * Prevent spoofing of the shell. Dunno how this needs to be modified for VMS * or DOS. - kw */ PRIVATE char *format_command ARGS2( char *, command, char *, param) { char *cmdbuf = NULL; #if defined(WIN_EX) if (*param != '\"' && strchr(param, ' ') != NULL) { char *cp = quote_pathname(param); format(&cmdbuf, command, cp); FREE(cp); } else { char pram_string[LY_MAXPATH]; LYstrncpy(pram_string, param, sizeof(pram_string)-1); decode_string(pram_string); param = pram_string; if (isMAILTO_URL(param)) { format(&cmdbuf, command, param + 7); } else if (strnicmp("telnet://", param, 9) == 0) { char host[sizeof(pram_string)]; int last_pos; strcpy(host, param + 9); last_pos = strlen(host) - 1; if (last_pos > 1 && host[last_pos] == '/') host[last_pos] = '\0'; format(&cmdbuf, command, host); } else if (strnicmp("file://localhost/", param, 17) == 0) { char e_buff[LY_MAXPATH], *p; p = param + 17; *e_buff = 0; if (strchr(p, ':') == NULL) { sprintf(e_buff, "%.3s/", windows_drive); } strncat(e_buff, p, sizeof(e_buff) - strlen(e_buff) - 1); p = strrchr(e_buff, '.'); if (p) { trimPoundSelector(p); } /* Less ==> short filename with backslashes, * less ==> long filename with forward slashes, may be quoted */ if (ISUPPER(command[0])) { format(&cmdbuf, command, HTDOS_short_name(e_buff)); } else { if (*e_buff != '\"' && strchr(e_buff, ' ') != NULL) { p = quote_pathname(e_buff); LYstrncpy(e_buff, p, sizeof(e_buff)-1); FREE(p); } format(&cmdbuf, command, e_buff); } } else { format(&cmdbuf, command, param); } } #else format(&cmdbuf, command, param); #endif return cmdbuf; }
PRIVATE DIR *HTVMSopendir(char *dirname) { static DIR dir; char *closebracket; long status; struct dsc$descriptor_s entryname_desc; struct dsc$descriptor_s dirname_desc; static char *DirEntry; char Actual[256]; char VMSentry[256]; char UnixEntry[256]; int index; char *dot; /* check if directory exists */ /* dirname can look like /disk$user/duns/www/test/multi */ /* or like /disk$user/duns/www/test/multi/ */ /* DirEntry should look like disk$user:[duns.www.test]multi in both cases */ /* dir.dirname should look like disk$user:[duns.www.test.multi] */ sprintf(UnixEntry, "%.*s", sizeof(UnixEntry) - 2, dirname); if (UnixEntry[strlen(UnixEntry)-1] != '/') strcat(UnixEntry,"/"); StrAllocCopy(DirEntry, HTVMS_name("",UnixEntry)); if (strlen(DirEntry) > sizeof(dir.dirname) - 1) return (NULL); strcpy(dir.dirname, DirEntry); index = strlen(DirEntry) - 1; if (DirEntry[index] == ']') DirEntry[index] = '\0'; if ((dot = strrchr(DirEntry,'.')) == NULL) { /* convert disk$user:[duns] into disk$user:[000000]duns.dir */ char *openbr = strrchr(DirEntry,'['); if (!openbr) { /* convert disk$user: into disk$user:[000000]000000.dir */ if (strlen(dir.dirname) > sizeof(dir.dirname) - 10) return (NULL); sprintf(dir.dirname, "%.*s[000000]", sizeof(dir.dirname) - 9, DirEntry); StrAllocCat(DirEntry,"[000000]000000.dir"); } else { char End[256]; strcpy(End,openbr+1); *(openbr+1) = '\0'; StrAllocCat(DirEntry,"000000]"); StrAllocCat(DirEntry,End); StrAllocCat(DirEntry,".dir"); } } else { *dot = ']'; StrAllocCat(DirEntry,".dir"); } /* lib$find_file needs a fixed-size buffer */ LYstrncpy(Actual, DirEntry, sizeof(Actual)-1); dir.context = 0; dirname_desc.dsc$w_length = strlen(Actual); dirname_desc.dsc$b_dtype = DSC$K_DTYPE_T; dirname_desc.dsc$b_class = DSC$K_CLASS_S; dirname_desc.dsc$a_pointer = (char *)&(Actual); /* look for the directory */ entryname_desc.dsc$w_length = 255; entryname_desc.dsc$b_dtype = DSC$K_DTYPE_T; entryname_desc.dsc$b_class = DSC$K_CLASS_S; entryname_desc.dsc$a_pointer = VMSentry; status = lib$find_file(&(dirname_desc), &entryname_desc, &(dir.context), 0,0,0,0); if (!(status & 0x01)) { /* directory not found */ return(NULL); } if (strlen(dir.dirname) > sizeof(dir.dirname) - 10) return (NULL); if (HTVMSFileVersions) strcat(dir.dirname,"*.*;*"); else strcat(dir.dirname,"*.*"); dir.context = 0; dir.dirname_desc.dsc$w_length = strlen(dir.dirname); dir.dirname_desc.dsc$b_dtype = DSC$K_DTYPE_T; dir.dirname_desc.dsc$b_class = DSC$K_CLASS_S; dir.dirname_desc.dsc$a_pointer = (char *)&(dir.dirname); return(&dir); }
/* ** The code below is for directory browsing by VMS Curses clients. ** It is based on the newer WWWLib's HTDirBrw.c. - Foteos Macrides */ PUBLIC int HTStat ARGS2( CONST char *, filename, struct stat *, info) { /* the following stuff does not work in VMS with a normal stat... --> /disk$user/duns/www if www is a directory is statted like: /disk$user/duns/www.dir after a normal stat has failed --> /disk$user/duns if duns is a toplevel directory is statted like: /disk$user/000000/duns.dir --> /disk$user since disk$user is a device is statted like: /disk$user/000000/000000.dir --> / searches all devices, no solution yet... --> /vxcern!/disk$cr/wwwteam/login.com is not statted but granted with fake information... */ int Result; int Len; char *Ptr, *Ptr2; static char *Name; /* try normal stat... */ Result = stat((char *)filename,info); if (Result == 0) return(Result); /* make local copy */ StrAllocCopy(Name,filename); /* failed,so do device search in case root is requested */ if (!strcmp(Name,"/")) { /* root requested */ return(-1); } /* failed so this might be a directory, add '.dir' */ Len = strlen(Name); if (Name[Len-1] == '/') Name[Len-1] = '\0'; /* fail in case of device */ Ptr = strchr(Name+1,'/'); if ((Ptr == NULL) && (Name[0] == '/')) { /* device only... */ StrAllocCat(Name, "/000000/000000"); } if (Ptr != NULL) { /* correct filename in case of toplevel dir */ Ptr2 = strchr(Ptr+1,'/'); if ((Ptr2 == NULL) && (Name[0] == '/')) { char End[256]; LYstrncpy(End, Ptr, sizeof(End) - 1); *(Ptr+1) = '\0'; StrAllocCat(Name, "000000"); StrAllocCat(Name, End); } } /* try in case a file on toplevel directory or .DIR was already specified */ Result = stat(Name,info); if (Result == 0) return(Result); /* add .DIR and try again */ StrAllocCat(Name, ".dir"); Result = stat(Name,info); return(Result); }
/* * 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); }
char *LYVersionDate( void ) { static char temp[12]; LYstrncpy( temp, "14 Dec 2008 16:24:56 -0800", 11 ); return temp; }