"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.6.1/src/init.c" (22 Dec 2021, 38456 Bytes) of package /linux/misc/tin-2.6.1.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.6.0_vs_2.6.1.

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