-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.c
211 lines (170 loc) · 3.86 KB
/
init.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* init.c
*/
/* This software is copyrighted as detailed in the LICENSE file. */
#include "EXTERN.h"
#include "common.h"
#include "list.h"
#include "env.h"
#include "util.h"
#include "util2.h"
#include "final.h"
#include "term.h"
#include "last.h"
#include "trn.h"
#include "hash.h"
#include "ngdata.h"
#include "nntpclient.h"
#include "datasrc.h"
#include "nntp.h"
#include "nntpinit.h"
#include "rcstuff.h"
#include "only.h"
#include "intrp.h"
#include "addng.h"
#include "sw.h"
#include "opt.h"
#include "art.h"
#include "artsrch.h"
#include "artio.h"
#include "backpage.h"
#include "cache.h"
#include "bits.h"
#include "head.h"
#include "help.h"
#include "mime.h"
#include "kfile.h"
#include "ngsrch.h"
#include "ngstuff.h"
#include "rcln.h"
#include "respond.h"
#include "rthread.h"
#include "ng.h"
#include "decode.h"
#ifdef SCAN
#include "scan.h"
#endif
#ifdef SCORE
#include "score.h"
#endif
#include "mempool.h"
#include "color.h"
#ifdef USE_TCL
#include "tkstuff.h"
#endif
#include "univ.h"
#include "INTERN.h"
#include "init.h"
#ifdef USE_FILTER
#include "filter.h"
#endif
bool
initialize(argc,argv)
int argc;
char* argv[];
{
char* tcbuf;
bool foundany = FALSE;
#ifdef NOLINEBUF
static char std_out_buf[BUFSIZ]; /* must be static or malloced */
setbuf(stdout, std_out_buf);
#endif
tcbuf = safemalloc(TCBUF_SIZE); /* make temp buffer for termcap and */
/* other initialization stuff */
our_pid = (long)getpid();
/* init terminal */
term_init(); /* must precede opt_init() so that */
/* ospeed is set for baud-rate */
/* switches. Actually terminal */
/* mode setting is in term_set() */
mp_init();
/* init syntax etc. for searching (must also precede opt_init()) */
search_init();
/* we have to know rnlib to look up global switches in %X/INIT */
env_init(tcbuf, 1);
head_init();
/* decode switches */
opt_init(argc,argv,&tcbuf); /* must not do % interps! */
/* (but may mung environment) */
color_init();
/* init signals, status flags */
final_init();
/* start up file expansion and the % interpreter */
intrp_init(tcbuf, TCBUF_SIZE);
/* now make sure we have a current working directory */
if (!checkflag)
cwd_check();
#ifdef SUPPORT_NNTP
if (init_nntp() < 0)
finalize(1);
#endif
/* if we aren't just checking, turn off echo */
if (!checkflag)
term_set(tcbuf);
/* get info on last trn run, if any */
last_init();
free(tcbuf); /* recover 1024 bytes */
#ifdef USE_TCL
if (UseTcl
#ifdef USE_TK
|| UseTk
#endif
) {
ttcl_init();
}
#endif
univ_init();
/* check for news news */
if (!checkflag)
newsnews_check();
/* process the newsid(s) and associate the newsrc(s) */
datasrc_init();
ngdata_init();
/* now read in the .newsrc file(s) */
foundany = rcstuff_init();
/* it looks like we will actually read something, so init everything */
addng_init();
art_init();
artio_init();
artsrch_init();
backpage_init();
bits_init();
cache_init();
help_init();
kfile_init();
#ifdef USE_FILTER
filter_init();
#endif
mime_init();
ng_init();
ngsrch_init();
ngstuff_init();
only_init();
rcln_init();
respond_init();
trn_init();
decode_init();
thread_init();
util_init();
xmouse_init(argv[0]);
writelast(); /* remember last runtime in .rnlast */
#ifdef FINDNEWNG
if (maxngtodo) /* patterns on command line? */
foundany |= scanactive(TRUE);
#endif
return foundany;
}
void
newsnews_check()
{
char* newsnewsname = filexp(NEWSNEWSNAME);
if ((tmpfp = fopen(newsnewsname,"r")) != NULL) {
fstat(fileno(tmpfp),&filestat);
if (filestat.st_mtime > (time_t)lasttime) {
while (fgets(buf,sizeof(buf),tmpfp) != NULL)
fputs(buf,stdout) FLUSH;
get_anything();
putchar('\n') FLUSH;
}
fclose(tmpfp);
}
}