tin  2.4.4
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.4.4.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

main.c
Go to the documentation of this file.
1 /*
2  * Project : tin - a Usenet reader
3  * Module : main.c
4  * Author : I. Lea & R. Skrenta
5  * Created : 1991-04-01
6  * Updated : 2019-07-16
7  * Notes :
8  *
9  * Copyright (c) 1991-2020 Iain Lea <iain@bricbrac.de>, Rich Skrenta <skrenta@pbm.com>
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 TCURSES_H
45 # include "tcurses.h"
46 #endif /* !TCURSES_H */
47 #ifndef VERSION_H
48 # include "version.h"
49 #endif /* !VERSION_H */
50 
51 signed long int read_newsrc_lines = -1;
52 
53 static char **cmdargs;
54 static int num_cmdargs;
55 static int max_cmdargs;
56 
57 static t_bool catchup = FALSE; /* mark all arts read in all subscribed groups */
58 static t_bool update_index = FALSE; /* update local overviews */
59 static t_bool check_any_unread = FALSE; /* print/return status if any unread */
60 static t_bool mail_news = FALSE; /* mail all arts to specified user */
61 static t_bool save_news = FALSE; /* save all arts to savedir structure */
62 static t_bool start_any_unread = FALSE; /* only start if unread news */
63 
64 
65 /*
66  * Local prototypes
67  */
68 static void create_mail_save_dirs(void);
69 static void read_cmd_line_options(int argc, char *argv[]);
70 static void show_intro_page(void);
71 static void update_index_files(void);
72 static void usage(char *theProgname);
73 
74 
75 /*
76  * OK lets start the ball rolling...
77  */
78 int
80  int argc,
81  char *argv[])
82 {
83  int count, start_groupnum;
84  int num_cmd_line_groups = 0;
85  t_bool tmp_no_write;
86 
87  cmd_line = TRUE;
88 
89  /* initialize locale support */
90 #if defined(HAVE_SETLOCALE) && !defined(NO_LOCALE)
91  if (setlocale(LC_ALL, "")) {
92 # ifdef ENABLE_NLS
93  bindtextdomain(NLS_TEXTDOMAIN, LOCALEDIR);
94  textdomain(NLS_TEXTDOMAIN);
95 # endif /* ENABLE_NLS */
96  } else
97  error_message(4, txt_error_locale);
98 #endif /* HAVE_SETLOCALE && !NO_LOCALE */
99 
100  /*
101  * determine local charset
102  */
103 #ifndef NO_LOCALE
104  {
105  const char *p;
106 
107  if ((p = tin_nl_langinfo(CODESET)) != NULL) {
108  if (!strcasecmp(p, "ANSI_X3.4-1968"))
109  STRCPY(tinrc.mm_local_charset, "US-ASCII");
110  else
112  }
113  }
114 #endif /* !NO_LOCALE */
115  /* always set a default value */
116  if (!*tinrc.mm_local_charset)
117  STRCPY(tinrc.mm_local_charset, "US-ASCII");
118 
120 
121  debug = 0; /* debug OFF */
122 
123  tin_progname = my_malloc(strlen(argv[0]) + 1);
124  base_name(argv[0], tin_progname);
125 
126 #ifdef NNTP_ONLY
128 #else
129  /*
130  * If called as rtin, read news remotely via NNTP
131  */
132  if (tin_progname[0] == 'r') {
133 # ifdef NNTP_ABLE
135 # else
136  error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
137  free(tin_progname);
138  giveup();
139 # endif /* NNTP_ABLE */
140  }
141 #endif /* NNTP_ONLY */
142 
143  /*
144  * Set up initial array sizes, char *'s: homedir, newsrc, etc.
145  */
146  init_alloc();
147  hash_init();
148  init_selfinfo();
149  init_group_hash();
150 
151  /*
152  * Set cCOLS temporarily to trim (localized) messages
153  * It does not matter if this value is greater than the actual
154  * terminal size
155  *
156  * cCOLS will be set later to the real terminal width
157  */
158  cCOLS = 80;
159 
160  /*
161  * Process envargs & command line options
162  * These override the configured in values
163  */
164  read_cmd_line_options(argc, argv);
165 
166  /* preinit keybindings if interactive */
167  if (!batch_mode)
169 
170  /*
171  * Read user local & global config files
172  * These override the compiled in defaults
173  *
174  * must be called before setup_screen()
175  */
178 
179  tmp_no_write = no_write; /* keep no_write */
180  no_write = TRUE; /* don't allow any writing back during startup */
181 
182  if (!batch_mode) {
183 #ifndef USE_CURSES
184  if (!get_termcaps()) {
186  free_all_arrays();
187  giveup();
188  }
189 #endif /* !USE_CURSES */
190 
191  /*
192  * Init curses emulation
193  */
194  if (!InitScreen()) {
196  free_all_arrays();
197  giveup();
198  }
199 
200  EndInverse();
201 
202  /*
203  * This depends on various things in tinrc
204  */
205  setup_screen();
206  }
207 
208  if (!batch_mode || verbose)
209  wait_message(0, "%s\n", cvers);
210 
211  /*
212  * Connect to nntp server?
213  */
214  if (!nntp_server || !*nntp_server)
217  nntp_close(FALSE);
218  free_all_arrays();
219  giveup();
220  }
221 
223 
224  /*
225  * exit early - unfortunately we can't do that in read_cmd_line_options()
226  * as nntp_caps.over_cmd is set in nntp_open()
227  *
228  * TODO: does the logic make sense? what
229  * if (update_index && !nntp_caps.over_cmd && !tinrc.cache_overview_files)
230  * no error message? why?
231  */
234  free_all_arrays();
235  giveup();
236  }
237 
238  /*
239  * Check if overview indexes contain Xref: lines
240  */
241 #ifdef NNTP_ABLE
243 #endif /* NNTP_ABLE */
245 
246  /*
247  * avoid empty regexp, we also need to do this in batch_mode
248  * as read_overview() calls eat_re() which uses a regexp to
249  * modify the subject *sigh*
250  */
251  postinit_regexp();
252 
254  /*
255  * Read user specific keybindings and input history
256  */
260 
261  /*
262  * Load the mail & news active files into active[]
263  *
264  * create_save_active_file cannot write to active.save
265  * if no_write != FALSE, so restore original value temporarily
266  */
267  if (read_saved_news) {
268  no_write = tmp_no_write;
270  no_write = TRUE;
271  }
272  }
273 
274 #ifdef HAVE_MH_MAIL_HANDLING
275  read_mail_active_file();
276 #endif /* HAVE_MH_MAIL_HANDLING */
277 
278  /*
279  * Initialise active[] and add new newsgroups to start of my_group[]
280  * also reads global/local attributes
281  */
282  selmenu.max = 0;
283  /*
284  * we need to restore the original no_write mode to be able to handle
285  * $AUTOSUBSCRIBE groups
286  */
287  no_write = tmp_no_write;
290  start_groupnum = read_news_active_file();
291 #ifdef DEBUG
292  debug_print_active();
293 #endif /* DEBUG */
294 
295  /*
296  * Read in users filter preferences file. This has to be done before
297  * quick post because the filters might be updated.
298  */
300 
301  no_write = TRUE;
302 #ifdef DEBUG
303  debug_print_filters();
304 #endif /* DEBUG */
305 
306  /*
307  * Preloads active[] with command line groups. They will follow any
308  * new newsgroups
309  */
311  num_cmd_line_groups = read_cmd_line_groups();
312 
313  /*
314  * Quick post an article and exit if -w or -o specified
315  */
317  no_write = tmp_no_write; /* restore original value */
318  quick_post_article(post_postponed_and_exit, num_cmd_line_groups);
320  no_write = TRUE; /* disable newsrc updates */
321  tin_done(EXIT_SUCCESS, NULL);
322  }
323 
324  /* TODO: replace hard coded key-name in txt_info_postponed */
325  if ((count = count_postponed_articles()))
326  wait_message(3, _(txt_info_postponed), count, PLURAL(count, txt_article));
327 
328  /*
329  * Read text descriptions for mail and/or news groups
330  */
331  if (show_description && !batch_mode) {
332  no_write = tmp_no_write; /* restore original value */
334  no_write = TRUE; /* disable newsrc updates */
335  }
336 
337  /* what about "if (!no_write)" here? */
339  if (created_rcdir) /* first start */
341 
342  if (!tmp_no_write) /* do not (over)write oldnewsrc with -X */
343  backup_newsrc();
344 
345  /*
346  * Load my_groups[] from the .newsrc file. We append these groups to any
347  * new newsgroups and command line newsgroups already loaded. Also does
348  * auto-subscribe to groups specified in /usr/lib/news/subscriptions
349  * locally or via NNTP if reading news remotely (LIST SUBSCRIPTIONS)
350  */
351  /*
352  * TODO:
353  * if (num_cmd_line_groups != 0 && check_any_unread)
354  * don't read newsrc.
355  * This makes -Z handle command line newsgroups. Test & document
356  */
358  no_write = tmp_no_write; /* restore old value */
359 
360  /*
361  * We have to show all groups with command line groups
362  */
363  if (num_cmd_line_groups)
365  else
366  toggle_my_groups(NULL);
367 
368  /*
369  * Check/start if any new/unread articles
370  */
371  if (check_any_unread)
373 
374  if (start_any_unread) {
375  batch_mode = TRUE; /* Suppress some unwanted on-screen garbage */
376  if ((start_groupnum = check_start_save_any_news(START_ANY_NEWS, catchup)) == -1) {
377  batch_mode = FALSE;
378  tin_done(EXIT_SUCCESS, NULL);
379  }
380  batch_mode = FALSE;
381  }
382 
383  /*
384  * Mail any new articles to specified user
385  * or
386  * Save any new articles to savedir structure for later reading
387  *
388  * TODO: should we temporarily set
389  * getart_limit=-1,thread_articles=0,sort_article_type=0
390  * for speed reasons?
391  */
392  if (mail_news || save_news) {
394  tin_done(EXIT_SUCCESS, NULL);
395  }
396 
397  /*
398  * Catchup newsrc file (-c option)
399  */
400  if (batch_mode && catchup && !update_index) {
402  tin_done(EXIT_SUCCESS, NULL);
403  }
404 
405  /*
406  * Update index files (-u option), also does catchup if requested
407  */
408  if (update_index)
410 
411  /*
412  * the code below this point can't be reached in batch mode
413  */
414 
415  /*
416  * If first time print welcome screen
417  */
418  if (created_rcdir)
419  show_intro_page();
420 
421 #ifdef XFACE_ABLE
422  if (tinrc.use_slrnface && !batch_mode)
423  slrnface_start();
424 #endif /* XFACE_ABLE */
425 
426 #ifdef USE_CURSES
427  /* Turn scrolling off now the startup messages have been displayed */
428  scrollok(stdscr, FALSE);
429 #endif /* USE_CURSES */
430 
431  /*
432  * Work loop
433  */
434  selection_page(start_groupnum, num_cmd_line_groups);
435  /* NOTREACHED */
436  return 0;
437 }
438 
439 
440 /*
441  * process command line options
442  * [01235789beEFijJkKLOtTyY] are unused
443  * [W] is reserved
444  * [BCPU] have been in use at some time, but now are unused:
445  * B BBS mode (M_AMIGA only)
446  * C count articles
447  * P purge group index files of articles that no longer exist
448  * U update index files in background
449  */
450 #define OPTIONS "46aAcdD:f:g:G:hHI:lm:M:nNop:qQrRs:SuvVwxXzZ"
451 
452 static void
454  int argc,
455  char *argv[])
456 {
457  int ch;
458  t_bool newsrc_set = FALSE;
459 
460  envargs(&argc, &argv, "TINRC");
461 
462  while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
463  switch (ch) {
464 
465  case '4':
466 #if defined(NNTP_ABLE) && defined(INET6)
467  force_ipv4 = TRUE;
469 #else
470 # ifdef NNTP_ABLE
471  error_message(2, _(txt_option_not_enabled), "-DENABLE_IPV6");
472 # else
473  error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
474 # endif /* NNTP_ABLE */
475  free_all_arrays();
476  giveup();
477  /* keep lint quiet: */
478  /* NOTREACHED */
479 #endif /* NNTP_ABLE && INET6 */
480  break;
481 
482  case '6':
483 #if defined(NNTP_ABLE) && defined(INET6)
484  force_ipv6 = TRUE;
486 # else
487 # ifdef NNTP_ABLE
488  error_message(2, _(txt_option_not_enabled), "-DENABLE_IPV6");
489 # else
490  error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
491 # endif /* NNTP_ABLE */
492  free_all_arrays();
493  giveup();
494  /* keep lint quiet: */
495  /* NOTREACHED */
496 #endif /* NNTP_ABLE && INET6 */
497  break;
498 
499  case 'a':
500 #ifdef HAVE_COLOR
502 #else
503  error_message(2, _(txt_option_not_enabled), "-DHAVE_COLOR");
504  free_all_arrays();
505  giveup();
506  /* keep lint quiet: */
507  /* NOTREACHED */
508 #endif /* HAVE_COLOR */
509  break;
510 
511  case 'A':
512 #ifdef NNTP_ABLE
513  force_auth_on_conn_open = TRUE;
515 #else
516  error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
517  free_all_arrays();
518  giveup();
519  /* keep lint quiet: */
520  /* NOTREACHED */
521 #endif /* NNTP_ABLE */
522  break;
523 
524  case 'c':
525  batch_mode = TRUE;
526  catchup = TRUE;
527  break;
528 
529  case 'd':
531  break;
532 
533  case 'D': /* debug mode */
534 #ifdef DEBUG
535  debug = atoi(optarg) & 0xff;
536  debug_delete_files();
537 #else
538  error_message(2, _(txt_option_not_enabled), "-DDEBUG");
539  free_all_arrays();
540  giveup();
541  /* keep lint quiet: */
542  /* NOTREACHED */
543 #endif /* DEBUG */
544  break;
545 
546  case 'f': /* newsrc file */
547  my_strncpy(newsrc, optarg, sizeof(newsrc) - 1);
548  newsrc_set = TRUE;
549  break;
550 
551  case 'G':
554  break;
555 
556  case 'g': /* select alternative NNTP-server, implies -r */
557 #ifdef NNTP_ABLE
561 #else
562  error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
563  free_all_arrays();
564  giveup();
565  /* keep lint quiet: */
566  /* NOTREACHED */
567 #endif /* NNTP_ABLE */
568  break;
569 
570  case 'H':
571  show_intro_page();
572  free_all_arrays();
573  exit(EXIT_SUCCESS);
574  /* keep lint quiet: */
575  /* FALLTHROUGH */
576 
577  case 'I':
579  break;
580 
581  case 'l':
582  list_active = TRUE;
583  break;
584 
585  case 'm':
588  break;
589 
590  case 'M': /* mail new news to specified user */
592  mail_news = TRUE;
593  batch_mode = TRUE;
594  break;
595 
596  case 'n':
598  break;
599 
600  case 'N': /* mail new news to your posts */
602  mail_news = TRUE;
603  batch_mode = TRUE;
604  break;
605 
606  case 'o': /* post postponed articles & exit */
607 #ifndef NO_POSTING
608  /*
609  * TODO: autoposting currently does some screen output, so we
610  * can't set batch_mode
611  */
614 #else
615  error_message(2, _(txt_option_not_enabled), "-UNO_POSTING");
616  free_all_arrays();
617  giveup();
618  /* keep lint quiet: */
619  /* NOTREACHED */
620 #endif /* !NO_POSTING */
621  break;
622 
623  case 'p': /* implies -r */
624 #ifdef NNTP_ABLE
626  if (atoi(optarg) != 0)
627  nntp_tcp_port = (unsigned short) atoi(optarg);
628 #else
629  error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
630  free_all_arrays();
631  giveup();
632  /* keep lint quiet: */
633  /* NOTREACHED */
634 #endif /* NNTP_ABLE */
635  break;
636 
637  case 'q':
639  break;
640 
641  case 'Q':
645  break;
646 
647  case 'r': /* read news remotely from default NNTP server */
648 #ifdef NNTP_ABLE
650 #else
651  error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
652  free_all_arrays();
653  giveup();
654  /* keep lint quiet: */
655  /* NOTREACHED */
656 #endif /* NNTP_ABLE */
657  break;
658 
659  case 'R': /* read news saved by -S option */
661  list_active = TRUE;
665  break;
666 
667  case 's':
670  break;
671 
672  case 'S': /* save new news to dir structure */
673  save_news = TRUE;
674  batch_mode = TRUE;
675  break;
676 
677  case 'u': /* update index files */
678  batch_mode = TRUE;
679  update_index = TRUE;
680  break;
681 
682  case 'v': /* verbose mode, can be used multiple times */
683  verbose++;
684  break;
685 
686  case 'V':
687  tin_version_info(stderr);
688  free_all_arrays();
689  exit(EXIT_SUCCESS);
690  /* keep lint quiet: */
691  /* FALLTHROUGH */
692 
693  case 'w': /* post article & exit */
694 #ifndef NO_POSTING
697 #else
698  error_message(2, _(txt_option_not_enabled), "-UNO_POSTING");
699  free_all_arrays();
700  giveup();
701  /* keep lint quiet: */
702  /* NOTREACHED */
703 #endif /* !NO_POSTING */
704  break;
705 
706 #if 0
707  case 'W': /* reserved according to SUSV3 XDB Utility Syntax Guidelines, Guideline 3 */
708  break;
709 #endif /* 0 */
710 
711  case 'x': /* enter no_posting mode */
713  break;
714 
715  case 'X': /* don't save ~/.newsrc on exit */
716  no_write = TRUE;
717  break;
718 
719  case 'z':
721  break;
722 
723  case 'Z':
725  batch_mode = TRUE;
726  break;
727 
728  case 'h':
729  case '?':
730  default:
732  free_all_arrays();
733  exit(EXIT_SUCCESS);
734  }
735  }
736  cmdargs = argv;
738  max_cmdargs = argc;
739  if (!newsrc_set) {
740  if (read_news_via_nntp) {
743  } else {
744 #if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
745  struct utsname uts;
746  (void) uname(&uts);
747  get_newsrcname(newsrc, sizeof(newsrc), uts.nodename);
748 #else
749  char nodenamebuf[256]; /* SUSv2 limit; better use HOST_NAME_MAX */
750 # ifdef HAVE_GETHOSTNAME
751  (void) gethostname(nodenamebuf, sizeof(nodenamebuf));
752 # endif /* HAVE_GETHOSTNAME */
753  get_newsrcname(newsrc, sizeof(newsrc), nodenamebuf);
754 #endif /* HAVE_SYS_UTSNAME_H && HAVE_UNAME */
755  }
756  }
757 
758  /*
759  * Sort out option conflicts
760  */
761  if (!batch_mode) {
762  if (catchup) {
764  catchup = FALSE;
765  }
766  } else {
767  if (read_saved_news) {
770  }
771  }
772  if (!(batch_mode || debug)) {
773  if (verbose) {
775  verbose = FALSE;
776  }
777  }
779  wait_message(2, _(txt_useless_combination), "-o", "-x", "-x");
781  }
783  wait_message(2, _(txt_useless_combination), "-w", "-x", "-x");
785  }
786  if (catchup && start_any_unread) {
787  wait_message(2, _(txt_useless_combination), "-c", "-z", "-c");
788  catchup = FALSE;
789  }
790  if (catchup && no_write) {
791  wait_message(2, _(txt_useless_combination), "-c", "-X", "-c");
792  catchup = FALSE;
793  }
794  if (catchup && check_any_unread) {
795  wait_message(2, _(txt_useless_combination), "-c", "-Z", "-c");
796  catchup = FALSE;
797  }
799  wait_message(2, _(txt_useless_combination), "-n", "-R", "-n");
801  }
802  if (start_any_unread && save_news) {
803  wait_message(2, _(txt_useless_combination), "-z", "-S", "-z");
805  }
806  if (save_news && check_any_unread) {
807  wait_message(2, _(txt_useless_combination), "-S", "-Z", "-S");
808  save_news = FALSE;
809  }
811  wait_message(2, _(txt_useless_combination), "-Z", "-z", "-Z");
813  }
814 # ifdef DEBUG
815  if ((debug & DEBUG_NNTP) && !read_news_via_nntp) {
816  /* TODO: lang.c */
817  wait_message(3, _(txt_useless_combination), _("reading from local spool"), "-D nntp", "-D nntp");
818  debug &= ~DEBUG_NNTP;
819  }
820 # endif /* DEBUG */
821 
822 #if defined(NNTP_ABLE) && defined(INET6)
823  if (force_ipv4 && force_ipv6) {
824  wait_message(2, _(txt_useless_combination), "-4", "-6", "-6");
825  force_ipv6 = FALSE;
826  }
827 #endif /* NNTP_ABLE && INET6 */
828 
830  batch_mode = TRUE;
831  else
832  batch_mode = FALSE;
834  batch_mode = FALSE;
835 
836  /*
837  * When updating index files set getart_limit to 0 in order to get overview
838  * information for all article; this overwrites '-G limit' and disables
839  * tinrc.getart_limit temporary
840  */
841  if (update_index) {
842  cmdline.getart_limit = 0;
844  }
845 #ifdef NNTP_ABLE
846  /*
847  * If we're reading from an NNTP server and we've been asked not to look
848  * for new newsgroups, trust our cached copy of the newsgroups file.
849  */
850  if (read_news_via_nntp)
852 #endif /* NNTP_ABLE */
853  /*
854  * If we use neither list_active nor newsrc_active,
855  * we use both of them.
856  */
857  if (!list_active && !newsrc_active)
859 }
860 
861 
862 /*
863  * usage
864  */
865 static void
867  char *theProgname)
868 {
869  error_message(2, _(txt_usage_tin), theProgname);
870 
871 #if defined(NNTP_ABLE) && defined(INET6)
872  error_message(2, _(txt_usage_force_ipv4));
873  error_message(2, _(txt_usage_force_ipv6));
874 #endif /* NNTP_ABLE && INET6 */
875 
876 #ifdef HAVE_COLOR
877  error_message(2, _(txt_usage_toggle_color));
878 #endif /* HAVE_COLOR */
879 #ifdef NNTP_ABLE
880  error_message(2, _(txt_usage_force_authentication));
881 #endif /* NNTP_ABLE */
882 
885 
886 #ifdef DEBUG
887  error_message(2, _(txt_usage_debug));
888 #endif /* DEBUG */
889 
892 
893 #ifdef NNTP_ABLE
894 # ifdef NNTP_DEFAULT_SERVER
895  error_message(2, _(txt_usage_newsserver), get_val("NNTPSERVER", NNTP_DEFAULT_SERVER));
896 # else
897  error_message(2, _(txt_usage_newsserver), get_val("NNTPSERVER", "news"));
898 # endif /* NNTP_DEFAULT_SERVER */
899 #endif /* NNTP_ABLE */
900 
902  error_message(2, _(txt_usage_help_information), theProgname);
910 
911 #ifdef NNTP_ABLE
912  error_message(2, _(txt_usage_port), nntp_tcp_port);
913 #endif /* NNTP_ABLE */
914 
917 
918 #ifdef NNTP_ABLE
919  if (!read_news_via_nntp)
920  error_message(2, _(txt_usage_read_news_remotely));
921 #endif /* NNTP_ABLE */
922 
934 
936 }
937 
938 
939 /*
940  * update index files
941  */
942 static void
944  void)
945 {
946  cCOLS = 132; /* set because curses has not started */
948  tinrc.thread_articles = THREAD_NONE; /* stop threading to run faster */
950  tin_done(EXIT_SUCCESS, NULL);
951 }
952 
953 
954 /*
955  * display page of general info. for first time user.
956  */
957 static void
959  void)
960 {
961  char buf[4096];
962 
963  if (!cmd_line) {
964  ClearScreen();
965  center_line(0, TRUE, cvers);
966  Raw(FALSE);
967  my_printf("\n");
968  }
969 
971 
972  my_fputs(buf, stdout);
973  my_flush();
974 
975  if (!cmd_line) {
976  Raw(TRUE);
977  prompt_continue();
978  }
979 }
980 
981 
982 /*
983  * Wildcard match any newsgroups on the command line. Sort of like a limited
984  * yank at startup. Return number of groups that were matched.
985  */
986 int
988  void)
989 {
990  int matched = 0;
991  int num;
992  int i;
993 
994  if (num_cmdargs < max_cmdargs) {
995  selmenu.max = skip_newgroups(); /* Reposition after any newgroups */
996 
997  for (num = num_cmdargs; num < max_cmdargs; num++) {
998  if (!batch_mode)
1000 
1001  for_each_group(i) {
1002  if (match_group_list(active[i].name, cmdargs[num])) {
1003  if (my_group_add(active[i].name, TRUE) != -1) {
1004  matched++;
1005  if (post_article_and_exit) {
1007  break;
1008  }
1009  }
1010  }
1011  }
1012  }
1013  }
1014  return matched;
1015 }
1016 
1017 
1018 /*
1019  * Create default mail & save directories if they do not exist
1020  */
1021 static void
1023  void)
1024 {
1025  char path[PATH_LEN];
1026  struct stat sb;
1027 
1028  if (!strfpath(tinrc.maildir, path, sizeof(path), NULL, FALSE))
1029  joinpath(path, sizeof(path), homedir, DEFAULT_MAILDIR);
1030 
1031  if (stat(path, &sb) == -1)
1032  my_mkdir(path, (mode_t) (S_IRWXU));
1033 
1034  if (!strfpath(tinrc.savedir, path, sizeof(path), NULL, FALSE))
1035  joinpath(path, sizeof(path), homedir, DEFAULT_SAVEDIR);
1036 
1037  if (stat(path, &sb) == -1)
1038  my_mkdir(path, (mode_t) (S_IRWXU));
1039 }
1040 
1041 
1042 /*
1043  * we don't try do free() any previously malloc()ed mem here as exit via
1044  * giveup() indicates a serious error and keeping track of what we've
1045  * already malloc()ed would be a PITA.
1046  */
1047 /* coverity[+kill] */
1048 void
1050  void)
1051 {
1052  static int nested;
1053 
1054 #ifdef XFACE_ABLE
1055  slrnface_stop();
1056 #endif /* XFACE_ABLE */
1057 
1058  if (!cmd_line && !nested++) {
1059  cursoron();
1060  EndWin();
1061  Raw(FALSE);
1062  }
1063  exit(EXIT_FAILURE);
1064 }
create_mail_save_dirs
static void create_mail_save_dirs(void)
Definition: main.c:1022
name
const char * name
Definition: signal.c:117
DEBUG_NNTP
#define DEBUG_NNTP
Definition: debug.h:47
txt_usage_check_for_unread_news
constext txt_usage_check_for_unread_news[]
Definition: lang.c:917
setlocale
#define setlocale(Category, Locale)
Definition: tin.h:78
txt_matching_cmd_line_groups
constext txt_matching_cmd_line_groups[]
Definition: lang.c:628
update_index_files
static void update_index_files(void)
Definition: main.c:943
usage
static void usage(char *theProgname)
Definition: main.c:866
read_input_history_file
void read_input_history_file(void)
Definition: misc.c:2188
strcasecmp
int strcasecmp(const char *p, const char *q)
Definition: string.c:468
t_cmdlineopts::maildir
char maildir[255]
Definition: tin.h:1468
EXIT_SUCCESS
#define EXIT_SUCCESS
Definition: tin.h:1273
_
#define _(Text)
Definition: tin.h:94
init_alloc
void init_alloc(void)
Definition: memory.c:91
count_postponed_articles
int count_postponed_articles(void)
Definition: post.c:2336
t_config::maildir
char maildir[PATH_LEN]
Definition: tinrc.h:94
txt_exiting
constext txt_exiting[]
Definition: lang.c:268
txt_usage_read_only_active
constext txt_usage_read_only_active[]
Definition: lang.c:1144
t_capabilities::over_cmd
const char * over_cmd
Definition: nntplib.h:210
lock_file
char lock_file[PATH_LEN]
Definition: init.c:88
OPTIONS
#define OPTIONS
Definition: main.c:450
center_line
void center_line(int line, t_bool inverse, const char *str)
Definition: screen.c:258
created_rcdir
t_bool created_rcdir
Definition: init.c:129
read_attributes_file
void read_attributes_file(t_bool global_file)
Definition: attrib.c:294
xref_supported
t_bool xref_supported
Definition: init.c:155
print_boolean
const char * print_boolean(t_bool value)
Definition: config.c:1683
LOCALEDIR
#define LOCALEDIR
Definition: tin.h:98
create_index_lock_file
void create_index_lock_file(char *the_lock_file)
Definition: misc.c:1127
txt_usage_mail_bugreport
constext txt_usage_mail_bugreport[]
Definition: lang.c:927
read_news_via_nntp
t_bool read_news_via_nntp
Definition: init.c:150
check_for_new_newsgroups
t_bool check_for_new_newsgroups
Definition: init.c:127
my_flush
#define my_flush()
Definition: tcurses.h:171
ClearScreen
void ClearScreen(void)
Definition: curses.c:410
set_signal_handlers
void set_signal_handlers(void)
Definition: signal.c:541
toggle_my_groups
void toggle_my_groups(const char *group)
Definition: select.c:1254
show_description
t_bool show_description
Definition: init.c:152
tinrc
struct t_config tinrc
Definition: init.c:191
check_start_save_any_news
int check_start_save_any_news(int function, t_bool catchup)
Definition: save.c:133
wait_message
void wait_message(unsigned int sdelay, const char *fmt,...)
Definition: screen.c:133
catchup_newsrc_file
void catchup_newsrc_file(void)
Definition: newsrc.c:1371
read_saved_news
t_bool read_saved_news
Definition: init.c:151
write_config_file
void write_config_file(char *file)
Definition: config.c:913
cmdargs
static char ** cmdargs
Definition: main.c:53
txt_usage_no_posting
constext txt_usage_no_posting[]
Definition: lang.c:931
create_save_active_file
void create_save_active_file(void)
Definition: active.c:1271
txt_option_not_enabled
constext txt_option_not_enabled[]
Definition: lang.c:710
optarg
char * optarg
index_newsdir
char index_newsdir[PATH_LEN]
Definition: init.c:80
txt_usage_help_information
constext txt_usage_help_information[]
Definition: lang.c:922
CMDLINE_GETART_LIMIT
#define CMDLINE_GETART_LIMIT
Definition: tin.h:1091
tcurses.h
overview_xref_support
t_bool overview_xref_support(void)
Definition: xref.c:82
hash_init
void hash_init(void)
Definition: hashstr.c:128
version.h
t_menu::max
int max
Definition: tin.h:2007
tin.h
tin_done
void tin_done(int ret, const char *fmt,...)
Definition: misc.c:557
CMDLINE_SAVEDIR
#define CMDLINE_SAVEDIR
Definition: tin.h:1094
mail_news_user
char mail_news_user[LEN]
Definition: init.c:90
read_server_config
void read_server_config(void)
Definition: config.c:2120
read_filter_file
t_bool read_filter_file(const char *file)
Definition: filter.c:308
cmdline
struct t_cmdlineopts cmdline
Definition: init.c:189
global_config_file
char global_config_file[PATH_LEN]
Definition: init.c:77
txt_useless_combination
constext txt_useless_combination[]
Definition: lang.c:944
check_any_unread
static t_bool check_any_unread
Definition: main.c:59
PATH_LEN
#define PATH_LEN
Definition: tin.h:837
EndInverse
void EndInverse(void)
Definition: curses.c:564
t_cmdlineopts::nntpserver
char nntpserver[255]
Definition: tin.h:1469
txt_reading_keymap_file
constext txt_reading_keymap_file[]
Definition: lang.c:766
txt_usage_mail_new_news
constext txt_usage_mail_new_news[]
Definition: lang.c:928
do_update
void do_update(t_bool catchup)
Definition: art.c:2748
tin_progname
char * tin_progname
Definition: init.c:105
filter_file
char filter_file[PATH_LEN]
Definition: init.c:89
txt_usage_catchup
constext txt_usage_catchup[]
Definition: lang.c:916
active
struct t_group * active
Definition: memory.c:66
txt_usage_index_newsdir
constext txt_usage_index_newsdir[]
Definition: lang.c:924
txt_usage_newsrc_file
constext txt_usage_newsrc_file[]
Definition: lang.c:930
Raw
void Raw(int state)
Definition: curses.c:624
txt_usage_verbose
constext txt_usage_verbose[]
Definition: lang.c:939
my_strncpy
void my_strncpy(char *p, const char *q, size_t n)
Definition: string.c:190
DEFAULT_SAVEDIR
#define DEFAULT_SAVEDIR
Definition: tin.h:632
CHECK_ANY_NEWS
#define CHECK_ANY_NEWS
Definition: tin.h:1220
txt_usage_post_article
constext txt_usage_post_article[]
Definition: lang.c:932
PRODUCT
#define PRODUCT
Definition: version.h:44
homedir
char homedir[PATH_LEN]
Definition: init.c:78
CODESET
#define CODESET
Definition: tin.h:770
t_config::thread_articles
int thread_articles
Definition: tinrc.h:152
nntp_caps
struct t_capabilities nntp_caps
Definition: init.c:516
txt_usage_dont_show_descriptions
constext txt_usage_dont_show_descriptions[]
Definition: lang.c:920
optind
int optind
PLURAL
#define PLURAL(x, y)
Definition: tin.h:1053
txt_usage_quickstart
constext txt_usage_quickstart[]
Definition: lang.c:1143
t_config::mm_local_charset
char mm_local_charset[LEN]
Definition: tinrc.h:103
quick_post_article
void quick_post_article(t_bool postponed_only, int num_cmd_line_groups)
Definition: post.c:2256
read_config_file
t_bool read_config_file(char *file, t_bool global_file)
Definition: config.c:74
setup_default_keys
void setup_default_keys(void)
Definition: keymap.c:2497
strfpath
int strfpath(const char *format, char *str, size_t maxsize, struct t_group *group, t_bool expand_all)
Definition: misc.c:1701
NNTP_SERVER_FILE
#define NNTP_SERVER_FILE
Definition: nntplib.h:45
cmd_line
t_bool cmd_line
Definition: init.c:128
buf
static char buf[16]
Definition: langinfo.c:50
read_descriptions
void read_descriptions(t_bool verb)
Definition: mail.c:441
free_all_arrays
void free_all_arrays(void)
Definition: memory.c:233
tin_version_info
int tin_version_info(FILE *fp)
Definition: misc.c:3871
list_active
t_bool list_active
Definition: init.c:142
get_termcaps
int get_termcaps(void)
Definition: curses.c:216
my_mkdir
int my_mkdir(char *path, mode_t mode)
Definition: misc.c:708
read_newsrc
signed long int read_newsrc(char *newsrc_file, t_bool allgroups)
Definition: newsrc.c:83
base_name
void base_name(const char *fullpath, char *file)
Definition: misc.c:868
THREAD_NONE
#define THREAD_NONE
Definition: tin.h:1127
txt_useful_without_batch_mode
constext txt_useful_without_batch_mode[]
Definition: lang.c:941
cCOLS
int cCOLS
Definition: curses.c:53
for_each_group
#define for_each_group(x)
Definition: tin.h:2210
show_intro_page
static void show_intro_page(void)
Definition: main.c:958
t_cmdlineopts::savedir
char savedir[255]
Definition: tin.h:1470
t_config::default_post_newsgroups
char default_post_newsgroups[HEADER_LEN]
Definition: tinrc.h:75
txt_usage_tin
constext txt_usage_tin[]
Definition: lang.c:938
post_postponed_and_exit
t_bool post_postponed_and_exit
Definition: init.c:146
txt_usage_read_only_subscribed
constext txt_usage_read_only_subscribed[]
Definition: lang.c:1145
txt_useful_with_batch_or_debug_mode
constext txt_useful_with_batch_or_debug_mode[]
Definition: lang.c:943
envargs
void envargs(int *Pargc, char ***Pargv, const char *envstr)
Definition: envarg.c:69
txt_usage_getart_limit
constext txt_usage_getart_limit[]
Definition: lang.c:921
mail_news
static t_bool mail_news
Definition: main.c:60
EXIT_FAILURE
#define EXIT_FAILURE
Definition: tin.h:1277
txt_screen_init_failed
constext txt_screen_init_failed[]
Definition: lang.c:817
cursoron
void cursoron(void)
Definition: curses.c:712
catchup
static t_bool catchup
Definition: main.c:57
txt_usage_savedir
constext txt_usage_savedir[]
Definition: lang.c:935
init_group_hash
void init_group_hash(void)
Definition: list.c:62
main
int main(int argc, char *argv[])
Definition: main.c:79
my_fputs
#define my_fputs(str, stream)
Definition: tcurses.h:153
tin_nl_langinfo
const char * tin_nl_langinfo(nl_item item)
Definition: langinfo.c:53
EndWin
void EndWin(void)
Definition: curses.c:368
txt_usage_dont_save_files_on_quit
constext txt_usage_dont_save_files_on_quit[]
Definition: lang.c:919
bool_not
#define bool_not(b)
Definition: bool.h:81
txt_batch_update_unavail
constext txt_batch_update_unavail[]
Definition: lang.c:116
selection_page
void selection_page(int start_groupnum, int num_cmd_line_groups)
Definition: select.c:109
batch_mode
t_bool batch_mode
Definition: init.c:126
my_printf
#define my_printf
Definition: tcurses.h:169
txt_usage_update_index_files
constext txt_usage_update_index_files[]
Definition: lang.c:925
read_news_active_file
int read_news_active_file(void)
Definition: active.c:751
t_cmdlineopts::args
unsigned int args
Definition: tin.h:1471
atoi
int atoi(const char *s)
t_config::savedir
char savedir[PATH_LEN]
Definition: tinrc.h:126
CMDLINE_NNTPSERVER
#define CMDLINE_NNTPSERVER
Definition: tin.h:1093
t_group::name
char * name
Definition: tin.h:1773
postinit_regexp
void postinit_regexp(void)
Definition: init.c:1018
getserverbyfile
char * getserverbyfile(const char *file)
Definition: nntplib.c:111
read_keymap_file
t_bool read_keymap_file(void)
Definition: keymap.c:325
update_index
static t_bool update_index
Definition: main.c:58
force_no_post
t_bool force_no_post
Definition: init.c:136
FALSE
#define FALSE
Definition: bool.h:70
STRCPY
#define STRCPY(dst, src)
Definition: tin.h:814
debug
unsigned short debug
Definition: debug.c:51
txt_usage_dont_check_new_newsgroups
constext txt_usage_dont_check_new_newsgroups[]
Definition: lang.c:918
local_config_file
char local_config_file[PATH_LEN]
Definition: init.c:84
verbose
int verbose
Definition: init.c:153
CMDLINE_USE_COLOR
#define CMDLINE_USE_COLOR
Definition: tin.h:1095
no_write
t_bool no_write
Definition: init.c:144
joinpath
void joinpath(char *result, size_t result_size, const char *dir, const char *file)
Definition: joinpath.c:50
get_newsrcname
t_bool get_newsrcname(char *newsrc_name, size_t newsrc_name_len, const char *nntpserver_name)
Definition: nrctbl.c:134
t_cmdlineopts::getart_limit
int getart_limit
Definition: tin.h:1467
nntp_open
int nntp_open(void)
Definition: nntplib.c:1349
newsrc_active
t_bool newsrc_active
Definition: init.c:143
newsrc
char newsrc[PATH_LEN]
Definition: init.c:96
backup_newsrc
void backup_newsrc(void)
Definition: newsrc.c:372
snprintf
#define snprintf
Definition: tin.h:2417
init_selfinfo
void init_selfinfo(void)
Definition: init.c:646
START_ANY_NEWS
#define START_ANY_NEWS
Definition: tin.h:1221
txt_usage_maildir
constext txt_usage_maildir[]
Definition: lang.c:926
read_newsrc_lines
signed long int read_newsrc_lines
Definition: main.c:51
error_message
void error_message(unsigned int sdelay, const char *fmt,...)
Definition: screen.c:184
num_cmdargs
static int num_cmdargs
Definition: main.c:54
textdomain
#define textdomain(Domain)
Definition: tin.h:93
t_config::show_only_unread_groups
t_bool show_only_unread_groups
Definition: tinrc.h:233
bug_addr
char bug_addr[LEN]
Definition: post.c:124
txt_usage_version
constext txt_usage_version[]
Definition: lang.c:940
txt_usage_help_message
constext txt_usage_help_message[]
Definition: lang.c:923
txt_usage_post_postponed_arts
constext txt_usage_post_postponed_arts[]
Definition: lang.c:933
userid
char userid[PATH_LEN]
Definition: init.c:107
selmenu
t_menu selmenu
Definition: select.c:85
t_config::cache_overview_files
t_bool cache_overview_files
Definition: tinrc.h:209
SAVE_ANY_NEWS
#define SAVE_ANY_NEWS
Definition: tin.h:1223
read_local_newsgroups_file
t_bool read_local_newsgroups_file
Definition: init.c:149
save_active_file
char save_active_file[PATH_LEN]
Definition: init.c:101
txt_info_postponed
constext txt_info_postponed[]
Definition: lang.c:551
t_bool
unsigned t_bool
Definition: bool.h:77
read_cmd_line_options
static void read_cmd_line_options(int argc, char *argv[])
Definition: main.c:453
giveup
void giveup(void)
Definition: main.c:1049
txt_usage_start_if_unread_news
constext txt_usage_start_if_unread_news[]
Definition: lang.c:937
txt_useful_with_batch_mode
constext txt_useful_with_batch_mode[]
Definition: lang.c:942
match_group_list
t_bool match_group_list(const char *group, const char *group_list)
Definition: active.c:1118
TRUE
#define TRUE
Definition: bool.h:74
txt_intro_page
constext txt_intro_page[]
Definition: lang.c:558
MAIL_ANY_NEWS
#define MAIL_ANY_NEWS
Definition: tin.h:1222
setup_screen
void setup_screen(void)
Definition: curses.c:170
start_any_unread
static t_bool start_any_unread
Definition: main.c:62
news_active_file
char news_active_file[PATH_LEN]
Definition: init.c:94
post_article_and_exit
t_bool post_article_and_exit
Definition: init.c:145
bindtextdomain
#define bindtextdomain(Domain, Directory)
Definition: tin.h:91
txt_usage_read_saved_news
constext txt_usage_read_saved_news[]
Definition: lang.c:934
nntp_server
char * nntp_server
Definition: nntplib.c:28
max_cmdargs
static int max_cmdargs
Definition: main.c:55
prompt_continue
void prompt_continue(void)
Definition: prompt.c:774
txt_usage_save_new_news
constext txt_usage_save_new_news[]
Definition: lang.c:936
S_IRWXU
#define S_IRWXU
Definition: tin.h:2135
InitScreen
int InitScreen(void)
Definition: curses.c:343
get_val
const char * get_val(const char *env, const char *def)
Definition: misc.c:355
cvers
char cvers[LEN]
Definition: init.c:70
skip_newgroups
int skip_newgroups(void)
Definition: select.c:1017
my_group_add
#define my_group_add(x, y)
Definition: tin.h:2209
DEFAULT_MAILDIR
#define DEFAULT_MAILDIR
Definition: tin.h:631
txt_usage_mail_new_news_to_user
constext txt_usage_mail_new_news_to_user[]
Definition: lang.c:929
save_news
static t_bool save_news
Definition: main.c:61
read_cmd_line_groups
int read_cmd_line_groups(void)
Definition: main.c:987
CMDLINE_MAILDIR
#define CMDLINE_MAILDIR
Definition: tin.h:1092
nntp_close
void nntp_close(t_bool send_no_quit)
Definition: nntplib.c:1723
my_malloc
#define my_malloc(size)
Definition: tin.h:2196