home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume23
/
tin
/
part07
< prev
next >
Wrap
Text File
|
1991-09-25
|
51KB
|
2,230 lines
Newsgroups: comp.sources.misc
From: iain@estevax.uucp (Iain J. Lea)
Subject: v23i021: tin - threaded full screen newsreader v1.0 PL2, Part07/09
Message-ID: <1991Sep25.205305.2189@sparky.imd.sterling.com>
X-Md4-Signature: 481f1a702446e7f5f78846924dc4af51
Date: Wed, 25 Sep 1991 20:53:05 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: iain@estevax.uucp (Iain J. Lea)
Posting-number: Volume 23, Issue 21
Archive-name: tin/part07
Environment: BSD, SCO, ISC, SUNOS, SYSVR3, SYSVR4, ULTRIX, XENIX
#!/bin/sh
# this is tin.shar.07 (part 7 of tin1.02)
# do not concatenate these parts, unpack them in order with /bin/sh
# file rcfile.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" != 7; then
echo "Please unpack part $Scheck next!"
exit 1
else
exit 0
fi
) < shar3_seq_.tmp || exit 1
echo "x - Continuing file rcfile.c"
sed 's/^X//' << 'SHAR_EOF' >> rcfile.c &&
X do {
X MoveCursor (INDEX_TOP+8, (int) strlen (txt_opt_process_type));
X if ((ch = ReadCh()) == ' ') {
X if (post_proc_type + 1 > POST_PROC_PATCH) {
X post_proc_type = POST_PROC_NONE;
X } else {
X post_proc_type++;
X }
X switch (post_proc_type) {
X case POST_PROC_NONE:
X str = txt_post_process_none;
X proc_ch_default = 'n';
X break;
X case POST_PROC_SHAR:
X str = txt_post_process_sh;
X proc_ch_default = 's';
X break;
X case POST_PROC_UUDECODE:
X str = txt_post_process_uudecode;
X proc_ch_default = 'u';
X break;
X case POST_PROC_UUD_LST_ZOO:
X str = txt_post_process_uud_lst_zoo;
X proc_ch_default = 'U';
X break;
X case POST_PROC_UUD_EXT_ZOO:
X str = txt_post_process_uud_ext_zoo;
X proc_ch_default = 'U';
X break;
X case POST_PROC_PATCH:
X str = txt_post_process_patch;
X proc_ch_default = 'p';
X break;
X }
X CleartoEOLN ();
X printf ("%s", str);
X fflush(stdout);
X }
X } while (ch != CR);
X break;
X case 10:
X show_menu_help (txt_help_sort_type);
X do {
X MoveCursor (INDEX_TOP+10, (int) strlen (txt_opt_sort_type));
X if ((ch = ReadCh()) == ' ') {
X if (sort_art_type + 1 > SORT_BY_DATE_ASCEND) {
X sort_art_type = SORT_BY_NOTHING;
X } else {
X sort_art_type++;
X }
X switch (sort_art_type) {
X case SORT_BY_NOTHING:
X str = txt_sort_by_nothing;
X break;
X case SORT_BY_SUBJ_DESCEND:
X str = txt_sort_by_subj_descend;
X break;
X case SORT_BY_SUBJ_ASCEND:
X str = txt_sort_by_subj_ascend;
X break;
X case SORT_BY_FROM_DESCEND:
X str = txt_sort_by_from_descend;
X break;
X case SORT_BY_FROM_ASCEND:
X str = txt_sort_by_from_ascend;
X break;
X case SORT_BY_DATE_DESCEND:
X str = txt_sort_by_date_descend;
X break;
X case SORT_BY_DATE_ASCEND:
X str = txt_sort_by_date_ascend;
X break;
X }
X CleartoEOLN ();
X printf ("%s", str);
X fflush(stdout);
X }
X } while (ch != CR);
X break;
X case 11:
X show_menu_help (txt_help_savedir);
X parse_menu_string (INDEX_TOP+12, (int) strlen (txt_opt_savedir), savedir);
X expand_rel_abs_pathname (INDEX_TOP+12, (int) strlen (txt_opt_savedir), savedir);
X break;
X case 12:
X show_menu_help (txt_help_maildir);
X parse_menu_string (INDEX_TOP+14, (int) strlen (txt_opt_maildir), maildir);
X expand_rel_abs_pathname (INDEX_TOP+14, (int) strlen (txt_opt_maildir), maildir);
X break;
X case 13:
X show_menu_help (txt_help_printer);
X parse_menu_string (INDEX_TOP+16, (int) strlen (txt_opt_printer), printer);
X expand_rel_abs_pathname (INDEX_TOP+16, (int) strlen (txt_opt_printer), printer);
X break;
X }
X show_menu_help (txt_select_rcfile_option);
X }
X}
X
X
Xvoid show_rcfile_menu ()
X{
X char *str;
X
X ClearScreen ();
X
X center_line (0, TRUE, txt_options_menu);
X
X MoveCursor (INDEX_TOP, 0);
X printf ("%s%s\r\n\r\n", txt_opt_autosave, (save_archive_name ? "ON " : "OFF"));
X printf ("%s%s\r\n\r\n", txt_opt_mark_saved_read, (mark_saved_read ? "ON " : "OFF"));
X printf ("%s%s\r\n\r\n", txt_opt_show_author, (show_author ? "ON " : "OFF"));
X printf ("%s%s", txt_opt_print_header, (print_header ? "ON " : "OFF"));
X
X MoveCursor(INDEX_TOP, COL2);
X printf ("%s%s", txt_opt_save_separate, (save_separate ? "ON " : "OFF"));
X MoveCursor(INDEX_TOP+2, COL2);
X printf ("%s%s", txt_opt_kill_articles, (kill_articles ? "ON " : "OFF"));
X MoveCursor(INDEX_TOP+4, COL2);
X printf ("%s%s", txt_opt_draw_arrow, (draw_arrow_mark ? "ON " : "OFF"));
X MoveCursor(INDEX_TOP+6, COL2);
X printf ("%s%s", txt_opt_pos_first_unread, (pos_first_unread ? "ON " : "OFF"));
X
X MoveCursor(INDEX_TOP+8, 0);
X switch (post_proc_type) {
X case POST_PROC_NONE:
X str = txt_post_process_none;
X break;
X case POST_PROC_SHAR:
X str = txt_post_process_sh;
X break;
X case POST_PROC_UUDECODE:
X str = txt_post_process_uudecode;
X break;
X case POST_PROC_UUD_LST_ZOO:
X str = txt_post_process_uud_lst_zoo;
X break;
X case POST_PROC_UUD_EXT_ZOO:
X str = txt_post_process_uud_ext_zoo;
X break;
X case POST_PROC_PATCH:
X str = txt_post_process_patch;
X break;
X }
X printf ("%s%s\r\n\r\n", txt_opt_process_type, str);
X
X MoveCursor(INDEX_TOP+10, 0);
X switch (sort_art_type) {
X case SORT_BY_NOTHING:
X str = txt_sort_by_nothing;
X break;
X case SORT_BY_SUBJ_DESCEND:
X str = txt_sort_by_subj_descend;
X break;
X case SORT_BY_SUBJ_ASCEND:
X str = txt_sort_by_subj_ascend;
X break;
X case SORT_BY_FROM_DESCEND:
X str = txt_sort_by_from_descend;
X break;
X case SORT_BY_FROM_ASCEND:
X str = txt_sort_by_from_ascend;
X break;
X case SORT_BY_DATE_DESCEND:
X str = txt_sort_by_date_descend;
X break;
X case SORT_BY_DATE_ASCEND:
X str = txt_sort_by_date_ascend;
X break;
X }
X printf ("%s%s\r\n\r\n", txt_opt_sort_type, str);
X
X printf ("%s%s\r\n\r\n", txt_opt_savedir, savedir);
X printf ("%s%s\r\n\r\n", txt_opt_maildir, maildir);
X printf ("%s%s\r\n\r\n", txt_opt_printer, printer);
X fflush(stdout);
X
X show_menu_help (txt_select_rcfile_option);
X MoveCursor (LINES, 0);
X}
X
X/*
X * parse_menu_string
X * get a string from the user
X * Return TRUE if a valid string was typed, FALSE otherwise
X */
X
Xvoid parse_menu_string (line, col, var)
X int line;
X int col;
X char *var;
X{
X char buf[LEN+1];
X char ch;
X int len;
X int i;
X
X MoveCursor (line, col);
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 strcpy (var, buf);
X MoveCursor(line, col);
X CleartoEOLN();
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
X if (buf[0]) {
X strcpy (var, buf);
X }
X}
X
X/*
X * expand ~/News to /usr/username/News and print to screen
X */
X
Xvoid expand_rel_abs_pathname (line, col, str)
X int line;
X int col;
X char *str;
X{
X char buf[LEN+1];
X
X if (str[0] == '~') {
X if (strlen (str) == 1) {
X strcpy (str, homedir);
X } else {
X sprintf (buf, "%s%s", homedir, str+1);
X strcpy (str, buf);
X }
X }
X MoveCursor (line, col);
X CleartoEOLN ();
X puts (str);
X fflush (stdout);
X}
X
X/*
X * show_menu_help
X */
X
Xvoid show_menu_help (help_message)
X char *help_message;
X{
X MoveCursor (LINES-2, 0);
X CleartoEOLN ();
X center_line (LINES-2, FALSE, help_message);
X}
SHAR_EOF
echo "File rcfile.c is complete" &&
$TOUCH -am 0923175591 rcfile.c &&
chmod 0600 rcfile.c ||
echo "restore of rcfile.c failed"
set `wc -c rcfile.c`;Wc_c=$1
if test "$Wc_c" != "18379"; then
echo original size 18379, current size $Wc_c
fi
# ============= save.c ==============
echo "x - extracting save.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > save.c &&
X/*
X * Project : tin - a visual threaded usenet newsreader
X * Module : save.c
X * Author : R.Skrenta / I.Lea
X * Created : 01-04-91
X * Updated : 22-09-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#define INITIAL 1
X#define MIDDLE 2
X#define OFF 3
X#define END 4
X
Xint create_subdir = TRUE;
X
Xstruct save_t *save;
Xint save_num=0;
Xint max_save;
X
X/*
X * types of archive programs
X * 0=archiver, 1=extension, 2=extract option, 3=list option
X */
X
Xstruct archiver_t {
X char *name;
X char *ext;
X char *extract;
X char *list;
X};
X
Xstruct archiver_t archiver[] = {
X { "", "", "", "" },
X { "", "", "", "" },
X { "", "", "", "" },
X { "zoo", "zoo", "-extract", "-list" },
X { (char *) 0, (char *) 0, (char *) 0, (char *) 0 }
X};
X
Xextern char *glob_group;
Xextern char note_h_path[LEN+1]; /* Path: */
Xextern char note_h_date[LEN+1]; /* Date: */
Xextern FILE *note_fp; /* the body of the current article */
Xextern int index_point;
Xextern int note_end;
Xextern int note_page;
Xextern long note_mark[MAX_PAGES];
X
X
Xint save_art_to_file (respnum, index, mailbox, filename)
X int respnum;
X int index;
X int mailbox;
X char *filename;
X{
X char file[LEN+1];
X char save_art_info[LEN+1];
X FILE *fp;
X int is_mailbox = FALSE;
X int i = 0, ret_code = FALSE;
X
X if (filename) {
X my_strncpy (file, filename, LEN);
X is_mailbox = mailbox;
X i = index;
X } else if (save_archive_name && arts[respnum].archive) {
X my_strncpy (file, arts[respnum].archive, LEN);
X }
X
X if (! append_to_existing_file (i)) {
X save[i].saved = FALSE;
X info_message (txt_art_not_saved);
X sleep (1);
X return (ret_code);
X }
X
X set_real_uid_gid ();
X
X if ((fp = fopen (save_filename (i), "a+")) == NULL) {
X save[i].saved = FALSE;
X info_message (txt_art_not_saved);
X set_tin_uid_gid ();
X return (ret_code);
X }
X
X if (! filename) {
X wait_message (txt_saving);
X }
X
X fprintf(fp, "From %s %s\n", note_h_path, note_h_date);
X
X if (fseek(note_fp, 0L, 0) == -1) {
X error_message ("fseek() error on [%s]", arts[respnum].subject);
X }
X copy_fp(note_fp, fp, "");
X fputs("\n", fp);
X fclose(fp);
X fseek(note_fp, note_mark[note_page], 0);
X
X save[i].saved = TRUE;
X
X if (mark_saved_read) {
X arts[respnum].unread = ART_READ;
X }
X
X set_tin_uid_gid ();
X
X if (! filename) {
X if (is_mailbox) {
X sprintf (save_art_info, txt_saved_to_mailbox, get_first_savefile ());
X } else {
X sprintf (save_art_info, txt_art_saved_to, get_first_savefile ());
X }
X info_message(save_art_info);
X }
X return TRUE;
X}
X
X
Xint save_thread_to_file (is_mailbox, group_path)
X int is_mailbox;
X char *group_path;
X{
X char save_thread_info[LEN+1];
X char *first_savefile;
X FILE *fp;
X int count = 0;
X int i, ret_code = FALSE;
X
X set_real_uid_gid ();
X
X for (i=0 ; i < save_num ; i++) {
X if (! append_to_existing_file (i)) {
X save[i].saved = FALSE;
X info_message (txt_art_not_saved);
X sleep (1);
X continue;
X }
X sprintf (msg, "%s%d", txt_saving, ++count);
X wait_message (msg);
X
X if ((fp = fopen (save_filename (i), "a+")) == NULL) {
X info_message (txt_thread_not_saved);
X set_tin_uid_gid ();
X return (ret_code);
X }
X
X open_note (arts[save[i].index].artnum, group_path);
X fprintf (fp, "From %s %s\n", note_h_path, note_h_date);
X fseek (note_fp, 0L, 0);
X copy_fp (note_fp, fp, "");
X note_cleanup ();
X save[i].saved = TRUE;
X
X if (mark_saved_read) {
X arts[save[i].index].unread = ART_READ;
X }
X
X fclose (fp);
X }
X set_tin_uid_gid ();
X
X if (! (first_savefile = get_first_savefile ())) {
X info_message (txt_thread_not_saved);
X } else {
X if (is_mailbox) {
X sprintf (save_thread_info, txt_saved_to_mailbox, first_savefile);
X } else {
X if (save_num == 1) {
X sprintf (save_thread_info, txt_art_saved_to, first_savefile);
X } else {
X if (save_separate) {
X sprintf (save_thread_info, txt_thread_saved_to_many,
X first_savefile, get_last_savefile ());
X } else {
X sprintf (save_thread_info, txt_thread_saved_to,
X first_savefile);
X }
X }
X free (first_savefile);
X first_savefile = (char *) 0;
X }
X info_message (save_thread_info);
X }
X return TRUE;
X}
X
X
Xint save_regex_arts (is_mailbox, group_path)
X int is_mailbox;
X char *group_path;
X{
X char buf[LEN+1];
X char buf2[LEN+1];
X char mailbox[LEN+1];
X int i, ret_code;
X
X for (i=0 ; i < save_num ; i++) {
X sprintf(buf, "%s%d", txt_saving, i+1);
X wait_message (buf);
X
X if (is_mailbox) {
X strcpy (buf2, mailbox);
X }else {
X sprintf (buf2, "%s.%02d", save[i].file, i+1);
X }
X
X open_note (arts[save[i].index].artnum, group_path);
X ret_code = save_art_to_file (save[i].index, i, is_mailbox, buf2);
X note_cleanup ();
X save[i].saved = TRUE;
X }
X
X if (! save_num) {
X info_message(txt_no_match);
X } else {
X if (is_mailbox) {
X sprintf (buf, txt_saved_to_mailbox, get_first_savefile ());
X } else {
X sprintf (buf,txt_saved_pattern_to,
X get_first_savefile (), get_last_savefile ());
X }
X info_message(buf);
X }
X return (ret_code);
X}
X
X
Xint append_to_existing_file (i)
X int i;
X{
X char buf[LEN+1];
X char *file;
X struct stat st;
X
X if (! save[i].is_mailbox && save_separate) {
X file = save_filename (i);
X if (stat(file, &st) != -1) {
X sprintf (buf, txt_append_to_file, file);
X if (! prompt_yn (LINES, buf, 'n')) {
X free (file);
X file = NULL;
X return FALSE;
X }
X }
X free (file);
X file = NULL;
X }
X
X return TRUE;
X}
X
X
Xint create_path (path)
X char *path;
X{
X char buf[LEN];
X char group[LEN];
X int i, j, len;
X struct stat st;
X
X /*
X * save in mailbox format to ~/Mail/<group.name>
X */
X if (path[0] == '=') {
X return TRUE;
X }
X
X /*
X * if ~/file expand (ie. /usr/homedir/file)
X */
X switch (path[0]) {
X case '~':
X my_strncpy (buf, path+1, LEN);
X sprintf (path, "%s%s", homedir, buf);
X break;
X case '+':
X my_strncpy (buf, path+1, LEN);
X#ifdef USE_LONG_FILENAMES
X strcpy (group, glob_group);
X#else
X my_strncpy (group, glob_group, 14);
X#endif
X /*
X * convert 1st letter to uppercase
X */
X if (group[0] >= 'a' && group[0] <= 'z') {
X group[0] = group[0] - 32;
X }
X sprintf (path, "%s/%s/%s", savedir, group, buf);
X break;
X case '.':
X error_message ("Cannot create %s", buf);
X return FALSE;
X /* NOTREACHED */
X default:
X sprintf (buf, "%s/%s", savedir, path);
X my_strncpy (path, buf, LEN);
X break;
X }
X
X /*
X * create any directories, otherwise check
X * errno and give appropiate error message
X */
X len = (int) strlen (path);
X
X for (i=0, j=0 ; i < len ; i++, j++) {
X buf[j] = path[i];
X if (i+1 < len && path[i+1] == '/') {
X buf[j+1] = '\0';
X if (stat (buf, &st) == -1) {
X if (mkdir (buf, 0755) == -1) {
X error_message ("Cannot create %s", buf);
X return FALSE;
X }
X }
X }
X }
X return FALSE;
X}
X
X
Xint create_sub_dir (i)
X int i;
X{
X char dir[LEN+1];
X struct stat st;
X
X if (! save[i].is_mailbox && save[i].archive) {
X sprintf (dir, "%s/%s", save[i].dir, save[i].archive);
X if (stat (dir, &st) == -1) {
X mkdir (dir, 0755);
X return TRUE;
X }
X if ((st.st_mode & S_IFMT) == S_IFDIR) {
X return TRUE;
X } else {
X return FALSE;
X }
X }
X return FALSE;
X}
X
X/*
X * add files to be saved to save array
X */
X
Xvoid add_to_save_list (index, article, is_mailbox, path)
X int index;
X struct header *article;
X int is_mailbox;
X char *path;
X{
X char dir[LEN+1];
X char file[LEN+1];
X int i;
X
X dir[0] = '\0';
X file[0] = '\0';
X
X if (save_num == max_save-1) {
X expand_save ();
X }
X
X save[save_num].index = index;
X save[save_num].saved = FALSE;
X save[save_num].is_mailbox = is_mailbox;
X save[save_num].dir = (char *) 0;
X save[save_num].file = (char *) 0;
X save[save_num].archive = (char *) 0;
X save[save_num].part = (char *) 0;
X save[save_num].patch = (char *) 0;
X
X save[save_num].subject = str_dup (article->subject);
X if (article->archive) {
X save[save_num].archive = str_dup (article->archive);
X }
X if (article->part) {
X save[save_num].part = str_dup (article->part);
X }
X if (article->patch) {
X save[save_num].patch = str_dup (article->patch);
X }
X
X if (is_mailbox) {
X if ((int) strlen (path) > 1) {
X if (path[0] == '=') {
X strcpy (file, path+1);
X } else {
X strcpy (file, path);
X }
X } else {
X strcpy (file, glob_group);
X }
X save[save_num].dir = maildir;
X save[save_num].file = str_dup (file);
X } else {
X if (path[0]) {
X for (i=strlen (path) ; i ; i--) {
X if (path[i] == '/') {
X strncpy (dir, path, i);
X dir[i] = '\0';
X strcpy (file, path+i+1);
X break;
X }
X }
X }
X
X if (dir[0]) {
X save[save_num].dir = str_dup (dir);
X } else {
X save[save_num].dir = str_dup (savedir);
X }
X
X if (file[0]) {
X save[save_num].file = str_dup (file);
X } else {
X if (path[0]) {
X save[save_num].file = str_dup (path);
X } else {
X save[save_num].file = save[save_num].archive;
X }
X }
X }
X save_num++;
X}
X
X/*
X * print save array of files to be saved
X */
X
Xvoid sort_save_list ()
X{
X qsort ((char *) save, save_num, sizeof (struct save_t), save_comp);
X}
X
X/*
X * string comparison routine for the qsort()
X * ie. qsort(array, 5, 32, save_comp);
X */
X
Xint save_comp (p1, p2)
X char *p1;
X char *p2;
X{
X struct save_t *s1 = (struct save_t *)p1;
X struct save_t *s2 = (struct save_t *)p2;
X
X /* s1->subject less than s2->subject */
X if (strcmp (s1->subject, s2->subject) < 0) {
X return -1;
X }
X /* s1->subject greater than s2->subject */
X if (strcmp (s1->subject, s2->subject) > 0) {
X return 1;
X }
X return 0;
X}
X
X
Xchar *save_filename (i)
X int i;
X{
X char *filename;
X
X filename = (char *) my_malloc (LEN);
X
X if (save[i].is_mailbox) {
X sprintf (filename, "%s/%s", save[i].dir, save[i].file);
X return (filename);
X }
X
X if (! save_separate || ! save_archive_name || (! save[i].part && ! save[i].patch)) {
X if (! save_separate || save_num == 1) {
X sprintf (filename, "%s/%s", save[i].dir, save[i].file);
X } else {
X sprintf (filename, "%s/%s.%02d", save[i].dir, save[i].file, i+1);
X }
X } else {
X if (save[i].part) {
X if (create_sub_dir (i)) {
X sprintf (filename, "%s/%s/%s.%s%s", save[i].dir, save[i].archive, save[i].archive, LONG_PATH_PART, save[i].part);
X } else {
X sprintf (filename, "%s/%s.%s%s", save[i].dir, save[i].archive, LONG_PATH_PART, save[i].part);
X }
X } else {
X if (save[i].patch) {
X if (create_sub_dir (i)) {
X sprintf (filename, "%s/%s/%s.%s%s", save[i].dir, save[i].archive, save[i].archive, LONG_PATH_PATCH, save[i].patch);
X } else {
X sprintf (filename, "%s/%s.%s%s", save[i].dir, save[i].archive, LONG_PATH_PATCH, save[i].patch);
X }
X } else {
X sprintf (filename, "%s/%s", save[i].dir, save[i].file);
X }
X }
X }
X
X return (filename);
X}
X
X
Xchar *get_first_savefile ()
X{
X char *file;
X int i;
X
X for (i=0 ; i < save_num ; i++) {
X if (save[i].saved) {
X file = (char *) my_malloc (LEN);
X if (save[i].is_mailbox) {
X sprintf (file, "%s/%s", save[i].dir, save[i].file);
X return (file);
X } else {
X if (save[i].archive && save_archive_name) {
X if (save[i].part) {
X if (create_subdir) {
X sprintf (file, "%s/%s.%s%s", save[i].archive, save[i].archive, LONG_PATH_PART, save[i].part);
X } else {
X sprintf (file, "%s.%s%s", save[i].archive, LONG_PATH_PART, save[i].part);
X }
X } else {
X if (create_subdir) {
X sprintf (file, "%s/%s.%s%s", save[i].archive, save[i].archive, LONG_PATH_PATCH, save[i].patch);
X } else {
X sprintf (file, "%s.%s%s", save[i].archive, LONG_PATH_PATCH, save[i].patch);
X }
X }
X } else {
X if (! save_separate || save_num == 1) {
X sprintf (file, "%s", save[i].file);
X } else {
X sprintf (file, "%s.%02d", save[i].file, i+1);
X }
X }
X return (file);
X }
X }
X }
X return ((char *) 0);
X}
X
X
Xchar *get_last_savefile ()
X{
X char *file;
X int i;
X
X for (i=save_num-1 ; i >= 0 ; i--) {
X if (save[i].saved) {
X file = (char *) my_malloc (LEN);
X if (save[i].is_mailbox) {
X sprintf (file, "%s/%s", save[i].dir, save[i].file);
X return (file);
X } else {
X if (save[i].archive && save_archive_name) {
X if (save[i].part) {
X if (create_subdir) {
X sprintf (file, "%s/%s.%s%s", save[i].archive, save[i].archive, LONG_PATH_PART, save[i].part);
X } else {
X sprintf (file, "%s.%s%s", save[i].archive, LONG_PATH_PART, save[i].part);
X }
X } else {
X if (create_subdir) {
X sprintf (file, "%s/%s.%s%s", save[i].archive, save[i].archive, LONG_PATH_PATCH, save[i].patch);
X } else {
X sprintf (file, "%s.%s%s", save[i].archive, LONG_PATH_PATCH, save[i].patch);
X }
X }
X } else {
X if (! save_separate || save_num == 1) {
X sprintf (file, "%s", save[i].file);
X } else {
X sprintf (file, "%s.%02d", save[i].file, i+1);
X }
X }
X return (file);
X }
X }
X }
X return ((char *) 0);
X}
X
X
Xint post_process_files (proc_type_ch)
X char proc_type_ch;
X{
X if (save_num) {
X wait_message (txt_post_processing);
X
X switch (proc_type_ch) {
X case 's':
X post_process_sh ();
X break;
X
X case 'u':
X post_process_uud (POST_PROC_UUDECODE);
X break;
X
X case 'U':
X if (post_proc_type == POST_PROC_UUD_EXT_ZOO) {
X post_process_uud (POST_PROC_UUD_EXT_ZOO);
X } else {
X post_process_uud (POST_PROC_UUD_LST_ZOO);
X }
X break;
X
X case 'p':
X post_process_patch ();
X break;
X }
X info_message (txt_post_processing_finished);
X sleep (1);
X return TRUE;
X }
X return FALSE;
X}
X
X
Xvoid post_process_uud (pp)
X int pp;
X{
X char s[LEN+1], t[LEN+1], u[LEN+1];
X char buf[LEN+1], *file;
X char file_out[LEN+1];
X char file_out_dir[LEN+1];
X FILE *fp_in, *fp_out;
X int i, state = INITIAL;
X int file_size = 0;
X struct stat st;
X
X t[0] = '\0';
X u[0] = '\0';
X
X my_strncpy (file_out_dir, save_filename (0), LEN);
X for (i=strlen(file_out_dir) ; i > 0 ; i--) {
X if (file_out_dir[i] == '/') {
X file_out_dir[i] = '\0';
X break;
X }
X }
X
X sprintf (file_out, "%s/tin.%05d", file_out_dir, getpid ());
X
X if ((fp_out = fopen (file_out, "a+")) == NULL) {
X error_message (txt_cannot_open, file_out);
X }
X
X
X for (i=0 ; i < save_num ; i++) {
X my_strncpy (buf, save_filename (i), LEN);
X
X if ((fp_in = fopen (buf, "r")) != NULL) {
X if (fgets (s, sizeof s, fp_in) == NULL) {
X fclose (fp_in);
X continue;
X }
X while (state != END) {
X switch (state) {
X case INITIAL:
X if (! strncmp ("begin", s, 5)) {
X state = MIDDLE;
X fprintf (fp_out, "%s", s);
X }
X break;
X
X case MIDDLE:
X if (s[0] == 'M') {
X fprintf (fp_out, "%s", s);
X } else if (strncmp("end", s, 3)) {
X state = OFF;
X } else { /* end */
X state = END;
X if (u[0] != 'M') {
X fprintf (fp_out, "%s", u);
X }
X if (t[0] != 'M') {
X fprintf (fp_out, "%s", t);
X }
X fprintf (fp_out, "%s\n", s);
X }
X break;
X
X case OFF:
X if ((s[0] == 'M') && (t[0] == 'M') && (u[0] == 'M')) {
X fprintf (fp_out, "%s", u);
X fprintf (fp_out, "%s", t);
X fprintf (fp_out, "%s", s);
X state = MIDDLE;
X } else if (! strncmp ("end", s, 3)) {
X state = END;
X if (u[0] != 'M') {
X fprintf (fp_out, "%s", u);
X }
X if (t[0] != 'M') {
X fprintf (fp_out, "%s", t);
X }
X fprintf (fp_out, "%s\n", s);
X }
X break;
X
X case END:
X break;
X
X default:
X fprintf (stderr, "\r\nerror: ASSERT - default state\n");
X fclose (fp_in);
X fclose (fp_out);
X unlink (file_out);
X return;
X }
X strcpy (u,t);
X strcpy (t,s);
X /*
X * read next line & if error goto next file in save array
X */
X if (fgets (s, sizeof s, fp_in) == NULL) {
X break;
X }
X }
X fclose (fp_in);
X }
X }
X fclose (fp_out);
X
X /*
X * uudecode file
X */
X wait_message ("Uudecoding...");
X
X sprintf (buf, "cd %s; uudecode %s", file_out_dir, file_out);
X if (invoke_cmd (buf)) {
X /*
X * sum file
X */
X if ((file = get_archive_file (file_out_dir, "*")) != NULL) {
X sprintf (buf, "%s %s", DEFAULT_SUM, file);
X printf ("\r\n\r\nChecksum of %s...\r\n\r\n", file);
X fflush (stdout);
X if ((fp_in = popen (buf, "r")) == NULL) {
X printf ("Cannot execute %s\r\n", buf);
X fflush (stdout);
X } else {
X if (stat (file, &st) != -1) {
X file_size = (int) st.st_size;
X }
X if (fgets (buf, sizeof buf, fp_in) != NULL) {
X buf[strlen (buf)-1] = '\0';
X }
X fclose (fp_in);
X printf ("%s %8d bytes\r\n", buf, file_size);
X fflush (stdout);
X }
X free (file);
X file = (char *) 0;
X }
X }
X
X if (pp > POST_PROC_UUDECODE) {
X sprintf (buf, "*.%s", archiver[pp].ext);
X if ((file = get_archive_file (file_out_dir, buf)) != NULL) {
X if (pp == POST_PROC_UUD_EXT_ZOO) {
X sprintf (buf, "cd %s; %s %s %s", file_out_dir,
X archiver[pp].name, archiver[pp].extract, file);
X printf ("\r\n\r\nListing %s archive...\r\n", file);
X } else {
X sprintf (buf, "cd %s; %s %s %s", file_out_dir,
X archiver[pp].name, archiver[pp].list, file);
X printf ("\r\n\r\nExtracting %s archive...\r\n", file);
X }
X fflush (stdout);
X free (file);
X file = (char *) 0;
X if (! invoke_cmd (buf)) {
X error_message ("Post processing failed", "");
X }
X/*
Xcontinue_prompt ();
X*/
X }
X }
X delete_processed_files ();
X
X unlink (file_out);
X}
X
X/*
X * Unpack /bin/sh archives
X */
X
Xvoid post_process_sh ()
X{
X char buf[LEN+1];
X char file_in[LEN+1];
X char file_out[LEN+1];
X char file_out_dir[LEN+1];
X char *ptr1, *ptr2;
X FILE *fp_in, *fp_out;
X int found_header;
X int i, j;
X char sh_pattern_1[16];
X char sh_pattern_2[16];
X
X strcpy (sh_pattern_1, "#! /bin/sh");
X strcpy (sh_pattern_2, "#!/bin/sh");
X
X my_strncpy (file_out_dir, save_filename (0), LEN);
X for (i=strlen(file_out_dir) ; i > 0 ; i--) {
X if (file_out_dir[i] == '/') {
X file_out_dir[i] = '\0';
X break;
X }
X }
X
X sprintf (file_out, "%s/tin.%05d", file_out_dir, getpid ());
X
X for (j=0 ; j < save_num ; j++) {
X my_strncpy (file_in, save_filename (j), LEN);
X
X printf ("\r\nExtracting %s...\r\n", file_in);
X fflush (stdout);
X
X found_header = FALSE;
X
X if ((fp_out = fopen (file_out, "w")) != NULL) {
X if ((fp_in = fopen (file_in, "r")) != NULL) {
X while (! feof (fp_in)) {
X if (fgets (buf, sizeof buf, fp_in)) {
X /*
X * find #!/bin/sh or #! /bin/sh pattern
X */
X if (!found_header) {
X ptr1 = sh_pattern_1;
X ptr2 = sh_pattern_2;
X if (str_str (buf, ptr1) != 0 ||
X str_str (buf, ptr2) != 0) {
X found_header = TRUE;
X }
X }
X
X /*
X * Write to temp file
X */
X if (found_header) {
X fputs (buf, fp_out);
X }
X }
X }
X fclose (fp_in);
X }
X fclose (fp_out);
X
X sprintf (buf, "cd %s; sh %s", file_out_dir, file_out);
X printf ("\r\n");
X fflush (stdout);
X Raw (FALSE);
X invoke_cmd (buf);
X Raw (TRUE);
X unlink (file_out);
X }
X }
X delete_processed_files ();
X}
X
X
Xchar *get_archive_file (dir, ext)
X char *dir;
X char *ext;
X{
X char buf[LEN+1];
X char *file = NULL;
X FILE *fp;
X
X sprintf (buf, "ls -t %s/%s", dir, ext);
X
X if ((fp = popen (buf, "r")) == NULL) {
X return (char *) 0;
X }
X
X if (fgets (buf, sizeof buf, fp) != NULL) {
X file = str_dup (buf);
X file[strlen (file)-1] = '\0';
X }
X
X fclose (fp);
X
X return (file);
X}
X
X
Xvoid delete_processed_files ()
X{
X int i;
X
X printf ("\r\n");
X fflush (stdout);
X
X if (prompt_yn (LINES, "Delete saved files that have been post processed? (y/n): ", 'y')) {
X wait_message (txt_deleting);
X
X for (i=0 ; i < save_num ; i++) {
X unlink (save_filename (i));
X }
X }
X}
X
X
Xvoid post_process_patch ()
X{
X}
SHAR_EOF
$TOUCH -am 0923175591 save.c &&
chmod 0600 save.c ||
echo "restore of save.c failed"
set `wc -c save.c`;Wc_c=$1
if test "$Wc_c" != "19585"; then
echo original size 19585, current size $Wc_c
fi
# ============= screen.c ==============
echo "x - extracting screen.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > screen.c &&
X/*
X * Project : tin - a visual threaded usenet newsreader
X * Module : screen.c
X * Author : R.Skrenta / I.Lea
X * Created : 01-04-91
X * Updated : 08-09-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
Xextern int errno;
X
Xchar msg[LEN+1];
Xstruct screen_t *screen;
X
X
Xvoid info_message (msg)
X char *msg;
X{
X clear_message(); /* Clear any old messages hanging around */
X center_line(LINES, FALSE, msg); /* center the message at screen bottom */
X MoveCursor(LINES, 0);
X}
X
X
Xvoid wait_message (msg)
X char *msg;
X{
X if (RawState ()) {
X clear_message(); /* Clear any old messages hanging around */
X }
X printf ("%s", msg);
X fflush (stdout);
X}
X
X
Xvoid error_message (template, msg)
X char *template;
X char *msg;
X{
X errno = 0;
X
X if (update == FALSE && RawState ()) {
X clear_message (); /* Clear any old messages hanging around */
X }
X
X fprintf (stderr, template, msg);
X fflush (stderr);
X
X if (update == FALSE && RawState ()) {
X MoveCursor (LINES, 0);
X sleep (2);
X } else {
X fprintf (stderr, "\n");
X fflush (stderr);
X }
X}
X
X
Xvoid clear_message ()
X{
X MoveCursor(LINES, 0);
X CleartoEOLN();
X}
X
X
Xvoid center_line (line, inverse, str)
X int line;
X int inverse;
X char *str;
X{
X int pos;
X
X pos = (COLS - (int) strlen (str)) / 2;
X MoveCursor (line, pos);
X if (inverse) {
X StartInverse ();
X }
X printf ("%s", str);
X fflush (stdout);
X if (inverse) {
X EndInverse ();
X }
X}
X
X
Xvoid draw_arrow (line)
X int line;
X{
X MoveCursor (line, 0);
X
X if (draw_arrow_mark) {
X printf ("->");
X fflush (stdout);
X } else {
X StartInverse ();
X printf ("%s", screen[line-INDEX_TOP].col);
X fflush (stdout);
X EndInverse ();
X }
X MoveCursor (LINES, 0);
X}
X
X
Xvoid erase_arrow (line)
X int line;
X{
X MoveCursor (line, 0);
X
X if (draw_arrow_mark) {
X printf (" ");
X } else {
X printf ("%s", screen[line-INDEX_TOP].col);
X }
X fflush (stdout);
X}
SHAR_EOF
$TOUCH -am 0923175591 screen.c &&
chmod 0600 screen.c ||
echo "restore of screen.c failed"
set `wc -c screen.c`;Wc_c=$1
if test "$Wc_c" != "2171"; then
echo original size 2171, current size $Wc_c
fi
# ============= search.c ==============
echo "x - extracting search.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > search.c &&
X/*
X * Project : tin - a visual threaded usenet newsreader
X * Module : search.c
X * Author : R.Skrenta / I.Lea
X * Created : 01-04-91
X * Updated : 26-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
Xextern FILE *note_fp;
Xextern int cur_groupnum;
Xextern int first_group_on_screen;
Xextern int last_group_on_screen;
Xextern int first_subj_on_screen;
Xextern int last_subj_on_screen;
Xextern int index_point;
Xextern int note_line;
Xextern int note_page;
Xextern int note_end;
Xextern long note_mark[MAX_PAGES];
X
X/*
X * last search patterns
X */
X
Xchar author_search_string[LEN+1];
Xchar group_search_string[LEN+1];
Xchar subject_search_string[LEN+1];
Xchar art_search_string[LEN+1];
X
X
X/*
X * group.c & page.c
X */
X
Xint search_author (current_art, forward)
X int current_art;
X int forward;
X{
X char buf[LEN+1];
X char buf2[LEN+1];
X int i;
X
X clear_message();
X
X if (forward) {
X sprintf (buf2, txt_author_search_forwards, author_search_string);
X } else {
X sprintf (buf2, txt_author_search_backwards, author_search_string);
X }
X
X
X if (! parse_string (buf2, buf)) {
X return -1;
X }
X
X if (strlen (buf)) {
X strcpy (author_search_string, buf);
X } else {
X if (author_search_string[0]) {
X strcpy (buf, author_search_string);
X } else {
X info_message (txt_no_search_string);
X return -1;
X }
X }
X
X wait_message (txt_searching);
X
X make_lower(author_search_string, buf);
X
X i = current_art;
X
X do {
X if (forward) {
X i = next_response(i);
X if (i < 0)
X i = 0;
X } else {
X i = prev_response(i);
X if (i < 0)
X i = top - 1;
X }
X
X make_lower(arts[i].from, buf2);
X if (str_str (buf2, buf) != 0) {
X clear_message ();
X return i;
X }
X } while (i != current_art);
X
X info_message(txt_no_match);
X return -1;
X}
X
X/*
X * select.c
X */
X
Xvoid search_group (forward)
X int forward;
X{
X char buf[LEN+1];
X char buf2[LEN+1];
X int i;
X
X clear_message();
X
X if (forward) {
X sprintf (buf2, txt_search_forwards, group_search_string);
X } else {
X sprintf (buf2, txt_search_backwards, group_search_string);
X }
X
X if (! parse_string (buf2, buf)) {
X return;
X }
X
X if (strlen (buf)) {
X strcpy (group_search_string, buf);
X } else {
X if (group_search_string[0]) {
X strcpy (buf, group_search_string);
X } else {
X info_message (txt_no_search_string);
X return;
X }
X }
X
X wait_message (txt_searching);
X
X i = cur_groupnum;
X
X make_lower(group_search_string, buf);
X
X do {
X if (forward)
X i++;
X else
X i--;
X
X if (i >= local_top)
X i = 0;
X if (i < 0)
X i = local_top - 1;
X
X make_lower(active[my_group[i]].name, buf2);
X if (str_str (buf2, buf) != 0) {
X if (i >= first_group_on_screen
X && i < last_group_on_screen) {
X clear_message ();
X erase_group_arrow();
X cur_groupnum = i;
X draw_group_arrow();
X } else {
X cur_groupnum = i;
X group_selection_page();
X }
X return;
X }
X } while (i != cur_groupnum);
X
X info_message(txt_no_match);
X}
X
X/*
X * group.c
X */
X
Xvoid search_subject (forward, group)
X int forward;
X char *group;
X{
X char buf[LEN+1];
X char buf2[LEN+1];
X int i, j;
X
X if (index_point < 0) {
X info_message (txt_no_arts);
X return;
X }
X
X clear_message();
X
X if (forward) {
X sprintf (buf2, txt_search_forwards, subject_search_string);
X } else {
X sprintf (buf2, txt_search_backwards, subject_search_string);
X }
X
X if (! parse_string (buf2, buf)) {
X return;
X }
X
X if (strlen (buf)) {
X strcpy (subject_search_string, buf);
X } else {
X if (subject_search_string[0]) {
X strcpy (buf, subject_search_string);
X } else {
X info_message (txt_no_search_string);
X return;
X }
X }
X
X wait_message (txt_searching);
X
X i = index_point;
X
X make_lower(subject_search_string, buf);
X
X do {
X if (forward)
X i++;
X else
X i--;
X
X if (i >= top_base)
X i = 0;
X if (i < 0)
X i = top_base - 1;
X
X j = base[i];
X make_lower(arts[j].subject, buf2);
X if (str_str (buf2, buf) != 0) {
X if (i >= first_subj_on_screen
X && i < last_subj_on_screen) {
X clear_message ();
X erase_subject_arrow();
X index_point = i;
X draw_subject_arrow();
X } else {
X index_point = i;
X show_group_page(group);
X }
X return;
X }
X } while (i != index_point);
X
X info_message(txt_no_match);
X}
X
X/*
X * page.c (search article body)
X */
X
Xint search_article (forward)
X int forward;
X{
X char buf[LEN+1];
X char buf2[LEN+1];
X char string[LEN+1];
X char pattern[LEN+1];
X char *p, *q;
X int ctrl_L;
X int i, j;
X int orig_note_end;
X int orig_note_page;
X
X clear_message ();
X
X if (forward) {
X sprintf (buf2, txt_search_forwards, art_search_string);
X } else {
X sprintf (buf2, txt_search_backwards, art_search_string);
X }
X
X if (! parse_string (buf2, buf)) {
X return FALSE;
X }
X
X if (strlen (buf)) {
X strcpy (art_search_string, buf);
X } else {
X if (art_search_string[0]) {
X strcpy (buf, art_search_string);
X } else {
X info_message (txt_no_search_string);
X return FALSE;
X }
X }
X
X make_lower (art_search_string, pattern);
X /*
X * save current position in article
X */
X orig_note_end = note_end;
X orig_note_page = note_page;
X
X wait_message (txt_searching);
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
X make_lower(buf2, string);
X
X if (str_str (string, pattern) != 0) {
X fseek (note_fp, note_mark[note_page], 0);
X return TRUE;
X }
X
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
X note_end = orig_note_end;
X note_page = orig_note_page;
X fseek (note_fp, note_mark[note_page], 0);
X info_message (txt_no_match);
X return FALSE;
X}
X
X/*
X * ANSI C strstr () - Use Boyer-Moore algorithm. Downloaded from net.
X */
X
Xchar *str_str (text, pattern)
X char *text;
X char *pattern;
X{
X register unsigned char *p, *t;
X register int i, p1, j, *delta;
X int deltaspace[256];
X int patlen;
X int textlen;
X
X textlen= strlen (text);
X patlen = strlen (pattern);
X
X /* algorithm fails if pattern is empty */
X if ((p1 = patlen) == 0)
X return (text);
X
X /* code below fails (whenever i is unsigned) if pattern too long */
X if (p1 > textlen)
X return (NULL);
X
X /* set up deltas */
X delta = deltaspace;
X for (i = 0; i <= 255; i++)
X delta[i] = p1;
X for (p = (unsigned char *) pattern, i = p1; --i > 0;)
X delta[*p++] = i;
X
X /*
X * From now on, we want patlen - 1.
X * In the loop below, p points to the end of the pattern,
X * t points to the end of the text to be tested against the
X * pattern, and i counts the amount of text remaining, not
X * including the part to be tested.
X */
X p1--;
X p = (unsigned char *) pattern + p1;
X t = (unsigned char *) text + p1;
X i = textlen - patlen;
X for (;;) {
X if (*p == *t && memcmp((p - p1), (t - p1), p1) == 0)
X return ((char *)t - p1);
X j = delta[*t];
X if (i < j)
X break;
X i -= j;
X t += j;
X }
X return (NULL);
X}
X
X
Xvoid make_lower (s, t)
X char *s;
X char *t;
X{
X
X while (*s) {
X if (isupper(*s))
X *t = tolower(*s);
X else
X *t = *s;
X s++;
X t++;
X }
X *t = 0;
X}
SHAR_EOF
$TOUCH -am 0923175591 search.c &&
chmod 0600 search.c ||
echo "restore of search.c failed"
set `wc -c search.c`;Wc_c=$1
if test "$Wc_c" != "7830"; then
echo original size 7830, current size $Wc_c
fi
# ============= select.c ==============
echo "x - extracting select.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > select.c &&
X/*
X * Project : tin - a visual threaded usenet newsreader
X * Module : select.c
X * Author : R.Skrenta / I.Lea
X * Created : 01-04-91
X * Updated : 22-09-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
Xextern int index_point;
Xextern char cvers[LEN+1];
X
Xint first_group_on_screen;
Xint last_group_on_screen;
Xint cur_groupnum = 0;
Xint reread_active_file = TRUE;
Xint space_mode;
X
X
Xvoid selection_index()
X{
X char ch;
X int i, n;
X int subscribe_num;
X char buf[LEN+1];
X
X#ifndef USE_CLEARSCREEN
X ClearScreen();
X#endif
X
X group_selection_page (); /* display group selection page */
X
X while (1) {
X num_of_tagged_files = 0;
X ch = ReadCh();
X
X if (ch > '0' && ch <= '9') {
X prompt_group_num (ch);
X } else switch (ch) {
X case '!':
X shell_escape ();
X group_selection_page ();
X break;
X
X case '$': /* show last page of groups */
Xend_of_list:
X if (cur_groupnum != local_top - 1) {
X cur_groupnum = local_top - 1;
X group_selection_page ();
X }
X break;
X
X case '/': /* search forward */
X case '?': /* search backward */
X i = (ch == '/');
X search_group (i);
X break;
X
X case '\r': /* go into group */
X case '\n':
X n = my_group[cur_groupnum];
X if (active[n].min <= active[n].max) {
X space_mode = pos_first_unread;
X clear_message();
X index_point = -1;
X do {
X n = my_group[cur_groupnum];
X group_page (active[n].name);
X } while (index_point == -3);
X group_selection_page ();
X } else {
X info_message (txt_no_arts);
X }
X break;
X
X case '\t': /* enter next group containing unread articles */
X next_unread_group (TRUE);
X break;
X
X case 27: /* (ESC) common arrow keys */
X ch = ReadCh();
X if (ch == '[' || ch == 'O')
X ch = ReadCh();
X switch (ch) {
X case 'A':
X case 'D':
X case 'i':
X goto select_up;
X
X case 'B':
X case 'C':
X goto select_down;
X
X case 'G': /* ansi PgDn */
X case 'U': /* at386 PgDn */
X goto select_page_down;
X
X case 'I': /* ansi PgUp */
X case 'V': /* at386 PgUp */
X goto select_page_up;
X
X case 'H': /* at386 Home */
X if (cur_groupnum != 0) {
X cur_groupnum = 0;
X group_selection_page ();
X }
X break;
X
X case 'F': /* ansi End */
X case 'Y': /* at386 End */
X goto end_of_list;
X }
X break;
X
X case ctrl('D'): /* page down */
X case ' ':
Xselect_page_down:
X erase_group_arrow ();
X cur_groupnum += NOTESLINES / 2;
X if (cur_groupnum >= local_top)
X cur_groupnum = local_top - 1;
X
X if (cur_groupnum <= first_group_on_screen
X || cur_groupnum >= last_group_on_screen)
X group_selection_page();
X else
X draw_group_arrow();
X break;
X
X case ctrl('K'):
X if (local_top <= 0) {
X info_message (txt_no_groups_to_delete);
X break;
X }
X
X sprintf (buf, active[my_group[cur_groupnum]].name);
X sprintf (msg, txt_del_group_in_newsrc, buf);
X if (prompt_yn (LINES, msg, 'y')) {
X delete_group (active[my_group[cur_groupnum]].name);
X active[my_group[cur_groupnum]].flag = NOTGOT;
X
X local_top--;
X for (i = cur_groupnum; i < local_top; i++) {
X my_group[i] = my_group[i+1];
X unread[i] = unread[i+1];
X }
X if (cur_groupnum >= local_top)
X cur_groupnum = local_top - 1;
X
X group_selection_page ();
X sprintf (msg, txt_group_deleted, buf);
X info_message (msg);
X }
X break;
X
X case ctrl('L'): /* redraw */
X case 't':
X#ifndef USE_CLEARSCREEN
X ClearScreen ();
X#endif
X group_selection_page();
X break;
X
X case ctrl('N'): /* line down */
X case 'j':
Xselect_down:
X if (cur_groupnum + 1 >= local_top)
X break;
X
X if (cur_groupnum + 1 >= last_group_on_screen) {
X#ifndef USE_CLEARSCREEN
X erase_group_arrow();
X#endif
X cur_groupnum++;
X group_selection_page();
X } else {
X erase_group_arrow();
X cur_groupnum++;
X draw_group_arrow();
X }
X break;
X
X case ctrl('P'): /* line up */
X case 'k':
Xselect_up:
X if (!cur_groupnum)
X break;
X
X if (cur_groupnum <= first_group_on_screen) {
X cur_groupnum--;
X group_selection_page();
X } else {
X erase_group_arrow();
X cur_groupnum--;
X draw_group_arrow();
X }
X break;
X
X case ctrl('R'): /* reset .newsrc */
X if (prompt_yn (LINES, txt_reset_newsrc, 'n')) {
X reset_newsrc ();
X cur_groupnum = 0;
X group_selection_page ();
X }
X break;
X
X case ctrl('U'): /* page up */
X case 'b':
Xselect_page_up:
X erase_group_arrow();
X cur_groupnum -= NOTESLINES / 2;
X if (cur_groupnum < 0)
X cur_groupnum = 0;
X if (cur_groupnum < first_group_on_screen
X || cur_groupnum >= last_group_on_screen)
X group_selection_page();
X else
X draw_group_arrow();
X break;
X
X case 'B': /* bug/gripe/comment mailed to author */
X mail_bug_report ();
X#ifndef USE_CLEARSCREEN
X ClearScreen ();
X#endif
X group_selection_page();
X break;
X
X case 'c': /* catchup--mark all articles as read */
X case 'C': /* catchup & goto next unread group */
X catchup_group ((ch == 'C'));
X break;
X
X case 'g': /* prompt for a new group name */
X if ((n = choose_new_group ()) >= 0) {
X if (active[my_group[n]].flag != SUBS) {
X subscribe (active[my_group[n]].name, ':',
X my_group[n], FALSE);
X }
X erase_group_arrow();
X cur_groupnum = reposition_group (active[my_group[n]].name,
X (n ? n : cur_groupnum));
X if (cur_groupnum < first_group_on_screen ||
X cur_groupnum >= last_group_on_screen ||
X cur_groupnum != n) {
X group_selection_page();
X } else {
X clear_message ();
X draw_group_arrow();
X }
X }
X break;
X
X case 'h':
X show_info_page (HELP_INFO, help_select, txt_group_select_com);
X group_selection_page ();
X break;
X
X case 'H':
X help_select_info ();
X group_selection_page ();
X break;
X
X case 'I': /* toggle inverse video */
X inverse_okay = !inverse_okay;
X if (inverse_okay) {
X group_selection_page ();
X info_message (txt_inverse_on);
X } else {
X draw_arrow_mark = TRUE;
X clear_note_area ();
X group_selection_page ();
X info_message (txt_inverse_off);
X }
X break;
X
X case 'm': /* reposition group within group list */
X if (active[my_group[cur_groupnum]].flag == SUBS) {
X n = cur_groupnum;
X erase_group_arrow ();
X cur_groupnum = reposition_group (active[my_group[n]].name, n);
X if (cur_groupnum < first_group_on_screen ||
X cur_groupnum >= last_group_on_screen ||
X cur_groupnum != n) {
X group_selection_page ();
X } else {
X clear_message ();
X draw_group_arrow ();
X }
X }
X break;
X
X case 'M': /* options menu */
X change_rcfile ("", TRUE);
X group_selection_page ();
X break;
X
X case 'q': /* quit */
X tin_done (0);
X
X case 's': /* subscribe to current group */
X if (active[my_group[cur_groupnum]].flag != SUBS) {
X MoveCursor (INDEX_TOP + (cur_groupnum-first_group_on_screen), 3);
X if (draw_arrow_mark) {
X putchar (' ');
X } else {
X screen[cur_groupnum-first_group_on_screen].col[3] = ' ';
X draw_group_arrow ();
X }
X fflush (stdout);
X MoveCursor (LINES, 0);
X
X subscribe (active[my_group[cur_groupnum]].name,
X ':', my_group[cur_groupnum], FALSE);
X sprintf (buf, txt_subscribed_to, active[my_group[cur_groupnum]].name);
X info_message (buf);
X }
X break;
X
X case 'S': /* subscribe to groups matching pattern */
X if (parse_string (txt_subscribe_pattern, buf) && buf[0]) {
X wait_message (txt_subscribing);
X for (subscribe_num=0, i=0 ; i < local_top ; i++) {
X#ifdef DONT_USE_REGEX
X if (str_str (active[my_group[i]].name, buf)) {
X#else
X if (wildmat (active[my_group[i]].name, buf)) {
X#endif
X if (active[my_group[i]].flag != SUBS) {
X#ifndef SLOW_SCREEN_UPDATE
X sprintf (msg, txt_subscribing_to, active[my_group[i]].name);
X wait_message (msg);
X#endif
X subscribe (active[my_group[i]].name,
X ':', my_group[i], FALSE);
X }
X subscribe_num++;
X }
X }
X if (subscribe_num) {
X group_selection_page ();
X sprintf (buf, txt_subscribed_num_groups, subscribe_num);
X info_message (buf);
X } else {
X info_message (txt_no_match);
X }
X } else {
X clear_message ();
X }
X break;
X
X case 'u': /* unsubscribe to current group */
X if (active[my_group[cur_groupnum]].flag == SUBS) {
X MoveCursor(INDEX_TOP + (cur_groupnum-first_group_on_screen), 3);
X if (draw_arrow_mark) {
X putchar('u');
X } else {
X screen[cur_groupnum-first_group_on_screen].col[3] = 'u';
X draw_group_arrow ();
X }
X fflush(stdout);
X MoveCursor(LINES, 0);
X
X subscribe(active[my_group[cur_groupnum]].name,
X '!', my_group[cur_groupnum], FALSE);
X sprintf(buf, txt_unsubscribed_to,active[my_group[cur_groupnum]].name);
X info_message(buf);
X }
X break;
X
X case 'U': /* unsubscribe to groups matching pattern */
X if (parse_string (txt_unsubscribe_pattern, buf) && buf[0]) {
X wait_message (txt_unsubscribing);
X for (subscribe_num=0, i=0 ; i < local_top ; i++) {
X#ifdef DONT_USE_REGEX
X if (str_str (active[my_group[i]].name, buf)) {
X#else
X if (wildmat (active[my_group[i]].name, buf)) {
SHAR_EOF
echo "End of tin1.02 part 7"
echo "File select.c is continued in part 8"
echo "8" > 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.