"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.6.2/src/init.c" (22 Dec 2022, 38765 Bytes) of package /linux/misc/tin-2.6.2.tar.xz:


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

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