home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-09-25 | 49.6 KB | 2,142 lines |
- Newsgroups: comp.sources.misc
- From: iain@estevax.uucp (Iain J. Lea)
- Subject: v23i020: tin - threaded full screen newsreader v1.0 PL2, Part06/09
- Message-ID: <1991Sep25.205241.2122@sparky.imd.sterling.com>
- X-Md4-Signature: 4f4146a2f69dee28cd7e6a7e74733ca8
- Date: Wed, 25 Sep 1991 20:52:41 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: iain@estevax.uucp (Iain J. Lea)
- Posting-number: Volume 23, Issue 20
- Archive-name: tin/part06
- Environment: BSD, SCO, ISC, SUNOS, SYSVR3, SYSVR4, ULTRIX, XENIX
-
- #!/bin/sh
- # this is tin.shar.06 (part 6 of tin1.02)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file page.c continued
- #
- if touch 2>&1 | fgrep '[-amc]' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- if test ! -r shar3_seq_.tmp; then
- echo "Please unpack part 1 first!"
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 6; then
- echo "Please unpack part $Scheck next!"
- exit 1
- else
- exit 0
- fi
- ) < shar3_seq_.tmp || exit 1
- echo "x - Continuing file page.c"
- sed 's/^X//' << 'SHAR_EOF' >> page.c &&
- X } else {
- X reload_index_file (group, FALSE); /* unkill arts */
- X }
- X return find_new_pos (old_top, old_artnum, respnum);
- X }
- X return (which_base (respnum));
- X
- X case 'I': /* toggle inverse video */
- X inverse_okay = !inverse_okay;
- X if (inverse_okay) {
- X info_message (txt_inverse_on);
- X } else {
- X draw_arrow_mark = TRUE;
- X info_message (txt_inverse_off);
- X }
- X redraw_page (respnum, group);
- X break;
- X
- X case 'k':
- X if (note_page == NOTE_UNAVAIL) {
- X n = next_unread (next_response(respnum));
- X if (n == -1)
- X return (which_base (respnum));
- X } else {
- X note_cleanup ();
- X n = next_unread (next_response (respnum));
- X if (n == -1)
- X return (which_base (respnum));
- X }
- X respnum = n;
- X goto restart;
- X /* NOTREACHED */
- X
- X case 'K': /* mark rest of thread as read */
- X for (n = respnum; n >= 0; n = arts[n].thread)
- X arts[n].unread = ART_READ;
- X n = next_unread (next_response (respnum));
- X if (n == -1)
- X goto return_to_index;
- X note_cleanup ();
- X respnum = n;
- X goto restart;
- X /* NOTREACHED */
- X
- X case 'm': /* mail article/thread/tagged articles to somebody */
- X feed_articles (FEED_MAIL, PAGE_LEVEL, "Mail", respnum, group_path);
- X break;
- X
- X case 'M': /* options menu */
- X if (change_rcfile (group, FALSE) == KILLING) {
- X kill_state = KILLING;
- X }
- X redraw_page (respnum, group);
- X break;
- X
- X case 'n': /* skip to next article */
- X note_cleanup ();
- X n = next_response (respnum);
- X if (n == -1)
- X return (which_base(respnum));
- X
- X respnum = n;
- X goto restart;
- X /* NOTREACHED */
- X
- X case 'N': /* next unread article */
- X n = next_unread(next_response(respnum));
- X if (n == -1)
- X info_message(txt_no_next_unread_art);
- X else {
- X note_cleanup();
- X respnum = n;
- X goto restart;
- X }
- X break;
- X
- X case 'o': /* output art/thread/tagged arts to printer */
- X feed_articles (FEED_PRINT, PAGE_LEVEL, "Print", respnum, group_path);
- X break;
- X
- X case 'p': /* previous article */
- X note_cleanup ();
- X n = prev_response (respnum);
- X if (n == -1)
- X return (which_resp (respnum));
- X
- X respnum = n;
- X goto restart;
- X
- X case 'P': /* previous unread article */
- X n = prev_unread (prev_response (respnum));
- X if (n == -1)
- X info_message (txt_no_prev_unread_art);
- X else {
- X note_cleanup ();
- X respnum = n;
- X goto restart;
- X }
- X break;
- X
- X case 'q': /* quit */
- X if (prompt_yn (LINES, txt_quit, 'y')) {
- X return -2;
- X }
- X break;
- X
- X case 'r': /* reply to author through mail */
- X mail_to_author (FALSE);
- X redraw_page (respnum, group);
- X break;
- X
- X case 'R': /* reply to author, copy text */
- X mail_to_author (TRUE);
- X redraw_page (respnum, group);
- X break;
- X
- X case 's': /* save article/thread/tagged articles */
- X feed_articles (FEED_SAVE, PAGE_LEVEL, "Save", respnum, group_path);
- X break;
- X
- X case 't': /* return to group selection page */
- X note_cleanup ();
- X if (kill_state == KILLING) {
- X if (kill_articles) {
- X kill_any_articles (group);
- X reload_index_file (group, TRUE); /* kill arts */
- X } else {
- X reload_index_file (group, FALSE); /* unkill arts */
- X }
- X }
- X update_newsrc (group, my_group[cur_groupnum], FALSE);
- X fix_new_highest (cur_groupnum);
- X return -1;
- X
- X case 'T': /* tag/untag article for saving */
- X if (arts[respnum].tagged) {
- X arts[respnum].tagged = 0;
- X info_message (txt_untagged_art);
- X } else {
- X arts[respnum].tagged = ++num_of_tagged_files;
- X info_message (txt_tagged_art);
- X }
- X break;
- X
- X case 'v':
- X info_message (cvers);
- X break;
- X
- X case 'w': /* post a basenote */
- X if (post_base (group)) {
- X update_newsrc (group, my_group[cur_groupnum], FALSE);
- X index_group (group, group_path);
- X read_newsrc_line (group);
- X redraw_page (respnum, group);
- X }
- X break;
- X
- X case 'W': /* display messages posted by user */
- X if (user_posted_messages ()) {
- X redraw_page(respnum, group);
- X }
- X break;
- X
- X case 'z': /* mark article as unread (to return) */
- X arts[respnum].unread = ART_WILL_RETURN;
- X info_message(txt_art_marked_as_unread);
- X break;
- X
- X default:
- X info_message(txt_bad_command);
- X }
- X }
- X}
- X
- X
- Xvoid redraw_page (respnum, group)
- X int respnum;
- X char *group;
- X{
- X
- X if (note_page == NOTE_UNAVAIL) {
- X ClearScreen ();
- X printf (txt_art_unavailable, arts[respnum].artnum);
- X fflush (stdout);
- X } else if (note_page > 0) {
- X note_page--;
- X fseek (note_fp, note_mark[note_page], 0);
- X show_note_page (respnum, group);
- X }
- X}
- X
- X
- Xvoid show_note_page (respnum, group)
- X int respnum;
- X char *group;
- X{
- X char buf[LEN+1];
- X char buf2[LEN+50];
- X char *p, *q;
- X int i, j;
- X int ctrl_L; /* form feed character detected */
- X
- X ClearScreen();
- X
- X note_line = 1;
- X
- X if (note_page == 0)
- X show_first_header (respnum, group);
- X else
- X show_cont_header (respnum);
- X
- X ctrl_L = FALSE;
- X while (note_line < LINES) {
- X if (fgets(buf, sizeof buf, note_fp) == NULL) {
- X note_end = TRUE;
- X break;
- X }
- X
- X buf[LEN-1] = '\0';
- X if (rotate)
- X for (p = buf, q = buf2;
- X *p && *p != '\n' && q<&buf2[LEN]; p++) {
- X if (*p == '\b' && q > buf2) {
- X q--;
- X } else if (*p == 12) { /* ^L */
- X *q++ = '^';
- X *q++ = 'L';
- X ctrl_L = TRUE;
- X } else if (*p == '\t') {
- X i = q - buf2;
- X j = (i|7) + 1;
- X
- X while (i++ < j)
- X *q++ = ' ';
- X } else if (((*p) & 0x7F) < 32) {
- X *q++ = '^';
- X *q++ = ((*p) & 0x7F) + '@';
- X } else if (*p >= 'A' && *p <= 'Z')
- X *q++ = 'A' + (*p - 'A' + rotate) % 26;
- X else if (*p >= 'a' && *p <= 'z')
- X *q++ = 'a' + (*p - 'a' + rotate) % 26;
- X else
- X *q++ = *p;
- X }
- X else
- X for (p = buf, q = buf2;
- X *p && *p != '\n' && q<&buf2[LEN]; p++) {
- X if (*p == '\b' && q > buf2) {
- X q--;
- X } else if (*p == 12) { /* ^L */
- X *q++ = '^';
- X *q++ = 'L';
- X ctrl_L = TRUE;
- X } else if (*p == '\t') {
- X i = q - buf2;
- X j = (i|7) + 1;
- X
- X while (i++ < j)
- X *q++ = ' ';
- X } else if (((*p) & 0x7F) < 32) {
- X *q++ = '^';
- X *q++ = ((*p) & 0x7F) + '@';
- X } else
- X *q++ = *p;
- X }
- X
- X *q = '\0';
- X
- X printf("%s\r\n", buf2);
- X
- X note_line += ((int) strlen (buf2) / COLS) + 1;
- X
- X if (ctrl_L) {
- X break;
- X }
- X }
- X
- X note_mark[++note_page] = ftell(note_fp);
- X
- X if (note_end) {
- X MoveCursor (LINES, MORE_POS-(5+BLANK_PAGE_COLS));
- X StartInverse ();
- X if (arts[respnum].thread != -1) {
- X printf (txt_next_resp);
- X fflush (stdout);
- X } else {
- X printf (txt_last_resp);
- X fflush (stdout);
- X }
- X EndInverse ();
- X } else {
- X if (note_size > 0) {
- X draw_percent_mark ((int) note_mark[note_page], note_size);
- X } else {
- X MoveCursor (LINES, MORE_POS-BLANK_PAGE_COLS);
- X StartInverse ();
- X printf (txt_more);
- X fflush (stdout);
- X EndInverse ();
- X }
- X }
- X MoveCursor (LINES, 0);
- X}
- X
- X
- Xvoid show_first_header (respnum, group)
- X int respnum;
- X char *group;
- X{
- X int whichresp;
- X int x_resp;
- X char buf[LEN+1];
- X char tmp[LEN+1];
- X int pos, i;
- X int n;
- X
- X whichresp = which_resp (respnum);
- X x_resp = nresp (which_base (respnum));
- X
- X ClearScreen ();
- X
- X strcpy (buf, note_h_date);
- X pos = (COLS - (int) strlen (group)) / 2;
- X for (i = strlen(buf); i < pos; i++)
- X buf[i] = ' ';
- X buf[i] = '\0';
- X
- X strcat (buf, group);
- X
- X for (i = strlen(buf); i < RIGHT_POS ; i++)
- X buf[i] = ' ';
- X buf[i] = '\0';
- X
- X printf (txt_thread_x_of_n, buf, which_base (respnum) + 1, top_base);
- X
- X sprintf (buf, txt_art, arts[respnum].artnum);
- X n = strlen (buf);
- X fputs (buf, stdout);
- X
- X strcpy (buf, note_h_subj);
- X buf[RIGHT_POS - 5 - n] = '\0';
- X
- X pos = ((COLS - (int) strlen (buf)) / 2) - 2;
- X
- X if (pos > n) {
- X MoveCursor (1, pos);
- X } else {
- X MoveCursor (1, n);
- X }
- X
- X StartInverse ();
- X fputs (buf, stdout);
- X EndInverse ();
- X
- X MoveCursor (1, RIGHT_POS);
- X if (whichresp)
- X printf (txt_resp_x_of_n, whichresp, x_resp);
- X else {
- X if (x_resp == 0)
- X printf (txt_no_resp);
- X else if (x_resp == 1)
- X printf (txt_1_resp);
- X else
- X printf (txt_x_resp, x_resp);
- X }
- X
- X if (*note_h_org)
- X sprintf (tmp, txt_s_at_s, note_full_name, note_h_org);
- X else
- X strcpy (tmp, note_full_name);
- X
- X tmp[LEN] = '\0';
- X
- X sprintf (buf, "%s ", note_from_addr);
- X
- X pos = COLS - 1 - (int) strlen(tmp);
- X if ((int) strlen (buf) + (int) strlen (tmp) >= COLS - 1) {
- X strncat (buf, tmp, COLS - 1 - (int) strlen(buf));
- X buf[COLS - 1] = '\0';
- X } else {
- X for (i = strlen(buf); i < pos; i++)
- X buf[i] = ' ';
- X buf[i] = '\0';
- X strcat (buf, tmp);
- X }
- X printf ("%s\r\n\r\n", buf);
- X
- X note_line += 4;
- X}
- X
- X
- Xvoid show_cont_header (respnum)
- X int respnum;
- X{
- X int whichresp;
- X int whichbase;
- X char buf[LEN+1];
- X
- X whichresp = which_resp (respnum);
- X whichbase = which_base (respnum);
- X
- X assert (whichbase < top_base);
- X
- X if (whichresp)
- X sprintf(buf, txt_thread_resp_page,
- X whichbase + 1,
- X top_base,
- X whichresp,
- X note_page + 1,
- X note_h_subj);
- X else
- X sprintf(buf, txt_thread_page,
- X whichbase + 1,
- X top_base,
- X note_page + 1,
- X note_h_subj);
- X
- X buf[COLS] = '\0';
- X printf("%s\r\n\r\n", buf);
- X
- X note_line += 2;
- X}
- X
- X
- Xvoid open_note (art, group_path)
- X long art;
- X char *group_path;
- X{
- X char buf[1025];
- X char *p;
- X
- X note_page = 0;
- X
- X if ((note_fp = open_art_fp (group_path, art)) == NULL) {
- X note_page = NOTE_UNAVAIL;
- X return;
- X }
- X
- X note_h_from[0] = '\0';
- X note_h_path[0] = '\0';
- X note_h_subj[0] = '\0';
- X note_h_org[0] = '\0';
- X note_h_date[0] = '\0';
- X note_h_newsgroups[0] = '\0';
- X note_h_messageid[0] = '\0';
- X note_h_distrib[0] = '\0';
- X note_h_followup[0] = '\0';
- X
- X while (fgets(buf, sizeof buf, note_fp) != NULL) {
- X buf[1024] = '\0';
- X
- X for (p=buf ; *p && *p != '\n' ; p++) {
- X if (((*p) & 0x7F) < 32)
- X *p = ' ';
- X }
- X *p = '\0';
- X
- X if (*buf == '\0')
- X break;
- X
- X if (strncmp(buf, "From: ", 6) == 0) {
- X strcpy(note_h_from, &buf[6]);
- X note_h_from[LEN-1] = '\0';
- X } else if (strncmp(buf, "Path: ", 6) == 0) {
- X strcpy(note_h_path, &buf[6]);
- X note_h_path[LEN-1] = '\0';
- X } else if (strncmp(buf, "Subject: ", 9) == 0) {
- X strcpy(note_h_subj, &buf[9]);
- X note_h_subj[LEN-1] = '\0';
- X } else if (strncmp(buf, "Organization: ", 14) == 0) {
- X strcpy(note_h_org, &buf[14]);
- X note_h_org[LEN-1] = '\0';
- X } else if (strncmp(buf, "Date: ", 6) == 0) {
- X strcpy(note_h_date, &buf[6]);
- X note_h_date[LEN-1] = '\0';
- X } else if (strncmp(buf, "Newsgroups: ", 12) == 0) {
- X strcpy(note_h_newsgroups, &buf[12]);
- X note_h_newsgroups[LEN-1] = '\0';
- X } else if (strncmp(buf, "Message-ID: ", 12) == 0) {
- X strcpy(note_h_messageid, &buf[12]);
- X note_h_messageid[LEN-1] = '\0';
- X } else if (strncmp(buf, "Distribution: ", 14) == 0) {
- X strcpy(note_h_distrib, &buf[14]);
- X note_h_distrib[LEN-1] = '\0';
- X } else if (strncmp(buf, "Followup-To: ", 13) == 0) {
- X strcpy(note_h_followup, &buf[13]);
- X note_h_followup[LEN-1] = '\0';
- X }
- X }
- X
- X note_page = 0;
- X note_mark[0] = ftell (note_fp);
- X
- X parse_from (note_h_from, note_from_addr, note_full_name);
- X note_end = FALSE;
- X
- X return;
- X}
- X
- X
- Xvoid note_cleanup()
- X{
- X if (note_page != NOTE_UNAVAIL)
- X fclose(note_fp);
- X}
- X
- X
- Xint prompt_response(ch, respnum)
- X int respnum;
- X{
- X int num;
- X
- X clear_message ();
- X
- X if ((num = parse_num (ch, txt_read_resp)) == -1) {
- X clear_message ();
- X return -1;
- X }
- X
- X return choose_resp (which_base (respnum), num);
- X}
- X
- X/*
- X * return response number n from thread i
- X */
- X
- Xint choose_resp (i, n)
- X int i;
- X int n;
- X{
- X int j;
- X
- X j = base[i];
- X
- X while (n-- && arts[j].thread >= 0) {
- X j = arts[j].thread;
- X }
- X
- X return j;
- X}
- X
- X
- X/*
- X * Parse various From: lines into the component mail addresses and
- X * real names
- X */
- X
- Xvoid parse_from (str, addr, name)
- X char *str;
- X char *addr;
- X char *name;
- X{
- X char *p;
- X
- X for (p=str ; *p ; p++) {
- X if (((*p) & 0x7F) < 32)
- X *p = ' ';
- X }
- X
- X while (*str && *str != ' ')
- X *addr++ = *str++;
- X *addr = '\0';
- X if (*str++ == ' ') {
- X if (*str++ == '(') {
- X if (*str == '"')
- X str++; /* Kill "quotes around names" */
- X /* But don't touch quotes inside the */
- X /* Name (that's what that nonsense */
- X /* below is for */
- X while (*str && *str != ')' && !(*str=='"'&&str[1]==')'))
- X *name++ = *str++;
- X }
- X }
- X *name = '\0';
- X}
- X
- X
- X/*
- X * Find the previous response. Go to the last response in the previous
- X * thread if we go past the beginning of this thread.
- X */
- X
- Xint prev_response (n)
- X int n;
- X{
- X int resp;
- X int i;
- X
- X resp = which_resp (n);
- X
- X if (resp > 0)
- X return choose_resp (which_base (n), resp-1);
- X
- X i = which_base (n) - 1;
- X
- X if (i < 0)
- X return -1;
- X
- X return choose_resp (i, nresp (i));
- X}
- X
- X
- X/*
- X * Find the next response. Go to the next basenote if there
- X * are no more responses in this thread
- X */
- X
- Xint next_response (n)
- X int n;
- X{
- X int i;
- X
- X if (arts[n].thread >= 0)
- X return arts[n].thread;
- X
- X i = which_base (n) + 1;
- X
- X if (i >= top_base)
- X return -1;
- X
- X return base[i];
- X}
- X
- X
- X/*
- X * Given a respnum (index into arts[]), find the respnum of the
- X * next basenote
- X */
- X
- Xint next_basenote (n)
- X int n;
- X{
- X int i;
- X
- X i = which_base (n) + 1;
- X if (i >= top_base)
- X return -1;
- X
- X return base[i];
- X}
- X
- X
- Xvoid yank_to_addr (orig, addr)
- X char *orig;
- X char *addr;
- X{
- X char *p;
- X
- X for (p = orig; *p; p++)
- X if (((*p) & 0x7F) < 32)
- X *p = ' ';
- X
- X while (*addr)
- X addr++;
- X
- X while (*orig) {
- X while (*orig && (*orig == ' ' || *orig == '"' || *orig == ','))
- X orig++;
- X *addr++ = ' ';
- X while (*orig && (*orig != ' ' && *orig != ',' && *orig != '"'))
- X *addr++ = *orig++;
- X while (*orig && (*orig == ' ' || *orig == '"' || *orig == ','))
- X orig++;
- X if (*orig == '(') {
- X while (*orig && *orig != ')')
- X orig++;
- X if (*orig == ')')
- X orig++;
- X }
- X }
- X *addr = '\0';
- X}
- X
- X
- Xint show_last_page ()
- X{
- X char buf[LEN+1];
- X char buf2[LEN+50];
- X char *p, *q;
- X int ctrl_L; /* form feed character detected */
- X int i, j;
- X
- X if (note_end) {
- X return FALSE;
- X }
- X
- X while (! note_end) {
- X note_line = 1;
- X ctrl_L = FALSE;
- X
- X if (note_page == 0) {
- X note_line += 4;
- X } else {
- X note_line += 2;
- X }
- X while (note_line < LINES) {
- X if (fgets(buf, sizeof buf, note_fp) == NULL) {
- X note_end = TRUE;
- X break;
- X }
- X buf[LEN-1] = '\0';
- X for (p = buf, q = buf2; *p && *p != '\n' && q<&buf2[LEN]; p++) {
- X if (*p == '\b' && q > buf2) {
- X q--;
- X } else if (*p == 12) { /* ^L */
- X *q++ = '^';
- X *q++ = 'L';
- X ctrl_L = TRUE;
- X } else if (*p == '\t') {
- X i = q - buf2;
- X j = (i|7) + 1;
- X
- X while (i++ < j) {
- X *q++ = ' ';
- X }
- X } else if (((*p) & 0x7F) < 32) {
- X *q++ = '^';
- X *q++ = ((*p) & 0x7F) + '@';
- X } else {
- X *q++ = *p;
- X }
- X }
- X *q = '\0';
- X note_line += ((int) strlen (buf2) / COLS) + 1;
- X
- X if (ctrl_L) {
- X break;
- X }
- X }
- X if (! note_end) {
- X note_mark[++note_page] = ftell(note_fp);
- X }
- X }
- X fseek (note_fp, note_mark[note_page], 0);
- X return TRUE;
- X}
- SHAR_EOF
- echo "File page.c is complete" &&
- $TOUCH -am 0924082391 page.c &&
- chmod 0600 page.c ||
- echo "restore of page.c failed"
- set `wc -c page.c`;Wc_c=$1
- if test "$Wc_c" != "24185"; then
- echo original size 24185, current size $Wc_c
- fi
- # ============= post.c ==============
- echo "x - extracting post.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > post.c &&
- X/*
- X * Project : tin - a visual threaded usenet newsreader
- X * Module : post.c
- X * Author : I.Lea
- X * Created : 01-04-91
- X * Updated : 22-09-91
- X * Release : 1.0
- X * Notes : mailing/posting/replying/followup & cancel article routines
- X * Copyright : (c) Copyright 1991 by Rich Skrenta & Iain Lea
- X * You may freely copy or redistribute this software,
- X * so long as there is no profit made from its use, sale
- X * trade or reproduction. You may not change this copy-
- X * right notice, and it must be included in any copy made
- X */
- X
- X#include "tin.h"
- X
- Xextern char note_h_distrib[LEN+1]; /* Distribution: */
- Xextern char note_h_followup[LEN+1]; /* Followup-To: */
- Xextern char note_h_from[LEN+1]; /* From: */
- Xextern char note_h_messageid[LEN+1]; /* Message-ID: */
- Xextern char note_h_newsgroups[LEN+1]; /* Newsgroups: */
- Xextern char note_h_subj[LEN+1]; /* Subject: */
- X
- Xextern char note_from_addr[100];
- Xextern char note_full_name[100];
- X
- Xextern FILE *note_fp; /* the body of the current article */
- X
- Xextern long note_mark[MAX_PAGES]; /* ftells on beginnings of pages */
- X
- Xstruct posted_t *posted;
- X
- X
- Xint user_posted_messages ()
- X{
- X char buf[LEN];
- X FILE *fp;
- X int i, j, k;
- X int no_of_lines = 0;
- X
- X set_real_uid_gid ();
- X
- X if ((fp = fopen (postfile, "r")) == NULL) {
- X clear_message ();
- X set_tin_uid_gid ();
- X return FALSE;
- X } else {
- X while (fgets (buf, sizeof (buf), fp) != NULL) {
- X no_of_lines++;
- X }
- X if (! no_of_lines) {
- X fclose (fp);
- X info_message (txt_no_arts_posted);
- X return FALSE;
- X }
- X rewind (fp);
- X posted = (struct posted_t *) my_malloc ((no_of_lines+1) * sizeof (struct posted_t));
- X for (i=0 ; fgets (buf, sizeof (buf), fp) != NULL ; i++) {
- X for (j=0 ; buf[j] != '|' && buf[j] != '\n' ; j++) {
- X posted[i].date[j] = buf[j]; /* posted date */
- X }
- X if (buf[j] == '\n') {
- X error_message ("Corrupted file %s", postfile);
- X sleep (1);
- X fclose (fp);
- X clear_message ();
- X return FALSE;
- X }
- X posted[i].date[j++] = '\0';
- X for (k=j,j=0 ; buf[k] != '|' && buf[k] != ',' ; k++, j++) {
- X posted[i].group[j] = buf[k];
- X }
- X if (buf[k] == ',') {
- X while (buf[k] != '|' && buf[k] != '\n') {
- X k++;
- X }
- X posted[i].group[j++] = ',';
- X posted[i].group[j++] = '.';
- X posted[i].group[j++] = '.';
- X posted[i].group[j++] = '.';
- X }
- X posted[i].group[j++] = '\0';
- X k++;
- X for (j=k,k=0 ; buf[j] != '\n' ; j++, k++) {
- X posted[i].subj[k] = buf[j];
- X }
- X posted[i].subj[k++] = '\0';
- X }
- X fclose (fp);
- X set_tin_uid_gid ();
- X
- X show_info_page (POST_INFO, (char *) 0, txt_post_history_menu);
- X return TRUE;
- X }
- X}
- X
- X
- Xvoid update_art_posted_file (group, subj)
- X char *group;
- X char *subj;
- X{
- X char buf[LEN+1];
- X char tmp_post[LEN+1];
- X FILE *fp, *tmp_fp;
- X long epoch;
- X struct tm *tm;
- X
- X sprintf (tmp_post, "%s.%d", postfile, getpid ());
- X
- X set_real_uid_gid ();
- X
- X if ((tmp_fp = fopen (tmp_post, "w")) != NULL) {
- X time (&epoch);
- X tm = localtime (&epoch);
- X fprintf (tmp_fp, "%02d-%02d-%02d|%s|%s\n",
- X tm->tm_mday, tm->tm_mon+1, tm->tm_year, group, subj);
- X fclose (tmp_fp);
- X }
- X
- X if ((tmp_fp = fopen (tmp_post, "a+")) != NULL) {
- X if ((fp = fopen (postfile, "r")) != NULL) {
- X while (fgets (buf, sizeof buf, fp) != NULL) {
- X fprintf (tmp_fp, "%s", buf);
- X }
- X fclose (fp);
- X rename_file (tmp_post, postfile);
- X }
- X fclose (tmp_fp);
- X }
- X set_tin_uid_gid ();
- X}
- X
- X/*
- X * Post an original article (not a followup)
- X */
- X
- Xint post_base (group)
- X char *group;
- X{
- X FILE *fp;
- X char ch;
- X char ch_default = 'p';
- X char subj[LEN+1];
- X char buf[LEN+1];
- X int redraw_screen = FALSE;
- X
- X start_line_offset = 4;
- X
- X if (! parse_string (txt_post_subject, subj)) {
- X clear_message ();
- X return (redraw_screen);
- X }
- X if (subj[0] == '\0') {
- X info_message (txt_no_subject);
- X return (redraw_screen);
- X }
- X
- X set_real_uid_gid ();
- X
- X if ((fp = fopen (article, "w")) == NULL) {
- X error_message (txt_cannot_open, article);
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X }
- X chmod (article, 0600);
- X
- X fprintf (fp, "Subject: %s\n", subj);
- X fprintf (fp, "Newsgroups: %s\n", group);
- X fprintf (fp, "Distribution: \n");
- X if (*my_org) {
- X fprintf (fp, "Organization: %s\n", my_org);
- X start_line_offset++;
- X }
- X if (*reply_to) {
- X fprintf (fp, "Reply-To: %s\n", reply_to);
- X start_line_offset++;
- X }
- X fprintf (fp, "\n");
- X
- X add_signature (fp, FALSE);
- X fclose (fp);
- X
- X ch = 'e';
- X while (1) {
- X switch (ch) {
- X case 'e':
- X invoke_editor (article);
- X redraw_screen = TRUE;
- X break;
- X
- X case 'a':
- X unlink (article);
- X clear_message ();
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X
- X case 'p':
- X wait_message (txt_posting);
- X if (debug) {
- X sprintf (buf, "%s/inews -h < %s", INEWSDIR, article);
- X } else {
- X sprintf (buf, "%s/inews -h < %s > /dev/null 2>&1",
- X INEWSDIR, article);
- X }
- X if (invoke_cmd (buf)) {
- X unlink (article);
- X info_message (txt_art_posted);
- X goto post_base_done;
- X } else {
- X rename_file (article, dead_article);
- X sprintf (buf, txt_art_rejected, dead_article);
- X info_message (buf);
- X sleep (3);
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X }
- X }
- X
- X do {
- X sprintf (msg, "%s%c", txt_abort_edit_post, ch_default);
- X wait_message (msg);
- X MoveCursor (LINES, (int) strlen (txt_abort_edit_post));
- X if ((ch = ReadCh ()) == CR)
- X ch = ch_default;
- X } while (ch != 'a' && ch != 'e' && ch != 'p');
- X }
- X
- Xpost_base_done:
- X set_tin_uid_gid ();
- X update_art_posted_file (group, subj);
- X return (redraw_screen);
- X}
- X
- X
- Xint post_response (group, respnum)
- X char *group;
- X int respnum;
- X{
- X FILE *fp;
- X char ch, *ptr;
- X char ch_default = 'p';
- X char buf[LEN+1];
- X int redraw_screen = FALSE;
- X
- X start_line_offset = 4;
- X
- X if (*note_h_followup && strcmp (note_h_followup, "poster") == 0) {
- X clear_message ();
- X if (! prompt_yn (LINES, txt_resp_to_poster, 'y')) {
- X return (redraw_screen);
- X }
- X *note_h_followup = '\0';
- X } else if (*note_h_followup && strcmp(note_h_followup, group) != 0) {
- X MoveCursor (LINES/2, 0);
- X CleartoEOS ();
- X center_line ((LINES/2)+2, TRUE, txt_resp_redirect);
- X MoveCursor ((LINES/2)+4, 0);
- X
- X printf (" ");
- X ptr = note_h_followup;
- X while (*ptr) {
- X if (*ptr != ',') {
- X putc (*ptr, stdout);
- X } else {
- X printf ("\r\n ");
- X }
- X fflush (stdout);
- X ptr++;
- X }
- X
- X if (! prompt_yn (LINES, txt_continue, 'y')) {
- X return (redraw_screen);
- X }
- X }
- X
- X set_real_uid_gid ();
- X
- X if ((fp = fopen (article, "w")) == NULL) {
- X error_message (txt_cannot_open, article);
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X }
- X chmod (article, 0600);
- X
- X fprintf (fp, "Subject: Re: %s\n", eat_re (note_h_subj));
- X
- X if (*note_h_followup && strcmp(note_h_followup, "poster") != 0) {
- X fprintf (fp, "Newsgroups: %s\n", note_h_followup);
- X } else {
- X fprintf (fp, "Newsgroups: %s\n", note_h_newsgroups);
- X }
- X if (note_h_distrib != '\0') {
- X fprintf (fp, "Distribution: %s\n", note_h_distrib);
- X start_line_offset++;
- X }
- X fprintf (fp, "References: %s\n", note_h_messageid);
- X
- X if (*my_org) {
- X fprintf (fp, "Organization: %s\n", my_org);
- X start_line_offset++;
- X }
- X if (*reply_to) {
- X fprintf (fp, "Reply-To: %s\n", reply_to);
- X start_line_offset++;
- X }
- X fprintf (fp, "\n");
- X
- X if (respnum) { /* if "copy_text" */
- X if (note_h_from[0]) {
- X fprintf (fp, txt_writes, note_h_from);
- X }
- X fseek (note_fp, note_mark[0], 0);
- X copy_fp (note_fp, fp, DEFAULT_COMMENT);
- X }
- X
- X add_signature (fp, FALSE);
- X fclose (fp);
- X
- X ch = 'e';
- X while (1) {
- X switch (ch) {
- X case 'e':
- X invoke_editor (article);
- X redraw_screen = TRUE;
- X break;
- X
- X case 'a':
- X unlink (article);
- X clear_message ();
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X
- X case 'p':
- X wait_message (txt_posting);
- X if (debug) {
- X sprintf (buf, "%s/inews -h < %s", INEWSDIR, article);
- X } else {
- X sprintf (buf, "%s/inews -h < %s > /dev/null 2>&1",
- X INEWSDIR, article);
- X }
- X if (invoke_cmd (buf)) {
- X unlink (article);
- X info_message (txt_art_posted);
- X goto post_response_done;
- X } else {
- X rename_file (article, dead_article);
- X sprintf (buf, txt_art_rejected, dead_article);
- X info_message (buf);
- X sleep (3);
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X }
- X }
- X
- X do {
- X sprintf (msg, "%s%c", txt_abort_edit_post, ch_default);
- X wait_message (msg);
- X MoveCursor(LINES, (int) strlen (txt_abort_edit_post));
- X if ((ch = ReadCh()) == CR)
- X ch = ch_default;
- X } while (ch != 'a' && ch != 'e' && ch != 'p');
- X }
- X
- Xpost_response_done:
- X set_tin_uid_gid ();
- X
- X if (*note_h_followup && strcmp(note_h_followup, "poster") != 0)
- X update_art_posted_file (note_h_followup, note_h_subj);
- X else
- X update_art_posted_file (note_h_newsgroups, note_h_subj);
- X
- X return (redraw_screen);
- X}
- X
- X
- Xint mail_to_someone (address)
- X char *address;
- X{
- X char nam[100];
- X char ch, ch_default = 's';
- X char buf[LEN+1];
- X char mail_to[LEN+1];
- X FILE *fp;
- X int redraw_screen = FALSE;
- X
- X start_line_offset = 4;
- X
- X strcpy (mail_to, address);
- X clear_message ();
- X
- X set_real_uid_gid ();
- X
- X sprintf (nam, "%s/.letter", homedir);
- X if ((fp = fopen (nam, "w")) == NULL) {
- X error_message (txt_cannot_open, nam);
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X }
- X chmod (nam, 0600);
- X
- X fprintf (fp, "To: %s\n", mail_to);
- X fprintf (fp, "Subject: %s\n", note_h_subj);
- X if (*note_h_followup) {
- X fprintf (fp, "Newsgroups: %s\n\n", note_h_followup);
- X } else {
- X fprintf (fp, "Newsgroups: %s\n", note_h_newsgroups);
- X }
- X if (*my_org) {
- X fprintf (fp, "Organization: %s\n", my_org);
- X start_line_offset++;
- X }
- X if (*reply_to) {
- X fprintf (fp, "Reply-To: %s\n", reply_to);
- X start_line_offset++;
- X }
- X fputs ("\n", fp);
- X
- X fseek (note_fp, 0L, 0);
- X copy_fp (note_fp, fp, "");
- X
- X add_signature (fp, TRUE);
- X fclose (fp);
- X
- X while (1) {
- X do {
- X my_strncpy (buf, note_h_subj, COLS-30);
- X sprintf (msg, "%s [%s]: %c", txt_abort_edit_send, buf, ch_default);
- X wait_message (msg);
- X MoveCursor (LINES, (int) strlen (msg)-1);
- X if ((ch = ReadCh ()) == CR)
- X ch = ch_default;
- X } while (ch != 'a' && ch != 'e' && ch != 's');
- X
- X switch (ch) {
- X case 'e':
- X invoke_editor (nam);
- X redraw_screen = TRUE;
- X break;
- X
- X case 'a':
- X unlink (nam);
- X clear_message ();
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X
- X case 's':
- X/*
- X * Open letter and get the To: line in case they changed it with
- X * the editor
- X */
- X find_new_to (nam, mail_to);
- X sprintf (msg, txt_mailing_to, mail_to);
- X wait_message (msg);
- X sprintf (buf, "%s \"%s\" < %s", mailer, mail_to, nam);
- X if (invoke_cmd (buf)) {
- X info_message (txt_message_sent);
- X goto mail_to_someone_done;
- X } else {
- X error_message (txt_command_failed_s, buf);
- X break;
- X }
- X }
- X }
- X
- Xmail_to_someone_done:
- X unlink (nam);
- X set_tin_uid_gid ();
- X
- X return (redraw_screen);
- X}
- X
- X
- Xint mail_bug_report ()
- X{
- X char nam[100];
- X FILE *fp;
- X char ch;
- X char ch_default = 's';
- X char buf[LEN+1];
- X char mail_to[LEN+1];
- X
- X start_line_offset = 5;
- X
- X set_real_uid_gid ();
- X
- X sprintf (nam, "%s/.bugreport", homedir);
- X if ((fp = fopen (nam, "w")) == NULL) {
- X error_message (txt_cannot_open, nam);
- X set_tin_uid_gid ();
- X return FALSE;
- X }
- X chmod(nam, 0600);
- X
- X fprintf (fp, "To: %s\n", bug_addr);
- X fprintf (fp, "Subject: BUG REPORT %s %s PL%d %s\n", progname,
- X version, PATCHLEVEL, (compiled_with_nntp ? "(NNTP)" : ""));
- X if (*my_org) {
- X fprintf (fp, "Organization: %s\n", my_org);
- X start_line_offset++;
- X }
- X if (*reply_to) {
- X fprintf (fp, "Reply-To: %s\n", reply_to);
- X start_line_offset++;
- X }
- X fprintf (fp, "\nPlease enter the following information:\n");
- X fprintf (fp, "1) machine:\n");
- X fprintf (fp, "2) os type:\n");
- X fprintf (fp, "\nPlease enter bug/gripe/comment report:\n");
- X
- X add_signature (fp, TRUE);
- X fclose (fp);
- X
- X ch = 'e';
- X while (1) {
- X switch (ch) {
- X case 'e':
- X invoke_editor (nam);
- X break;
- X
- X case 'a':
- X unlink (nam);
- X clear_message ();
- X set_tin_uid_gid ();
- X return TRUE;
- X
- X case 's':
- X strcpy (mail_to, bug_addr);
- X find_new_to (nam, mail_to);
- X sprintf (msg, txt_mailing_to, mail_to);
- X wait_message (msg);
- X sprintf (buf, "%s \"%s\" < %s", mailer, mail_to, nam);
- X if (invoke_cmd (buf)) {
- X info_message (txt_message_sent);
- X goto mail_bug_report_done;
- X } else {
- X error_message (txt_command_failed_s, buf);
- X break;
- X }
- X }
- X
- X do {
- X sprintf (msg, "%s: %c", txt_abort_edit_send, ch_default);
- X wait_message (msg);
- X MoveCursor (LINES, (int) strlen (msg)-1);
- X if ((ch = ReadCh ()) == CR)
- X ch = ch_default;
- X } while (ch != 'a' && ch != 'e' && ch != 's');
- X }
- X
- Xmail_bug_report_done:
- X unlink (nam);
- X set_tin_uid_gid ();
- X
- X return TRUE;
- X}
- X
- X
- Xint mail_to_author (copy_text)
- X int copy_text;
- X{
- X char buf[LEN+1];
- X char nam[100];
- X char mail_to[LEN+1];
- X char ch, ch_default = 's';
- X FILE *fp;
- X int redraw_screen = FALSE;
- X
- X start_line_offset = 4;
- X
- X set_real_uid_gid ();
- X
- X sprintf (nam, "%s/.letter", homedir);
- X if ((fp = fopen (nam, "w")) == NULL) {
- X error_message (txt_cannot_open, nam);
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X }
- X chmod (nam, 0600);
- X
- X fprintf (fp, "To: %s%s (%s)\n", note_from_addr, add_addr, note_full_name);
- X fprintf (fp, "Subject: Re: %s\n", eat_re(note_h_subj) );
- X fprintf (fp, "Newsgroups: %s\n", note_h_newsgroups);
- X if (*my_org) {
- X fprintf (fp, "Organization: %s\n", my_org);
- X start_line_offset++;
- X }
- X if (*reply_to) {
- X fprintf (fp, "Reply-To: %s\n", reply_to);
- X start_line_offset++;
- X }
- X fputs ("\n", fp);
- X
- X if (copy_text) { /* if "copy_text" */
- X fprintf (fp, txt_in_art_you_write, note_h_messageid);
- X fseek (note_fp, note_mark[0], 0);
- X copy_fp (note_fp, fp, DEFAULT_COMMENT);
- X }
- X
- X add_signature (fp, TRUE);
- X fclose (fp);
- X
- X ch = 'e';
- X while (1) {
- X switch (ch) {
- X case 'e':
- X invoke_editor (nam);
- X redraw_screen = TRUE;
- X break;
- X
- X case 'a':
- X unlink (nam);
- X clear_message ();
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X
- X case 's':
- X strcpy (mail_to, note_from_addr);
- X find_new_to (nam, mail_to);
- X sprintf (msg, txt_mailing_to, mail_to);
- X wait_message (msg);
- X sprintf (buf, "%s \"%s\" < %s", mailer, mail_to, nam);
- X if (invoke_cmd (buf)) {
- X info_message (txt_message_sent);
- X goto mail_to_author_done;
- X } else {
- X error_message (txt_command_failed_s, buf);
- X break;
- X }
- X }
- X
- X do {
- X sprintf (msg, "%s: %c", txt_abort_edit_send, ch_default);
- X wait_message (msg);
- X MoveCursor (LINES, (int) strlen (msg)-1);
- X if ((ch = ReadCh ()) == CR)
- X ch = ch_default;
- X } while (ch != 'a' && ch != 'e' && ch != 's');
- X }
- X
- Xmail_to_author_done:
- X unlink (nam);
- X set_tin_uid_gid ();
- X
- X return (redraw_screen);
- X}
- X
- X/*
- X * Read a file grabbing the address given for To: and
- X * sticking it in mail_to
- X */
- X
- Xvoid find_new_to (nam, mail_to)
- X char *nam;
- X char *mail_to;
- X{
- X FILE *fp;
- X char buf[LEN+1];
- X char buf2[LEN+1];
- X char new_mail_to[LEN+1];
- X char *p;
- X
- X *new_mail_to = '\0';
- X
- X if ((fp = fopen(nam, "r")) == NULL) {
- X fprintf(stderr, txt_cannot_open, nam);
- X return;
- X }
- X
- X while (fgets(buf, 1024, fp) != NULL) {
- X for (p = buf; *p && *p != '\n'; p++)
- X continue;
- X *p = '\0';
- X
- X if (*buf == '\0')
- X break;
- X
- X if (strncmp(buf, "To: ", 4) == 0) {
- X strncpy(buf2, &buf[4], LEN);
- X buf2[LEN-1] = '\0';
- X yank_to_addr(buf2, new_mail_to);
- X } else if (strncmp(buf, "Cc: ", 4) == 0) {
- X strncpy(buf2, &buf[4], LEN);
- X buf2[LEN-1] = '\0';
- X yank_to_addr(buf2, new_mail_to);
- X }
- X }
- X
- X fclose (fp);
- X if (new_mail_to[0] == ' ')
- X my_strncpy (mail_to, &new_mail_to[1], LEN);
- X else
- X my_strncpy (mail_to, new_mail_to, LEN);
- X}
- X
- X
- Xint cancel_article ()
- X{
- X char ch, ch_default = 'c';
- X char buf[LEN];
- X char cancel[LEN];
- X FILE *fp;
- X int redraw_screen = FALSE;
- X
- X start_line_offset = 4;
- X
- X clear_message ();
- X
- X set_real_uid_gid ();
- X
- X sprintf (cancel, "%s/.cancel", homedir);
- X if ((fp = fopen (cancel, "w")) == NULL) {
- X error_message (txt_cannot_open, cancel);
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X }
- X chmod (cancel, 0600);
- X
- X fprintf (fp, "Subject: cancel %s\n", note_h_messageid);
- X if (*note_h_followup) {
- X fprintf (fp, "Newsgroups: %s\n", note_h_followup);
- X } else {
- X fprintf (fp, "Newsgroups: %s\n", note_h_newsgroups);
- X }
- X fprintf (fp, "Control: cancel %s\n", note_h_messageid);
- X if (*my_org) {
- X fprintf (fp, "Organization: %s\n", my_org);
- X start_line_offset++;
- X }
- X if (*reply_to) {
- X fprintf (fp, "Reply-To: %s\n", reply_to);
- X start_line_offset++;
- X }
- X fputs ("\n", fp);
- X
- X fprintf (fp, "Article cancelled from within tin\n");
- X
- X add_signature (fp, TRUE);
- X fclose (fp);
- X
- X while (1) {
- X do {
- X my_strncpy (buf, note_h_subj, COLS-30);
- X sprintf (msg, "%s [%s]: %c", txt_abort_edit_cancel, buf, ch_default);
- X wait_message (msg);
- X MoveCursor (LINES, (int) strlen (msg)-1);
- X if ((ch = ReadCh ()) == CR)
- X ch = ch_default;
- X } while (ch != 'a' && ch != 'e' && ch != 'c');
- X
- X switch (ch) {
- X case 'e':
- X invoke_editor (cancel);
- X redraw_screen = TRUE;
- X break;
- X
- X case 'a':
- X unlink (cancel);
- X clear_message ();
- X set_tin_uid_gid ();
- X return (redraw_screen);
- X
- X case 'c':
- X wait_message (txt_cancelling);
- X sprintf (buf, "%s/inews -h < %s", INEWSDIR, cancel);
- X if (invoke_cmd (buf)) {
- X info_message (txt_art_cancelled);
- X goto cancel_article_done;
- X } else {
- X error_message (txt_command_failed_s, buf);
- X break;
- X }
- X }
- X }
- X
- Xcancel_article_done:
- X unlink (cancel);
- X set_tin_uid_gid ();
- X
- X return (redraw_screen);
- X}
- SHAR_EOF
- $TOUCH -am 0923175591 post.c &&
- chmod 0600 post.c ||
- echo "restore of post.c failed"
- set `wc -c post.c`;Wc_c=$1
- if test "$Wc_c" != "17061"; then
- echo original size 17061, current size $Wc_c
- fi
- # ============= prompt.c ==============
- echo "x - extracting prompt.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > prompt.c &&
- X/*
- X * Project : tin - a visual threaded usenet newsreader
- X * Module : prompt.c
- X * Author : R.Skrenta / I.Lea
- X * Created : 01-04-91
- X * Updated : 10-08-91
- X * Release : 1.0
- X * Notes :
- X * Copyright : (c) Copyright 1991 by Rich Skrenta & Iain Lea
- X * You may freely copy or redistribute this software,
- X * so long as there is no profit made from its use, sale
- X * trade or reproduction. You may not change this copy-
- X * right notice, and it must be included in any copy made
- X */
- X
- X#include "tin.h"
- X
- X/*
- X * parse_num
- X * get a number from the user
- X * Return -1 if missing or bad number typed
- X */
- X
- Xint parse_num (ch, prompt)
- X char ch;
- X char *prompt;
- X{
- X char buf[40];
- X int len;
- X int i;
- X int num;
- X
- X MoveCursor (LINES,0);
- X printf ("%s %c",prompt,ch);
- X fflush (stdout);
- X buf[0] = ch;
- X buf[1] = '\0';
- X len = 1;
- X ch = ReadCh ();
- X while (ch != '\n' && ch != '\r') {
- X if (ch == 8 || ch == 127) {
- X if (len) {
- X len--;
- X buf[len] = '\0';
- X putchar ('\b');
- X putchar (' ');
- X putchar ('\b');
- X } else {
- X MoveCursor (LINES, 0);
- X CleartoEOLN ();
- X return (-1);
- X }
- X } else if (ch == 21) { /* control-U */
- X for (i = len ; i>0 ; i--) {
- X putchar ('\b');
- X putchar (' ');
- X putchar ('\b');
- X }
- X buf[0] = '\0';
- X len = 0;
- X } else if (ch >= '0' && ch <= '9' && len < 4) {
- X buf[len++] = ch;
- X buf[len] = '\0';
- X putchar (ch);
- X } else
- X putchar (7);
- X fflush (stdout);
- X ch = ReadCh ();
- X }
- X
- X MoveCursor (LINES, 0);
- X CleartoEOLN ();
- X
- X if (len) {
- X num = atoi (buf);
- X return (num);
- X } else
- X return(-1);
- X}
- X
- X
- X/*
- X * parse_string
- X * get a string from the user
- X * Return TRUE if a valid string was typed, FALSE otherwise
- X */
- X
- Xint parse_string (prompt, buf)
- X char *prompt;
- X char *buf;
- X{
- X int len;
- X int i;
- X char ch;
- X
- X clear_message();
- X MoveCursor(LINES,0);
- X printf("%s", prompt);
- X fflush(stdout);
- X
- X buf[0] = '\0';
- X len = 0;
- X ch = ReadCh();
- X while (ch != '\n' && ch != '\r') {
- X if (ch == 8 || ch == 127) {
- X if (len) {
- X len--;
- X buf[len] = '\0';
- X putchar('\b');
- X putchar(' ');
- X putchar('\b');
- X } else {
- X MoveCursor(LINES, 0);
- X CleartoEOLN();
- X return(FALSE);
- X }
- X } else if (ch == 21) { /* control-U */
- X for (i = len;i>0;i--) {
- X putchar('\b');
- X putchar(' ');
- X putchar('\b');
- X }
- X buf[0] = '\0';
- X len = 0;
- X } else if (ch >= ' ' && len < 60) {
- X buf[len++] = ch;
- X buf[len] = '\0';
- X putchar (ch);
- X } else
- X putchar(7);
- X fflush(stdout);
- X ch = ReadCh();
- X }
- X MoveCursor(LINES,0);
- X CleartoEOLN();
- X
- X return TRUE;
- X}
- X
- X
- Xint prompt_yn (line, prompt, default_ch)
- X int line;
- X char *prompt;
- X char default_ch;
- X{
- X char ch;
- X
- X MoveCursor (line, 0);
- X CleartoEOLN ();
- X printf ("%s%c", prompt, default_ch);
- X fflush (stdout);
- X MoveCursor (line, (int) strlen (prompt));
- X
- X if ((ch = ReadCh()) == CR) {
- X ch = default_ch;
- X }
- X
- X if (line == LINES) {
- X clear_message();
- X } else {
- X MoveCursor (line, (int) strlen (prompt));
- X printf ("%c", ch);
- X fflush (stdout);
- X }
- X
- X return (ch == 'y' ? TRUE : FALSE);
- X}
- X
- X
- Xvoid continue_prompt()
- X{
- X info_message(txt_hit_any_key);
- X ReadCh();
- X}
- X
- X
- SHAR_EOF
- $TOUCH -am 0923175591 prompt.c &&
- chmod 0600 prompt.c ||
- echo "restore of prompt.c failed"
- set `wc -c prompt.c`;Wc_c=$1
- if test "$Wc_c" != "3098"; then
- echo original size 3098, current size $Wc_c
- fi
- # ============= rcfile.c ==============
- echo "x - extracting rcfile.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > rcfile.c &&
- X/*
- X * Project : tin - a visual threaded usenet newsreader
- X * Module : rcfile.c
- X * Author : I.Lea
- X * Created : 01-04-91
- X * Updated : 16-09-91
- X * Release : 1.0
- X * Notes :
- X * Copyright : (c) Copyright 1991 by Iain Lea
- X * You may freely copy or redistribute this software,
- X * so long as there is no profit made from its use, sale
- X * trade or reproduction. You may not change this copy-
- X * right notice, and it must be included in any copy made
- X */
- X
- X#include "tin.h"
- X
- X#define COL2 COLS/2
- X
- Xextern char index_file[LEN+1];
- X
- X/*
- X * read_rcfile - read defaults from ~/.tin/tinrc
- X */
- X
- Xint read_rcfile ()
- X{
- X char buf[LEN+1];
- X FILE *fp;
- X
- X if ((fp = fopen (rcfile, "r")) != NULL) {
- X while (fgets (buf, sizeof buf, fp) != NULL) {
- X if (buf[0] != '#') {
- X if (strncmp (buf, "save_archive=", 13) == 0) {
- X save_archive_name = (strncmp (&buf[13], "ON", 2) == 0 ? TRUE : FALSE);
- X } else if (strncmp (buf, "save_separate=", 14) == 0) {
- X save_separate = (strncmp (&buf[14], "ON", 2) == 0 ? TRUE : FALSE);
- X } else if (strncmp (buf, "mark_saved_read=", 16) == 0) {
- X mark_saved_read = (strncmp (&buf[16], "ON", 2) == 0 ? TRUE : FALSE);
- X } else if (strncmp (buf, "kill_articles=", 14) == 0) {
- X kill_articles = (strncmp (&buf[14], "ON", 2) == 0 ? TRUE : FALSE);
- X } else if (strncmp (buf, "show_author=", 12) == 0) {
- X show_author = (strncmp (&buf[12], "ON", 2) == 0 ? TRUE : FALSE);
- X } else if (strncmp (buf, "draw_arrow=", 11) == 0) {
- X draw_arrow_mark = (strncmp (&buf[11], "ON", 2) == 0 ? TRUE : FALSE);
- X if (draw_arrow_mark == FALSE && inverse_okay == FALSE) {
- X inverse_okay = TRUE;
- X }
- X } else if (strncmp (buf, "print_header=", 13) == 0) {
- X print_header = (strncmp (&buf[13], "ON", 2) == 0 ? TRUE : FALSE);
- X } else if (strncmp (buf, "pos_first_unread=", 17) == 0) {
- X pos_first_unread = (strncmp (&buf[17], "ON", 2) == 0 ? TRUE : FALSE);
- X } else if (strncmp (buf, "post_process_type=", 18) == 0) {
- X post_proc_type = atoi (&buf[18]);
- X switch (post_proc_type) {
- X case POST_PROC_NONE:
- X proc_ch_default = 'n';
- X break;
- X case POST_PROC_SHAR:
- X proc_ch_default = 's';
- X break;
- X case POST_PROC_UUDECODE:
- X proc_ch_default = 'u';
- X break;
- X case POST_PROC_UUD_LST_ZOO:
- X proc_ch_default = 'U';
- X break;
- X case POST_PROC_UUD_EXT_ZOO:
- X proc_ch_default = 'U';
- X break;
- X case POST_PROC_PATCH:
- X proc_ch_default = 'p';
- X break;
- X }
- X } else if (strncmp (buf, "sort_article_type=", 18) == 0) {
- X sort_art_type = atoi (&buf[18]);
- X } else if (strncmp (buf, "savedir=", 8) == 0) {
- X strncpy (savedir, &buf[8], LEN);
- X savedir[strlen (savedir) - 1] = '\0';
- X if (savedir[0] == '.' && strlen (savedir) == 1) {
- X#ifdef BSD
- X getwd (buf);
- X#else
- X getcwd (buf, LEN);
- X#endif
- X my_strncpy (savedir, buf, LEN);
- X }
- X } else if (strncmp (buf, "maildir=", 8) == 0) {
- X strncpy (maildir, &buf[8], LEN);
- X maildir[strlen (maildir) - 1] = '\0';
- X } else if (strncmp (buf, "printer=", 8) == 0) {
- X strncpy (printer, &buf[8], LEN);
- X printer[strlen (printer) - 1] = '\0';
- X } else if (strncmp (buf, "spooldir=", 9) == 0) {
- X strncpy (spooldir, &buf[9], LEN);
- X spooldir[strlen (spooldir) - 1] = '\0';
- X } else if (strncmp (buf, "signature=", 10) == 0) {
- X strncpy (signature, &buf[10], LEN);
- X signature[strlen (signature) - 1] = '\0';
- X } else if (strncmp (buf, "sig=", 4) == 0) {
- X strncpy (sig, &buf[4], LEN);
- X sig[strlen (sig) - 1] = '\0';
- X }
- X }
- X }
- X fclose (fp);
- X return TRUE;
- X }
- X return FALSE;
- X}
- X
- X/*
- X * write_rcfile - write defaults to ~/.tin/tinrc
- X */
- X
- Xvoid write_rcfile ()
- X{
- X FILE *fp;
- X
- X set_real_uid_gid ();
- X
- X if ((fp = fopen (rcfile, "w")) != NULL) {
- X wait_message (txt_saving);
- X
- X fprintf (fp, "# if ON articles/threads with Archive-name: in mail header will\n");
- X fprintf (fp, "# be automatically saved with the Archive-name & part/patch no.\n");
- X fprintf (fp, "save_archive=%s\n\n", (save_archive_name ? "ON" : "OFF"));
- X fprintf (fp, "# if ON articles of a threads will be saved to separate files\n");
- X fprintf (fp, "# otherwise the whole thread will be saved to one file\n");
- X fprintf (fp, "save_separate=%s\n\n", (save_separate ? "ON" : "OFF"));
- X fprintf (fp, "# if ON mark articles that are saved as read\n");
- X fprintf (fp, "mark_saved_read=%s\n\n", (mark_saved_read ? "ON" : "OFF"));
- X fprintf (fp, "# if ON show Subject & From otherwise just Subject\n");
- X fprintf (fp, "show_author=%s\n\n", (show_author ? "ON" : "OFF"));
- X fprintf (fp, "# if ON use -> otherwise highlighted bar for selection\n");
- X fprintf (fp, "draw_arrow=%s\n\n", (draw_arrow_mark ? "ON" : "OFF"));
- X fprintf (fp, "# if ON kill articles that match kill file\n");
- X fprintf (fp, "kill_articles=%s\n\n", (kill_articles ? "ON" : "OFF"));
- X fprintf (fp, "# if ON print all of mail header otherwise Subject: & From: lines\n");
- X fprintf (fp, "print_header=%s\n\n", (print_header ? "ON" : "OFF"));
- X fprintf (fp, "# if ON put cursor at first unread art in group otherwise last art\n");
- X fprintf (fp, "pos_first_unread=%s\n\n", (pos_first_unread ? "ON" : "OFF"));
- X fprintf (fp, "# type of post processing to perform after saving articles.\n");
- X fprintf (fp, "# 0) none 1) shar 2) uudecode 3) uud & list zoo 4) uud & extract zoo 5) patch.\n");
- X fprintf (fp, "post_process_type=%d\n\n", post_proc_type);
- X fprintf (fp, "# sort articles by 0) nothing 1) Subject (descending) 2) Subject (ascending)\n");
- X fprintf (fp, "# 3) From (descend) 4) From (ascend) 5) Date (descend) 6) Date (ascend)\n");
- X fprintf (fp, "sort_article_type=%d\n\n", sort_art_type);
- X fprintf (fp, "# (-d) directory where articles/threads are saved\n");
- X fprintf (fp, "savedir=%s\n\n", savedir);
- X fprintf (fp, "# (-M) directory where articles/threads are saved in mailbox format\n");
- X fprintf (fp, "maildir=%s\n\n", maildir);
- X fprintf (fp, "# (-p) print program with parameters used to print articles/threads\n");
- X fprintf (fp, "printer=%s\n\n", printer);
- X fprintf (fp, "# (-S) directory where news is spooled\n");
- X fprintf (fp, "spooldir=%s\n\n", spooldir);
- X
- X fprintf (fp, "# .signature file used for replies, followups\n");
- X fprintf (fp, "signature=%s\n\n", signature);
- X fprintf (fp, "# .Sig file used for postings\n");
- X fprintf (fp, "sig=%s\n\n", sig);
- X
- X fclose (fp);
- X chmod (rcfile, 0600);
- X }
- X set_tin_uid_gid ();
- X}
- X
- X/*
- X * options menu so that the user can dynamically change parameters
- X */
- X
- Xint change_rcfile (group, kill_at_once)
- X char *group;
- X int kill_at_once;
- X{
- X char *str;
- X int ch;
- X int kill_changed = FALSE;
- X int orig_kill_state;
- X int option;
- X int ret_code = NO_KILLING;
- X#ifdef SIGTSTP
- X void (*susp)();
- X
- X if (do_sigtstp) {
- X#ifdef POSIX_JOB_CONTROL
- X sigemptyset (&rcfile_act.sa_mask);
- X rcfile_act.sa_flags = SA_RESTART | SA_RESETHAND;
- X rcfile_act.sa_handler = SIG_DFL;
- X sigaction (SIGTSTP, &rcfile_act, &old_act);
- X#else
- X susp = signal (SIGTSTP, SIG_DFL);
- X#endif
- X }
- X#endif
- X
- X show_rcfile_menu ();
- X
- X while (1) {
- X
- X#ifdef SIGTSTP
- X if (do_sigtstp) {
- X#ifdef POSIX_JOB_CONTROL
- X sigemptyset (&rcfile_act.sa_mask);
- X rcfile_act.sa_flags = SA_RESTART | SA_RESETHAND;
- X rcfile_act.sa_handler = rcfile_suspend;
- X sigaction (SIGTSTP, &rcfile_act, 0L);
- X#else
- X signal (SIGTSTP, rcfile_suspend);
- X#endif
- X }
- X#endif
- X MoveCursor (LINES, 0);
- X ch = ReadCh ();
- X if (ch >= '1' && ch <= '9') {
- X option = parse_num (ch, "Enter option number> ");
- X } else {
- X option = 0;
- X }
- X#ifdef SIGTSTP
- X if (do_sigtstp) {
- X#ifdef POSIX_JOB_CONTROL
- X sigemptyset (&rcfile_act.sa_mask);
- X rcfile_act.sa_flags = SA_RESTART | SA_RESETHAND;
- X rcfile_act.sa_handler = SIG_IGN;
- X sigaction (SIGTSTP, &rcfile_act, 0L);
- X#else
- X signal (SIGTSTP, SIG_IGN);
- X#endif
- X }
- X#endif
- X switch (option) {
- X case 0:
- X write_rcfile ();
- X if (kill_changed) {
- X if (kill_at_once) {
- X if (kill_articles) {
- X read_kill_file ();
- X if (kill_any_articles (group)) {
- X reload_index_file (group, TRUE); /* kill arts */
- X }
- X } else {
- X reload_index_file (group, FALSE); /* add killed arts */
- X }
- X }
- X ret_code = KILLING;
- X }
- X clear_note_area ();
- X#ifdef SIGTSTP
- X if (do_sigtstp) {
- X#ifdef POSIX_JOB_CONTROL
- X sigemptyset (&rcfile_act.sa_mask);
- X rcfile_act.sa_flags = SA_RESTART | SA_RESETHAND;
- X rcfile_act.sa_handler = SIG_IGN;
- X sigaction (SIGTSTP, &old_act, 0L);
- X#else
- X signal (SIGTSTP, susp);
- X#endif
- X }
- X#endif
- X return ret_code;
- X
- X case 1: /* auto save */
- X show_menu_help (txt_help_autosave);
- X do {
- X MoveCursor (INDEX_TOP, (int) strlen (txt_opt_autosave));
- X if ((ch = ReadCh()) == ' ') {
- X save_archive_name = !save_archive_name;
- X printf ("%s", (save_archive_name ? "ON " : "OFF"));
- X fflush(stdout);
- X }
- X } while (ch != CR);
- X break;
- X
- X case 2: /* save sperate */
- X show_menu_help (txt_help_save_separate);
- X do {
- X MoveCursor (INDEX_TOP, COL2 + (int) strlen (txt_opt_save_separate));
- X if ((ch = ReadCh()) == ' ') {
- X save_separate = !save_separate;
- X printf ("%s", (save_separate ? "ON " : "OFF"));
- X fflush(stdout);
- X }
- X } while (ch != CR);
- X break;
- X
- X case 3: /* mark saved articles read */
- X show_menu_help (txt_help_mark_saved_read);
- X do {
- X MoveCursor (INDEX_TOP+2, (int) strlen (txt_opt_mark_saved_read));
- X if ((ch = ReadCh()) == ' ') {
- X mark_saved_read = !mark_saved_read;
- X printf ("%s", (mark_saved_read ? "ON " : "OFF"));
- X fflush(stdout);
- X }
- X } while (ch != CR);
- X break;
- X
- X case 4: /* kill articles */
- X orig_kill_state = kill_articles;
- X show_menu_help (txt_help_kill_articles);
- X do {
- X MoveCursor (INDEX_TOP+2, COL2 + (int) strlen (txt_opt_kill_articles));
- X if ((ch = ReadCh()) == ' ') {
- X kill_articles = !kill_articles;
- X kill_changed = (kill_articles != orig_kill_state ? TRUE : FALSE);
- X printf ("%s", (kill_articles ? "ON " : "OFF"));
- X fflush(stdout);
- X }
- X } while (ch != CR);
- X break;
- X
- X case 5: /* show subject & author / subject only */
- X show_menu_help (txt_help_show_author);
- X do {
- X MoveCursor (INDEX_TOP+4, (int) strlen (txt_opt_show_author));
- X if ((ch = ReadCh()) == ' ') {
- X show_author = !show_author;
- X printf ("%s", (show_author ? "ON " : "OFF"));
- X fflush(stdout);
- X }
- X } while (ch != CR);
- X break;
- X
- X case 6: /* draw -> / highlighted bar */
- X show_menu_help (txt_help_draw_arrow);
- X do {
- X MoveCursor (INDEX_TOP+4, COL2 + (int) strlen (txt_opt_draw_arrow));
- X if ((ch = ReadCh()) == ' ') {
- X draw_arrow_mark = !draw_arrow_mark;
- X printf ("%s", (draw_arrow_mark ? "ON " : "OFF"));
- X fflush(stdout);
- X }
- X } while (ch != CR);
- X if (draw_arrow_mark == FALSE && inverse_okay == FALSE) {
- X inverse_okay = TRUE;
- X }
- X break;
- X
- X case 7: /* print header */
- X show_menu_help (txt_help_print_header);
- X do {
- X MoveCursor (INDEX_TOP+6, (int) strlen (txt_opt_print_header));
- X if ((ch = ReadCh()) == ' ') {
- X print_header = !print_header;
- X printf ("%s", (print_header ? "ON " : "OFF"));
- X fflush(stdout);
- X }
- X } while (ch != CR);
- X break;
- X
- X case 8: /* position cursor at first / last unread art */
- X show_menu_help (txt_help_pos_first_unread);
- X do {
- X MoveCursor (INDEX_TOP+6, COL2 + (int) strlen (txt_opt_pos_first_unread));
- X if ((ch = ReadCh()) == ' ') {
- X pos_first_unread = !pos_first_unread;
- X printf ("%s", (pos_first_unread ? "ON " : "OFF"));
- X fflush(stdout);
- X }
- X } while (ch != CR);
- X break;
- X
- X case 9:
- X show_menu_help (txt_help_post_proc_type);
- SHAR_EOF
- echo "End of tin1.02 part 6"
- echo "File rcfile.c is continued in part 7"
- echo "7" > shar3_seq_.tmp
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-