"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.1/src/init.c" (12 Oct 2016, 38270 Bytes) of package /linux/misc/tin-2.4.1.tar.gz:


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.0_vs_2.4.1.

    1 /*
    2  *  Project   : tin - a Usenet reader
    3  *  Module    : init.c
    4  *  Author    : I. Lea
    5  *  Created   : 1991-04-01
    6  *  Updated   : 2016-04-17
    7  *  Notes     :
    8  *
    9  * Copyright (c) 1991-2017 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[PATH_LEN];     /* 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     INTERACTIVE_NONE,       /* interactive_mailer */
  404     FALSE,      /* use_mouse */
  405 #ifdef HAVE_KEYPAD
  406     FALSE,      /* use_keypad */
  407 #endif /* HAVE_KEYPAD */
  408     TRUE,       /* wrap_on_next_unread */
  409     FALSE,      /* ask_for_metamail */
  410     FALSE,      /* default_filter_kill_case */
  411     FALSE,      /* default_filter_kill_expire */
  412     TRUE,       /* default_filter_kill_global */
  413     FALSE,      /* default_filter_select_case */
  414     FALSE,      /* default_filter_select_expire */
  415 #ifdef XFACE_ABLE
  416     FALSE,      /* use_slrnface */
  417 #endif /* XFACE_ABLE */
  418     TRUE,       /* default_filter_select_global */
  419     DEFAULT_SELECT_FORMAT,  /* select_format */
  420     DEFAULT_GROUP_FORMAT,   /* group_format */
  421     DEFAULT_THREAD_FORMAT,  /* thread_format */
  422     DEFAULT_DATE_FORMAT,    /* date_format */
  423 #ifdef HAVE_UNICODE_NORMALIZATION
  424     DEFAULT_NORMALIZE,      /* normalization form */
  425 #endif /* HAVE_UNICODE_NORMALIZATION */
  426 #if defined(HAVE_LIBICUUC) && defined(MULTIBYTE_ABLE) && defined(HAVE_UNICODE_UBIDI_H) && !defined(NO_LOCALE)
  427     FALSE,      /* render_bidi */
  428 #endif /* HAVE_LIBICUUC && MULTIBYTE_ABLE && HAVE_UNICODE_UBIDI_H && !NO_LOCALE */
  429 #ifdef CHARSET_CONVERSION
  430     -1,     /* attrib_mm_network_charset, defaults to $MM_CHARSET */
  431     "",     /* attrib_undeclared_charset */
  432 #endif /* !CHARSET_CONVERSION */
  433     "",     /* attrib_editor_format */
  434     "",     /* attrib_fcc */
  435     "",     /* attrib_maildir */
  436     "",     /* attrib_from */
  437     "",     /* attrib_mailing_list */
  438     "",     /* attrib_organization */
  439     "",     /* attrib_followup_to */
  440     "",     /* attrib_mime_types_to_save */
  441     "",     /* attrib_news_headers_to_display */
  442     "",     /* attrib_news_headers_to_not_display */
  443     "",     /* attrib_news_quote_format */
  444     "",     /* attrib_quote_chars */
  445     "",     /* attrib_sigfile */
  446     "",     /* attrib_savedir */
  447     "",     /* attrib_savefile */
  448     "",     /* attrib_x_body */
  449     "",     /* attrib_x_headers */
  450 #ifdef HAVE_ISPELL
  451     "",     /* attrib_ispell */
  452 #endif /* HAVE_ISPELL */
  453     "",     /* attrib_quick_kill_scope */
  454     "",     /* attrib_quick_select_scope */
  455     "",     /* attrib_group_format */
  456     "",     /* attrib_thread_format */
  457     "",     /* attrib_date_format */
  458     0,      /* attrib_trim_article_body */
  459     0,      /* attrib_auto_cc_bcc */
  460     FILTER_SUBJ_CASE_SENSITIVE,     /* attrib_quick_kill_header */
  461     FILTER_SUBJ_CASE_SENSITIVE,     /* attrib_quick_select_header */
  462     MIME_ENCODING_QP,       /* attrib_mail_mime_encoding */
  463 #if defined(HAVE_ALARM) && defined(SIGALRM)
  464     120,    /* nntp_read_timeout_secs */
  465 #endif /* HAVE_ALARM && SIGALRM */
  466     MIME_ENCODING_8BIT,     /* attrib_post_mime_encoding */
  467     POST_PROC_NO,           /* attrib_post_process_type */
  468     SHOW_FROM_NAME,         /* attrib_show_author */
  469     SORT_ARTICLES_BY_DATE_ASCEND,       /* attrib_sort_article_type */
  470     SORT_THREADS_BY_SCORE_DESCEND,      /* attrib_sort_threads_type */
  471     THREAD_BOTH,        /* attrib_thread_articles */
  472     THREAD_PERC_DEFAULT,    /* attrib_thread_perc */
  473     TRUE,       /* attrib_add_posted_to_filter */
  474     TRUE,       /* attrib_advertising */
  475     TRUE,       /* attrib_alternative_handling */
  476     TRUE,       /* attrib_auto_list_thread */
  477     FALSE,      /* attrib_auto_select */
  478     FALSE,      /* attrib_auto_save */
  479     TRUE,       /* attrib_batch_save */
  480     TRUE,       /* attrib_delete_tmp_files */
  481     TRUE,       /* attrib_group_catchup_on_exit */
  482     FALSE,      /* attrib_mail_8bit_header */
  483     FALSE,      /* attrib_mime_forward */
  484     FALSE,      /* attrib_mark_ignore_tags */
  485     TRUE,       /* attrib_mark_saved_read */
  486     TRUE,       /* attrib_pos_first_unread */
  487     FALSE,      /* attrib_post_8bit_header */
  488     TRUE,       /* attrib_post_process_view */
  489 #ifndef DISABLE_PRINTING
  490     FALSE,      /* attrib_print_header */
  491 #endif /* !DISABLE_PRINTING */
  492     FALSE,      /* attrib_process_only_unread */
  493     FALSE,      /* attrib_prompt_followupto */
  494     TRUE,       /* attrib_show_only_unread_arts */
  495     TRUE,       /* attrib_show_signatures */
  496     TRUE,       /* attrib_sigdashes */
  497     TRUE,       /* attrib_signature_repost */
  498 #ifdef M_UNIX
  499     TRUE,       /* attrib_start_editor_offset */
  500 #else
  501     FALSE,      /* attrib_start_editor_offset */
  502 #endif /* M_UNIX */
  503     FALSE,      /* attrib_tex2iso_conv */
  504     TRUE,       /* attrib_thread_catchup_on_exit */
  505     TRUE,       /* attrib_verbatim_handling */
  506 #ifdef HAVE_COLOR
  507     FALSE,      /* attrib_extquote_handling */
  508 #endif /* HAVE_COLOR */
  509     FALSE,      /* attrib_x_comment_to */
  510     TRUE,       /* attrib_wrap_on_next_unread */
  511     FALSE,      /* attrib_ask_for_metamail */
  512     FALSE,      /* attrib_quick_kill_case */
  513     FALSE,      /* attrib_quick_kill_expire */
  514     FALSE,      /* attrib_quick_select_case */
  515     FALSE       /* attrib_quick_select_expire */
  516 };
  517 
  518 struct t_capabilities nntp_caps = {
  519     NONE, /* type (NONE, CAPABILITIES, BROKEN) */
  520     0, /* CAPABILITIES version */
  521     FALSE, /* MODE-READER: "MODE READER" */
  522     FALSE, /* READER: "ARTICLE", "BODY" */
  523     FALSE, /* POST */
  524     FALSE, /* LIST: "LIST ACTIVE" */
  525     FALSE, /* LIST: "LIST ACTIVE.TIMES" */
  526     FALSE, /* LIST: "LIST DISTRIB.PATS" */
  527     FALSE, /* LIST: "LIST HEADERS" */
  528     FALSE, /* LIST: "LIST NEWSGROUPS" */
  529     FALSE, /* LIST: "LIST OVERVIEW.FMT" */
  530     FALSE, /* LIST: "LIST MOTD" */
  531     FALSE, /* LIST: "LIST SUBSCRIPTIONS" */
  532     FALSE, /* LIST: "LIST DISTRIBUTIONS" */
  533     FALSE, /* LIST: "LIST MODERATORS" */
  534     FALSE, /* LIST: "LIST COUNTS" */
  535     FALSE, /* XPAT */
  536     FALSE, /* HDR: "HDR", "LIST HEADERS" */
  537     NULL, /* [X]HDR */
  538     FALSE, /* OVER: "OVER", "LIST OVERVIEW.FMT" */
  539     FALSE, /* OVER: "OVER mid" */
  540     NULL, /* [X]OVER */
  541     FALSE, /* NEWNEWS */
  542     NULL, /* IMPLEMENTATION */
  543     FALSE, /* STARTTLS */
  544     FALSE, /* AUTHINFO USER/PASS */
  545     FALSE, /* AUTHINFO SASL */
  546     FALSE, /* AUTHINFO available but not in current state */
  547     SASL_NONE, /* SASL CRAM-MD5 DIGEST-MD5 PLAIN GSSAPI EXTERNAL OTP NTLM LOGIN */
  548     FALSE, /* COMPRESS */
  549     COMPRESS_NONE, /* COMPRESS_NONE, COMPRESS_DEFLATE */
  550 #if 0
  551     FALSE, /* STREAMING: "MODE STREAM", "CHECK", "TAKETHIS" */
  552     FALSE /* IHAVE */
  553 #endif /* 0 */
  554 #ifndef BROKEN_LISTGROUP
  555     FALSE /* LISTGROUP doesn't select group */
  556 #else
  557     TRUE
  558 #endif /* !BROKEN_LISTGROUP */
  559 };
  560 
  561 static char libdir[PATH_LEN];           /* directory where news config files are (ie. active) */
  562 static mode_t real_umask;
  563 
  564 #ifdef HAVE_COLOR
  565 
  566 #   define DFT_FORE -1
  567 #   define DFT_BACK -2
  568 #   define DFT_INIT -3
  569 
  570 static const struct {
  571     int *colorp;
  572     int color_dft;  /* -2 back, -1 fore, >=0 normal */
  573 } our_colors[] = {
  574     { &tinrc.col_back,       DFT_BACK },
  575     { &tinrc.col_from,        2 },
  576     { &tinrc.col_head,        2 },
  577     { &tinrc.col_help,       DFT_FORE },
  578     { &tinrc.col_invers_bg,   4 },
  579     { &tinrc.col_invers_fg,   7 },
  580     { &tinrc.col_markdash,   13 },
  581     { &tinrc.col_markstar,   11 },
  582     { &tinrc.col_markslash,  14 },
  583     { &tinrc.col_markstroke, 12 },
  584     { &tinrc.col_message,     6 },
  585     { &tinrc.col_minihelp,    3 },
  586     { &tinrc.col_newsheaders, 9 },
  587     { &tinrc.col_normal,     DFT_FORE },
  588     { &tinrc.col_quote,       2 },
  589     { &tinrc.col_quote2,      3 },
  590     { &tinrc.col_quote3,      4 },
  591     { &tinrc.col_extquote,    5 },
  592     { &tinrc.col_response,    2 },
  593     { &tinrc.col_signature,   4 },
  594     { &tinrc.col_urls,       DFT_FORE },
  595     { &tinrc.col_verbatim,    5 },
  596     { &tinrc.col_subject,     6 },
  597     { &tinrc.col_text,       DFT_FORE },
  598     { &tinrc.col_title,       4 },
  599 };
  600 
  601 
  602 static void
  603 preinit_colors(
  604     void)
  605 {
  606     size_t n;
  607 
  608     for (n = 0; n < ARRAY_SIZE(our_colors); n++)
  609         *(our_colors[n].colorp) = DFT_INIT;
  610 }
  611 
  612 
  613 void
  614 postinit_colors(
  615     int last_color)
  616 {
  617     size_t n;
  618 
  619     for (n = 0; n < ARRAY_SIZE(our_colors); n++) {
  620         if (*(our_colors[n].colorp) == DFT_INIT
  621          || *(our_colors[n].colorp) >= last_color) {
  622             switch (our_colors[n].color_dft) {
  623                 case DFT_FORE:
  624                     *(our_colors[n].colorp) = default_fcol;
  625                     break;
  626 
  627                 case DFT_BACK:
  628                     *(our_colors[n].colorp) = default_bcol;
  629                     break;
  630 
  631                 default:
  632                     *(our_colors[n].colorp) = our_colors[n].color_dft;
  633                     break;
  634             }
  635         }
  636         TRACE(("postinit_colors [%d] = %d", n, *(our_colors[n].colorp)));
  637     }
  638 }
  639 #endif /* HAVE_COLOR */
  640 
  641 
  642 /*
  643  * Get users home directory, userid, and a bunch of other stuff!
  644  */
  645 void
  646 init_selfinfo(
  647     void)
  648 {
  649     FILE *fp;
  650     char *ptr;
  651     char tmp[PATH_LEN];
  652     struct stat sb;
  653     struct passwd *myentry;
  654 #if defined(DOMAIN_NAME) || defined(HAVE_GETHOSTBYNAME)
  655     const char *cptr;
  656 #endif /* DOMAIN_NAME || HAVE_GETHOSTBYNAME */
  657 
  658     domain_name[0] = '\0';
  659 
  660 #ifdef HAVE_SYS_UTSNAME_H
  661 #   ifdef HAVE_UNAME
  662     if (uname(&system_info) == -1)
  663 #   endif /* HAVE_UNAME */
  664     {
  665         strcpy(system_info.sysname, "unknown");
  666         *system_info.machine = '\0';
  667         *system_info.release = '\0';
  668         *system_info.nodename = '\0';
  669     }
  670 #endif /* HAVE_SYS_UTSNAME_H */
  671 
  672 #ifdef DOMAIN_NAME
  673     if ((cptr = get_domain_name()) != NULL)
  674         my_strncpy(domain_name, cptr, MAXHOSTNAMELEN);
  675 #endif /* DOMAIN_NAME */
  676 
  677 #ifdef HAVE_GETHOSTBYNAME
  678     if (domain_name[0] == '\0') {
  679         cptr = get_fqdn(get_host_name());
  680         if (cptr != NULL)
  681             my_strncpy(domain_name, cptr, MAXHOSTNAMELEN);
  682     }
  683 #endif /* HAVE_GETHOSTBYNAME */
  684 
  685     process_id = getpid();
  686 
  687     real_umask = umask(0);
  688     (void) umask(real_umask);
  689 
  690     if ((myentry = getpwuid(getuid())) == NULL) {
  691         error_message(2, _(txt_error_passwd_missing));
  692         free(tin_progname);
  693         giveup();
  694     }
  695 
  696     my_strncpy(userid, myentry->pw_name, sizeof(userid) - 1);
  697 
  698     if (((ptr = getenv("TIN_HOMEDIR")) != NULL) && strlen(ptr)) {
  699         my_strncpy(homedir, ptr, sizeof(homedir) - 1);
  700     } else if (((ptr = getenv("HOME")) != NULL) && strlen(ptr)) {
  701         my_strncpy(homedir, ptr, sizeof(homedir) - 1);
  702     } else if (strlen(myentry->pw_dir)) {
  703         strncpy(homedir, myentry->pw_dir, sizeof(homedir) - 1);
  704     } else
  705         strncpy(homedir, TMPDIR, sizeof(homedir) - 1);
  706 
  707     created_rcdir = FALSE;
  708     dangerous_signal_exit = FALSE;
  709     disable_gnksa_domain_check = TRUE;
  710     disable_sender = FALSE; /* we set force_no_post=TRUE later on if we don't have a valid FQDN */
  711     iso2asc_supported = atoi(get_val("ISO2ASC", DEFAULT_ISO2ASC));
  712     if (iso2asc_supported >= NUM_ISO_TABLES || iso2asc_supported < 0) /* TODO: issue a warning here? */
  713         iso2asc_supported = -1;
  714     list_active = FALSE;
  715     newsrc_active = FALSE;
  716     post_article_and_exit = FALSE;
  717     post_postponed_and_exit = FALSE;
  718     read_local_newsgroups_file = FALSE;
  719     force_reread_active_file = TRUE;
  720     reread_active_for_posted_arts = TRUE;
  721     batch_mode = FALSE;
  722     check_for_new_newsgroups = TRUE;
  723 
  724 #ifdef HAVE_COLOR
  725     preinit_colors();
  726     use_color = FALSE;
  727 #endif /* HAVE_COLOR */
  728 
  729     word_highlight = TRUE;
  730 
  731     index_maildir[0] = '\0';
  732     index_newsdir[0] = '\0';
  733     index_savedir[0] = '\0';
  734     newsrc[0] = '\0';
  735 
  736     snprintf(page_header, sizeof(page_header), "%s %s release %s (\"%s\") [%s%s]",
  737         PRODUCT, VERSION, RELEASEDATE, RELEASENAME, OSNAME,
  738         (iso2asc_supported >= 0 ? " ISO2ASC" : ""));
  739     snprintf(cvers, sizeof(cvers), txt_copyright_notice, page_header);
  740 
  741     default_organization[0] = '\0';
  742 
  743     strncpy(bug_addr, BUG_REPORT_ADDRESS, sizeof(bug_addr) - 1);
  744 
  745     bug_nntpserver1[0] = '\0';
  746     bug_nntpserver2[0] = '\0';
  747 
  748 #ifdef INEWSDIR
  749     strncpy(inewsdir, INEWSDIR, sizeof(inewsdir) - 1);
  750 #else
  751     inewsdir[0] = '\0';
  752 #endif /* INEWSDIR */
  753 
  754 #ifdef apollo
  755     my_strncpy(default_organization, get_val("NEWSORG", ""), sizeof(default_organization) - 1);
  756 #else
  757     my_strncpy(default_organization, get_val("ORGANIZATION", ""), sizeof(default_organization) - 1);
  758 #endif /* apollo */
  759 
  760 #ifndef NNTP_ONLY
  761     my_strncpy(libdir, get_val("TIN_LIBDIR", NEWSLIBDIR), sizeof(libdir) - 1);
  762     my_strncpy(novrootdir, get_val("TIN_NOVROOTDIR", NOVROOTDIR), sizeof(novrootdir) - 1);
  763     my_strncpy(novfilename, get_val("TIN_NOVFILENAME", OVERVIEW_FILE), sizeof(novfilename) - 1);
  764     my_strncpy(spooldir, get_val("TIN_SPOOLDIR", SPOOLDIR), sizeof(spooldir) - 1);
  765 #endif /* !NNTP_ONLY */
  766     /* clear news_active_file, active_time_file, newsgroups_file */
  767     news_active_file[0] = '\0';
  768     active_times_file[0] = '\0';
  769     newsgroups_file[0] = '\0';
  770     overviewfmt_file[0] = '\0';
  771     subscriptions_file[0] = '\0';
  772 
  773     /*
  774      * read the global site config file to override some default
  775      * values given at compile time
  776      */
  777     (void) read_site_config();
  778 
  779     /*
  780      * the site_config-file was the last chance to set the domainname
  781      * if it's still unset fall into no posting mode.
  782      */
  783     if (domain_name[0] == '\0') {
  784         error_message(4, _(txt_error_no_domain_name));
  785         force_no_post = TRUE;
  786     }
  787 
  788     /*
  789      * only set the following variables if they weren't set from within
  790      * read_site_config()
  791      *
  792      * TODO: do we really want that read_site_config() overwrites
  793      * values given in env-vars? ($MM_CHARSET, $TIN_ACTIVEFILE)
  794      */
  795     if (!*news_active_file) /* TODO: really prepend libdir here in case of $TIN_ACTIVEFILE is set? */
  796         joinpath(news_active_file, sizeof(news_active_file), libdir, get_val("TIN_ACTIVEFILE", ACTIVE_FILE));
  797     if (!*active_times_file)
  798         joinpath(active_times_file, sizeof(active_times_file), libdir, ACTIVE_TIMES_FILE);
  799     if (!*newsgroups_file)
  800         joinpath(newsgroups_file, sizeof(newsgroups_file), libdir, NEWSGROUPS_FILE);
  801     if (!*subscriptions_file)
  802         joinpath(subscriptions_file, sizeof(subscriptions_file), libdir, SUBSCRIPTIONS_FILE);
  803     if (!*overviewfmt_file)
  804         joinpath(overviewfmt_file, sizeof(overviewfmt_file), libdir, OVERVIEW_FMT);
  805     if (!*default_organization) {
  806         char buf[LEN], filename[PATH_LEN];
  807 
  808         joinpath(filename, sizeof(filename), libdir, "organization");
  809         if ((fp = fopen(filename, "r")) != NULL) {
  810             if (fgets(buf, (int) sizeof(buf), fp) != NULL) {
  811                 ptr = strrchr(buf, '\n');
  812                 if (ptr != NULL)
  813                     *ptr = '\0';
  814             }
  815             fclose(fp);
  816             my_strncpy(default_organization, buf, sizeof(default_organization) - 1);
  817         }
  818     }
  819 
  820     /*
  821      * Formerly get_mm_charset(), read_site_config() may set mm_charset
  822      */
  823 #ifndef CHARSET_CONVERSION
  824     if (!*tinrc.mm_charset)
  825         STRCPY(tinrc.mm_charset, get_val("MM_CHARSET", MM_CHARSET));
  826 #else
  827     if (tinrc.mm_network_charset < 0) {
  828         size_t space = 255;
  829 
  830         ptr = my_malloc(space + 1);
  831         strcpy(ptr, "mm_network_charset=");
  832         space -= strlen(ptr);
  833         strncat(ptr, get_val("MM_CHARSET", MM_CHARSET), space);
  834         if ((space -= strlen(ptr)) > 0) {
  835             strncat(ptr, "\n", space);
  836             match_list(ptr, "mm_network_charset=", txt_mime_charsets, &tinrc.mm_network_charset);
  837         }
  838         free(ptr);
  839     }
  840 #endif /* !CHARSET_CONVERSION */
  841 
  842 #ifdef TIN_DEFAULTS_DIR
  843     joinpath(global_attributes_file, sizeof(global_attributes_file), TIN_DEFAULTS_DIR, ATTRIBUTES_FILE);
  844     joinpath(global_config_file, sizeof(global_config_file), TIN_DEFAULTS_DIR, CONFIG_FILE);
  845 #else
  846     /* read_site_config() might have changed the value of libdir */
  847     joinpath(global_attributes_file, sizeof(global_attributes_file), libdir, ATTRIBUTES_FILE);
  848     joinpath(global_config_file, sizeof(global_config_file), libdir, CONFIG_FILE);
  849 #endif /* TIN_DEFAULTS_DIR */
  850 
  851     joinpath(rcdir, sizeof(rcdir), homedir, RCDIR);
  852     if (stat(rcdir, &sb) == -1) {
  853         my_mkdir(rcdir, (mode_t) (S_IRWXU)); /* TODO: bail out? give error message? no_write = TRUE? */
  854         created_rcdir = TRUE;
  855     }
  856     strcpy(tinrc.mailer_format, MAILER_FORMAT);
  857     my_strncpy(mailer, get_val(ENV_VAR_MAILER, DEFAULT_MAILER), sizeof(mailer) - 1);
  858 #ifndef DISABLE_PRINTING
  859     strcpy(tinrc.printer, DEFAULT_PRINTER);
  860 #endif /* !DISABLE_PRINTING */
  861     strcpy(tinrc.inews_prog, PATH_INEWS);
  862     joinpath(article_name, sizeof(article_name), homedir, TIN_ARTICLE_NAME);
  863 #ifdef APPEND_PID
  864     snprintf(article_name + strlen(article_name), sizeof(article_name) - strlen(article_name), ".%ld", (long) process_id);
  865 #endif /* APPEND_PID */
  866     joinpath(dead_article, sizeof(dead_article), homedir, "dead.article");
  867     joinpath(dead_articles, sizeof(dead_articles), homedir, "dead.articles");
  868     joinpath(tinrc.maildir, sizeof(tinrc.maildir), homedir, DEFAULT_MAILDIR);
  869     joinpath(tinrc.savedir, sizeof(tinrc.savedir), homedir, DEFAULT_SAVEDIR);
  870     joinpath(tinrc.sigfile, sizeof(tinrc.sigfile), homedir, ".Sig");
  871     joinpath(default_signature, sizeof(default_signature), homedir, ".signature");
  872 
  873     if (!index_newsdir[0])
  874         joinpath(index_newsdir, sizeof(index_newsdir), get_val("TIN_INDEX_NEWSDIR", rcdir), INDEX_NEWSDIR);
  875     joinpath(index_maildir, sizeof(index_maildir), get_val("TIN_INDEX_MAILDIR", rcdir), INDEX_MAILDIR);
  876     if (stat(index_maildir, &sb) == -1)
  877         my_mkdir(index_maildir, (mode_t) S_IRWXU);
  878     joinpath(index_savedir, sizeof(index_savedir), get_val("TIN_INDEX_SAVEDIR", rcdir), INDEX_SAVEDIR);
  879     if (stat(index_savedir, &sb) == -1)
  880         my_mkdir(index_savedir, (mode_t) S_IRWXU);
  881     joinpath(local_attributes_file, sizeof(local_attributes_file), rcdir, ATTRIBUTES_FILE);
  882     joinpath(local_config_file, sizeof(local_config_file), rcdir, CONFIG_FILE);
  883     joinpath(filter_file, sizeof(filter_file), rcdir, FILTER_FILE);
  884     joinpath(local_input_history_file, sizeof(local_input_history_file), rcdir, INPUT_HISTORY_FILE);
  885     joinpath(local_newsrctable_file, sizeof(local_newsrctable_file), rcdir, NEWSRCTABLE_FILE);
  886 #ifdef HAVE_MH_MAIL_HANDLING
  887     joinpath(mail_active_file, sizeof(mail_active_file), rcdir, ACTIVE_MAIL_FILE);
  888 #endif /* HAVE_MH_MAIL_HANDLING */
  889     joinpath(mailbox, sizeof(mailbox), DEFAULT_MAILBOX, userid);
  890 #ifdef HAVE_MH_MAIL_HANDLING
  891     joinpath(mailgroups_file, sizeof(mailgroups_file), rcdir, MAILGROUPS_FILE);
  892 #endif /* HAVE_MH_MAIL_HANDLING */
  893     joinpath(newsrc, sizeof(newsrc), homedir, NEWSRC_FILE);
  894     joinpath(newnewsrc, sizeof(newnewsrc), homedir, NEWNEWSRC_FILE);
  895 #ifdef APPEND_PID
  896     snprintf(newnewsrc + strlen(newnewsrc), sizeof(newnewsrc) - strlen(newnewsrc), ".%d", (int) process_id);
  897 #endif /* APPEND_PID */
  898     joinpath(posted_info_file, sizeof(posted_info_file), rcdir, POSTED_FILE);
  899     joinpath(postponed_articles_file, sizeof(postponed_articles_file), rcdir, POSTPONED_FILE);
  900     joinpath(save_active_file, sizeof(save_active_file), rcdir, ACTIVE_SAVE_FILE);
  901 
  902     snprintf(tmp, sizeof(tmp), INDEX_LOCK, userid);
  903     joinpath(lock_file, sizeof(lock_file), TMPDIR, tmp);
  904 
  905 #ifdef NNTP_ABLE
  906     nntp_tcp_port = (unsigned short) atoi(get_val("NNTPPORT", NNTP_TCP_PORT));
  907 #endif /* NNTP_ABLE */
  908 
  909     if ((fp = fopen(posted_info_file, "a")) != NULL) {
  910         if (!fstat(fileno(fp), &sb)) {
  911             if (sb.st_size == 0) {
  912                 fprintf(fp, "%s", _(txt_posted_info_file));
  913                 fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR));
  914             }
  915         }
  916         fclose(fp);
  917     }
  918 
  919     init_postinfo();
  920     snprintf(txt_help_bug_report, sizeof(txt_help_bug_report), _(txt_help_bug), bug_addr);
  921 
  922 #ifdef HAVE_PGP_GPG
  923     init_pgp();
  924 #endif /* HAVE_PGP_GPG */
  925 }
  926 
  927 
  928 /*
  929  * read_site_config()
  930  *
  931  * This function permits the local administrator to override a few compile
  932  * time defined parameters, especially the concerning the place of a local
  933  * news spool. This has especially binary distributions of TIN in mind.
  934  *
  935  * Sven Paulus <sven@tin.org>, 26-Jan-'98
  936  */
  937 static int
  938 read_site_config(
  939     void)
  940 {
  941     FILE *fp = (FILE *) 0;
  942     char buf[LEN], filename[PATH_LEN];
  943     static const char *tin_defaults[] = { TIN_DEFAULTS };
  944     int i = 0;
  945 
  946     /*
  947      * try to find tin.defaults in some different locations
  948      */
  949     while (tin_defaults[i] != NULL) {
  950         joinpath(filename, sizeof(filename), tin_defaults[i++], "tin.defaults");
  951         if ((fp = fopen(filename, "r")) != NULL)
  952             break;
  953     }
  954 
  955     if (!fp)
  956         return -1;
  957 
  958     while (fgets(buf, (int) sizeof(buf), fp)) {
  959         /* ignore comments */
  960         if (*buf == '#' || *buf == ';' || *buf == ' ')
  961             continue;
  962 #ifndef NNTP_ONLY
  963         if (match_string(buf, "spooldir=", spooldir, sizeof(spooldir)))
  964             continue;
  965         if (match_string(buf, "overviewdir=", novrootdir, sizeof(novrootdir)))
  966             continue;
  967         if (match_string(buf, "overviewfile=", novfilename, sizeof(novfilename)))
  968             continue;
  969 #endif /* !NNTP_ONLY */
  970         if (match_string(buf, "activefile=", news_active_file, sizeof(news_active_file)))
  971             continue;
  972         if (match_string(buf, "activetimesfile=", active_times_file, sizeof(active_times_file)))
  973             continue;
  974         if (match_string(buf, "newsgroupsfile=", newsgroups_file, sizeof(newsgroups_file)))
  975             continue;
  976         if (match_string(buf, "newslibdir=", libdir, sizeof(libdir)))
  977             continue;
  978         if (match_string(buf, "subscriptionsfile=", subscriptions_file, sizeof(subscriptions_file)))
  979             continue;
  980         if (match_string(buf, "overviewfmtfile=", overviewfmt_file, sizeof(overviewfmt_file)))
  981             continue;
  982         if (match_string(buf, "domainname=", domain_name, sizeof(domain_name)))
  983             continue;
  984         if (match_string(buf, "inewsdir=", inewsdir, sizeof(inewsdir)))
  985             continue;
  986         if (match_string(buf, "bugaddress=", bug_addr, sizeof(bug_addr)))
  987             continue;
  988         if (match_string(buf, "organization=", default_organization, sizeof(default_organization)))
  989             continue;
  990 #ifndef CHARSET_CONVERSION
  991         if (match_string(buf, "mm_charset=", tinrc.mm_charset, sizeof(tinrc.mm_charset)))
  992             continue;
  993 #else
  994         if (match_list(buf, "mm_charset=", txt_mime_charsets, &tinrc.mm_network_charset))
  995             continue;
  996 #endif /* !CHARSET_CONVERSION */
  997         if (match_list(buf, "post_mime_encoding=", txt_mime_encodings, &tinrc.post_mime_encoding))
  998             continue;
  999         if (match_list(buf, "mail_mime_encoding=", txt_mime_encodings, &tinrc.mail_mime_encoding))
 1000             continue;
 1001         if (match_boolean(buf, "disable_gnksa_domain_check=", &disable_gnksa_domain_check))
 1002             continue;
 1003         if (match_boolean(buf, "disable_sender=", &disable_sender))
 1004             continue;
 1005     }
 1006 
 1007     fclose(fp);
 1008     return 0;
 1009 }
 1010 
 1011 
 1012 /*
 1013  * set defaults if needed to avoid empty regexp
 1014  */
 1015 void
 1016 postinit_regexp(
 1017     void)
 1018 {
 1019     if (!strlen(tinrc.strip_re_regex))
 1020         STRCPY(tinrc.strip_re_regex, DEFAULT_STRIP_RE_REGEX);
 1021     compile_regex(tinrc.strip_re_regex, &strip_re_regex, PCRE_ANCHORED);
 1022 
 1023     if (strlen(tinrc.strip_was_regex)) {
 1024         /*
 1025          * try to be clever, if we still use the initial default value
 1026          * convert it to our needs
 1027          *
 1028          * TODO: a global soultion
 1029          */
 1030 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1031             if (IS_LOCAL_CHARSET("UTF-8") && utf8_pcre()) {
 1032                 if (!strcmp(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX))
 1033                     STRCPY(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX);
 1034             } else {
 1035                 if (!strcmp(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX))
 1036                     STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1037             }
 1038 #else
 1039             if (!strcmp(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX))
 1040                 STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1041 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 1042     } else {
 1043 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1044         if (IS_LOCAL_CHARSET("UTF-8") && utf8_pcre())
 1045             STRCPY(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX);
 1046         else
 1047 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 1048             STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1049     }
 1050     compile_regex(tinrc.strip_was_regex, &strip_was_regex, 0);
 1051 
 1052 #ifdef HAVE_COLOR
 1053     if (!strlen(tinrc.extquote_regex))
 1054         STRCPY(tinrc.extquote_regex, DEFAULT_EXTQUOTE_REGEX);
 1055     compile_regex(tinrc.extquote_regex, &extquote_regex, PCRE_CASELESS);
 1056     if (!strlen(tinrc.quote_regex))
 1057         STRCPY(tinrc.quote_regex, DEFAULT_QUOTE_REGEX);
 1058     compile_regex(tinrc.quote_regex, &quote_regex, PCRE_CASELESS);
 1059     if (!strlen(tinrc.quote_regex2))
 1060         STRCPY(tinrc.quote_regex2, DEFAULT_QUOTE_REGEX2);
 1061     compile_regex(tinrc.quote_regex2, &quote_regex2, PCRE_CASELESS);
 1062     if (!strlen(tinrc.quote_regex3))
 1063         STRCPY(tinrc.quote_regex3, DEFAULT_QUOTE_REGEX3);
 1064     compile_regex(tinrc.quote_regex3, &quote_regex3, PCRE_CASELESS);
 1065 #endif /* HAVE_COLOR */
 1066 
 1067     if (!strlen(tinrc.slashes_regex))
 1068         STRCPY(tinrc.slashes_regex, DEFAULT_SLASHES_REGEX);
 1069     compile_regex(tinrc.slashes_regex, &slashes_regex, PCRE_CASELESS);
 1070     if (!strlen(tinrc.stars_regex))
 1071         STRCPY(tinrc.stars_regex, DEFAULT_STARS_REGEX);
 1072     compile_regex(tinrc.stars_regex, &stars_regex, PCRE_CASELESS);
 1073     if (!strlen(tinrc.strokes_regex))
 1074         STRCPY(tinrc.strokes_regex, DEFAULT_STROKES_REGEX);
 1075     compile_regex(tinrc.strokes_regex, &strokes_regex, PCRE_CASELESS);
 1076     if (!strlen(tinrc.underscores_regex))
 1077         STRCPY(tinrc.underscores_regex, DEFAULT_UNDERSCORES_REGEX);
 1078     compile_regex(tinrc.underscores_regex, &underscores_regex, PCRE_CASELESS);
 1079 
 1080     if (!strlen(tinrc.verbatim_begin_regex))
 1081         STRCPY(tinrc.verbatim_begin_regex, DEFAULT_VERBATIM_BEGIN_REGEX);
 1082     compile_regex(tinrc.verbatim_begin_regex, &verbatim_begin_regex, PCRE_ANCHORED);
 1083     if (!strlen(tinrc.verbatim_end_regex))
 1084         STRCPY(tinrc.verbatim_end_regex, DEFAULT_VERBATIM_END_REGEX);
 1085     compile_regex(tinrc.verbatim_end_regex, &verbatim_end_regex, PCRE_ANCHORED);
 1086 
 1087     compile_regex(UUBEGIN_REGEX, &uubegin_regex, PCRE_ANCHORED);
 1088     compile_regex(UUBODY_REGEX, &uubody_regex, PCRE_ANCHORED);
 1089 
 1090     compile_regex(URL_REGEX, &url_regex, PCRE_CASELESS);
 1091     compile_regex(MAIL_REGEX, &mail_regex, PCRE_CASELESS);
 1092     compile_regex(NEWS_REGEX, &news_regex, PCRE_CASELESS);
 1093 
 1094     compile_regex(SHAR_REGEX, &shar_regex, PCRE_ANCHORED);
 1095 }
 1096 
 1097 
 1098 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1099 t_bool
 1100 utf8_pcre(
 1101     void)
 1102 {
 1103     int i = 0;
 1104 
 1105 #   if (defined(PCRE_MAJOR) && PCRE_MAJOR >= 4)
 1106     (void) pcre_config(PCRE_CONFIG_UTF8, &i);
 1107 #   endif /* PCRE_MAJOR && PCRE_MAJOR >= 4 */
 1108 
 1109     return (i ? TRUE : FALSE);
 1110 }
 1111 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */