tin  2.6.1
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.6.1.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 : 2021-02-13
7 * Notes :
8 *
9 * Copyright (c) 1991-2022 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
51signed long int read_newsrc_lines = -1;
52
53static char **cmdargs;
54static int num_cmdargs;
55static int max_cmdargs;
56
57static t_bool catchup = FALSE; /* mark all arts read in all subscribed groups */
58static t_bool update_index = FALSE; /* update local overviews */
59static t_bool check_any_unread = FALSE; /* print/return status if any unread */
60static t_bool mail_news = FALSE; /* mail all arts to specified user */
61static t_bool save_news = FALSE; /* save all arts to savedir structure */
62static t_bool start_any_unread = FALSE; /* only start if unread news */
63
64
65/*
66 * Local prototypes
67 */
68static void create_mail_save_dirs(void);
69static void read_cmd_line_options(int argc, char *argv[]);
70static void show_intro_page(void);
71static void update_index_files(void);
72static void usage(char *theProgname);
73
74
75/*
76 * OK lets start the ball rolling...
77 */
78int
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 */
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();
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()) {
187 giveup();
188 }
189#endif /* !USE_CURSES */
190
191 /*
192 * Init curses emulation
193 */
194 if (!InitScreen()) {
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) {
210 ring_bell();
212 }
213 wait_message(0, "%s\n", cvers);
214 }
215
216 /*
217 * Connect to nntp server?
218 */
219 if (!nntp_server || !*nntp_server)
224 giveup();
225 }
226
228
229 /*
230 * exit early - unfortunately we can't do that in read_cmd_line_options()
231 * as nntp_caps.over_cmd is set in nntp_open()
232 *
233 * TODO: does the logic make sense? what
234 * if (update_index && !nntp_caps.over_cmd && !tinrc.cache_overview_files)
235 * no error message? why?
236 */
240 giveup();
241 }
242
243 /*
244 * Check if overview indexes contain Xref: lines
245 */
246#ifdef NNTP_ABLE
248#endif /* NNTP_ABLE */
250
251 /*
252 * avoid empty regexp, we also need to do this in batch_mode
253 * as read_overview() calls eat_re() which uses a regexp to
254 * modify the subject *sigh*
255 */
257
259 /*
260 * Read user specific keybindings and input history
261 */
265
266 /*
267 * Load the mail & news active files into active[]
268 *
269 * create_save_active_file cannot write to active.save
270 * if no_write != FALSE, so restore original value temporarily
271 */
272 if (read_saved_news) {
273 no_write = tmp_no_write;
275 no_write = TRUE;
276 }
277 }
278
279#ifdef HAVE_MH_MAIL_HANDLING
280 read_mail_active_file();
281#endif /* HAVE_MH_MAIL_HANDLING */
282
283 /*
284 * Initialise active[] and add new newsgroups to start of my_group[]
285 * also reads global/local attributes
286 */
287 selmenu.max = 0;
288 /*
289 * we need to restore the original no_write mode to be able to handle
290 * $AUTOSUBSCRIBE groups
291 */
292 no_write = tmp_no_write;
295 start_groupnum = read_news_active_file();
296#ifdef DEBUG
297 if (debug & DEBUG_MISC)
298 debug_print_active();
299#endif /* DEBUG */
300
301 /*
302 * Read in users filter preferences file. This has to be done before
303 * quick post because the filters might be updated.
304 */
306
307 no_write = TRUE;
308#ifdef DEBUG
309 if (debug & DEBUG_FILTER)
310 debug_print_filters();
311#endif /* DEBUG */
312
313 /*
314 * Preloads active[] with command line groups. They will follow any
315 * new newsgroups
316 */
318 num_cmd_line_groups = read_cmd_line_groups();
319
320 /*
321 * Quick post an article and exit if -w or -o specified
322 */
324 no_write = tmp_no_write; /* restore original value */
325 quick_post_article(post_postponed_and_exit, num_cmd_line_groups);
327 no_write = TRUE; /* disable newsrc updates */
328 tin_done(EXIT_SUCCESS, NULL);
329 }
330
331 /* TODO: replace hard coded key-name in txt_info_postponed */
332 if ((count = count_postponed_articles()))
333 wait_message(3, _(txt_info_postponed), count, PLURAL(count, txt_article));
334
335 /*
336 * Read text descriptions for mail and/or news groups
337 */
339 no_write = tmp_no_write; /* restore original value */
341 no_write = TRUE; /* disable newsrc updates */
342 }
343
344 /* what about "if (!no_write)" here? */
346 if (created_rcdir) /* first start */
348
349 if (!tmp_no_write) /* do not (over)write oldnewsrc with -X */
351
352 /*
353 * Load my_groups[] from the .newsrc file. We append these groups to any
354 * new newsgroups and command line newsgroups already loaded. Also does
355 * auto-subscribe to groups specified in /usr/lib/news/subscriptions
356 * locally or via NNTP if reading news remotely (LIST SUBSCRIPTIONS)
357 */
358 /*
359 * TODO:
360 * if (num_cmd_line_groups != 0 && check_any_unread)
361 * don't read newsrc.
362 * This makes -Z handle command line newsgroups. Test & document
363 */
365 no_write = tmp_no_write; /* restore old value */
366
367 /*
368 * We have to show all groups with command line groups
369 */
370 if (num_cmd_line_groups)
372 else
373 toggle_my_groups(NULL);
374
375 /*
376 * Check/start if any new/unread articles
377 */
380
381 if (start_any_unread) {
382 batch_mode = TRUE; /* Suppress some unwanted on-screen garbage */
383 if ((start_groupnum = check_start_save_any_news(START_ANY_NEWS, catchup)) == -1) {
385 tin_done(EXIT_SUCCESS, NULL);
386 }
388 }
389
390 /*
391 * Mail any new articles to specified user
392 * or
393 * Save any new articles to savedir structure for later reading
394 *
395 * TODO: should we temporarily set
396 * getart_limit=-1,thread_articles=0,sort_article_type=0
397 * for speed reasons?
398 */
399 if (mail_news || save_news) {
401 tin_done(EXIT_SUCCESS, NULL);
402 }
403
404 /*
405 * Catchup newsrc file (-c option)
406 */
407 if (batch_mode && catchup && !update_index) {
409 tin_done(EXIT_SUCCESS, NULL);
410 }
411
412 /*
413 * Update index files (-u option), also does catchup if requested
414 */
415 if (update_index)
417
418 /*
419 * the code below this point can't be reached in batch mode
420 */
421
422 /*
423 * If first time print welcome screen
424 */
425 if (created_rcdir)
427
428#ifdef XFACE_ABLE
429 if (tinrc.use_slrnface && !batch_mode)
430 slrnface_start();
431#endif /* XFACE_ABLE */
432
433#ifdef USE_CURSES
434 /* Turn scrolling off now the startup messages have been displayed */
435 scrollok(stdscr, FALSE);
436#endif /* USE_CURSES */
437
438 /*
439 * Work loop
440 */
441 selection_page(start_groupnum, num_cmd_line_groups);
442 /* NOTREACHED */
443 return 0;
444}
445
446
447/*
448 * process command line options
449 * [01235789beEFijJkKLOtTyY] are unused
450 * [W] is reserved
451 * [BCPU] have been in use at some time, but now are unused:
452 * B BBS mode (M_AMIGA only)
453 * C count articles
454 * P purge group index files of articles that no longer exist
455 * U update index files in background
456 */
457#define OPTIONS "46aAcdD:f:g:G:hHI:lm:M:nNop:qQrRs:SuvVwxXzZ"
458
459static void
461 int argc,
462 char *argv[])
463{
464 int ch;
465 t_bool newsrc_set = FALSE;
466
467 envargs(&argc, &argv, "TINRC");
468
469 while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
470 switch (ch) {
471
472 case '4':
473#if defined(NNTP_ABLE) && defined(INET6)
474 force_ipv4 = TRUE;
476#else
477# ifdef NNTP_ABLE
478 error_message(2, _(txt_option_not_enabled), "-DENABLE_IPV6");
479# else
480 error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
481# endif /* NNTP_ABLE */
483 giveup();
484 /* keep lint quiet: */
485 /* NOTREACHED */
486#endif /* NNTP_ABLE && INET6 */
487 break;
488
489 case '6':
490#if defined(NNTP_ABLE) && defined(INET6)
491 force_ipv6 = TRUE;
493# else
494# ifdef NNTP_ABLE
495 error_message(2, _(txt_option_not_enabled), "-DENABLE_IPV6");
496# else
497 error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
498# endif /* NNTP_ABLE */
500 giveup();
501 /* keep lint quiet: */
502 /* NOTREACHED */
503#endif /* NNTP_ABLE && INET6 */
504 break;
505
506 case 'a':
507#ifdef HAVE_COLOR
509#else
510 error_message(2, _(txt_option_not_enabled), "-DHAVE_COLOR");
512 giveup();
513 /* keep lint quiet: */
514 /* NOTREACHED */
515#endif /* HAVE_COLOR */
516 break;
517
518 case 'A':
519#ifdef NNTP_ABLE
520 force_auth_on_conn_open = TRUE;
522#else
523 error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
525 giveup();
526 /* keep lint quiet: */
527 /* NOTREACHED */
528#endif /* NNTP_ABLE */
529 break;
530
531 case 'c':
533 catchup = TRUE;
534 break;
535
536 case 'd':
538 break;
539
540 case 'D': /* debug mode */
541#ifdef DEBUG
542 debug = atoi(optarg) & 0xff;
543 debug_delete_files();
544#else
545 error_message(2, _(txt_option_not_enabled), "-DDEBUG");
547 giveup();
548 /* keep lint quiet: */
549 /* NOTREACHED */
550#endif /* DEBUG */
551 break;
552
553 case 'f': /* newsrc file */
554 my_strncpy(newsrc, optarg, sizeof(newsrc) - 1);
555 newsrc_set = TRUE;
556 break;
557
558 case 'G':
561 break;
562
563 case 'g': /* select alternative NNTP-server, implies -r */
564#ifdef NNTP_ABLE
568#else
569 error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
571 giveup();
572 /* keep lint quiet: */
573 /* NOTREACHED */
574#endif /* NNTP_ABLE */
575 break;
576
577 case 'H':
580 exit(EXIT_SUCCESS);
581 /* keep lint quiet: */
582 /* FALLTHROUGH */
583
584 case 'I':
586 break;
587
588 case 'l':
590 break;
591
592 case 'm':
595 break;
596
597 case 'M': /* mail new news to specified user */
599 mail_news = TRUE;
601 break;
602
603 case 'n':
605 break;
606
607 case 'N': /* mail new news to your posts */
609 mail_news = TRUE;
611 break;
612
613 case 'o': /* post postponed articles & exit */
614#ifndef NO_POSTING
615 /*
616 * TODO: autoposting currently does some screen output, so we
617 * can't set batch_mode
618 */
621#else
622 error_message(2, _(txt_option_not_enabled), "-UNO_POSTING");
624 giveup();
625 /* keep lint quiet: */
626 /* NOTREACHED */
627#endif /* !NO_POSTING */
628 break;
629
630 case 'p': /* implies -r */
631#ifdef NNTP_ABLE
633 if (atoi(optarg) != 0)
634 nntp_tcp_port = (unsigned short) atoi(optarg);
635#else
636 error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
638 giveup();
639 /* keep lint quiet: */
640 /* NOTREACHED */
641#endif /* NNTP_ABLE */
642 break;
643
644 case 'q':
646 break;
647
648 case 'Q':
652 break;
653
654 case 'r': /* read news remotely from default NNTP server */
655#ifdef NNTP_ABLE
657#else
658 error_message(2, _(txt_option_not_enabled), "-DNNTP_ABLE");
660 giveup();
661 /* keep lint quiet: */
662 /* NOTREACHED */
663#endif /* NNTP_ABLE */
664 break;
665
666 case 'R': /* read news saved by -S option */
672 break;
673
674 case 's':
677 break;
678
679 case 'S': /* save new news to dir structure */
680 save_news = TRUE;
682 break;
683
684 case 'u': /* update index files */
687 break;
688
689 case 'v': /* verbose mode, can be used multiple times */
690 verbose++;
691 break;
692
693 case 'V':
694 tin_version_info(stderr);
696 exit(EXIT_SUCCESS);
697 /* keep lint quiet: */
698 /* FALLTHROUGH */
699
700 case 'w': /* post article & exit */
701#ifndef NO_POSTING
704#else
705 error_message(2, _(txt_option_not_enabled), "-UNO_POSTING");
707 giveup();
708 /* keep lint quiet: */
709 /* NOTREACHED */
710#endif /* !NO_POSTING */
711 break;
712
713#if 0
714 case 'W': /* reserved according to SUSV3 XDB Utility Syntax Guidelines, Guideline 3 */
715 break;
716#endif /* 0 */
717
718 case 'x': /* enter no_posting mode */
720 break;
721
722 case 'X': /* don't save ~/.newsrc on exit */
723 no_write = TRUE;
724 break;
725
726 case 'z':
728 break;
729
730 case 'Z':
733 break;
734
735 case 'h':
736 case '?':
737 default:
740 exit(EXIT_SUCCESS);
741 }
742 }
743 cmdargs = argv;
745 max_cmdargs = argc;
746 if (!newsrc_set) {
747 if (read_news_via_nntp) {
750 } else {
751#if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
752 struct utsname uts;
753 (void) uname(&uts);
754 get_newsrcname(newsrc, sizeof(newsrc), uts.nodename);
755#else
756 char nodenamebuf[256]; /* SUSv2 limit; better use HOST_NAME_MAX */
757# ifdef HAVE_GETHOSTNAME
758 (void) gethostname(nodenamebuf, sizeof(nodenamebuf));
759# endif /* HAVE_GETHOSTNAME */
760 get_newsrcname(newsrc, sizeof(newsrc), nodenamebuf);
761#endif /* HAVE_SYS_UTSNAME_H && HAVE_UNAME */
762 }
763 }
764
765 /*
766 * Sort out option conflicts
767 */
768 if (!batch_mode) {
769 if (catchup) {
771 catchup = FALSE;
772 }
773 } else {
774 if (read_saved_news) {
777 }
778 }
779 if (!(batch_mode || debug)) {
780 if (verbose) {
782 verbose = FALSE;
783 }
784 }
786 wait_message(2, _(txt_useless_combination), "-o", "-x", "-x");
788 }
790 wait_message(2, _(txt_useless_combination), "-w", "-x", "-x");
792 }
793 if (catchup && start_any_unread) {
794 wait_message(2, _(txt_useless_combination), "-c", "-z", "-c");
795 catchup = FALSE;
796 }
797 if (catchup && no_write) {
798 wait_message(2, _(txt_useless_combination), "-c", "-X", "-c");
799 catchup = FALSE;
800 }
801 if (catchup && check_any_unread) {
802 wait_message(2, _(txt_useless_combination), "-c", "-Z", "-c");
803 catchup = FALSE;
804 }
806 wait_message(2, _(txt_useless_combination), "-n", "-R", "-n");
808 }
810 wait_message(2, _(txt_useless_combination), "-z", "-S", "-z");
812 }
814 wait_message(2, _(txt_useless_combination), "-S", "-Z", "-S");
816 }
818 wait_message(2, _(txt_useless_combination), "-Z", "-z", "-Z");
820 }
821# ifdef DEBUG
822 if ((debug & DEBUG_NNTP) && !read_news_via_nntp) {
823 /* TODO: lang.c */
824 wait_message(3, _(txt_useless_combination), _("reading from local spool"), "-D nntp", "-D nntp");
825 debug &= ~DEBUG_NNTP;
826 }
827# endif /* DEBUG */
828
829#if defined(NNTP_ABLE) && defined(INET6)
830 if (force_ipv4 && force_ipv6) {
831 wait_message(2, _(txt_useless_combination), "-4", "-6", "-6");
832 force_ipv6 = FALSE;
833 }
834#endif /* NNTP_ABLE && INET6 */
835
838 else
842
843 /*
844 * When updating index files set getart_limit to 0 in order to get overview
845 * information for all article; this overwrites '-G limit' and disables
846 * tinrc.getart_limit temporary
847 */
848 if (update_index) {
851 }
852#ifdef NNTP_ABLE
853 /*
854 * If we're reading from an NNTP server and we've been asked not to look
855 * for new newsgroups, trust our cached copy of the newsgroups file.
856 */
859#endif /* NNTP_ABLE */
860 /*
861 * If we use neither list_active nor newsrc_active,
862 * we use both of them.
863 */
864 if (!list_active && !newsrc_active)
866}
867
868
869/*
870 * usage
871 */
872static void
874 char *theProgname)
875{
876 error_message(2, _(txt_usage_tin), theProgname);
877
878#if defined(NNTP_ABLE) && defined(INET6)
879 error_message(2, _(txt_usage_force_ipv4));
880 error_message(2, _(txt_usage_force_ipv6));
881#endif /* NNTP_ABLE && INET6 */
882
883#ifdef HAVE_COLOR
884 error_message(2, _(txt_usage_toggle_color));
885#endif /* HAVE_COLOR */
886#ifdef NNTP_ABLE
887 error_message(2, _(txt_usage_force_authentication));
888#endif /* NNTP_ABLE */
889
892
893#ifdef DEBUG
894 error_message(2, _(txt_usage_debug));
895#endif /* DEBUG */
896
899
900#ifdef NNTP_ABLE
901# ifdef NNTP_DEFAULT_SERVER
902 error_message(2, _(txt_usage_newsserver), get_val("NNTPSERVER", NNTP_DEFAULT_SERVER));
903# else
904 error_message(2, _(txt_usage_newsserver), get_val("NNTPSERVER", "news"));
905# endif /* NNTP_DEFAULT_SERVER */
906#endif /* NNTP_ABLE */
907
917
918#ifdef NNTP_ABLE
919 error_message(2, _(txt_usage_port), nntp_tcp_port);
920#endif /* NNTP_ABLE */
921
924
925#ifdef NNTP_ABLE
927 error_message(2, _(txt_usage_read_news_remotely));
928#endif /* NNTP_ABLE */
929
941
943}
944
945
946/*
947 * update index files
948 */
949static void
951 void)
952{
953 cCOLS = 132; /* set because curses has not started */
955 tinrc.thread_articles = THREAD_NONE; /* stop threading to run faster */
959 tin_done(EXIT_SUCCESS, NULL);
960}
961
962
963/*
964 * display page of general info. for first time user.
965 */
966static void
968 void)
969{
970 char buf[4096];
971
972 if (!cmd_line) {
973 ClearScreen();
975 Raw(FALSE);
976 my_printf("\n");
977 }
978
980
981 my_fputs(buf, stdout);
982 my_flush();
983
984 if (!cmd_line) {
985 Raw(TRUE);
987 }
988}
989
990
991/*
992 * Wildcard match any newsgroups on the command line. Sort of like a limited
993 * yank at startup. Return number of groups that were matched.
994 */
995int
997 void)
998{
999 int matched = 0;
1000 int num;
1001 int i;
1002
1003 if (num_cmdargs < max_cmdargs) {
1004 selmenu.max = skip_newgroups(); /* Reposition after any newgroups */
1005
1006 for (num = num_cmdargs; num < max_cmdargs; num++) {
1007 if (!batch_mode)
1009
1010 for_each_group(i) {
1011 if (match_group_list(active[i].name, cmdargs[num])) {
1012 if (my_group_add(active[i].name, TRUE) != -1) {
1013 matched++;
1016 break;
1017 }
1018 }
1019 }
1020 }
1021 }
1022 }
1023 return matched;
1024}
1025
1026
1027/*
1028 * Create default mail & save directories if they do not exist
1029 */
1030static void
1032 void)
1033{
1034 char path[PATH_LEN];
1035 struct stat sb;
1036
1037 if (!strfpath(tinrc.maildir, path, sizeof(path), NULL, FALSE))
1038 joinpath(path, sizeof(path), homedir, DEFAULT_MAILDIR);
1039
1040 if (stat(path, &sb) == -1)
1041 my_mkdir(path, (mode_t) (S_IRWXU));
1042
1043 if (!strfpath(tinrc.savedir, path, sizeof(path), NULL, FALSE))
1044 joinpath(path, sizeof(path), homedir, DEFAULT_SAVEDIR);
1045
1046 if (stat(path, &sb) == -1)
1047 my_mkdir(path, (mode_t) (S_IRWXU));
1048}
1049
1050
1051/*
1052 * we don't try do free() any previously malloc()ed mem here as exit via
1053 * giveup() indicates a serious error and keeping track of what we've
1054 * already malloc()ed would be a PITA.
1055 */
1056/* coverity[+kill] */
1057_Noreturn void
1059 void)
1060{
1061 static int nested;
1062
1063#ifdef XFACE_ABLE
1064 slrnface_stop();
1065#endif /* XFACE_ABLE */
1066
1067 if (!cmd_line && !nested++) {
1068 cursoron();
1069 EndWin();
1070 Raw(FALSE);
1071 }
1072 exit(EXIT_FAILURE);
1073}
unsigned t_bool
Definition: bool.h:77
#define bool_not(b)
Definition: bool.h:81
#define TRUE
Definition: bool.h:74
#define FALSE
Definition: bool.h:70
#define DEBUG_MISC
Definition: debug.h:54
#define DEBUG_FILTER
Definition: debug.h:49
#define DEBUG_NNTP
Definition: debug.h:47
constext txt_usage_mail_new_news_to_user[]
Definition: lang.c:942
int verbose
Definition: init.c:154
constext txt_usage_post_postponed_arts[]
Definition: lang.c:946
constext txt_usage_dont_show_descriptions[]
Definition: lang.c:933
constext txt_usage_read_only_active[]
Definition: lang.c:1157
char bug_addr[LEN]
Definition: post.c:124
constext txt_usage_mail_bugreport[]
Definition: lang.c:940
constext txt_useful_with_batch_or_debug_mode[]
Definition: lang.c:956
t_bool check_for_new_newsgroups
Definition: init.c:128
constext txt_useful_without_batch_mode[]
Definition: lang.c:954
constext txt_usage_maildir[]
Definition: lang.c:939
t_bool xref_supported
Definition: init.c:156
constext txt_usage_post_article[]
Definition: lang.c:945
t_bool show_description
Definition: init.c:153
constext txt_usage_help_information[]
Definition: lang.c:935
struct t_capabilities nntp_caps
Definition: init.c:513
constext txt_useful_with_batch_mode[]
Definition: lang.c:955
t_bool post_postponed_and_exit
Definition: init.c:147
char homedir[PATH_LEN]
Definition: init.c:78
char * nntp_server
Definition: nntplib.c:28
constext txt_usage_dont_save_files_on_quit[]
Definition: lang.c:932
t_bool cmd_line
Definition: init.c:129
t_bool read_saved_news
Definition: init.c:152
constext txt_usage_index_newsdir[]
Definition: lang.c:937
constext txt_option_not_enabled[]
Definition: lang.c:721
t_menu selmenu
Definition: select.c:84
constext txt_usage_catchup[]
Definition: lang.c:929
constext txt_usage_verbose[]
Definition: lang.c:952
constext txt_usage_newsrc_file[]
Definition: lang.c:943
constext txt_usage_no_posting[]
Definition: lang.c:944
constext txt_usage_quickstart[]
Definition: lang.c:1156
t_bool post_article_and_exit
Definition: init.c:146
constext txt_usage_dont_check_new_newsgroups[]
Definition: lang.c:931
constext txt_usage_check_for_unread_news[]
Definition: lang.c:930
constext txt_exiting[]
Definition: lang.c:271
char index_newsdir[PATH_LEN]
Definition: init.c:80
constext txt_intro_page[]
Definition: lang.c:567
constext txt_reading_keymap_file[]
Definition: lang.c:779
char news_active_file[PATH_LEN]
Definition: init.c:94
constext txt_usage_version[]
Definition: lang.c:953
constext txt_usage_mail_new_news[]
Definition: lang.c:941
char global_config_file[PATH_LEN]
Definition: init.c:77
char userid[PATH_LEN]
Definition: init.c:107
constext txt_batch_update_unavail[]
Definition: lang.c:116
constext txt_info_postponed[]
Definition: lang.c:560
char filter_file[PATH_LEN]
Definition: init.c:89
t_bool read_local_newsgroups_file
Definition: init.c:150
constext txt_usage_start_if_unread_news[]
Definition: lang.c:950
constext txt_usage_read_only_subscribed[]
Definition: lang.c:1158
char cvers[LEN]
Definition: init.c:70
t_bool newsrc_active
Definition: init.c:144
char lock_file[PATH_LEN]
Definition: init.c:88
constext txt_screen_init_failed[]
Definition: lang.c:830
constext txt_usage_savedir[]
Definition: lang.c:948
t_bool list_active
Definition: init.c:143
char save_active_file[PATH_LEN]
Definition: init.c:101
constext txt_screen_too_small_exiting[]
Definition: lang.c:834
char newsrc[PATH_LEN]
Definition: init.c:96
constext txt_matching_cmd_line_groups[]
Definition: lang.c:637
int cCOLS
Definition: curses.c:53
int cLINES
Definition: curses.c:52
char mail_news_user[LEN]
Definition: init.c:90
char * tin_progname
Definition: init.c:105
constext txt_usage_getart_limit[]
Definition: lang.c:934
char local_config_file[PATH_LEN]
Definition: init.c:84
int optind
constext txt_usage_save_new_news[]
Definition: lang.c:949
char * optarg
struct t_config tinrc
Definition: init.c:192
unsigned short debug
Definition: debug.c:51
constext txt_useless_combination[]
Definition: lang.c:957
constext txt_usage_update_index_files[]
Definition: lang.c:938
t_bool no_write
Definition: init.c:145
constext txt_usage_read_saved_news[]
Definition: lang.c:947
constext txt_usage_tin[]
Definition: lang.c:951
struct t_cmdlineopts cmdline
Definition: init.c:190
t_bool created_rcdir
Definition: init.c:130
t_bool read_news_via_nntp
Definition: init.c:151
constext txt_usage_help_message[]
Definition: lang.c:936
struct t_group * active
Definition: memory.c:66
t_bool batch_mode
Definition: init.c:127
t_bool force_no_post
Definition: init.c:137
static char buf[16]
Definition: langinfo.c:50
int main(int argc, char *argv[])
Definition: main.c:79
static void usage(char *theProgname)
Definition: main.c:873
int read_cmd_line_groups(void)
Definition: main.c:996
signed long int read_newsrc_lines
Definition: main.c:51
static t_bool check_any_unread
Definition: main.c:59
static int num_cmdargs
Definition: main.c:54
static void read_cmd_line_options(int argc, char *argv[])
Definition: main.c:460
static void show_intro_page(void)
Definition: main.c:967
static t_bool update_index
Definition: main.c:58
static void update_index_files(void)
Definition: main.c:950
static int max_cmdargs
Definition: main.c:55
void giveup(void)
Definition: main.c:1058
static t_bool mail_news
Definition: main.c:60
static char ** cmdargs
Definition: main.c:53
static t_bool catchup
Definition: main.c:57
static t_bool start_any_unread
Definition: main.c:62
#define OPTIONS
Definition: main.c:457
static void create_mail_save_dirs(void)
Definition: main.c:1031
static t_bool save_news
Definition: main.c:61
#define NNTP_SERVER_FILE
Definition: nntplib.h:45
const char * tin_nl_langinfo(nl_item item)
Definition: langinfo.c:53
void read_input_history_file(void)
Definition: misc.c:2199
void center_line(int line, t_bool inverse, const char *str)
Definition: screen.c:298
void do_update(t_bool catchup)
Definition: art.c:2779
void set_signal_handlers(void)
Definition: signal.c:542
void create_save_active_file(void)
Definition: active.c:1270
void prompt_continue(void)
Definition: prompt.c:803
t_bool read_filter_file(const char *file)
Definition: filter.c:308
int get_termcaps(void)
Definition: curses.c:216
void init_alloc(void)
Definition: memory.c:91
int atoi(const char *s)
void read_attributes_file(t_bool global_file)
Definition: attrib.c:293
void read_server_config(void)
Definition: config.c:2139
void backup_newsrc(void)
Definition: newsrc.c:388
int tin_version_info(FILE *fp)
Definition: misc.c:3927
int count_postponed_articles(void)
Definition: post.c:2780
void base_name(const char *fullpath, char *file)
Definition: misc.c:860
void error_message(unsigned int sdelay, const char *fmt,...)
Definition: screen.c:224
_Noreturn void tin_done(int ret, const char *fmt,...)
Definition: misc.c:562
t_bool match_group_list(const char *group, const char *group_list)
Definition: active.c:1117
const char * get_val(const char *env, const char *def)
Definition: misc.c:361
void ClearScreen(void)
Definition: curses.c:410
void write_config_file(char *file)
Definition: config.c:932
void init_selfinfo(void)
Definition: init.c:643
void EndWin(void)
Definition: curses.c:368
void free_all_arrays(void)
Definition: memory.c:237
void joinpath(char *result, size_t result_size, const char *dir, const char *file)
Definition: joinpath.c:50
void create_index_lock_file(char *the_lock_file)
Definition: misc.c:1119
void catchup_newsrc_file(void)
Definition: newsrc.c:1411
t_bool overview_xref_support(void)
Definition: xref.c:82
t_bool get_newsrcname(char *newsrc_name, size_t newsrc_name_len, const char *nntpserver_name)
Definition: nrctbl.c:140
void ring_bell(void)
Definition: screen.c:480
void hash_init(void)
Definition: hashstr.c:123
int nntp_open(void)
Definition: nntplib.c:1350
char * getserverbyfile(const char *file)
Definition: nntplib.c:111
signed long int read_newsrc(char *newsrc_file, t_bool allgroups)
Definition: newsrc.c:83
void Raw(int state)
Definition: curses.c:624
void read_descriptions(t_bool verb)
Definition: mail.c:441
int my_mkdir(char *path, mode_t mode)
Definition: misc.c:717
void envargs(int *Pargc, char ***Pargv, const char *envstr)
Definition: envarg.c:69
void init_group_hash(void)
Definition: list.c:62
const char * print_boolean(t_bool value)
Definition: config.c:1702
void cursoron(void)
Definition: curses.c:712
void setup_screen(void)
Definition: curses.c:170
int strfpath(const char *format, char *str, size_t maxsize, struct t_group *group, t_bool expand_all)
Definition: misc.c:1699
void wait_message(unsigned int sdelay, const char *fmt,...)
Definition: screen.c:133
void my_strncpy(char *p, const char *q, size_t n)
Definition: string.c:196
int skip_newgroups(void)
Definition: select.c:1045
t_bool read_keymap_file(void)
Definition: keymap.c:327
void selection_page(int start_groupnum, int num_cmd_line_groups)
Definition: select.c:108
void nntp_close(t_bool send_no_quit)
Definition: nntplib.c:1724
void quick_post_article(t_bool postponed_only, int num_cmd_line_groups)
Definition: post.c:2700
void setup_default_keys(void)
Definition: keymap.c:2523
int check_start_save_any_news(int function, t_bool catchup)
Definition: save.c:133
int strcasecmp(const char *p, const char *q)
Definition: string.c:475
int InitScreen(void)
Definition: curses.c:343
int read_news_active_file(void)
Definition: active.c:750
void toggle_my_groups(const char *group)
Definition: select.c:1292
t_bool read_config_file(char *file, t_bool global_file)
Definition: config.c:92
void EndInverse(void)
Definition: curses.c:564
void postinit_regexp(void)
Definition: init.c:1021
const char * name
Definition: signal.c:117
const char * over_cmd
Definition: nntplib.h:210
char savedir[255]
Definition: tin.h:1502
unsigned int args
Definition: tin.h:1503
char maildir[255]
Definition: tin.h:1500
char nntpserver[255]
Definition: tin.h:1501
int getart_limit
Definition: tin.h:1499
char maildir[PATH_LEN]
Definition: tinrc.h:106
int sort_threads_type
Definition: tinrc.h:159
char default_post_newsgroups[HEADER_LEN]
Definition: tinrc.h:87
t_bool cache_overview_files
Definition: tinrc.h:220
char savedir[PATH_LEN]
Definition: tinrc.h:138
t_bool show_only_unread_groups
Definition: tinrc.h:244
int thread_articles
Definition: tinrc.h:164
int sort_article_type
Definition: tinrc.h:158
char mm_local_charset[LEN]
Definition: tinrc.h:115
char * name
Definition: tin.h:1817
int max
Definition: tin.h:2057
#define my_flush()
Definition: tcurses.h:177
#define my_fputs(str, stream)
Definition: tcurses.h:159
#define my_printf
Definition: tcurses.h:175
#define PLURAL(x, y)
Definition: tin.h:1064
#define START_ANY_NEWS
Definition: tin.h:1233
#define CMDLINE_MAILDIR
Definition: tin.h:1103
#define THREAD_NONE
Definition: tin.h:1139
#define for_each_group(x)
Definition: tin.h:2259
#define STRCPY(dst, src)
Definition: tin.h:820
#define textdomain(Domain)
Definition: tin.h:93
#define CMDLINE_NNTPSERVER
Definition: tin.h:1104
#define my_malloc(size)
Definition: tin.h:2245
#define EXIT_SUCCESS
Definition: tin.h:1298
#define EXIT_FAILURE
Definition: tin.h:1302
#define DEFAULT_SAVEDIR
Definition: tin.h:638
#define MIN_LINES_ON_TERMINAL
Definition: tin.h:1095
#define CMDLINE_USE_COLOR
Definition: tin.h:1106
#define MAIL_ANY_NEWS
Definition: tin.h:1234
#define DEFAULT_MAILDIR
Definition: tin.h:637
#define _(Text)
Definition: tin.h:94
#define CMDLINE_SAVEDIR
Definition: tin.h:1105
#define PATH_LEN
Definition: tin.h:843
#define SAVE_ANY_NEWS
Definition: tin.h:1235
#define CMDLINE_GETART_LIMIT
Definition: tin.h:1102
#define SORT_THREADS_BY_NOTHING
Definition: tin.h:1201
#define snprintf
Definition: tin.h:2464
#define SORT_ARTICLES_BY_NOTHING
Definition: tin.h:1185
#define LOCALEDIR
Definition: tin.h:98
#define setlocale(Category, Locale)
Definition: tin.h:78
#define my_group_add(x, y)
Definition: tin.h:2258
#define INDEX_NEWSDIR
Definition: tin.h:627
#define CHECK_ANY_NEWS
Definition: tin.h:1232
#define CODESET
Definition: tin.h:776
#define bindtextdomain(Domain, Directory)
Definition: tin.h:91
#define MIN_COLUMNS_ON_TERMINAL
Definition: tin.h:1096
#define _Noreturn
Definition: tin.h:2495
#define S_IRWXU
Definition: tin.h:2184
#define PRODUCT
Definition: version.h:44