"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.5/src/init.c" (1 Dec 2020, 38563 Bytes) of package /linux/misc/tin-2.4.5.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.4_vs_2.4.5.

    1 /*
    2  *  Project   : tin - a Usenet reader
    3  *  Module    : init.c
    4  *  Author    : I. Lea
    5  *  Created   : 1991-04-01
    6  *  Updated   : 2020-09-28
    7  *  Notes     :
    8  *
    9  * Copyright (c) 1991-2021 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  *
   16  * 1. Redistributions of source code must retain the above copyright notice,
   17  *    this list of conditions and the following disclaimer.
   18  *
   19  * 2. Redistributions in binary form must reproduce the above copyright
   20  *    notice, this list of conditions and the following disclaimer in the
   21  *    documentation and/or other materials provided with the distribution.
   22  *
   23  * 3. Neither the name of the copyright holder nor the names of its
   24  *    contributors may be used to endorse or promote products derived from
   25  *    this software without specific prior written permission.
   26  *
   27  * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 
   41 #ifndef TIN_H
   42 #   include "tin.h"
   43 #endif /* !TIN_H */
   44 #ifndef TNNTP_H
   45 #   include "tnntp.h"
   46 #endif /* !TNNTP_H */
   47 #ifndef included_trace_h
   48 #   include "trace.h"
   49 #endif /* !included_trace_h */
   50 #ifndef VERSION_H
   51 #   include "version.h"
   52 #endif /* !VERSION_H */
   53 #ifndef BUGREP_H
   54 #   include "bugrep.h"
   55 #endif /* !BUGREP_H */
   56 
   57 /*
   58  * local prototypes
   59  */
   60 static int read_site_config(void);
   61 #ifdef HAVE_COLOR
   62     static void preinit_colors(void);
   63 #endif /* HAVE_COLOR */
   64 
   65 
   66 char active_times_file[PATH_LEN];
   67 char article_name[PATH_LEN];            /* ~/TIN_ARTICLE_NAME file */
   68 char bug_nntpserver1[PATH_LEN];     /* welcome message of NNTP server used */
   69 char bug_nntpserver2[PATH_LEN];     /* welcome message of NNTP server used */
   70 char cvers[LEN];
   71 char dead_article[PATH_LEN];        /* ~/dead.article file */
   72 char dead_articles[PATH_LEN];       /* ~/dead.articles file */
   73 char default_organization[PATH_LEN];    /* Organization: */
   74 char default_signature[PATH_LEN];
   75 char domain_name[MAXHOSTNAMELEN + 1];
   76 char global_attributes_file[PATH_LEN];
   77 char global_config_file[PATH_LEN];
   78 char homedir[PATH_LEN];
   79 char index_maildir[PATH_LEN];
   80 char index_newsdir[PATH_LEN];   /* directory for private overview data */
   81 char index_savedir[PATH_LEN];
   82 char inewsdir[PATH_LEN];
   83 char local_attributes_file[PATH_LEN];
   84 char local_config_file[PATH_LEN];
   85 char local_input_history_file[PATH_LEN];
   86 char local_newsgroups_file[PATH_LEN];   /* local copy of NNTP newsgroups file */
   87 char local_newsrctable_file[PATH_LEN];
   88 char lock_file[PATH_LEN];       /* contains name of index lock file */
   89 char filter_file[PATH_LEN];
   90 char mail_news_user[LEN];       /* mail new news to this user address */
   91 char mailbox[PATH_LEN];         /* system mailbox for each user */
   92 char mailer[PATH_LEN];          /* mail program */
   93 char newnewsrc[PATH_LEN];
   94 char news_active_file[PATH_LEN];
   95 char newsgroups_file[PATH_LEN];
   96 char newsrc[PATH_LEN];
   97 char page_header[LEN];          /* page header of pgm name and version */
   98 char posted_info_file[PATH_LEN];
   99 char postponed_articles_file[PATH_LEN]; /* ~/.tin/postponed.articles file */
  100 char rcdir[PATH_LEN];
  101 char save_active_file[PATH_LEN];
  102 char spooldir[PATH_LEN];        /* directory where news is */
  103 char overviewfmt_file[PATH_LEN];    /* full path to overview.fmt */
  104 char subscriptions_file[PATH_LEN];  /* full path to subscriptions */
  105 char *tin_progname;     /* program name */
  106 char txt_help_bug_report[LEN];      /* address to send bug reports to */
  107 char userid[PATH_LEN];
  108 #ifdef HAVE_MH_MAIL_HANDLING
  109     char mail_active_file[PATH_LEN];
  110     char mailgroups_file[PATH_LEN];
  111 #endif /* HAVE_MH_MAIL_HANDLING */
  112 #ifndef NNTP_ONLY
  113     char novfilename[NAME_LEN + 1];     /* file name of a single nov index file */
  114     char novrootdir[PATH_LEN];      /* root directory of nov index files */
  115 #endif /* !NNTP_ONLY */
  116 
  117 t_function last_search = GLOBAL_SEARCH_REPEAT;  /* for repeated search */
  118 int hist_last[HIST_MAXNUM + 1];
  119 int hist_pos[HIST_MAXNUM + 1];
  120 int iso2asc_supported;          /* Convert ISO-Latin1 to Ascii */
  121 int system_status;
  122 int xmouse, xrow, xcol;         /* xterm button pressing information */
  123 
  124 pid_t process_id;           /* Useful to have around for .suffixes */
  125 
  126 t_bool batch_mode;          /* update index files only mode */
  127 t_bool check_for_new_newsgroups;    /* don't check for new newsgroups */
  128 t_bool cmd_line;            /* batch / interactive mode */
  129 t_bool created_rcdir;           /* checks if first time tin is started */
  130 t_bool dangerous_signal_exit;       /* no get_respcode() in nntp_command when dangerous signal exit */
  131 t_bool disable_gnksa_domain_check;  /* disable checking TLD in From: etc. */
  132 t_bool disable_sender;          /* disable generation of Sender: header */
  133 #ifdef NO_POSTING
  134     t_bool force_no_post = TRUE;        /* force no posting mode */
  135 #else
  136     t_bool force_no_post = FALSE;   /* don't force no posting mode */
  137 #endif /* NO_POSTING */
  138 #if defined(NNTP_ABLE) && defined(INET6)
  139     t_bool force_ipv4 = FALSE;
  140     t_bool force_ipv6 = FALSE;
  141 #endif /* NNTP_ABLE && INET6 */
  142 t_bool list_active;
  143 t_bool newsrc_active;
  144 t_bool no_write = FALSE;        /* do not write newsrc on quit (-X cmd-line flag) */
  145 t_bool post_article_and_exit;       /* quick post of an article then exit(elm like) */
  146 t_bool post_postponed_and_exit;     /* post postponed articles and exit */
  147 t_bool range_active;        /* Set if a range is defined */
  148 t_bool reread_active_for_posted_arts;
  149 t_bool read_local_newsgroups_file;  /* read newsgroups file locally or via NNTP */
  150 t_bool read_news_via_nntp = FALSE;  /* read news locally or via NNTP */
  151 t_bool read_saved_news = FALSE;     /* tin -R read saved news from tin -S */
  152 t_bool show_description = TRUE;     /* current copy of tinrc flag */
  153 int verbose = 0;            /* batch or debug mode */
  154 t_bool word_highlight;      /* word highlighting on/off */
  155 t_bool xref_supported = TRUE;
  156 #ifdef HAVE_COLOR
  157     t_bool use_color;       /* enables/disables ansi-color support under linux-console and color-xterm */
  158 #endif /* HAVE_COLOR */
  159 #ifdef NNTP_ABLE
  160     t_bool force_auth_on_conn_open = FALSE; /* authenticate on connection startup */
  161     unsigned short nntp_tcp_port;
  162 #endif /* NNTP_ABLE */
  163 
  164 /* Currently active menu parameters */
  165 t_menu *currmenu;
  166 
  167 /* History entries */
  168 char *input_history[HIST_MAXNUM + 1][HIST_SIZE + 1];
  169 
  170 #ifdef HAVE_SYS_UTSNAME_H
  171     struct utsname system_info;
  172 #endif /* HAVE_SYS_UTSNAME_H */
  173 
  174 struct regex_cache
  175         strip_re_regex, strip_was_regex,
  176         uubegin_regex, uubody_regex,
  177         verbatim_begin_regex, verbatim_end_regex,
  178         url_regex, mail_regex, news_regex,
  179         shar_regex,
  180         slashes_regex, stars_regex, underscores_regex, strokes_regex
  181 #ifdef HAVE_COLOR
  182         , extquote_regex, quote_regex, quote_regex2, quote_regex3
  183 #endif /* HAVE_COLOR */
  184     = {
  185         NULL,
  186         NULL
  187     };
  188 
  189 struct t_cmdlineopts cmdline;
  190 
  191 struct t_config tinrc = {
  192     ART_MARK_DELETED,       /* art_marked_deleted */
  193     MARK_INRANGE,           /* art_marked_inrange */
  194     ART_MARK_RETURN,        /* art_marked_return */
  195     ART_MARK_SELECTED,      /* art_marked_selected */
  196     ART_MARK_RECENT,        /* art_marked_recent */
  197     ART_MARK_UNREAD,        /* art_marked_unread */
  198     ART_MARK_READ,          /* art_marked_read */
  199     ART_MARK_KILLED,        /* art_marked_killed */
  200     ART_MARK_READ_SELECTED,     /* art_marked_read_selected */
  201     "",     /* editor_format */
  202     "",     /* default_goto_group */
  203     "",     /* default_mail_address */
  204     "",     /* mailer_format */
  205 #ifndef DONT_HAVE_PIPING
  206     "",     /* default_pipe_command */
  207 #endif /* !DONT_HAVE_PIPING */
  208     "",     /* default_post_newsgroups */
  209     "",     /* default_post_subject */
  210 #ifndef DISABLE_PRINTING
  211     "",     /* printer */
  212 #endif /* !DISABLE_PRINTING */
  213     "1-.",  /* default_range_group */
  214     "1-.",  /* default_range_select */
  215     "1-.",  /* default_range_thread */
  216     "",     /* default_pattern */
  217     "",     /* default_repost_group */
  218     "savefile.tin",     /* default_save_file */
  219     "",     /* default_search_art */
  220     "",     /* default_search_author */
  221     "",     /* default_search_config */
  222     "",     /* default_search_group */
  223     "",     /* default_search_subject */
  224     "",     /* default_select_pattern */
  225     "",     /* default_shell_command */
  226     "In article %M you wrote:",     /* mail_quote_format */
  227     "",     /* maildir */
  228 #ifdef SCO_UNIX
  229     2,          /* mailbox_format = MMDF */
  230 #else
  231     0,          /* mailbox_format = MBOXO */
  232 #endif /* SCO_UNIX */
  233     "",     /* mail_address */
  234 #ifdef HAVE_METAMAIL
  235     METAMAIL_CMD,       /* metamail_prog */
  236 #else
  237     INTERNAL_CMD,       /* metamail_prog */
  238 #endif /* HAVE_METAMAIL */
  239 #ifndef CHARSET_CONVERSION
  240     "",     /* mm_charset, defaults to $MM_CHARSET */
  241 #else
  242     -1,     /* mm_network_charset, defaults to $MM_CHARSET */
  243 #endif /* !CHARSET_CONVERSION */
  244     "US-ASCII",     /* mm_local_charset, display charset */
  245 #ifdef HAVE_ICONV_OPEN_TRANSLIT
  246     FALSE,  /* translit */
  247 #endif /* HAVE_ICONV_OPEN_TRANSLIT */
  248     "Newsgroups Followup-To Summary Keywords X-Comment-To",     /* news_headers_to_display */
  249     "",     /* news_headers_to_not_display */
  250     "%F wrote:",        /* news_quote_format */
  251     DEFAULT_COMMENT,    /* quote_chars */
  252 #ifdef HAVE_COLOR
  253     "",     /* quote_regex */
  254     "",     /* quote_regex 2nd level */
  255     "",     /* quote_regex >= 3rd level */
  256     "",     /* extquote_regex */
  257 #endif /* HAVE_COLOR */
  258     "",     /* slashes_regex */
  259     "",     /* stars_regex */
  260     "",     /* underscores_regex */
  261     "",     /* strokes_regex */
  262     "",     /* sigfile */
  263     "",     /* strip_re_regex */
  264     "",     /* strip_was_regex */
  265     "",     /* verbatim_begin_regex */
  266     "",     /* verbatim_end_regex */
  267     "",     /* savedir */
  268     "",     /* spamtrap_warning_addresses */
  269     DEFAULT_URL_HANDLER,    /* url_handler */
  270     "In %G %F wrote:",          /* xpost_quote_format */
  271     DEFAULT_FILTER_DAYS,            /* filter_days */
  272     FILTER_SUBJ_CASE_SENSITIVE,     /* default_filter_kill_header */
  273     FILTER_SUBJ_CASE_SENSITIVE,     /* default_filter_select_header */
  274     0,      /* default_move_group */
  275     'a',        /* default_save_mode */
  276     0,      /* getart_limit */
  277     2,      /* recent_time */
  278     GOTO_NEXT_UNREAD_TAB,       /* goto_next_unread */
  279     UUE_NO, /* hide_uue */
  280     KILL_UNREAD,        /* kill_level */
  281     MIME_ENCODING_QP,       /* mail_mime_encoding */
  282     MIME_ENCODING_8BIT,     /* post_mime_encoding */
  283     POST_PROC_NO,           /* post_process_type */
  284     REREAD_ACTIVE_FILE_SECS,    /* reread_active_file_secs */
  285     1,      /* scroll_lines */
  286     SHOW_FROM_NAME,             /* show_author */
  287     SORT_ARTICLES_BY_DATE_ASCEND,       /* sort_article_type */
  288     SORT_THREADS_BY_SCORE_DESCEND,      /* sort_threads_type */
  289 #ifdef USE_HEAPSORT
  290     0,              /* sort_function default qsort */
  291 #endif /* USE_HEAPSORT */
  292     BOGUS_SHOW,     /* strip_bogus */
  293     THREAD_BOTH,        /* thread_articles */
  294     THREAD_PERC_DEFAULT,    /* thread_perc */
  295     THREAD_SCORE_MAX,   /* thread_score */
  296     0,      /* Default to wildmat, not regex */
  297     -50,        /* score_limit_kill */
  298     50,     /* score_limit_select */
  299     -100,       /* score_kill */
  300     100,        /* score_select */
  301     0,      /* trim_article_body */
  302 #ifdef HAVE_COLOR
  303     0,      /* col_back (initialised later) */
  304     0,      /* col_from (initialised later) */
  305     0,      /* col_head (initialised later) */
  306     0,      /* col_help (initialised later) */
  307     0,      /* col_invers_bg (initialised later) */
  308     0,      /* col_invers_fg (initialised later) */
  309     0,      /* col_minihelp (initialised later) */
  310     0,      /* col_normal (initialised later) */
  311     0,      /* col_markdash (initialised later) */
  312     0,      /* col_markstar (initialised later) */
  313     0,      /* col_markslash (initialised later) */
  314     0,      /* col_markstroke (initialised later) */
  315     0,      /* col_message (initialised later) */
  316     0,      /* col_newsheaders (initialised later) */
  317     0,      /* col_quote (initialised later) */
  318     0,      /* col_quote2 (initialised later) */
  319     0,      /* col_quote3 (initialised later) */
  320     0,      /* col_extquote (initialised later) */
  321     0,      /* col_response (initialised later) */
  322     0,      /* col_signature (initialised later) */
  323     0,      /* col_urls (initialised later) */
  324     0,      /* col_verbatim (initialised later) */
  325     0,      /* col_subject (initialised later) */
  326     0,      /* col_text (initialised later) */
  327     0,      /* col_title (initialised later) */
  328 #endif /* HAVE_COLOR */
  329     2,      /* word_h_display_marks */
  330     2,      /* mono_markdash */
  331     6,      /* mono_markstar */
  332     5,      /* mono_markslash */
  333     3,      /* mono_markstroke */
  334     TRUE,       /* word_highlight */
  335     TRUE,       /* url_highlight */
  336     0,      /* wrap_column */
  337 #ifdef HAVE_COLOR
  338     FALSE,      /* use_color */
  339 #endif /* HAVE_COLOR */
  340     FALSE,      /* abbreviate_groupname */
  341     TRUE,       /* add_posted_to_filter */
  342     TRUE,       /* advertising */
  343     TRUE,       /* alternative_handling */
  344     0,          /* auto_cc_bcc */
  345     TRUE,       /* auto_list_thread */
  346     FALSE,      /* auto_reconnect */
  347     FALSE,      /* auto_save */
  348     TRUE,       /* batch_save */
  349     TRUE,       /* beginner_level */
  350     FALSE,      /* cache_overview_files */
  351     FALSE,      /* catchup_read_groups */
  352     4,      /* confirm_choice */
  353 #ifdef USE_INVERSE_HACK
  354     TRUE,       /* draw_arrow */
  355 #else
  356     FALSE,      /* draw_arrow */
  357 #endif /* USE_INVERSE_HACK */
  358     FALSE,      /* force_screen_redraw */
  359     TRUE,       /* group_catchup_on_exit */
  360     FALSE,      /* info_in_last_line */
  361 #ifdef USE_INVERSE_HACK
  362     FALSE,      /* inverse_okay */
  363 #else
  364     TRUE,       /* inverse_okay */
  365 #endif /* USE_INVERSE_HACK */
  366     TRUE,       /* keep_dead_articles */
  367     POSTED_FILE,    /* posted_articles_file */
  368     FALSE,      /* mail_8bit_header */
  369     FALSE,      /* mark_ignore_tags */
  370     TRUE,       /* mark_saved_read */
  371     TRUE,       /* pos_first_unread */
  372     FALSE,      /* post_8bit_header */
  373     TRUE,       /* post_process_view */
  374 #ifndef DISABLE_PRINTING
  375     FALSE,      /* print_header */
  376 #endif /* !DISABLE_PRINTING */
  377     FALSE,      /* process_only_unread */
  378     FALSE,      /* prompt_followupto */
  379     QUOTE_COMPRESS|QUOTE_EMPTY, /* quote_style */
  380     TRUE,       /* show_description */
  381     TRUE,       /* show_only_unread_arts */
  382     FALSE,      /* show_only_unread_groups */
  383     TRUE,       /* show_signatures */
  384     TRUE,       /* sigdashes */
  385     TRUE,       /* signature_repost */
  386     TRUE,       /* start_editor_offset */
  387 #ifndef USE_CURSES
  388     TRUE,       /* strip_blanks */
  389 #endif /* !USE_CURSES */
  390     FALSE,      /* strip_newsrc */
  391     FALSE,      /* tex2iso_conv */
  392     TRUE,       /* thread_catchup_on_exit */
  393     TRUE,       /* unlink_article */
  394 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  395     FALSE,      /* utf8_graphics */
  396 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  397     TRUE,       /* verbatim_handling */
  398 #ifdef HAVE_COLOR
  399     FALSE,      /* extquote_handling */
  400 #endif /* HAVE_COLOR */
  401     "",     /* inews_prog */
  402 #ifdef USE_CANLOCK
  403     1,          /* cancel_lock_algo, sha1 */
  404 #endif /* USE_CANLOCK */
  405     INTERACTIVE_NONE,       /* interactive_mailer */
  406     FALSE,      /* use_mouse */
  407 #ifdef HAVE_KEYPAD
  408     FALSE,      /* use_keypad */
  409 #endif /* HAVE_KEYPAD */
  410     TRUE,       /* wrap_on_next_unread */
  411     FALSE,      /* ask_for_metamail */
  412     FALSE,      /* default_filter_kill_case */
  413     FALSE,      /* default_filter_kill_expire */
  414     TRUE,       /* default_filter_kill_global */
  415     FALSE,      /* default_filter_select_case */
  416     FALSE,      /* default_filter_select_expire */
  417 #ifdef XFACE_ABLE
  418     FALSE,      /* use_slrnface */
  419 #endif /* XFACE_ABLE */
  420     TRUE,       /* default_filter_select_global */
  421     DEFAULT_SELECT_FORMAT,  /* select_format */
  422     DEFAULT_GROUP_FORMAT,   /* group_format */
  423     DEFAULT_THREAD_FORMAT,  /* thread_format */
  424     DEFAULT_DATE_FORMAT,    /* date_format */
  425 #ifdef HAVE_UNICODE_NORMALIZATION
  426     DEFAULT_NORMALIZE,      /* normalization form */
  427 #endif /* HAVE_UNICODE_NORMALIZATION */
  428 #if defined(HAVE_LIBICUUC) && defined(MULTIBYTE_ABLE) && defined(HAVE_UNICODE_UBIDI_H) && !defined(NO_LOCALE)
  429     FALSE,      /* render_bidi */
  430 #endif /* HAVE_LIBICUUC && MULTIBYTE_ABLE && HAVE_UNICODE_UBIDI_H && !NO_LOCALE */
  431 #ifdef CHARSET_CONVERSION
  432     -1,     /* attrib_mm_network_charset, defaults to $MM_CHARSET */
  433     "",     /* attrib_undeclared_charset */
  434 #endif /* CHARSET_CONVERSION */
  435     "",     /* attrib_editor_format */
  436     "",     /* attrib_fcc */
  437     "",     /* attrib_maildir */
  438     "",     /* attrib_from */
  439     "",     /* attrib_mailing_list */
  440     "",     /* attrib_organization */
  441     "",     /* attrib_followup_to */
  442     "",     /* attrib_mime_types_to_save */
  443     "",     /* attrib_news_headers_to_display */
  444     "",     /* attrib_news_headers_to_not_display */
  445     "",     /* attrib_news_quote_format */
  446     "",     /* attrib_quote_chars */
  447     "",     /* attrib_sigfile */
  448     "",     /* attrib_savedir */
  449     "",     /* attrib_savefile */
  450     "",     /* attrib_x_body */
  451     "",     /* attrib_x_headers */
  452 #ifdef HAVE_ISPELL
  453     "",     /* attrib_ispell */
  454 #endif /* HAVE_ISPELL */
  455     "",     /* attrib_quick_kill_scope */
  456     "",     /* attrib_quick_select_scope */
  457     "",     /* attrib_group_format */
  458     "",     /* attrib_thread_format */
  459     "",     /* attrib_date_format */
  460     0,      /* attrib_trim_article_body */
  461     0,      /* attrib_auto_cc_bcc */
  462     FILTER_SUBJ_CASE_SENSITIVE,     /* attrib_quick_kill_header */
  463     FILTER_SUBJ_CASE_SENSITIVE,     /* attrib_quick_select_header */
  464     MIME_ENCODING_QP,       /* attrib_mail_mime_encoding */
  465 #if defined(HAVE_ALARM) && defined(SIGALRM)
  466     120,    /* nntp_read_timeout_secs */
  467 #endif /* HAVE_ALARM && SIGALRM */
  468     MIME_ENCODING_8BIT,     /* attrib_post_mime_encoding */
  469     POST_PROC_NO,           /* attrib_post_process_type */
  470     SHOW_FROM_NAME,         /* attrib_show_author */
  471     SORT_ARTICLES_BY_DATE_ASCEND,       /* attrib_sort_article_type */
  472     SORT_THREADS_BY_SCORE_DESCEND,      /* attrib_sort_threads_type */
  473     THREAD_BOTH,        /* attrib_thread_articles */
  474     THREAD_PERC_DEFAULT,    /* attrib_thread_perc */
  475     TRUE,       /* attrib_add_posted_to_filter */
  476     TRUE,       /* attrib_advertising */
  477     TRUE,       /* attrib_alternative_handling */
  478     TRUE,       /* attrib_auto_list_thread */
  479     FALSE,      /* attrib_auto_select */
  480     FALSE,      /* attrib_auto_save */
  481     TRUE,       /* attrib_batch_save */
  482     TRUE,       /* attrib_delete_tmp_files */
  483     TRUE,       /* attrib_group_catchup_on_exit */
  484     FALSE,      /* attrib_mail_8bit_header */
  485     FALSE,      /* attrib_mime_forward */
  486     FALSE,      /* attrib_mark_ignore_tags */
  487     TRUE,       /* attrib_mark_saved_read */
  488     TRUE,       /* attrib_pos_first_unread */
  489     FALSE,      /* attrib_post_8bit_header */
  490     TRUE,       /* attrib_post_process_view */
  491 #ifndef DISABLE_PRINTING
  492     FALSE,      /* attrib_print_header */
  493 #endif /* !DISABLE_PRINTING */
  494     FALSE,      /* attrib_process_only_unread */
  495     FALSE,      /* attrib_prompt_followupto */
  496     TRUE,       /* attrib_show_only_unread_arts */
  497     TRUE,       /* attrib_show_signatures */
  498     TRUE,       /* attrib_sigdashes */
  499     TRUE,       /* attrib_signature_repost */
  500     TRUE,       /* attrib_start_editor_offset */
  501     FALSE,      /* attrib_tex2iso_conv */
  502     TRUE,       /* attrib_thread_catchup_on_exit */
  503     TRUE,       /* attrib_verbatim_handling */
  504 #ifdef HAVE_COLOR
  505     FALSE,      /* attrib_extquote_handling */
  506 #endif /* HAVE_COLOR */
  507     FALSE,      /* attrib_x_comment_to */
  508     TRUE,       /* attrib_wrap_on_next_unread */
  509     FALSE,      /* attrib_ask_for_metamail */
  510     FALSE,      /* attrib_quick_kill_case */
  511     FALSE,      /* attrib_quick_kill_expire */
  512     FALSE,      /* attrib_quick_select_case */
  513     FALSE       /* attrib_quick_select_expire */
  514 };
  515 
  516 struct t_capabilities nntp_caps = {
  517     NONE, /* type (NONE, CAPABILITIES, BROKEN) */
  518     0, /* CAPABILITIES version */
  519     FALSE, /* MODE-READER: "MODE READER" */
  520     FALSE, /* READER: "ARTICLE", "BODY" */
  521     FALSE, /* POST */
  522     FALSE, /* LIST: "LIST ACTIVE" */
  523     FALSE, /* LIST: "LIST ACTIVE.TIMES" */
  524     FALSE, /* LIST: "LIST DISTRIB.PATS" */
  525     FALSE, /* LIST: "LIST HEADERS" */
  526     NULL, /* list of headers by range */
  527     NULL, /* list of headers by id */
  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",
  737         PRODUCT, VERSION, RELEASEDATE, RELEASENAME,
  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         joinpath(tmp, sizeof(tmp), libdir, "organization");
  807         if ((fp = fopen(tmp, "r")) != NULL) {
  808             char buf[LEN];
  809 
  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 
  832         snprintf(ptr, space, "mm_network_charset=%s\n", get_val("MM_CHARSET", MM_CHARSET));
  833         if (!match_list(ptr, "mm_network_charset=", txt_mime_charsets, &tinrc.mm_network_charset)) /* $MM_CHARSET may be set invalid, fallback */
  834             snprintf(ptr, space, "mm_network_charset=%s\n", MM_CHARSET);
  835 
  836         free(ptr);
  837     }
  838 #endif /* !CHARSET_CONVERSION */
  839 
  840 #ifdef TIN_DEFAULTS_DIR
  841     joinpath(global_attributes_file, sizeof(global_attributes_file), TIN_DEFAULTS_DIR, ATTRIBUTES_FILE);
  842     joinpath(global_config_file, sizeof(global_config_file), TIN_DEFAULTS_DIR, CONFIG_FILE);
  843 #else
  844     /* read_site_config() might have changed the value of libdir */
  845     joinpath(global_attributes_file, sizeof(global_attributes_file), libdir, ATTRIBUTES_FILE);
  846     joinpath(global_config_file, sizeof(global_config_file), libdir, CONFIG_FILE);
  847 #endif /* TIN_DEFAULTS_DIR */
  848 
  849     joinpath(rcdir, sizeof(rcdir), homedir, RCDIR);
  850     if (stat(rcdir, &sb) == -1) {
  851         my_mkdir(rcdir, (mode_t) (S_IRWXU)); /* TODO: bail out? give error message? no_write = TRUE? */
  852         created_rcdir = TRUE;
  853     }
  854     strcpy(tinrc.mailer_format, MAILER_FORMAT);
  855     my_strncpy(mailer, get_val(ENV_VAR_MAILER, DEFAULT_MAILER), sizeof(mailer) - 1);
  856 #ifndef DISABLE_PRINTING
  857     strcpy(tinrc.printer, DEFAULT_PRINTER);
  858 #endif /* !DISABLE_PRINTING */
  859     strcpy(tinrc.inews_prog, PATH_INEWS);
  860     joinpath(article_name, sizeof(article_name), homedir, TIN_ARTICLE_NAME);
  861 #ifdef APPEND_PID
  862     snprintf(article_name + strlen(article_name), sizeof(article_name) - strlen(article_name), ".%ld", (long) process_id);
  863 #endif /* APPEND_PID */
  864     joinpath(dead_article, sizeof(dead_article), homedir, "dead.article");
  865     joinpath(dead_articles, sizeof(dead_articles), homedir, "dead.articles");
  866     joinpath(tinrc.maildir, sizeof(tinrc.maildir), homedir, DEFAULT_MAILDIR);
  867     joinpath(tinrc.savedir, sizeof(tinrc.savedir), homedir, DEFAULT_SAVEDIR);
  868     joinpath(tinrc.sigfile, sizeof(tinrc.sigfile), homedir, ".Sig");
  869     joinpath(default_signature, sizeof(default_signature), homedir, ".signature");
  870 
  871     if (!index_newsdir[0])
  872         joinpath(index_newsdir, sizeof(index_newsdir), get_val("TIN_INDEX_NEWSDIR", rcdir), INDEX_NEWSDIR);
  873     joinpath(index_maildir, sizeof(index_maildir), get_val("TIN_INDEX_MAILDIR", rcdir), INDEX_MAILDIR);
  874     if (stat(index_maildir, &sb) == -1)
  875         my_mkdir(index_maildir, (mode_t) S_IRWXU);
  876     joinpath(index_savedir, sizeof(index_savedir), get_val("TIN_INDEX_SAVEDIR", rcdir), INDEX_SAVEDIR);
  877     if (stat(index_savedir, &sb) == -1)
  878         my_mkdir(index_savedir, (mode_t) S_IRWXU);
  879     joinpath(local_attributes_file, sizeof(local_attributes_file), rcdir, ATTRIBUTES_FILE);
  880     joinpath(local_config_file, sizeof(local_config_file), rcdir, CONFIG_FILE);
  881     joinpath(filter_file, sizeof(filter_file), rcdir, FILTER_FILE);
  882     joinpath(local_input_history_file, sizeof(local_input_history_file), rcdir, INPUT_HISTORY_FILE);
  883     joinpath(local_newsrctable_file, sizeof(local_newsrctable_file), rcdir, NEWSRCTABLE_FILE);
  884 #ifdef HAVE_MH_MAIL_HANDLING
  885     joinpath(mail_active_file, sizeof(mail_active_file), rcdir, ACTIVE_MAIL_FILE);
  886 #endif /* HAVE_MH_MAIL_HANDLING */
  887     ptr = getenv("MAIL");
  888     if (ptr == NULL || (*ptr == '\0'))
  889         joinpath(mailbox, sizeof(mailbox), DEFAULT_MAILBOX, userid);
  890     else
  891         STRCPY(mailbox, ptr);
  892 #ifdef HAVE_MH_MAIL_HANDLING
  893     joinpath(mailgroups_file, sizeof(mailgroups_file), rcdir, MAILGROUPS_FILE);
  894 #endif /* HAVE_MH_MAIL_HANDLING */
  895     joinpath(newsrc, sizeof(newsrc), homedir, NEWSRC_FILE);
  896     joinpath(newnewsrc, sizeof(newnewsrc), homedir, NEWNEWSRC_FILE);
  897 #ifdef APPEND_PID
  898     snprintf(newnewsrc + strlen(newnewsrc), sizeof(newnewsrc) - strlen(newnewsrc), ".%d", (int) process_id);
  899 #endif /* APPEND_PID */
  900     joinpath(posted_info_file, sizeof(posted_info_file), rcdir, POSTED_FILE);
  901     joinpath(postponed_articles_file, sizeof(postponed_articles_file), rcdir, POSTPONED_FILE);
  902     joinpath(save_active_file, sizeof(save_active_file), rcdir, ACTIVE_SAVE_FILE);
  903 
  904     snprintf(tmp, sizeof(tmp), INDEX_LOCK, userid);
  905     joinpath(lock_file, sizeof(lock_file), TMPDIR, tmp);
  906 
  907 #ifdef NNTP_ABLE
  908     nntp_tcp_port = (unsigned short) atoi(get_val("NNTPPORT", NNTP_TCP_PORT));
  909 #endif /* NNTP_ABLE */
  910 
  911     if ((fp = fopen(posted_info_file, "a")) != NULL) {
  912         if (!fstat(fileno(fp), &sb)) {
  913             if (sb.st_size == 0) {
  914                 fprintf(fp, "%s", _(txt_posted_info_file));
  915 #ifdef HAVE_FCHMOD
  916                 fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR));
  917 #else
  918 #   ifdef HAVE_CHMOD
  919                 chmod(posted_info_file, (mode_t) (S_IRUSR|S_IWUSR));
  920 #   endif /* HAVE_CHMOD */
  921 #endif /* HAVE_FCHMOD */
  922             }
  923         }
  924         fclose(fp);
  925     }
  926 
  927     init_postinfo();
  928     snprintf(txt_help_bug_report, sizeof(txt_help_bug_report), _(txt_help_bug), bug_addr);
  929 
  930 #ifdef HAVE_PGP_GPG
  931     init_pgp();
  932 #endif /* HAVE_PGP_GPG */
  933 }
  934 
  935 
  936 /*
  937  * read_site_config()
  938  *
  939  * This function permits the local administrator to override a few compile
  940  * time defined parameters, especially the concerning the place of a local
  941  * news spool. This has especially binary distributions of TIN in mind.
  942  *
  943  * Sven Paulus <sven@tin.org>, 26-Jan-'98
  944  */
  945 static int
  946 read_site_config(
  947     void)
  948 {
  949     FILE *fp = (FILE *) 0;
  950     char buf[LEN], filename[PATH_LEN];
  951     static const char *tin_defaults[] = { TIN_DEFAULTS };
  952     int i = 0;
  953 
  954     /*
  955      * try to find tin.defaults in some different locations
  956      */
  957     while (tin_defaults[i] != NULL) {
  958         joinpath(filename, sizeof(filename), tin_defaults[i++], "tin.defaults");
  959         if ((fp = fopen(filename, "r")) != NULL)
  960             break;
  961     }
  962 
  963     if (!fp)
  964         return -1;
  965 
  966     while (fgets(buf, (int) sizeof(buf), fp)) {
  967         /* ignore comments */
  968         if (*buf == '#' || *buf == ';' || *buf == ' ')
  969             continue;
  970 #ifndef NNTP_ONLY
  971         if (match_string(buf, "spooldir=", spooldir, sizeof(spooldir)))
  972             continue;
  973         if (match_string(buf, "overviewdir=", novrootdir, sizeof(novrootdir)))
  974             continue;
  975         if (match_string(buf, "overviewfile=", novfilename, sizeof(novfilename)))
  976             continue;
  977 #endif /* !NNTP_ONLY */
  978         if (match_string(buf, "activefile=", news_active_file, sizeof(news_active_file)))
  979             continue;
  980         if (match_string(buf, "activetimesfile=", active_times_file, sizeof(active_times_file)))
  981             continue;
  982         if (match_string(buf, "newsgroupsfile=", newsgroups_file, sizeof(newsgroups_file)))
  983             continue;
  984         if (match_string(buf, "newslibdir=", libdir, sizeof(libdir)))
  985             continue;
  986         if (match_string(buf, "subscriptionsfile=", subscriptions_file, sizeof(subscriptions_file)))
  987             continue;
  988         if (match_string(buf, "overviewfmtfile=", overviewfmt_file, sizeof(overviewfmt_file)))
  989             continue;
  990         if (match_string(buf, "domainname=", domain_name, sizeof(domain_name)))
  991             continue;
  992         if (match_string(buf, "inewsdir=", inewsdir, sizeof(inewsdir)))
  993             continue;
  994         if (match_string(buf, "bugaddress=", bug_addr, sizeof(bug_addr)))
  995             continue;
  996         if (match_string(buf, "organization=", default_organization, sizeof(default_organization)))
  997             continue;
  998 #ifndef CHARSET_CONVERSION
  999         if (match_string(buf, "mm_charset=", tinrc.mm_charset, sizeof(tinrc.mm_charset)))
 1000             continue;
 1001 #else
 1002         if (match_list(buf, "mm_charset=", txt_mime_charsets, &tinrc.mm_network_charset))
 1003             continue;
 1004 #endif /* !CHARSET_CONVERSION */
 1005         if (match_list(buf, "post_mime_encoding=", txt_mime_encodings, &tinrc.post_mime_encoding))
 1006             continue;
 1007         if (match_list(buf, "mail_mime_encoding=", txt_mime_encodings, &tinrc.mail_mime_encoding))
 1008             continue;
 1009         if (match_boolean(buf, "disable_gnksa_domain_check=", &disable_gnksa_domain_check))
 1010             continue;
 1011         if (match_boolean(buf, "disable_sender=", &disable_sender))
 1012             continue;
 1013     }
 1014 
 1015     fclose(fp);
 1016     return 0;
 1017 }
 1018 
 1019 
 1020 /*
 1021  * set defaults if needed to avoid empty regexp
 1022  */
 1023 void
 1024 postinit_regexp(
 1025     void)
 1026 {
 1027     if (!strlen(tinrc.strip_re_regex))
 1028         STRCPY(tinrc.strip_re_regex, DEFAULT_STRIP_RE_REGEX);
 1029     compile_regex(tinrc.strip_re_regex, &strip_re_regex, PCRE_ANCHORED);
 1030 
 1031     if (strlen(tinrc.strip_was_regex)) {
 1032         /*
 1033          * try to be clever, if we still use the initial default value
 1034          * convert it to our needs
 1035          *
 1036          * TODO: a global solution
 1037          */
 1038 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1039             if (IS_LOCAL_CHARSET("UTF-8") && utf8_pcre()) {
 1040                 if (!strcmp(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX))
 1041                     STRCPY(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX);
 1042             } else {
 1043                 if (!strcmp(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX))
 1044                     STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1045             }
 1046 #else
 1047             if (!strcmp(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX))
 1048                 STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1049 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 1050     } else {
 1051 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1052         if (IS_LOCAL_CHARSET("UTF-8") && utf8_pcre())
 1053             STRCPY(tinrc.strip_was_regex, DEFAULT_U8_STRIP_WAS_REGEX);
 1054         else
 1055 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 1056             STRCPY(tinrc.strip_was_regex, DEFAULT_STRIP_WAS_REGEX);
 1057     }
 1058     compile_regex(tinrc.strip_was_regex, &strip_was_regex, 0);
 1059 
 1060 #ifdef HAVE_COLOR
 1061     if (!strlen(tinrc.extquote_regex))
 1062         STRCPY(tinrc.extquote_regex, DEFAULT_EXTQUOTE_REGEX);
 1063     compile_regex(tinrc.extquote_regex, &extquote_regex, PCRE_CASELESS);
 1064     if (!strlen(tinrc.quote_regex))
 1065         STRCPY(tinrc.quote_regex, DEFAULT_QUOTE_REGEX);
 1066     compile_regex(tinrc.quote_regex, &quote_regex, PCRE_CASELESS);
 1067     if (!strlen(tinrc.quote_regex2))
 1068         STRCPY(tinrc.quote_regex2, DEFAULT_QUOTE_REGEX2);
 1069     compile_regex(tinrc.quote_regex2, &quote_regex2, PCRE_CASELESS);
 1070     if (!strlen(tinrc.quote_regex3))
 1071         STRCPY(tinrc.quote_regex3, DEFAULT_QUOTE_REGEX3);
 1072     compile_regex(tinrc.quote_regex3, &quote_regex3, PCRE_CASELESS);
 1073 #endif /* HAVE_COLOR */
 1074 
 1075     if (!strlen(tinrc.slashes_regex))
 1076         STRCPY(tinrc.slashes_regex, DEFAULT_SLASHES_REGEX);
 1077     compile_regex(tinrc.slashes_regex, &slashes_regex, PCRE_CASELESS);
 1078     if (!strlen(tinrc.stars_regex))
 1079         STRCPY(tinrc.stars_regex, DEFAULT_STARS_REGEX);
 1080     compile_regex(tinrc.stars_regex, &stars_regex, PCRE_CASELESS);
 1081     if (!strlen(tinrc.strokes_regex))
 1082         STRCPY(tinrc.strokes_regex, DEFAULT_STROKES_REGEX);
 1083     compile_regex(tinrc.strokes_regex, &strokes_regex, PCRE_CASELESS);
 1084     if (!strlen(tinrc.underscores_regex))
 1085         STRCPY(tinrc.underscores_regex, DEFAULT_UNDERSCORES_REGEX);
 1086     compile_regex(tinrc.underscores_regex, &underscores_regex, PCRE_CASELESS);
 1087 
 1088     if (!strlen(tinrc.verbatim_begin_regex))
 1089         STRCPY(tinrc.verbatim_begin_regex, DEFAULT_VERBATIM_BEGIN_REGEX);
 1090     compile_regex(tinrc.verbatim_begin_regex, &verbatim_begin_regex, PCRE_ANCHORED);
 1091     if (!strlen(tinrc.verbatim_end_regex))
 1092         STRCPY(tinrc.verbatim_end_regex, DEFAULT_VERBATIM_END_REGEX);
 1093     compile_regex(tinrc.verbatim_end_regex, &verbatim_end_regex, PCRE_ANCHORED);
 1094 
 1095     compile_regex(UUBEGIN_REGEX, &uubegin_regex, PCRE_ANCHORED);
 1096     compile_regex(UUBODY_REGEX, &uubody_regex, PCRE_ANCHORED);
 1097 
 1098     compile_regex(URL_REGEX, &url_regex, PCRE_CASELESS);
 1099     compile_regex(MAIL_REGEX, &mail_regex, PCRE_CASELESS);
 1100     compile_regex(NEWS_REGEX, &news_regex, PCRE_CASELESS);
 1101 
 1102     compile_regex(SHAR_REGEX, &shar_regex, PCRE_ANCHORED);
 1103 }
 1104 
 1105 
 1106 #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 1107 t_bool
 1108 utf8_pcre(
 1109     void)
 1110 {
 1111     int i = 0;
 1112 
 1113 #   if (defined(PCRE_MAJOR) && PCRE_MAJOR >= 4)
 1114     (void) pcre_config(PCRE_CONFIG_UTF8, &i);
 1115 #   endif /* PCRE_MAJOR && PCRE_MAJOR >= 4 */
 1116 
 1117     return (i ? TRUE : FALSE);
 1118 }
 1119 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */