home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume30 / tin / part05 / rcfile.c < prev   
Encoding:
C/C++ Source or Header  |  1992-05-20  |  23.3 KB  |  823 lines

  1. /*
  2.  *  Project   : tin - a threaded Netnews reader
  3.  *  Module    : rcfile.c
  4.  *  Author    : I.Lea
  5.  *  Created   : 01-04-91
  6.  *  Updated   : 09-05-92
  7.  *  Notes     :
  8.  *  Copyright : (c) Copyright 1991-92 by Iain Lea
  9.  *              You may  freely  copy or  redistribute  this software,
  10.  *              so  long as there is no profit made from its use, sale
  11.  *              trade or  reproduction.  You may not change this copy-
  12.  *              right notice, and it must be included in any copy made
  13.  */
  14.  
  15. #include    "tin.h"
  16.  
  17. extern int index_point;
  18.  
  19. static int COL1;
  20. static int COL2;
  21. static int COL3;
  22.  
  23. /*
  24.  *  read_rcfile - read defaults from ~/.tin/tinrc
  25.  */
  26.  
  27. int read_rcfile ()
  28. {
  29.     char buf[LEN];
  30.     FILE *fp;
  31.  
  32.     if ((fp = fopen (rcfile, "r")) == NULL) {
  33.         return (FALSE);
  34.     }    
  35.  
  36.     while (fgets (buf, sizeof (buf), fp) != NULL) {
  37.         if (buf[0] == '#' || buf[0] == '\n') { 
  38.             continue;
  39.         }    
  40.         if (match_boolean (buf, "save_archive=", &save_archive_name)) {
  41.             continue;
  42.         }    
  43.         if (match_boolean (buf, "start_editor_offset=", &start_editor_offset)) {
  44.             continue;
  45.         }    
  46.         if (match_boolean (buf, "mark_saved_read=", &mark_saved_read)) {
  47.             continue;
  48.         }    
  49.         if (match_boolean (buf, "draw_arrow=", &draw_arrow_mark)) {
  50.             if (draw_arrow_mark == FALSE && inverse_okay == FALSE) {
  51.                 inverse_okay = TRUE;
  52.             }
  53.             continue;
  54.         }    
  55.         if (match_boolean (buf, "print_header=", &print_header)) {
  56.             continue;
  57.         }
  58.         if (match_number (buf, "kill_level=", &kill_level)) {
  59.             continue;
  60.         }
  61.         if (match_boolean (buf, "pos_first_unread=", &pos_first_unread)) {
  62.             continue;
  63.         }    
  64.         if (match_boolean (buf, "full_page_scroll=", &full_page_scroll)) {
  65.             continue;
  66.         }    
  67.         if (match_boolean (buf, "catchup_read_groups=", &catchup_read_groups)) {
  68.             continue;
  69.         }    
  70.         if (match_boolean (buf, "thread_articles=", &thread_arts)) {
  71.             continue;
  72.         }    
  73.         if (match_boolean (buf, "unlink_article=", &unlink_article)) {
  74.             continue;
  75.         }    
  76.         if (match_boolean (buf, "show_only_unread=", &show_only_unread)) {
  77.             continue;
  78.         }    
  79.         if (match_boolean (buf, "confirm_action=", &confirm_action)) {
  80.             continue;
  81.         }
  82.         if (match_number (buf, "show_author=", &default_show_author)) {
  83.             continue;
  84.         }    
  85.         if (match_number (buf, "post_process_type=", &post_proc_type)) {
  86.             switch (post_proc_type) {
  87.                 case POST_PROC_SHAR:
  88.                     proc_ch_default = 's';
  89.                     break;
  90.                 case POST_PROC_UUDECODE:
  91.                     proc_ch_default = 'u';
  92.                     break;
  93.                 case POST_PROC_UUD_LST_ZOO:
  94.                     proc_ch_default = 'U';
  95.                     break;
  96.                 case POST_PROC_UUD_EXT_ZOO:
  97.                     proc_ch_default = 'U';
  98.                     break;
  99.                 case POST_PROC_NONE:
  100.                 default:
  101.                     proc_ch_default = 'n';
  102.                     break;
  103.             }
  104.             continue;
  105.         }    
  106.         if (match_number (buf, "sort_article_type=", &sort_art_type)) {
  107.             continue;
  108.         }    
  109.         if (match_string (buf, "savedir=", default_savedir, sizeof (default_savedir))) {
  110.             if (default_savedir[0] == '.' && strlen (default_savedir) == 1) {
  111. #if defined(BSD) && ! defined(sinix)
  112.                 getwd (buf);    
  113. #else
  114.                 getcwd (buf, LEN);
  115. #endif
  116.                 my_strncpy (default_savedir, buf, sizeof (default_savedir));
  117.             }
  118.             continue;
  119.         }    
  120.         if (match_string (buf, "maildir=", default_maildir, sizeof (default_maildir))) {
  121.             continue;
  122.         }
  123.         if (match_string (buf, "printer=", printer, sizeof (printer))) {
  124.             continue;
  125.         }
  126.         if (match_string (buf, "default_spooldir_alias=", spooldir_alias, sizeof (spooldir_alias))) {
  127.             set_tindir ();
  128.             continue;
  129.         }
  130.         if (match_string (buf, "default_author_search=", default_author_search, sizeof (default_author_search))) {
  131.             continue;
  132.         }
  133.         if (match_string (buf, "default_goto_group=", default_goto_group, sizeof (default_goto_group))) {
  134.             continue;
  135.         }
  136.         if (match_string (buf, "default_group_search=", default_group_search, sizeof (default_group_search))) {
  137.             continue;
  138.         }
  139.         if (match_string (buf, "default_subject_search=", default_subject_search, sizeof (default_subject_search))) {
  140.             continue;
  141.         }
  142.         if (match_string (buf, "default_art_search=", default_art_search, sizeof (default_art_search))) {
  143.             continue;
  144.         }
  145.         if (match_string (buf, "default_crosspost_group=", default_crosspost_group, sizeof (default_crosspost_group))) {
  146.             continue;
  147.         }
  148.         if (match_string (buf, "default_mail_address=", default_mail_address, sizeof (default_mail_address))) {
  149.             continue;
  150.         }
  151.         if (match_number (buf, "default_move_group=", &default_move_group)) {
  152.             continue;
  153.         }
  154.         if (match_string (buf, "default_pipe_command=", default_pipe_command, sizeof (default_pipe_command))) {
  155.             continue;
  156.         }
  157.         if (match_string (buf, "default_post_subject=", default_post_subject, sizeof (default_post_subject))) {
  158.             continue;
  159.         }
  160.         if (match_string (buf, "default_regex_pattern=", default_regex_pattern, sizeof (default_regex_pattern))) {
  161.             continue;
  162.         }
  163.         if (match_string (buf, "default_save_file=", default_save_file, sizeof (default_save_file))) {
  164.             continue;
  165.         }
  166.         if (match_string (buf, "default_shell_command=", default_shell_command, sizeof (default_shell_command))) {
  167.             continue;
  168.         }
  169.     }
  170.     fclose (fp);
  171.     return TRUE;        
  172. }
  173.  
  174.  
  175. /*
  176.  *  write_rcfile - write defaults to ~/.tin/tinrc
  177.  */
  178.  
  179. void write_rcfile ()
  180. {
  181.     FILE *fp;
  182.  
  183.     if ((fp = fopen (rcfile, "w")) == NULL) {
  184.         return;
  185.     }    
  186.     
  187.     if (! cmd_line) {
  188.         wait_message (txt_saving);
  189.     }
  190.     fprintf (fp, "# if ON articles/threads with Archive-name: in mail header will\n");
  191.     fprintf (fp, "# be automatically saved with the Archive-name & part/patch no.\n");
  192.     fprintf (fp, "save_archive=%s\n\n", (save_archive_name ? "ON" : "OFF"));
  193.     fprintf (fp, "# if ON articles of a threads will be saved to separate files\n");
  194.     fprintf (fp, "# otherwise the whole thread will be saved to one file\n");
  195.     fprintf (fp, "start_editor_offset=%s\n\n", (start_editor_offset ? "ON" : "OFF"));
  196.     fprintf (fp, "# if ON mark articles that are saved as read\n");
  197.     fprintf (fp, "mark_saved_read=%s\n\n", (mark_saved_read ? "ON" : "OFF"));
  198.     fprintf (fp, "# if 0 killed articles are simply marked as being read\n");
  199.     fprintf (fp, "# if 1 killed articles are removed and never seen\n");
  200.     fprintf (fp, "kill_level=%d\n\n", kill_level);
  201.     fprintf (fp, "# if ON use -> otherwise highlighted bar for selection\n");
  202.     fprintf (fp, "draw_arrow=%s\n\n", (draw_arrow_mark ? "ON" : "OFF"));
  203.     fprintf (fp, "# if ON print all of mail header otherwise Subject: & From: lines\n");
  204.     fprintf (fp, "print_header=%s\n\n", (print_header ? "ON" : "OFF"));
  205.     fprintf (fp, "# if ON put cursor at first unread art in group otherwise last art\n");
  206.     fprintf (fp, "pos_first_unread=%s\n\n", (pos_first_unread ? "ON" : "OFF"));
  207.     fprintf (fp, "# if ON scroll full page of groups/articles otherwise half a page\n");
  208.     fprintf (fp, "full_page_scroll=%s\n\n", (full_page_scroll ? "ON" : "OFF"));
  209.     fprintf (fp, "# if ON ask user if read groups should all be marked read\n");
  210.     fprintf (fp, "catchup_read_groups=%s\n\n", (catchup_read_groups ? "ON" : "OFF"));
  211.     fprintf (fp, "# if ON confirm certain commands with y/n before executing\n");
  212.     fprintf (fp, "confirm_action=%s\n\n", (confirm_action ? "ON" : "OFF"));
  213.     fprintf (fp, "# part of from field to display 0) none 1) address 2) full name 3) both\n");
  214.     fprintf (fp, "show_author=%d\n\n", default_show_author);
  215.     fprintf (fp, "# type of post processing to perform after saving articles.\n");
  216.     fprintf (fp, "# 0=(none) 1=(shar) 2=(uudecode) 3=(uud & list zoo) 4=(uud & extract zoo) 5=(patch).\n");
  217.     fprintf (fp, "post_process_type=%d\n\n", post_proc_type);
  218.     fprintf (fp, "# if ON and group not in ~/.tin/unthread articles will be threaded.\n");
  219.     fprintf (fp, "thread_articles=%s\n\n", (thread_arts ? "ON" : "OFF"));
  220.     fprintf (fp, "# if ON remove ~/.article after posting.\n");
  221.     fprintf (fp, "unlink_article=%s\n\n", (unlink_article ? "ON" : "OFF"));
  222.     fprintf (fp, "# if ON show only new/unread articles otherwise show all.\n");
  223.     fprintf (fp, "show_only_unread=%s\n\n", (show_only_unread ? "ON" : "OFF"));
  224.     fprintf (fp, "# sort articles by 0=(nothing) 1=(Subject descend) 2=(Subject ascend)\n");
  225.     fprintf (fp, "# 3=(From descend) 4=(From ascend) 5=(Date descend) 6=(Date ascend).\n");
  226.     fprintf (fp, "sort_article_type=%d\n\n", sort_art_type);
  227.     fprintf (fp, "# (-d) directory where articles/threads are saved\n");
  228.     fprintf (fp, "savedir=%s\n\n", default_savedir);
  229.     fprintf (fp, "# (-M) directory where articles/threads are saved in mailbox format\n");    
  230.     fprintf (fp, "maildir=%s\n\n", default_maildir);    
  231.     fprintf (fp, "# (-p) print program with parameters used to print articles/threads\n");
  232.     fprintf (fp, "printer=%s\n\n", printer);
  233.  
  234.     fprintf (fp, "# default actions/prompt strings for questions\n");
  235.     fprintf (fp, "default_spooldir_alias=%s\n", spooldir_alias);
  236.     fprintf (fp, "default_author_search=%s\n", default_author_search);
  237.     fprintf (fp, "default_goto_group=%s\n", default_goto_group);
  238.     fprintf (fp, "default_group_search=%s\n", default_group_search);
  239.     fprintf (fp, "default_subject_search=%s\n", default_subject_search);
  240.     fprintf (fp, "default_art_search=%s\n", default_art_search);
  241.     fprintf (fp, "default_crosspost_group=%s\n", default_crosspost_group);
  242.     fprintf (fp, "default_mail_address=%s\n", default_mail_address);
  243.     fprintf (fp, "default_move_group=%d\n", default_move_group);
  244.     fprintf (fp, "default_pipe_command=%s\n", default_pipe_command);
  245.     fprintf (fp, "default_post_subject=%s\n", default_post_subject);
  246.     fprintf (fp, "default_regex_pattern=%s\n", default_regex_pattern);
  247.     fprintf (fp, "default_save_file=%s\n", default_save_file);
  248.     fprintf (fp, "default_shell_command=%s\n", default_shell_command);
  249.  
  250.     fclose (fp);
  251.     chmod (rcfile, 0600);
  252. }
  253.  
  254. /*
  255.  *  options menu so that the user can dynamically change parameters
  256.  */
  257.  
  258. int change_rcfile (group, kill_at_once)
  259.     char *group;
  260.     int kill_at_once;
  261. {
  262.     char *str = (char *) 0;
  263.     int ch, i;
  264.     int kill_changed = FALSE;
  265.     int orig_kill_state;
  266.     int orig_show_only_unread;
  267.     int orig_thread_arts;
  268.     int option;
  269.     int ret_code = NO_KILLING;
  270.     int var_orig;
  271.     
  272. #ifdef SIGTSTP
  273.     sigtype_t (*susp)() = (sigtype_t *) 0;
  274.  
  275.     if (do_sigtstp) {
  276.         susp = sigdisp (SIGTSTP, SIG_DFL);
  277.     }
  278. #endif
  279.  
  280.     COL1 = 0;
  281.     COL2 = ((COLS / 3) * 1) + 1;
  282.     COL3 = ((COLS / 3) * 2) + 2;
  283.  
  284.     show_rcfile_menu ();
  285.  
  286.     while (1) {
  287.  
  288. #ifdef SIGTSTP
  289.         if (do_sigtstp) {
  290.             sigdisp (SIGTSTP, rcfile_suspend);
  291.         }
  292. #endif
  293.         MoveCursor (LINES, 0);
  294.         ch = ReadCh ();
  295.         if (ch >= '1' && ch <= '9') {
  296.             option = prompt_num (ch, "Enter option number> ");
  297.         } else {
  298.             if (ch == 'q' || ch == ESC) {
  299.                 option = -1;
  300.             } else {
  301.                 option = 0;
  302.             }
  303.         }
  304. #ifdef SIGTSTP
  305.         if (do_sigtstp) {
  306.             sigdisp (SIGTSTP, SIG_IGN);
  307.         }
  308. #endif
  309.         switch (option) {
  310.             case 0:
  311.                 write_rcfile ();
  312.                 /* FALLTHRU */
  313.             case -1:
  314.                 if (kill_changed) {
  315.                     if (kill_at_once) {
  316.                         if (killed_articles = read_kill_file ()) {
  317.                             if (kill_any_articles (group)) {
  318.                                 make_threads (FALSE);
  319.                                 find_base (show_only_unread);
  320.                             }
  321.                         } else {
  322.                             if (unkill_all_articles()) {
  323.                                 make_threads (FALSE);
  324.                                 find_base (show_only_unread);
  325.                             }
  326.                         }
  327.                     }
  328.                     ret_code = KILLING;
  329.                 }
  330.  
  331.                 clear_note_area ();
  332. #ifdef SIGTSTP
  333.                 if (do_sigtstp) {
  334.                     sigdisp (SIGTSTP, susp);
  335.                 }
  336. #endif
  337.                 return ret_code;
  338.             
  339.             case 1:        /* auto save */
  340.                 prompt_on_off (INDEX_TOP, COL1, &save_archive_name, 
  341.                     txt_help_autosave, txt_opt_autosave);
  342.                 break;
  343.  
  344.             case 2:        /* start editor with line offset */
  345.                 prompt_on_off (INDEX_TOP, COL2, &start_editor_offset, 
  346.                     txt_help_start_editor_offset, txt_opt_start_editor_offset);
  347.                 break;
  348.             
  349.             case 3:        /* mark saved articles read */
  350.                 prompt_on_off (INDEX_TOP, COL3, &mark_saved_read, 
  351.                     txt_help_mark_saved_read, txt_opt_mark_saved_read);
  352.                 break;
  353.  
  354.             case 4:        /* confirm action */
  355.                 prompt_on_off (INDEX_TOP+2, COL1, &confirm_action, 
  356.                     txt_help_confirm_action, txt_opt_confirm_action);
  357.                 break;
  358.  
  359.             case 5:        /* draw -> / highlighted bar */
  360.                 prompt_on_off (INDEX_TOP+2, COL2, &draw_arrow_mark, 
  361.                     txt_help_draw_arrow, txt_opt_draw_arrow);
  362.                 if (draw_arrow_mark == FALSE && inverse_okay == FALSE) {
  363.                     inverse_okay = TRUE;
  364.                 }
  365.                 break;
  366.  
  367.             case 6:        /* print header */
  368.                 prompt_on_off (INDEX_TOP+2, COL3, &print_header, 
  369.                     txt_help_print_header, txt_opt_print_header);
  370.                 break;
  371.             
  372.             case 7:        /* position cursor at first / last unread art */
  373.                 prompt_on_off (INDEX_TOP+4, COL1, &pos_first_unread, 
  374.                     txt_help_pos_first_unread, txt_opt_pos_first_unread);
  375.                 break;
  376.  
  377.             case 8:        /* scroll half/full page of groups/articles */
  378.                 prompt_on_off (INDEX_TOP+4, COL2, &full_page_scroll, 
  379.                     txt_help_page_scroll, txt_opt_page_scroll);
  380.                 break;
  381.  
  382.             case 9:        /* catchup read groups when quitting */
  383.                 prompt_on_off (INDEX_TOP+4, COL3, &catchup_read_groups, 
  384.                     txt_help_catchup_groups, txt_opt_catchup_groups);
  385.                 break;
  386.  
  387.             case 10:    /* thread/unthread all groups except those in ~/.tin/unthreaded */
  388.                 orig_thread_arts = thread_arts;    
  389.                 prompt_on_off (INDEX_TOP+6, COL1, &thread_arts, 
  390.                     txt_help_thread_arts, txt_opt_thread_arts);
  391.                 if (thread_arts != orig_thread_arts || group != (char *) 0) {
  392.                     make_threads (TRUE);
  393.                     find_base (show_only_unread);
  394.                 }
  395.                 break;
  396.  
  397.             case 11:    /* show all arts or just new/unread arts */
  398.                 orig_show_only_unread = show_only_unread;    
  399.                 prompt_on_off (INDEX_TOP+6, COL2, &show_only_unread, 
  400.                     txt_help_show_only_unread, txt_opt_show_only_unread);
  401.                 if (show_only_unread != orig_show_only_unread || group != (char *) 0) {
  402.                     make_threads (TRUE);
  403.                     find_base (show_only_unread);
  404.                     if (space_mode) {
  405.                         for (i = 0; i < top_base; i++) {
  406.                             if (new_responses (i)) {
  407.                                 break;
  408.                             }
  409.                         }
  410.                         if (i < top_base) {
  411.                             index_point = i;
  412.                         } else {
  413.                             index_point = top_base - 1;
  414.                         }
  415.                     } else {
  416.                         index_point = top_base - 1;
  417.                     }
  418.                 }
  419.                 break;
  420.  
  421.             case 13:        /* show subject & author / subject only */
  422.                 var_orig = show_author;
  423.                 show_menu_help (txt_help_show_author);
  424.                 do {
  425.                     MoveCursor (INDEX_TOP+8, COL1 + (int) strlen (txt_opt_show_author));
  426.                     if ((ch    = ReadCh()) == ' ') {
  427.                         if (show_author + 1 > SHOW_FROM_BOTH) {
  428.                             show_author = SHOW_FROM_NONE;
  429.                         } else {
  430.                             show_author++;
  431.                         }
  432.                         switch (show_author) {
  433.                             case SHOW_FROM_NONE:
  434.                                 str = txt_show_from_none;
  435.                                 break;
  436.                             case SHOW_FROM_ADDR:
  437.                                 str = txt_show_from_addr;
  438.                                 break;
  439.                             case SHOW_FROM_NAME:
  440.                                 str = txt_show_from_name;
  441.                                 break;
  442.                             case SHOW_FROM_BOTH:
  443.                                 str = txt_show_from_both;
  444.                                 break;
  445.                         }
  446.                         fputs (str, stdout);
  447.                         fflush (stdout);
  448.                     }
  449.                 } while (ch != CR && ch != ESC);
  450.  
  451.                 if (ch == ESC) {    /* restore original value */
  452.                     show_author = var_orig;
  453.                     switch (show_author) {
  454.                         case SHOW_FROM_NONE:
  455.                             str = txt_show_from_none;
  456.                             break;
  457.                         case SHOW_FROM_ADDR:
  458.                             str = txt_show_from_addr;
  459.                             break;
  460.                         case SHOW_FROM_NAME:
  461.                             str = txt_show_from_name;
  462.                             break;
  463.                         case SHOW_FROM_BOTH:
  464.                             str = txt_show_from_both;
  465.                             break;
  466.                     }
  467.                     fputs (str, stdout);
  468.                     fflush (stdout);
  469.                 } else {
  470.                     default_show_author = show_author;
  471.                     set_subj_from_size (COLS);
  472.                 }
  473.                 break;
  474.  
  475.             case 14:
  476.                 var_orig = post_proc_type;
  477.                 show_menu_help (txt_help_post_proc_type);
  478.                 do {
  479.                     MoveCursor (INDEX_TOP+8, COL2 + (int) strlen (txt_opt_process_type));
  480.                     if ((ch    = ReadCh()) == ' ') {
  481.                         if (post_proc_type + 1 > POST_PROC_UUD_EXT_ZOO) {
  482.                             post_proc_type = POST_PROC_NONE;
  483.                         } else {
  484.                             post_proc_type++;
  485.                         }
  486.                         switch (post_proc_type) {
  487.                             case POST_PROC_NONE:
  488.                                 str = txt_post_process_none;
  489.                                 proc_ch_default = 'n';
  490.                                 break;
  491.                             case POST_PROC_SHAR:
  492.                                 str = txt_post_process_sh;
  493.                                 proc_ch_default = 's';
  494.                                 break;
  495.                             case POST_PROC_UUDECODE:
  496.                                 str = txt_post_process_uudecode;
  497.                                 proc_ch_default = 'u';
  498.                                 break;
  499.                             case POST_PROC_UUD_LST_ZOO:
  500.                                 str = txt_post_process_uud_lst_zoo;
  501.                                 proc_ch_default = 'U';
  502.                                 break;
  503.                             case POST_PROC_UUD_EXT_ZOO:
  504.                                 str = txt_post_process_uud_ext_zoo;
  505.                                 proc_ch_default = 'U';
  506.                                 break;
  507.                         }
  508.                         CleartoEOLN (); 
  509.                         fputs (str, stdout);
  510.                         fflush (stdout);
  511.                     }
  512.                 } while (ch != CR && ch != ESC);
  513.  
  514.                 if (ch == ESC) {    /* restore original value */
  515.                     post_proc_type = var_orig;
  516.                     switch (post_proc_type) {
  517.                         case POST_PROC_NONE:
  518.                             str = txt_post_process_none;
  519.                             proc_ch_default = 'n';
  520.                             break;
  521.                         case POST_PROC_SHAR:
  522.                             str = txt_post_process_sh;
  523.                             proc_ch_default = 's';
  524.                             break;
  525.                         case POST_PROC_UUDECODE:
  526.                             str = txt_post_process_uudecode;
  527.                             proc_ch_default = 'u';
  528.                             break;
  529.                         case POST_PROC_UUD_LST_ZOO:
  530.                             str = txt_post_process_uud_lst_zoo;
  531.                             proc_ch_default = 'U';
  532.                             break;
  533.                         case POST_PROC_UUD_EXT_ZOO:
  534.                             str = txt_post_process_uud_ext_zoo;
  535.                             proc_ch_default = 'U';
  536.                             break;
  537.                     }
  538.                     CleartoEOLN (); 
  539.                     fputs (str, stdout);
  540.                     fflush (stdout);
  541.                 }
  542.                 break;
  543.  
  544.             case 15:
  545.                 var_orig = sort_art_type;
  546.                 show_menu_help (txt_help_sort_type);
  547.                 do {
  548.                     MoveCursor (INDEX_TOP+10, COL1 + (int) strlen (txt_opt_sort_type));
  549.                     if ((ch    = ReadCh()) == ' ') {
  550.                         if (sort_art_type + 1 > SORT_BY_DATE_ASCEND) {
  551.                             sort_art_type = SORT_BY_NOTHING;
  552.                         } else {
  553.                             sort_art_type++;
  554.                         }
  555.                         switch (sort_art_type) {
  556.                             case SORT_BY_NOTHING:
  557.                                 str = txt_sort_by_nothing;
  558.                                 break;
  559.                             case SORT_BY_SUBJ_DESCEND:
  560.                                 str = txt_sort_by_subj_descend;
  561.                                 break;
  562.                             case SORT_BY_SUBJ_ASCEND:
  563.                                 str = txt_sort_by_subj_ascend;
  564.                                 break;
  565.                             case SORT_BY_FROM_DESCEND:
  566.                                 str = txt_sort_by_from_descend;
  567.                                 break;
  568.                             case SORT_BY_FROM_ASCEND:
  569.                                 str = txt_sort_by_from_ascend;
  570.                                 break;
  571.                             case SORT_BY_DATE_DESCEND:
  572.                                 str = txt_sort_by_date_descend;
  573.                                 break;
  574.                             case SORT_BY_DATE_ASCEND:
  575.                                 str = txt_sort_by_date_ascend;
  576.                                 break;
  577.                         }
  578.                         CleartoEOLN (); 
  579.                         fputs (str, stdout);
  580.                         fflush (stdout);
  581.                     }
  582.                 } while (ch != CR && ch != ESC);
  583.  
  584.                 if (ch == ESC) {    /* restore original value */
  585.                     sort_art_type = var_orig;
  586.                     switch (sort_art_type) {
  587.                         case SORT_BY_NOTHING:
  588.                             str = txt_sort_by_nothing;
  589.                             break;
  590.                         case SORT_BY_SUBJ_DESCEND:
  591.                             str = txt_sort_by_subj_descend;
  592.                             break;
  593.                         case SORT_BY_SUBJ_ASCEND:
  594.                             str = txt_sort_by_subj_ascend;
  595.                             break;
  596.                         case SORT_BY_FROM_DESCEND:
  597.                             str = txt_sort_by_from_descend;
  598.                             break;
  599.                         case SORT_BY_FROM_ASCEND:
  600.                             str = txt_sort_by_from_ascend;
  601.                             break;
  602.                         case SORT_BY_DATE_DESCEND:
  603.                             str = txt_sort_by_date_descend;
  604.                             break;
  605.                         case SORT_BY_DATE_ASCEND:
  606.                             str = txt_sort_by_date_ascend;
  607.                             break;
  608.                     }
  609.                     CleartoEOLN (); 
  610.                     fputs (str, stdout);
  611.                     fflush (stdout);
  612.                 }
  613.                 break;
  614.  
  615.             case 16:
  616.                 show_menu_help (txt_help_savedir);
  617.                 prompt_menu_string (INDEX_TOP+12, COL1 + (int) strlen (txt_opt_savedir), default_savedir);
  618.                 expand_rel_abs_pathname (INDEX_TOP+12, COL1 + (int) strlen (txt_opt_savedir), default_savedir);
  619.                 break;
  620.  
  621.             case 17:
  622.                 show_menu_help (txt_help_maildir);
  623.                 prompt_menu_string (INDEX_TOP+14, COL1 + (int) strlen (txt_opt_maildir), default_maildir);
  624.                 expand_rel_abs_pathname (INDEX_TOP+14, COL1 + (int) strlen (txt_opt_maildir), default_maildir);
  625.                 break;
  626.  
  627.             case 18:
  628.                 show_menu_help (txt_help_printer);
  629.                 prompt_menu_string (INDEX_TOP+16, COL1 + (int) strlen (txt_opt_printer), printer);
  630.                 expand_rel_abs_pathname (INDEX_TOP+16, COL1 + (int) strlen (txt_opt_printer), printer);
  631.                 break;
  632.         }
  633.         show_menu_help (txt_select_rcfile_option);
  634.     }
  635. }
  636.  
  637.  
  638. void show_rcfile_menu ()
  639. {
  640.     char *str = (char *) 0;
  641.  
  642.     ClearScreen ();
  643.  
  644.     center_line (0, TRUE, txt_options_menu);
  645.     
  646.     MoveCursor (INDEX_TOP, 0);
  647.     printf ("%s%s\r\n\r\n", txt_opt_autosave, (save_archive_name ? "ON " : "OFF"));
  648.     printf ("%s%s\r\n\r\n", txt_opt_confirm_action, (confirm_action ? "ON " : "OFF"));
  649.     printf ("%s%s\r\n\r\n", txt_opt_pos_first_unread, (pos_first_unread ? "ON " : "OFF"));
  650.     printf ("%s%s", txt_opt_thread_arts, (thread_arts ? "ON " : "OFF"));
  651.  
  652.     MoveCursor(INDEX_TOP, COL2);
  653.     printf ("%s%s", txt_opt_start_editor_offset, (start_editor_offset ? "ON " : "OFF"));
  654.     MoveCursor(INDEX_TOP+2, COL2);
  655.     printf ("%s%s", txt_opt_draw_arrow, (draw_arrow_mark ? "ON " : "OFF"));
  656.     MoveCursor(INDEX_TOP+4, COL2);
  657.     printf ("%s%s", txt_opt_page_scroll, (full_page_scroll ? "ON " : "OFF"));
  658.     MoveCursor(INDEX_TOP+6, COL2);
  659.     printf ("%s%s", txt_opt_show_only_unread, (show_only_unread ? "ON " : "OFF"));
  660.  
  661.     MoveCursor(INDEX_TOP, COL3);
  662.     printf ("%s%s", txt_opt_mark_saved_read, (mark_saved_read ? "ON " : "OFF"));
  663.     MoveCursor(INDEX_TOP+2, COL3);
  664.     printf ("%s%s", txt_opt_print_header, (print_header ? "ON " : "OFF"));
  665.     MoveCursor(INDEX_TOP+4, COL3);
  666.     printf ("%s%s", txt_opt_catchup_groups, (catchup_read_groups ? "ON " : "OFF"));
  667.  
  668.     MoveCursor(INDEX_TOP+8, COL1);
  669.     switch (show_author) {
  670.         case SHOW_FROM_NONE:
  671.             str = txt_show_from_none;
  672.             break;
  673.         case SHOW_FROM_ADDR:
  674.             str = txt_show_from_addr;
  675.             break;
  676.         case SHOW_FROM_NAME:
  677.             str = txt_show_from_name;
  678.             break;
  679.         case SHOW_FROM_BOTH:
  680.             str = txt_show_from_both;
  681.             break;
  682.     }
  683.     printf ("%s%s", txt_opt_show_author, str);
  684.     MoveCursor(INDEX_TOP+8, COL2);
  685.     switch (post_proc_type) {
  686.         case POST_PROC_NONE:
  687.             str = txt_post_process_none;
  688.             break;
  689.         case POST_PROC_SHAR:
  690.             str = txt_post_process_sh;
  691.             break;
  692.         case POST_PROC_UUDECODE:
  693.             str = txt_post_process_uudecode;
  694.             break;
  695.         case POST_PROC_UUD_LST_ZOO:
  696.             str = txt_post_process_uud_lst_zoo;
  697.             break;
  698.         case POST_PROC_UUD_EXT_ZOO:
  699.             str = txt_post_process_uud_ext_zoo;
  700.             break;
  701.     }
  702.     printf ("%s%s\r\n\r\n", txt_opt_process_type, str);
  703.     
  704.     MoveCursor(INDEX_TOP+10, COL1);
  705.     switch (sort_art_type) {
  706.         case SORT_BY_NOTHING:
  707.             str = txt_sort_by_nothing;
  708.             break;
  709.         case SORT_BY_SUBJ_DESCEND:
  710.             str = txt_sort_by_subj_descend;
  711.             break;
  712.         case SORT_BY_SUBJ_ASCEND:
  713.             str = txt_sort_by_subj_ascend;
  714.             break;
  715.         case SORT_BY_FROM_DESCEND:
  716.             str = txt_sort_by_from_descend;
  717.             break;
  718.         case SORT_BY_FROM_ASCEND:
  719.             str = txt_sort_by_from_ascend;
  720.             break;
  721.         case SORT_BY_DATE_DESCEND:
  722.             str = txt_sort_by_date_descend;
  723.             break;
  724.         case SORT_BY_DATE_ASCEND:
  725.             str = txt_sort_by_date_ascend;
  726.             break;
  727.     }
  728.     printf ("%s%s\r\n\r\n", txt_opt_sort_type, str);
  729.  
  730.     printf ("%s%s\r\n\r\n", txt_opt_savedir, default_savedir);
  731.     printf ("%s%s\r\n\r\n", txt_opt_maildir, default_maildir);
  732.     printf ("%s%s\r\n\r\n", txt_opt_printer, printer);
  733.     fflush(stdout);
  734.  
  735.     show_menu_help (txt_select_rcfile_option);
  736.     MoveCursor (LINES, 0);
  737. }
  738.  
  739. /*
  740.  *  expand ~/News to /usr/username/News and print to screen
  741.  */
  742.  
  743. void expand_rel_abs_pathname (line, col, str)
  744.     int line;
  745.     int col;
  746.     char *str;
  747. {
  748.     char buf[LEN];
  749.     
  750.     if (str[0] == '~') {
  751.         if (strlen (str) == 1) {
  752.             strcpy (str, homedir);
  753.         } else {
  754.             sprintf (buf, "%s%s", homedir, str+1);
  755.             strcpy (str, buf);
  756.         }
  757.     }
  758.     MoveCursor (line, col);
  759.     CleartoEOLN ();
  760.     puts (str);
  761.     fflush (stdout);
  762. }
  763.  
  764. /*
  765.  *  show_menu_help
  766.  */
  767.  
  768. void show_menu_help (help_message)
  769.     char *help_message;
  770. {
  771.      MoveCursor (LINES-2, 0);
  772.      CleartoEOLN ();
  773.      center_line (LINES-2, FALSE, help_message);
  774. }
  775.  
  776.  
  777. int match_boolean (line, pat, dst)
  778.     char *line;
  779.     char *pat;
  780.     int *dst;
  781. {
  782.     int    patlen = strlen (pat);
  783.  
  784.     if (strncmp (line, pat, patlen) == 0) {
  785.         *dst = (strncmp (&line[patlen], "ON", 2) == 0 ? TRUE : FALSE);
  786.         return TRUE;
  787.     }
  788.     return FALSE;
  789. }
  790.  
  791.  
  792. int match_number (line, pat, dst)
  793.     char *line;
  794.     char *pat;
  795.     int *dst;
  796. {
  797.     int    patlen = strlen (pat);
  798.  
  799.     if (strncmp (line, pat, patlen) == 0) {
  800.         *dst = atoi (&line[patlen]);
  801.         return TRUE;
  802.     }
  803.     return FALSE;
  804. }
  805.  
  806.  
  807. int match_string (line, pat, dst, dstlen)
  808.     char *line;
  809.     char *pat;
  810.     char *dst;
  811.     int dstlen;
  812. {
  813.     int    patlen = strlen (pat);
  814.  
  815.     if (strncmp (line, pat, patlen) == 0) {
  816.         strncpy (dst, &line[patlen], dstlen);
  817.         dst[strlen (dst) - 1] = '\0';
  818.         return TRUE;
  819.     }
  820.     return FALSE;
  821. }
  822.  
  823.