"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.2/src/init.c" (8 Dec 2017, 38353 Bytes) of package /linux/misc/tin-2.4.2.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "init.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.4.1_vs_2.4.2.

    1 /*
    2  *  Project   : tin - a Usenet reader
    3  *  Module    : init.c
    4  *  Author    : I. Lea
    5  *  Created   : 1991-04-01
    6  *  Updated   : 2017-08-13
    7  *  Notes     :
    8  *
    9  * Copyright (c) 1991-2018 Iain Lea <iain@bricbrac.de>
   10  * All rights reserved.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. The name of the author may not be used to endorse or promote
   21  *    products derived from this software without specific prior written
   22  *    permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   25  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
   28  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   30  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   32  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   35  */
   36 
   37 
   38 #ifndef TIN_H
   39 #   include "tin.h"
   40 #endif /* !TIN_H */
   41 #ifndef TNNTP_H
   42 #   include "tnntp.h"
   43 #endif /* !TNNTP_H */
   44 #ifndef included_trace_h
   45 #   include "trace.h"
   46 #endif /* !included_trace_h */
   47 #ifndef VERSION_H
   48 #   include "version.h"
   49 #endif /* !VERSION_H */
   50 #ifndef BUGREP_H
   51 #   include "bugrep.h"
   52 #endif /* !BUGREP_H */
   53 
   54 /*
   55  * local prototypes
   56  */
   57 static int read_site_config(void);
   58 #ifdef HAVE_COLOR
   59     static void preinit_colors(void);
   60 #endif /* HAVE_COLOR */
   61 
   62 
   63 char active_times_file[PATH_LEN];
   64 char article_name[PATH_LEN];            /* ~/TIN_ARTICLE_NAME file */
   65 char bug_nntpserver1[PATH_LEN];     /* welcome message of NNTP server used */
   66 char bug_nntpserver2[PATH_LEN];     /* welcome message of NNTP server used */
   67 char cvers[LEN];
   68 char dead_article[PATH_LEN];        /* ~/dead.article file */
   69 char dead_articles[PATH_LEN];       /* ~/dead.articles file */
   70 char default_organization[PATH_LEN];    /* Organization: */
   71 char default_signature[PATH_LEN];
   72 char domain_name[MAXHOSTNAMELEN + 1];
   73 char global_attributes_file[PATH_LEN];
   74 char global_config_file[PATH_LEN];
   75 char homedir[PATH_LEN];
   76 char index_maildir[PATH_LEN];
   77 char index_newsdir[PATH_LEN];   /* directory for private overview data */
   78 char index_savedir[PATH_LEN];
   79 char inewsdir[PATH_LEN];
   80 char local_attributes_file[PATH_LEN];
   81 char local_config_file[PATH_LEN];
   82 char local_input_history_file[PATH_LEN];
   83 char local_newsgroups_file[PATH_LEN];   /* local copy of NNTP newsgroups file */
   84 char local_newsrctable_file[PATH_LEN];
   85 char lock_file[PATH_LEN];       /* contains name of index lock file */
   86 char filter_file[PATH_LEN];
   87 char mail_news_user[LEN];       /* mail new news to this user address */
   88 char mailbox[PATH_LEN];         /* system mailbox for each user */
   89 char mailer[PATH_LEN];          /* mail program */
   90 char newnewsrc[PATH_LEN];
   91 char news_active_file[PATH_LEN];
   92 char newsgroups_file[PATH_LEN];
   93 char newsrc[PATH_LEN];
   94 char page_header[LEN];          /* page header of pgm name and version */
   95 char posted_info_file[PATH_LEN];
   96 char postponed_articles_file[PATH_LEN]; /* ~/.tin/postponed.articles file */
   97 char rcdir[PATH_LEN];
   98 char save_active_file[PATH_LEN];
   99 char spooldir[PATH_LEN];        /* directory where news is */
  100 char overviewfmt_file[PATH_LEN];    /* full path to overview.fmt */
  101 char subscriptions_file[PATH_LEN];  /* full path to subscriptions */
  102 char *tin_progname;     /* program name */
  103 char txt_help_bug_report[LEN];      /* address to send bug reports to */
  104 char userid[PATH_LEN];
  105 #ifdef HAVE_MH_MAIL_HANDLING
  106     char mail_active_file[PATH_LEN];
  107     char mailgroups_file[PATH_LEN];
  108 #endif /* HAVE_MH_MAIL_HANDLING */
  109 #ifndef NNTP_ONLY
  110     char novfilename[NAME_LEN + 1];     /* file name of a single nov index file */
  111     char novrootdir[PATH_LEN];      /* root directory of nov index files */
  112 #endif /* !NNTP_ONLY */
  113 
  114 t_function last_search = GLOBAL_SEARCH_REPEAT;  /* for repeated search */
  115 int hist_last[HIST_MAXNUM + 1];
  116 int hist_pos[HIST_MAXNUM + 1];
  117 int iso2asc_supported;          /* Convert ISO-Latin1 to Ascii */
  118 int system_status;
  119 int xmouse, xrow, xcol;         /* xterm button pressing information */
  120 
  121 pid_t process_id;           /* Useful to have around for .suffixes */
  122 
  123 t_bool batch_mode;          /* update index files only mode */
  124 t_bool check_for_new_newsgroups;    /* don't check for new newsgroups */
  125 t_bool cmd_line;            /* batch / interactive mode */
  126 t_bool created_rcdir;           /* checks if first time tin is started */
  127 t_bool dangerous_signal_exit;       /* no get_respcode() in nntp_command when dangerous signal exit */
  128 t_bool disable_gnksa_domain_check;  /* disable checking TLD in From: etc. */
  129 t_bool disable_sender;          /* disable generation of Sender: header */
  130 #ifdef NO_POSTING
  131     t_bool force_no_post = TRUE;        /* force no posting mode */
  132 #else
  133     t_bool force_no_post = FALSE;   /* don't force no posting mode */
  134 #endif /* NO_POSTING */
  135 #if defined(NNTP_ABLE) && defined(INET6)
  136     t_bool force_ipv4 = FALSE;
  137     t_bool force_ipv6 = FALSE;
  138 #endif /* NNTP_ABLE && INET6 */
  139 t_bool list_active;
  140 t_bool newsrc_active;
  141 t_bool no_write = FALSE;        /* do not write newsrc on quit (-X cmd-line flag) */
  142 t_bool post_article_and_exit;       /* quick post of an article then exit(elm like) */
  143 t_bool post_postponed_and_exit;     /* post postponed articles and exit */
  144 t_bool range_active;        /* Set if a range is defined */
  145 t_bool reread_active_for_posted_arts;
  146 t_bool read_local_newsgroups_file;  /* read newsgroups file locally or via NNTP */
  147 t_bool read_news_via_nntp = FALSE;  /* read news locally or via NNTP */
  148 t_bool read_saved_news = FALSE;     /* tin -R read saved news from tin -S */
  149 t_bool show_description = TRUE;     /* current copy of tinrc flag */
  150 t_bool verbose = FALSE;         /* update index files only mode */
  151 t_bool word_highlight;      /* word highlighting on/off */
  152 t_bool xref_supported = TRUE;
  153 #ifdef HAVE_COLOR
  154     t_bool use_color;       /* enables/disables ansi-color support under linux-console and color-xterm */
  155 #endif /* HAVE_COLOR */
  156 #ifdef NNTP_ABLE
  157     t_bool force_auth_on_conn_open = FALSE; /* authenticate on connection startup */
  158     unsigned short nntp_tcp_port;
  159 #endif /* NNTP_ABLE */
  160 
  161 /* Currently active menu parameters */
  162 t_menu *currmenu;
  163 
  164 /* History entries */
  165 char *input_history[HIST_MAXNUM + 1][HIST_SIZE + 1];
  166 
  167 #ifdef HAVE_SYS_UTSNAME_H
  168     struct utsname system_info;
  169 #endif /* HAVE_SYS_UTSNAME_H */
  170 
  171 struct regex_cache
  172         strip_re_regex, strip_was_regex,
  173         uubegin_regex, uubody_regex,
  174         verbatim_begin_regex, verbatim_end_regex,
  175         url_regex, mail_regex, news_regex,
  176         shar_regex,
  177         slashes_regex, stars_regex, underscores_regex, strokes_regex
  178 #ifdef HAVE_COLOR
  179         , extquote_regex, quote_regex, quote_regex2, quote_regex3
  180 #endif /* HAVE_COLOR */
  181     = {
  182         NULL,
  183         NULL
  184     };
  185 
  186 struct t_cmdlineopts cmdline;
  187 
  188 struct t_config tinrc = {
  189     ART_MARK_DELETED,       /* art_marked_deleted */
  190     MARK_INRANGE,           /* art_marked_inrange */
  191     ART_MARK_RETURN,        /* art_marked_return */
  192     ART_MARK_SELECTED,      /* art_marked_selected */
  193     ART_MARK_RECENT,        /* art_marked_recent */
  194     ART_MARK_UNREAD,        /* art_marked_unread */
  195     ART_MARK_READ,          /* art_marked_read */
  196     ART_MARK_KILLED,        /* art_marked_killed */
  197     ART_MARK_READ_SELECTED,     /* art_marked_read_selected */
  198     "",     /* editor_format */
  199     "",     /* default_goto_group */
  200     "",     /* default_mail_address */
  201     "",     /* mailer_format */
  202 #ifndef DONT_HAVE_PIPING
  203     "",     /* default_pipe_command */
  204 #endif /* !DONT_HAVE_PIPING */
  205     "",     /* default_post_newsgroups */
  206     "",     /* default_post_subject */
  207 #ifndef DISABLE_PRINTING
  208     "",     /* printer */
  209 #endif /* !DISABLE_PRINTING */
  210     "1-.",  /* default_range_group */
  211     "1-.",  /* default_range_select */
  212     "1-.",  /* default_range_thread */
  213     "",     /* default_pattern */
  214     "",     /* default_repost_group */
  215     "savefile.tin",     /* default_save_file */
  216     "",     /* default_search_art */
  217     "",     /* default_search_author */
  218     "",     /* default_search_config */
  219     "",     /* default_search_group */
  220     "",     /* default_search_subject */
  221     "",     /* default_select_pattern */
  222     "",     /* default_shell_command */
  223     "In article %M you wrote:",     /* mail_quote_format */
  224     "",     /* maildir */
  225 #ifdef SCO_UNIX
  226     2,          /* mailbox_format = MMDF */
  227 #else
  228     0,          /* mailbox_format = MBOXO */
  229 #endif /* SCO_UNIX */
  230     "",     /* mail_address */
  231 #ifdef HAVE_METAMAIL
  232     METAMAIL_CMD,       /* metamail_prog */
  233 #else
  234     INTERNAL_CMD,       /* metamail_prog */
  235 #endif /* HAVE_METAMAIL */
  236 #ifndef CHARSET_CONVERSION
  237     "",     /* mm_charset, defaults to $MM_CHARSET */
  238 #else
  239     -1,     /* mm_network_charset, defaults to $MM_CHARSET */
  240 #endif /* !CHARSET_CONVERSION */
  241     "US-ASCII",     /* mm_local_charset, display charset */
  242 #ifdef HAVE_ICONV_OPEN_TRANSLIT
  243     FALSE,  /* translit */
  244 #endif /* HAVE_ICONV_OPEN_TRANSLIT */
  245     "Newsgroups Followup-To Summary Keywords X-Comment-To",     /* news_headers_to_display */
  246     "",     /* news_headers_to_not_display */
  247     "%F wrote:",        /* news_quote_format */
  248     DEFAULT_COMMENT,    /* quote_chars */
  249 #ifdef HAVE_COLOR
  250     "",     /* quote_regex */
  251     "",     /* quote_regex 2nd level */
  252     "",     /* quote_regex >= 3rd level */
  253     "",     /* extquote_regex */
  254 #endif /* HAVE_COLOR */
  255     "",     /* slashes_regex */
  256     "",     /* stars_regex */
  257     "",     /* underscores_regex */
  258     "",     /* strokes_regex */
  259     "",     /* sigfile */
  260     "",     /* strip_re_regex */
  261     "",     /* strip_was_regex */
  262     "",     /* verbatim_begin_regex */
  263     "",     /* verbatim_end_regex */
  264     "",     /* savedir */
  265     "",     /* spamtrap_warning_addresses */
  266     DEFAULT_URL_HANDLER,    /* url_handler */
  267     "In %G %F wrote:",          /* xpost_quote_format */
  268     DEFAULT_FILTER_DAYS,            /* filter_days */
  269     FILTER_SUBJ_CASE_SENSITIVE,     /* default_filter_kill_header */
  270     FILTER_SUBJ_CASE_SENSITIVE,     /* default_filter_select_header */
  271     0,      /* default_move_group */
  272     'a',        /* default_save_mode */
  273     0,      /* getart_limit */
  274     2,      /* recent_time */
  275     GOTO_NEXT_UNREAD_TAB,       /* goto_next_unread */
  276     UUE_NO, /* hide_uue */
  277     KILL_UNREAD,        /* kill_level */
  278     MIME_ENCODING_QP,       /* mail_mime_encoding */
  279     MIME_ENCODING_8BIT,     /* post_mime_encoding */
  280     POST_PROC_NO,           /* post_process_type */
  281     REREAD_ACTIVE_FILE_SECS,    /* reread_active_file_secs */
  282     1,      /* scroll_lines */
  283     SHOW_FROM_NAME,             /* show_author */
  284     SORT_ARTICLES_BY_DATE_ASCEND,       /* sort_article_type */
  285     SORT_THREADS_BY_SCORE_DESCEND,      /* sort_threads_type */
  286 #ifdef USE_HEAPSORT
  287     0,              /* sort_function default qsort */
  288 #endif /* USE_HEAPSORT */
  289     BOGUS_SHOW,     /* strip_bogus */
  290     THREAD_BOTH,        /* thread_articles */
  291     THREAD_PERC_DEFAULT,    /* thread_perc */
  292     THREAD_SCORE_MAX,   /* thread_score */
  293     0,      /* Default to wildmat, not regex */
  294     -50,        /* score_limit_kill */
  295     50,     /* score_limit_select */
  296     -100,       /* score_kill */
  297     100,        /* score_select */
  298     0,      /* trim_article_body */
  299 #ifdef HAVE_COLOR
  300     0,      /* col_back (initialised later) */
  301     0,      /* col_from (initialised later) */
  302     0,      /* col_head (initialised later) */
  303     0,      /* col_help (initialised later) */
  304     0,      /* col_invers_bg (initialised later) */
  305     0,      /* col_invers_fg (initialised later) */
  306     0,      /* col_minihelp (initialised later) */
  307     0,      /* col_normal (initialised later) */
  308     0,      /* col_markdash (initialised later) */
  309     0,      /* col_markstar (initialised later) */
  310     0,      /* col_markslash (initialised later) */
  311     0,      /* col_markstroke (initialised later) */
  312     0,      /* col_message (initialised later) */
  313     0,      /* col_newsheaders (initialised later) */
  314     0,      /* col_quote (initialised later) */
  315     0,      /* col_quote2 (initialised later) */
  316     0,      /* col_quote3 (initialised later) */
  317     0,      /* col_extquote (initialised later) */
  318     0,      /* col_response (initialised later) */
  319     0,      /* col_signature (initialised later) */
  320     0,      /* col_urls (initialised later) */
  321     0,      /* col_verbatim (initialised later) */
  322     0,      /* col_subject (initialised later) */
  323     0,      /* col_text (initialised later) */
  324     0,      /* col_title (initialised later) */
  325 #endif /* HAVE_COLOR */
  326     2,      /* word_h_display_marks */
  327     2,      /* mono_markdash */
  328     6,      /* mono_markstar */
  329     5,      /* mono_markslash */
  330     3,      /* mono_markstroke */
  331     TRUE,       /* word_highlight */
  332     TRUE,       /* url_highlight */
  333     0,      /* wrap_column */
  334 #ifdef HAVE_COLOR
  335     FALSE,      /* use_color */
  336 #endif /* HAVE_COLOR */
  337     FALSE,      /* abbreviate_groupname */
  338     TRUE,       /* add_posted_to_filter */
  339     TRUE,       /* advertising */
  340     TRUE,       /* alternative_handling */
  341     0,          /* auto_cc_bcc */
  342     TRUE,       /* auto_list_thread */
  343     FALSE,      /* auto_reconnect */
  344     FALSE,      /* auto_save */
  345     TRUE,       /* batch_save */
  346     TRUE,       /* beginner_level */
  347     FALSE,      /* cache_overview_files */
  348     FALSE,      /* catchup_read_groups */
  349     4,      /* confirm_choice */
  350 #ifdef USE_INVERSE_HACK
  351     TRUE,       /* draw_arrow */
  352 #else
  353     FALSE,      /* draw_arrow */
  354 #endif /* USE_INVERSE_HACK */
  355     FALSE,      /* force_screen_redraw */
  356     TRUE,       /* group_catchup_on_exit */
  357     FALSE,      /* info_in_last_line */
  358 #ifdef USE_INVERSE_HACK
  359     FALSE,      /* inverse_okay */
  360 #else
  361     TRUE,       /* inverse_okay */
  362 #endif /* USE_INVERSE_HACK */
  363     TRUE,       /* keep_dead_articles */
  364     POSTED_FILE,    /* posted_articles_file */
  365     FALSE,      /* mail_8bit_header */
  366     FALSE,      /* mark_ignore_tags */
  367     TRUE,       /* mark_saved_read */
  368     TRUE,       /* pos_first_unread */
  369     FALSE,      /* post_8bit_header */
  370     TRUE,       /* post_process_view */
  371 #ifndef DISABLE_PRINTING
  372     FALSE,      /* print_header */
  373 #endif /* !DISABLE_PRINTING */
  374     FALSE,      /* process_only_unread */
  375     FALSE,      /* prompt_followupto */
  376     QUOTE_COMPRESS|QUOTE_EMPTY, /* quote_style */
  377     TRUE,       /* show_description */
  378     TRUE,       /* show_only_unread_arts */
  379     FALSE,      /* show_only_unread_groups */
  380     TRUE,       /* show_signatures */
  381     TRUE,       /* sigdashes */
  382     TRUE,       /* signature_repost */
  383 #ifdef M_UNIX
  384     TRUE,       /* start_editor_offset */
  385 #else
  386     FALSE,      /* start_editor_offset */
  387 #endif /* M_UNIX */
  388 #ifndef USE_CURSES
  389     TRUE,       /* strip_blanks */
  390 #endif /* !USE_CURSES */
  391     FALSE,      /* strip_newsrc */
  392     FALSE,      /* tex2iso_conv */
  393     TRUE,       /* thread_catchup_on_exit */
  394     TRUE,       /* unlink_article */
  395 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  396     FALSE,      /* utf8_graphics */
  397 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  398     TRUE,       /* verbatim_handling */
  399 #ifdef HAVE_COLOR
  400     FALSE,      /* extquote_handling */
  401 #endif /* HAVE_COLOR */
  402     "",     /* inews_prog */
  403 #ifdef USE_CANLOCK
  404     1,          /* cancel_lock_algo, sha1 */
  405 #endif /* USE_CANLOCK */
  406     INTERACTIVE_NONE,       /* interactive_mailer */
  407     FALSE,      /* use_mouse */
  408 #ifdef HAVE_KEYPAD
  409     FALSE,      /* use_keypad */
  410 #endif /* HAVE_KEYPAD */
  411     TRUE,       /* wrap_on_next_unread */
  412     FALSE,      /* ask_for_metamail */
  413     FALSE,      /* default_filter_kill_case */
  414     FALSE,      /* default_filter_kill_expire */
  415     TRUE,       /* default_filter_kill_global */
  416     FALSE,      /* default_filter_select_case */
  417     FALSE,      /* default_filter_select_expire */
  418 #ifdef XFACE_ABLE
  419     FALSE,      /* use_slrnface */
  420 #endif /* XFACE_ABLE */
  421     TRUE,       /* default_filter_select_global */
  422     DEFAULT_SELECT_FORMAT,  /* select_format */
  423     DEFAULT_GROUP_FORMAT,   /* group_format */
  424     DEFAULT_THREAD_FORMAT,  /* thread_format */
  425     DEFAULT_DATE_FORMAT,    /* date_format */
  426 #ifdef HAVE_UNICODE_NORMALIZATION
  427     DEFAULT_NORMALIZE,      /* normalization form */
  428 #endif /* HAVE_UNICODE_NORMALIZATION */
  429 #if defined(HAVE_LIBICUUC) && defined(MULTIBYTE_ABLE) && defined(HAVE_UNICODE_UBIDI_H) && !defined(NO_LOCALE)
  430     FALSE,      /* render_bidi */
  431 #endif /* HAVE_LIBICUUC && MULTIBYTE_ABLE && HAVE_UNICODE_UBIDI_H && !NO_LOCALE */
  432 #ifdef CHARSET_CONVERSION
  433     -1,     /* attrib_mm_network_charset, defaults to $MM_CHARSET */
  434     "",     /* attrib_undeclared_charset */
  435 #endif /* !CHARSET_CONVERSION */
  436     "",     /* attrib_editor_format */
  437     "",     /* attrib_fcc */
  438     "",     /* attrib_maildir */
  439     "",     /* attrib_from */
  440     "",     /* attrib_mailing_list */
  441     "",     /* attrib_organization */
  442     "",     /* attrib_followup_to */
  443     "",     /* attrib_mime_types_to_save */
  444     "",     /* attrib_news_headers_to_display */
  445     "",     /* attrib_news_headers_to_not_display */
  446     "",     /* attrib_news_quote_format */
  447     "",     /* attrib_quote_chars */
  448     "",     /* attrib_sigfile */
  449     "",     /* attrib_savedir */
  450     "",     /* attrib_savefile */
  451     "",     /* attrib_x_body */
  452     "",     /* attrib_x_headers */
  453 #ifdef HAVE_ISPELL
  454     "",     /* attrib_ispell */
  455 #endif /* HAVE_ISPELL */
  456     "",     /* attrib_quick_kill_scope */
  457     "",     /* attrib_quick_select_scope */
  458     "",     /* attrib_group_format */
  459     "",     /* attrib_thread_format */
  460     "",     /* attrib_date_format */
  461     0,      /* attrib_trim_article_body */
  462     0,      /* attrib_auto_cc_bcc */
  463     FILTER_SUBJ_CASE_SENSITIVE,     /* attrib_quick_kill_header */
  464     FILTER_SUBJ_CASE_SENSITIVE,     /* attrib_quick_select_header */
  465     MIME_ENCODING_QP,       /* attrib_mail_mime_encoding */
  466 #if defined(HAVE_ALARM) && defined(SIGALRM)
  467     120,    /* nntp_read_timeout_secs */
  468 #endif /* HAVE_ALARM && SIGALRM */
  469     MIME_ENCODING_8BIT,     /* attrib_post_mime_encoding */
  470     POST_PROC_NO,           /* attrib_post_process_type */
  471     SHOW_FROM_NAME,         /* attrib_show_author */
  472     SORT_ARTICLES_BY_DATE_ASCEND,       /* attrib_sort_article_type */
  473     SORT_THREADS_BY_SCORE_DESCEND,      /* attrib_sort_threads_type */
  474     THREAD_BOTH,        /* attrib_thread_articles */
  475     THREAD_PERC_DEFAULT,    /* attrib_thread_perc */
  476     TRUE,       /* attrib_add_posted_to_filter */
  477     TRUE,       /* attrib_advertising */
  478     TRUE,       /* attrib_alternative_handling */
  479     TRUE,       /* attrib_auto_list_thread */
  480     FALSE,      /* attrib_auto_select */
  481     FALSE,      /* attrib_auto_save */
  482     TRUE,       /* attrib_batch_save */
  483     TRUE,       /* attrib_delete_tmp_files */
  484     TRUE,       /* attrib_group_catchup_on_exit */
  485     FALSE,      /* attrib_mail_8bit_header */
  486     FALSE,      /* attrib_mime_forward */
  487     FALSE,      /* attrib_mark_ignore_tags */
  488     TRUE,       /* attrib_mark_saved_read */
  489     TRUE,       /* attrib_pos_first_unread */
  490     FALSE,      /* attrib_post_8bit_header */
  491     TRUE,       /* attrib_post_process_view */
  492 #ifndef DISABLE_PRINTING
  493     FALSE,      /* attrib_print_header */
  494 #endif /* !DISABLE_PRINTING */
  495     FALSE,      /* attrib_process_only_unread */
  496     FALSE,      /* attrib_prompt_followupto */
  497     TRUE,       /* attrib_show_only_unread_arts */
  498     TRUE,       /* attrib_show_signatures */
  499     TRUE,       /* attrib_sigdashes */
  500     TRUE,       /* attrib_signature_repost */
  501 #ifdef M_UNIX
  502     TRUE,       /* attrib_start_editor_offset */
  503 #else
  504     FALSE,      /* attrib_start_editor_offset */
  505 #endif /* M_UNIX */
  506     FALSE,      /* attrib_tex2iso_conv */
  507     TRUE,       /* attrib_thread_catchup_on_exit */
  508     TRUE,       /* attrib_verbatim_handling */
  509 #ifdef HAVE_COLOR
  510     FALSE,      /* attrib_extquote_handling */
  511 #endif /* HAVE_COLOR */
  512     FALSE,      /* attrib_x_comment_to */
  513     TRUE,       /* attrib_wrap_on_next_unread */
  514     FALSE,      /* attrib_ask_for_metamail */
  515     FALSE,      /* attrib_quick_kill_case */
  516     FALSE,      /* attrib_quick_kill_expire */
  517     FALSE,      /* attrib_quick_select_case */
  518     FALSE       /* attrib_quick_select_expire */
  519 };
  520 
  521 struct t_capabilities nntp_caps = {
  522     NONE, /* type (NONE, CAPABILITIES, BROKEN) */
  523     0, /* CAPABILITIES version */
  524     FALSE, /* MODE-READER: "MODE READER" */
  525     FALSE, /* READER: "ARTICLE", "BODY" */
  526     FALSE, /* POST */
  527     FALSE, /* LIST: "LIST ACTIVE" */
  528     FALSE, /* LIST: "LIST ACTIVE.TIMES" */
  529     FALSE, /* LIST: "LIST DISTRIB.PATS" */
  530     FALSE, /* LIST: "LIST HEADERS" */
  531     FALSE, /* LIST: "LIST NEWSGROUPS" */
  532     FALSE, /* LIST: "LIST OVERVIEW.FMT" */
  533     FALSE, /* LIST: "LIST MOTD" */
  534     FALSE, /* LIST: "LIST SUBSCRIPTIONS" */
  535     FALSE, /* LIST: "LIST DISTRIBUTIONS" */
  536     FALSE, /* LIST: "LIST MODERATORS" */
  537     FALSE, /* LIST: "LIST COUNTS" */
  538     FALSE, /* XPAT */
  539     FALSE, /* HDR: "HDR", "LIST HEADERS" */
  540     NULL, /* [X]HDR */
  541     FALSE, /* OVER: "OVER", "LIST OVERVIEW.FMT" */
  542     FALSE, /* OVER: "OVER mid" */
  543     NULL, /* [X]OVER */
  544     FALSE, /* NEWNEWS */
  545     NULL, /* IMPLEMENTATION */
  546     FALSE, /* STARTTLS */
  547     FALSE, /* AUTHINFO USER/PASS */
  548     FALSE, /* AUTHINFO SASL */
  549     FALSE, /* AUTHINFO available but not in current state */
  550     SASL_NONE, /* SASL CRAM-MD5 DIGEST-MD5 PLAIN GSSAPI EXTERNAL OTP NTLM LOGIN */
  551     FALSE, /* COMPRESS */
  552     COMPRESS_NONE, /* COMPRESS_NONE, COMPRESS_DEFLATE */
  553 #if 0
  554     FALSE, /* STREAMING: "MODE STREAM", "CHECK", "TAKETHIS" */
  555     FALSE /* IHAVE */
  556 #endif /* 0 */
  557 #ifndef BROKEN_LISTGROUP
  558     FALSE /* LISTGROUP doesn't select group */
  559 #else
  560     TRUE
  561 #endif /* !BROKEN_LISTGROUP */
  562 };
  563 
  564 static char libdir[PATH_LEN];           /* directory where news config files are (ie. active) */
  565 static mode_t real_umask;
  566 
  567 #ifdef HAVE_COLOR
  568 
  569 #   define DFT_FORE -1
  570 #   define DFT_BACK -2
  571 #   define DFT_INIT -3
  572 
  573 static const struct {
  574     int *colorp;
  575     int color_dft;  /* -2 back, -1 fore, >=0 normal */
  576 } our_colors[] = {
  577     { &tinrc.col_back,       DFT_BACK },
  578     { &tinrc.col_from,        2 },
  579     { &tinrc.col_head,        2 },
  580     { &tinrc.col_help,       DFT_FORE },
  581     { &tinrc.col_invers_bg,   4 },
  582     { &tinrc.col_invers_fg,   7 },
  583     { &tinrc.col_markdash,   13 },
  584     { &tinrc.col_markstar,   11 },
  585     { &tinrc.col_markslash,  14 },
  586     { &tinrc.col_markstroke, 12 },
  587     { &tinrc.col_message,     6 },
  588     { &tinrc.col_minihelp,    3 },
  589     { &tinrc.col_newsheaders, 9 },
  590     { &tinrc.col_normal,     DFT_FORE },
  591     { &tinrc.col_quote,       2 },
  592     { &tinrc.col_quote2,      3 },
  593     { &tinrc.col_quote3,      4 },
  594     { &tinrc.col_extquote,    5 },
  595     { &tinrc.col_response,    2 },
  596     { &tinrc.col_signature,   4 },
  597     { &tinrc.col_urls,       DFT_FORE },
  598     { &tinrc.col_verbatim,    5 },
  599     { &tinrc.col_subject,     6 },
  600     { &tinrc.col_text,       DFT_FORE },
  601     { &tinrc.col_title,       4 },
  602 };
  603 
  604 
  605 static void
  606 preinit_colors(
  607     void)
  608 {
  609     size_t n;
  610 
  611     for (n = 0; n < ARRAY_SIZE(our_colors); n++)
  612         *(our_colors[n].colorp) = DFT_INIT;
  613 }
  614 
  615 
  616 void
  617 postinit_colors(
  618     int last_color)
  619 {
  620     size_t n;
  621 
  622     for (n = 0; n < ARRAY_SIZE(our_colors); n++) {
  623         if (*(our_colors[n].colorp) == DFT_INIT
  624          || *(our_colors[n].colorp) >= last_color) {
  625             switch (our_colors[n].color_dft) {
  626                 case DFT_FORE:
  627                     *(our_colors[n].colorp) = default_fcol;
  628                     break;
  629 
  630                 case DFT_BACK:
  631                     *(our_colors[n].colorp) = default_bcol;
  632                     break;
  633 
  634                 default:
  635                     *(our_colors[n].colorp) = our_colors[n].color_dft;
  636                     break;
  637             }
  638         }
  639         TRACE(("postinit_colors [%d] = %d", n, *(our_colors[n].colorp)));
  640     }
  641 }
  642 #endif /* HAVE_COLOR */
  643 
  644 
  645 /*
  646  * Get users home directory, userid, and a bunch of other stuff!
  647  */
  648 void
  649 init_selfinfo(
  650     void)
  651 {
  652     FILE *fp;
  653     char *ptr;
  654     char tmp[PATH_LEN];
  655     struct stat sb;
  656     struct passwd *myentry;
  657 #if defined(DOMAIN_NAME) || defined(HAVE_GETHOSTBYNAME)
  658     const char *cptr;
  659 #endif /* DOMAIN_NAME || HAVE_GETHOSTBYNAME */
  660 
  661     domain_name[0] = '\0';
  662 
  663 #ifdef HAVE_SYS_UTSNAME_H
  664 #   ifdef HAVE_UNAME
  665     if (uname(&system_info) == -1)
  666 #   endif /* HAVE_UNAME */
  667     {
  668         strcpy(system_info.sysname, "unknown");
  669         *system_info.machine = '\0';
  670         *system_info.release = '\0';
  671         *system_info.nodename = '\0';
  672     }
  673 #endif /* HAVE_SYS_UTSNAME_H */
  674 
  675 #ifdef DOMAIN_NAME
  676     if ((cptr = get_domain_name()) != NULL)
  677         my_strncpy(domain_name, cptr, MAXHOSTNAMELEN);
  678 #endif /* DOMAIN_NAME */
  679 
  680 #ifdef HAVE_GETHOSTBYNAME
  681     if (domain_name[0] == '\0') {
  682         cptr = get_fqdn(get_host_name());
  683         if (cptr != NULL)
  684             my_strncpy(domain_name, cptr, MAXHOSTNAMELEN);
  685     }
  686 #endif /* HAVE_GETHOSTBYNAME */
  687 
  688     process_id = getpid();
  689 
  690     real_umask = umask(0);
  691     (void) umask(real_umask);
  692 
  693     if ((myentry = getpwuid(getuid())) == NULL) {
  694         error_message(2, _(txt_error_passwd_missing));
  695         free(tin_progname);
  696         giveup();
  697     }
  698 
  699     my_strncpy(userid, myentry->pw_name, sizeof(userid) - 1);
  700 
  701     if (((ptr = getenv("TIN_HOMEDIR")) != NULL) && strlen(ptr)) {
  702         my_strncpy(homedir, ptr, sizeof(homedir) - 1);
  703     } else if (((ptr = getenv("HOME")) != NULL) && strlen(ptr)) {
  704         my_strncpy(homedir, ptr, sizeof(homedir) - 1);
  705     } else if (strlen(myentry->pw_dir)) {
  706         strncpy(homedir, myentry->pw_dir, sizeof(homedir) - 1);
  707     } else
  708         strncpy(homedir, TMPDIR, sizeof(homedir) - 1);
  709 
  710     created_rcdir = FALSE;
  711     dangerous_signal_exit = FALSE;
  712     disable_gnksa_domain_check = TRUE;
  713     disable_sender = FALSE; /* we set force_no_post=TRUE later on if we don't have a valid FQDN */
  714     iso2asc_supported = atoi(get_val("ISO2ASC", DEFAULT_ISO2ASC));
  715     if (iso2asc_supported >= NUM_ISO_TABLES || iso2asc_supported < 0) /* TODO: issue a warning here? */
  716         iso2asc_supported = -1;
  717     list_active = FALSE;
  718     newsrc_active = FALSE;
  719     post_article_and_exit = FALSE;
  720     post_postponed_and_exit = FALSE;
  721     read_local_newsgroups_file = FALSE;
  722     force_reread_active_file = TRUE;
  723     reread_active_for_posted_arts = TRUE;
  724     batch_mode = FALSE;
  725     check_for_new_newsgroups = TRUE;
  726 
  727 #ifdef HAVE_COLOR
  728     preinit_colors();
  729     use_color = FALSE;
  730 #endif /* HAVE_COLOR */
  731 
  732     word_highlight = TRUE;
  733 
  734     index_maildir[0] = '\0';
  735     index_newsdir[0] = '\0';
  736     index_savedir[0] = '\0';
  737     newsrc[0] = '\0';
  738 
  739     snprintf(page_header, sizeof(page_header), "%s %s release %s (\"%s\") [%s%s]",
  740         PRODUCT, VERSION, RELEASEDATE, RELEASENAME, OSNAME,
  741         (iso2asc_supported >= 0 ? " ISO2ASC" : ""));
  742     snprintf(cvers, sizeof(cvers), txt_copyright_notice, page_header);
  743 
  744     default_organization[0] = '\0';
  745 
  746     strncpy(bug_addr, BUG_REPORT_ADDRESS, sizeof(bug_addr) - 1);
  747 
  748     bug_nntpserver1[0] = '\0';
  749     bug_nntpserver2[0] = '\0';
  750 
  751 #ifdef INEWSDIR
  752     strncpy(inewsdir, INEWSDIR, sizeof(inewsdir) - 1);
  753 #else
  754     inewsdir[0] = '\0';
  755 #endif /* INEWSDIR */
  756 
  757 #ifdef apollo
  758     my_strncpy(default_organization, get_val("NEWSORG", ""), sizeof(default_organization) - 1);
  759 #else
  760     my_strncpy(default_organization, get_val("ORGANIZATION", ""), sizeof(default_organization) - 1);
  761 #endif /* apollo */
  762 
  763 #ifndef NNTP_ONLY
  764     my_strncpy(libdir, get_val("TIN_LIBDIR", NEWSLIBDIR), sizeof(libdir) - 1);
  765     my_strncpy(novrootdir, get_val("TIN_NOVROOTDIR", NOVROOTDIR), sizeof(novrootdir) - 1);
  766     my_strncpy(novfilename, get_val("TIN_NOVFILENAME", OVERVIEW_FILE), sizeof(novfilename) - 1);
  767     my_strncpy(spooldir, get_val("TIN_SPOOLDIR", SPOOLDIR), sizeof(spooldir) - 1);
  768 #endif /* !NNTP_ONLY */
  769     /* clear news_active_file, active_time_file, newsgroups_file */
  770     news_active_file[0] = '\0';
  771     active_times_file[0] = '\0';
  772     newsgroups_file[0] = '\0';
  773     overviewfmt_file[0] = '\0';
  774     subscriptions_file[0] = '\0';
  775 
  776     /*
  777      * read the global site config file to override some default
  778      * values given at compile time
  779      */
  780     (void) read_site_config();
  781 
  782     /*
  783      * the site_config-file was the last chance to set the domainname
  784      * if it's still unset fall into no posting mode.
  785      */
  786     if (domain_name[0] == '\0') {
  787         error_message(4, _(txt_error_no_domain_name));
  788         force_no_post = TRUE;
  789     }
  790 
  791     /*
  792      * only set the following variables if they weren't set from within
  793      * read_site_config()
  794      *
  795      * TODO: do we really want that read_site_config() overwrites
  796      * values given in env-vars? ($MM_CHARSET, $TIN_ACTIVEFILE)
  797      */
  798     if (!*news_active_file) /* TODO: really prepend libdir here in case of $TIN_ACTIVEFILE is set? */
  799         joinpath(news_active_file, sizeof(news_active_file), libdir, get_val("TIN_ACTIVEFILE", ACTIVE_FILE));
  800     if (!*active_times_file)
  801         joinpath(active_times_file, sizeof(active_times_file), libdir, ACTIVE_TIMES_FILE);
  802     if (!*newsgroups_file)
  803         joinpath(newsgroups_file, sizeof(newsgroups_file), libdir, NEWSGROUPS_FILE);
  804     if (!*subscriptions_file)
  805         joinpath(subscriptions_file, sizeof(subscriptions_file), libdir, SUBSCRIPTIONS_FILE);
  806     if (!*overviewfmt_file)
  807         joinpath(overviewfmt_file, sizeof(overviewfmt_file), libdir, OVERVIEW_FMT);
  808     if (!*default_organization) {
  809         char buf[LEN], filename[PATH_LEN];
  810 
  811         joinpath(filename, sizeof(filename), libdir, "organization");
  812         if ((fp = fopen(filename, "r")) != NULL) {
  813             if (fgets(buf, (int) sizeof(buf), fp) != NULL) {
  814                 ptr = strrchr(buf, '\n');
  815                 if (ptr != NULL)
  816                     *ptr = '\0';
  817             }
  818             fclose(fp);
  819             my_strncpy(default_organization, buf, sizeof(default_organization) - 1);
  820         }
  821     }
  822 
  823     /*
  824      * Formerly get_mm_charset(), read_site_config() may set mm_charset
  825      */
  826 #ifndef CHARSET_CONVERSION
  827     if (!*tinrc.mm_charset)
  828         STRCPY(tinrc.mm_charset, get_val("MM_CHARSET", MM_CHARSET));
  829 #else
  830     if (tinrc.mm_network_charset < 0) {
  831         size_t space = 255;
  832 
  833         ptr = my_malloc(space + 1);
  834         strcpy(ptr, "mm_network_charset=");
  835         space -= strlen(ptr);
  836         strncat(ptr, get_val("MM_CHARSET", MM_CHARSET), space);
  837         if ((space -= strlen(ptr)) > 0) {
  838             strncat(ptr, "\n", space);
  839             match_list(ptr, "mm_network_charset=", txt_mime_charsets, &tinrc.mm_network_charset);
  840         }
  841         free(ptr);
  842     }
  843 #endif /* !CHARSET_CONVERSION */
  844 
  845 #ifdef TIN_DEFAULTS_DIR
  846     joinpath(global_attributes_file, sizeof(global_attributes_file), TIN_DEFAULTS_DIR, ATTRIBUTES_FILE);
  847     joinpath(global_config_file, sizeof(global_config_file), TIN_DEFAULTS_DIR, CONFIG_FILE);
  848 #else
  849     /* read_site_config() might have changed the value of libdir */
  850     joinpath(global_attributes_file, sizeof(global_attributes_file), libdir, ATTRIBUTES_FILE);
  851     joinpath(global_config_file, sizeof(global_config_file), libdir, CONFIG_FILE);
  852 #endif /* TIN_DEFAULTS_DIR */
  853 
  854     joinpath(rcdir, sizeof(rcdir), homedir, RCDIR);
  855     if (stat(rcdir, &sb) == -1) {
  856         my_mkdir(rcdir, (mode_t) (S_IRWXU)); /* TODO: bail out? give error message? no_write = TRUE? */
  857         created_rcdir = TRUE;
  858     }
  859     strcpy(tinrc.mailer_format, MAILER_FORMAT);
  860     my_strncpy(mailer, get_val(ENV_VAR_MAILER, DEFAULT_MAILER), sizeof(mailer) - 1);
  861 #ifndef DISABLE_PRINTING
  862     strcpy(tinrc.printer, DEFAULT_PRINTER);
  863 #endif /* !DISABLE_PRINTING */
  864     strcpy(tinrc.inews_prog, PATH_INEWS);
  865     joinpath(article_name, sizeof(article_name), homedir, TIN_ARTICLE_NAME);
  866 #ifdef APPEND_PID
  867     snprintf(article_name + strlen(article_name), sizeof(article_name) - strlen(article_name), ".%ld", (long) process_id);
  868 #endif /* APPEND_PID */
  869     joinpath(dead_article, sizeof(dead_article), homedir, "dead.article");
  870     joinpath(dead_articles, sizeof(dead_articles), homedir, "dead.articles");
  871     joinpath(tinrc.maildir, sizeof(tinrc.maildir), homedir, DEFAULT_MAILDIR);
  872     joinpath(tinrc.savedir, sizeof(tinrc.savedir), homedir, DEFAULT_SAVEDIR);
  873     joinpath(tinrc.sigfile, sizeof(tinrc.sigfile), homedir, ".Sig");
  874     joinpath(default_signature, sizeof(default_signature), homedir, ".signature");
  875 
  876     if (!index_newsdir[0])
  877         joinpath(index_newsdir, sizeof(index_newsdir), get_val("TIN_INDEX_NEWSDIR", rcdir), INDEX_NEWSDIR);
  878     joinpath(index_maildir, sizeof(index_maildir), get_val("TIN_INDEX_MAILDIR", rcdir), INDEX_MAILDIR);
  879     if (stat(index_maildir, &sb) == -1)
  880         my_mkdir(index_maildir, (mode_t) S_IRWXU);
  881     joinpath(index_savedir, sizeof(index_savedir), get_val("TIN_INDEX_SAVEDIR", rcdir), INDEX_SAVEDIR);
  882     if (stat(index_savedir, &sb) == -1)
  883         my_mkdir(index_savedir, (mode_t) S_IRWXU);
  884     joinpath(local_attributes_file, sizeof(local_attributes_file), rcdir, ATTRIBUTES_FILE);
  885     joinpath(local_config_file, sizeof(local_config_file), rcdir, CONFIG_FILE);
  886     joinpath(filter_file, sizeof(filter_file), rcdir, FILTER_FILE);
  887     joinpath(local_input_history_file, sizeof(local_input_history_file), rcdir, INPUT_HISTORY_FILE);
  888     joinpath(local_newsrctable_file, sizeof(local_newsrctable_file), rcdir, NEWSRCTABLE_FILE);
  889 #ifdef HAVE_MH_MAIL_HANDLING
  890     joinpath(mail_active_file, sizeof(mail_active_file), rcdir, ACTIVE_MAIL_FILE);
  891 #endif /* HAVE_MH_MAIL_HANDLING */
  892     joinpath(mailbox, sizeof(mailbox), DEFAULT_MAILBOX, userid);
  893 #ifdef HAVE_MH_MAIL_HANDLING
  894     joinpath(mailgroups_file, sizeof(mailgroups_file), rcdir, MAILGROUPS_FILE);
  895 #endif /* HAVE_MH_MAIL_HANDLING */
  896     joinpath(newsrc, sizeof(newsrc), homedir, NEWSRC_FILE);
  897     joinpath(newnewsrc, sizeof(newnewsrc), homedir, NEWNEWSRC_FILE);
  898 #ifdef APPEND_PID
  899     snprintf(newnewsrc + strlen(newnewsrc), sizeof(newnewsrc) - strlen(newnewsrc), ".%d", (int) process_id);
  900 #endif /* APPEND_PID */
  901     joinpath(posted_info_file, sizeof(posted_info_file), rcdir, POSTED_FILE);
  902     joinpath(postponed_articles_file, sizeof(postponed_articles_file), rcdir, POSTPONED_FILE);
  903     joinpath(save_active_file, sizeof(save_active_file), rcdir, ACTIVE_SAVE_FILE);
  904 
  905     snprintf(tmp, sizeof(tmp), INDEX_LOCK, userid);
  906     joinpath(lock_file, sizeof(lock_file), TMPDIR, tmp);
  907 
  908 #ifdef NNTP_ABLE
  909     nntp_tcp_port = (unsigned short) atoi(get_val("NNTPPORT", NNTP_TCP_PORT));
  910 #endif /* NNTP_ABLE */
  911 
  912     if ((fp = fopen(posted_info_file, "a")) != NULL) {
  913         if (!fstat(fileno(fp), &sb)) {
  914             if (sb.st_size == 0) {
  915                 fprintf(fp, "%s", _(txt_posted_info_file));
  916                 fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR));
  917             }
  918         }
  919         fclose(fp);
  920     }
  921 
  922     init_postinfo();
  923     snprintf(txt_help_bug_report, sizeof(txt_help_bug_report), _(txt_help_bug), bug_addr);
  924 
  925 #ifdef HAVE_PGP_GPG
  926     init_pgp();
  927 #endif /* HAVE_PGP_GPG */
  928 }
  929 
  930 
  931 /*
  932  * read_site_config()
  933  *
  934  * This function permits the local administrator to override a few compile
  935  * time defined parameters, especially the concerning the place of a local
  936  * news spool. This has especially binary distributions of TIN in mind.
  937  *
  938  * Sven Paulus <sven@tin.org>, 26-Jan-'98
  939  */
  940 static int
  941 read_site_config(
  942     void)
  943 {
  944     FILE *fp = (FILE *) 0;
  945     char buf[LEN], filename[PATH_LEN];
  946     static const char *tin_defaults[] = { TIN_DEFAULTS };
  947     int i = 0;
  948 
  949     /*
  950      * try to find tin.defaults in some different locations
  951      */
  952     while (tin_defaults[i] != NULL) {
  953         joinpath(filename, sizeof(filename), tin_defaults[i++], "tin.defaults");
  954         if ((fp = fopen(filename, "r")) != NULL)
  955             break;
  956     }
  957 
  958     if (!fp)
  959         return -1;
  960 
  961     while (fgets(buf, (int) sizeof(buf), fp)) {
  962         /* ignore comments */
  963         if (*buf == '#' || *buf == ';' || *buf == ' ')
  964             continue;
  965 #ifndef NNTP_ONLY
  966         if (match_string(buf, "spooldir=", spooldir, sizeof(spooldir)))
  967             continue;
  968         if (match_string(buf, "overviewdir=", novrootdir, sizeof(novrootdir)))
  969             continue;
  970         if (match_string(buf, "overviewfile=", novfilename, sizeof(novfilename)))
  971             continue;
  972 #endif /* !NNTP_ONLY */
  973         if (match_string(buf, "activefile=", news_active_file, sizeof(news_active_file)))
  974             continue;
  975         if (match_string(buf, "activetimesfile=", active_times_file, sizeof(active_times_file)))
  976             continue;
  977         if (match_string(buf, "newsgroupsfile=", newsgroups_file, sizeof(newsgroups_file)))
  978             continue;
  979         if (match_string(buf, "newslibdir=", libdir, sizeof(libdir)))
  980             continue;
  981         if (match_string(buf, "subscriptionsfile=", subscriptions_file, sizeof(subscriptions_file)))
  982             continue;
  983         if (match_string(buf, "overviewfmtfile=", overviewfmt_file, sizeof(overviewfmt_file)))
  984             continue;
  985         if (match_string(buf, "domainname=", domain_name, sizeof(domain_name)))
  986             continue;
  987         if (match_string(buf, "inewsdir=", inewsdir, sizeof(inewsdir)))
  988             continue;
  989         if (match_string(buf, "bugaddress=", bug_addr, sizeof(bug_addr)))
  990             continue;
  991         if (match_string(buf, "organization=", default_organization, sizeof(default_organization)))
  992             continue;
  993 #ifndef CHARSET_CONVERSION
  994         if (match_string(buf, "mm_charset=", tinrc.mm_charset, sizeof(tinrc.mm_charset)))
  995             continue;
  996 #else
  997         if (match_list(buf, "mm_charset=", txt_mime_charsets, &tinrc.mm_network_charset))
  998             continue;
  999 #endif /* !CHARSET_CONVERSION */
 1000         if (match_list(buf, "post_mime_encoding=", txt_mime_encodings, &tinrc.post_mime_encoding))
 1001             continue;
 1002         if (match_list(buf, "mail_mime_encoding=", txt_mime_encodings, &tinrc.mail_mime_encoding))
 1003             continue;
 1004         if (match_boolean(buf, "disable_gnksa_domain_check=", &disable_gnksa_domain_check))
 1005             continue;
 1006         if (match_boolean(buf, "disable_sender=", &disable_sender))
 1007             continue;
 1008     }
 1009 
 1010     fclose(fp);
 1011     return 0;
 1012 }
 1013 
 1014 
 1015 /*
 1016  * set defaults if needed to avoid empty regexp
 1017  */
 1018 void
 1019 postinit_regexp(
 1020     void)
 1021 {
 1022     if (!strlen(tinrc.strip_re_regex))
 1023         STRCPY(tinrc.strip_re_regex, DEFAULT_STRIP_RE_REGEX);
 1024     compile_regex(tinrc.strip_re_regex, &strip_re_regex, PCRE_ANCHORED);
 1025 
 1026     if (strlen(tinrc.strip_was_regex)) {
 1027         /*
 1028          * try to be clever, if we still use the initial default value
 1029          * convert it to our needs
 1030          *
 1031          * TODO: a global soultion
 1032          */
 1033 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1034             if (IS_LOCAL_CHARSET("UTF-8") && utf8_pcre()) {
 1035                 if (!strcmp(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX))
 1036                     STRCPY(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX);
 1037             } else {
 1038                 if (!strcmp(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX))
 1039                     STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1040             }
 1041 #else
 1042             if (!strcmp(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX))
 1043                 STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1044 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 1045     } else {
 1046 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1047         if (IS_LOCAL_CHARSET("UTF-8") && utf8_pcre())
 1048             STRCPY(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX);
 1049         else
 1050 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 1051             STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1052     }
 1053     compile_regex(tinrc.strip_was_regex, &strip_was_regex, 0);
 1054 
 1055 #ifdef HAVE_COLOR
 1056     if (!strlen(tinrc.extquote_regex))
 1057         STRCPY(tinrc.extquote_regex, DEFAULT_EXTQUOTE_REGEX);
 1058     compile_regex(tinrc.extquote_regex, &extquote_regex, PCRE_CASELESS);
 1059     if (!strlen(tinrc.quote_regex))
 1060         STRCPY(tinrc.quote_regex, DEFAULT_QUOTE_REGEX);
 1061     compile_regex(tinrc.quote_regex, &quote_regex, PCRE_CASELESS);
 1062     if (!strlen(tinrc.quote_regex2))
 1063         STRCPY(tinrc.quote_regex2, DEFAULT_QUOTE_REGEX2);
 1064     compile_regex(tinrc.quote_regex2, &quote_regex2, PCRE_CASELESS);
 1065     if (!strlen(tinrc.quote_regex3))
 1066         STRCPY(tinrc.quote_regex3, DEFAULT_QUOTE_REGEX3);
 1067     compile_regex(tinrc.quote_regex3, &quote_regex3, PCRE_CASELESS);
 1068 #endif /* HAVE_COLOR */
 1069 
 1070     if (!strlen(tinrc.slashes_regex))
 1071         STRCPY(tinrc.slashes_regex, DEFAULT_SLASHES_REGEX);
 1072     compile_regex(tinrc.slashes_regex, &slashes_regex, PCRE_CASELESS);
 1073     if (!strlen(tinrc.stars_regex))
 1074         STRCPY(tinrc.stars_regex, DEFAULT_STARS_REGEX);
 1075     compile_regex(tinrc.stars_regex, &stars_regex, PCRE_CASELESS);
 1076     if (!strlen(tinrc.strokes_regex))
 1077         STRCPY(tinrc.strokes_regex, DEFAULT_STROKES_REGEX);
 1078     compile_regex(tinrc.strokes_regex, &strokes_regex, PCRE_CASELESS);
 1079     if (!strlen(tinrc.underscores_regex))
 1080         STRCPY(tinrc.underscores_regex, DEFAULT_UNDERSCORES_REGEX);
 1081     compile_regex(tinrc.underscores_regex, &underscores_regex, PCRE_CASELESS);
 1082 
 1083     if (!strlen(tinrc.verbatim_begin_regex))
 1084         STRCPY(tinrc.verbatim_begin_regex, DEFAULT_VERBATIM_BEGIN_REGEX);
 1085     compile_regex(tinrc.verbatim_begin_regex, &verbatim_begin_regex, PCRE_ANCHORED);
 1086     if (!strlen(tinrc.verbatim_end_regex))
 1087         STRCPY(tinrc.verbatim_end_regex, DEFAULT_VERBATIM_END_REGEX);
 1088     compile_regex(tinrc.verbatim_end_regex, &verbatim_end_regex, PCRE_ANCHORED);
 1089 
 1090     compile_regex(UUBEGIN_REGEX, &uubegin_regex, PCRE_ANCHORED);
 1091     compile_regex(UUBODY_REGEX, &uubody_regex, PCRE_ANCHORED);
 1092 
 1093     compile_regex(URL_REGEX, &url_regex, PCRE_CASELESS);
 1094     compile_regex(MAIL_REGEX, &mail_regex, PCRE_CASELESS);
 1095     compile_regex(NEWS_REGEX, &news_regex, PCRE_CASELESS);
 1096 
 1097     compile_regex(SHAR_REGEX, &shar_regex, PCRE_ANCHORED);
 1098 }
 1099 
 1100 
 1101 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1102 t_bool
 1103 utf8_pcre(
 1104     void)
 1105 {
 1106     int i = 0;
 1107 
 1108 #   if (defined(PCRE_MAJOR) && PCRE_MAJOR >= 4)
 1109     (void) pcre_config(PCRE_CONFIG_UTF8, &i);
 1110 #   endif /* PCRE_MAJOR && PCRE_MAJOR >= 4 */
 1111 
 1112     return (i ? TRUE : FALSE);
 1113 }
 1114 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */