1 /*        $NetBSD: extern.h,v 1.36 2023/08/10 20:36:28 mrg Exp $      */
2 
3 /*-
4  * Copyright (c) 1992, 1993
5  *        The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *        @(#)extern.h        8.2 (Berkeley) 4/20/95
32  *        $NetBSD: extern.h,v 1.36 2023/08/10 20:36:28 mrg Exp $
33  */
34 
35 #ifndef __EXTERN_H__
36 #define __EXTERN_H__
37 
38 /*
39  * from cmd1.c
40  */
41 int       More(void *);
42 int       Type(void *);
43 int       folders(void *);
44 int       from(void *);
45 int       headers(void *);
46 int       inc(void *);
47 int       mboxit(void *);
48 int       more(void *);
49 int       pcmdlist(void *);
50 int       pdot(void *);
51 int       pipecmd(void *);
52 int       scroll(void *);
53 int       stouch(void *);
54 int       top(void *);
55 int       type(void *);
56 #ifdef MIME_SUPPORT
57 int       page(void *);
58 int       Page(void *);
59 int       print(void *);
60 int       Print(void *);
61 int       view(void *);
62 int       View(void *);
63 #endif
64 /* XXX - should these be elsewhere? */
65 void      printhead(int);
66 char *    sget_msgnum(struct message *, struct message *);
67 void      show_msgnum(FILE *, struct message *, struct message *);
68 
69 /*
70  * from cmd2.c
71  */
72 int       Detach(void *);
73 int       Save(void *);
74 int       clobber(void *);
75 int       copycmd(void *);
76 int       core(void *);
77 int       delete(void *);
78 int       deltype(void *);
79 int       detach(void *);
80 int       igfield(void *);
81 int       next(void *);
82 int       retfield(void *);
83 int       save(void *);
84 int       saveigfield(void *);
85 int       saveretfield(void *);
86 int       swrite(void *);
87 int       undeletecmd(void *);
88 
89 /*
90  * from cmd3.c
91  */
92 int       Respond(void *);
93 int       alternates(void *);
94 int       bounce(void *);
95 int       dosh(void *);
96 int       echo(void *);
97 int       elsecmd(void *);
98 int       endifcmd(void *);
99 int       file(void *);
100 int       bounce(void *);
101 int       forward(void *);
102 int       group(void *);
103 int       help(void *);
104 int       ifcmd(void *);
105 int       ifdefcmd(void *v);
106 int       ifndefcmd(void *v);
107 int       markread(void *);
108 int       messize(void *);
109 int       null(void *);
110 int       preserve(void *);
111 int       respond(void *);
112 int       rexit(void *);
113 int       schdir(void *);
114 int       set(void *);
115 int       shell(void *);
116 int       show(void *);
117 int       unalias(void *);
118 int       unread(void *);
119 int       unset(void *);
120 /* XXX - Should this be elsewhere? */
121 void      sort(const char **);
122 
123 /*
124  * from cmd4.c
125  */
126 struct smopts_s *findsmopts(const char *, int);
127 int       smoptscmd(void *);
128 int       unsmoptscmd(void *);
129 int       Header(void *);
130 
131 /*
132  * from cmdtab.c
133  */
134 extern const struct cmd cmdtab[];
135 
136 /*
137  * from collect.c
138  */
139 FILE *    collect(struct header *, int);
140 void      savedeadletter(FILE *);
141 
142 /*
143  * from dotlock.c
144  */
145 int       dot_lock(const char *, int, FILE *, const char *);
146 void      dot_unlock(const char *);
147 
148 /*
149  * from edit.c
150  */
151 int       editor(void *);
152 int       visual(void *);
153 FILE *    run_editor(FILE *, off_t, int, int);
154 
155 /*
156  * from fio.c
157  */
158 const char *expand(const char *);
159 off_t     fsize(FILE *);
160 const char *getdeadletter(void);
161 int       getfold(char *, size_t);
162 #ifdef USE_EDITLINE
163 #define readline xreadline    /* readline() is defined in libedit */
164 #endif
165 int       readline(FILE *, char *, int, int);
166 int       putline(FILE *, const char *, int);
167 int       rm(char *);
168 FILE *    setinput(const struct message *);
169 void      setptr(FILE *, off_t);
170 
171 /*
172  * from getname.c
173  */
174 const char *getname(uid_t);
175 int       getuserid(char []);
176 
177 /*
178  * from head.c
179  */
180 int       ishead(const char []);
181 void      parse(const char [], struct headline *, char []);
182 
183 /*
184  * from lex.c
185  */
186 void      announce(void);
187 void      commands(void);
188 enum execute_contxt_e { ec_normal, ec_composing, ec_autoprint };
189 int       execute(char [], enum execute_contxt_e);
190 int       incfile(void);
191 const struct cmd *lex(char []);
192 void      load(const char *);
193 int       newfileinfo(int);
194 int       pversion(void *);
195 int       setfile(const char *);
196 char *    shellpr(char *);
197 char *    get_cmdname(char *);
198 
199 /*
200  * from list.c
201  */
202 int       first(int, int);
203 int       get_Hflag(char **);
204 int       getmsglist(char *, int *, int);
205 int       getrawlist(const char [], char **, int);
206 int       show_headers_and_exit(int) __dead;
207 
208 /*
209  * from main.c
210  */
211 struct name *lexpand(char *, int);
212 void      setscreensize(void);
213 
214 /*
215  * from names.c
216  */
217 struct name *cat(struct name *, struct name *);
218 int       count(struct name *);
219 struct name *delname(struct name *, char []);
220 char *    detract(struct name *, int);
221 struct name * elide(struct name *);
222 struct name * extract(char [], int);
223 struct name * gexpand(struct name *, struct grouphead *, int, int);
224 struct name * nalloc(char [], int);
225 struct name * outof(struct name *, FILE *, struct header *);
226 const char ** unpack(struct name *, struct name *);
227 struct name * usermap(struct name *);
228 #if 0
229 void      prettyprint(struct name *);   /* commented out? */
230 #endif
231 
232 /*
233  * from popen.c
234  */
235 int       Fclose(FILE *);
236 FILE *    Fdopen(int, const char *);
237 FILE *    Fopen(const char *, const char *);
238 int       Pclose(FILE *);
239 FILE *    Popen(const char *, const char *);
240 void      close_all_files(void);
241 void      close_top_files(FILE *);
242 void      free_child(int);
243 void      prepare_child(sigset_t *, int, int);
244 FILE *    last_registered_file(int);
245 void      register_file(FILE *, int, int);
246 int       run_command(const char *, sigset_t *, int, int, ...);
247 void      sigchild(int);
248 int       start_command(const char *, sigset_t *, int, int, ...);
249 int       wait_child(int);
250 #ifdef MIME_SUPPORT
251 void      flush_files(FILE *, int);
252 #endif
253 
254 /*
255  * from quit.c
256  */
257 void      quit(jmp_buf);
258 int       quitcmd(void *);
259 
260 /*
261  * from send.c
262  */
263 #ifndef MIME_SUPPORT
264 # define sendmessage(a,b,c,d,e)         legacy_sendmessage(a,b,c,d)
265 # define mail(a,b,c,d,e,f)    legacy_mail(a,b,c,d,e)
266 #endif
267 int       sendmessage(struct message *, FILE *, struct ignoretab *, const char *, struct mime_info *);
268 int       mail(struct name *, struct name *, struct name *, struct name *, char *, struct attachment *);
269 void      mail1(struct header *, int);
270 void      mail2(FILE *, const char **);
271 int       puthead(struct header *, FILE *, int);
272 int       sendmail(void *);
273 
274 /*
275  * from strings.c
276  */
277 void *    csalloc(size_t, size_t);
278 void *    salloc(size_t);
279 void      sreset(void);
280 void      spreserve(void);
281 
282 /*
283  * from support.c
284  */
285 void      add_ignore(const char *, struct ignoretab *);
286 void      alter(char *);
287 int       argcount(char **);
288 int       blankline(char []);
289 char *    copy(char *, char *);
290 char *    hfield(const char [], const struct message *);
291 int       isdir(const char []);
292 int       isign(const char *, struct ignoretab [2]);
293 void      istrcpy(char *, const char *);
294 int       member(char *, struct ignoretab *);
295 char *    nameof(struct message *, int);
296 int       sasprintf(char **ret, const char *format, ...) __printflike(2, 3);
297 char *    savestr(const char *);
298 struct message *set_m_flag(int, int, int);
299 char *    skin(char *);
300 int       source(void *);
301 void      touch(struct message *);
302 int       unstack(void);
303 int       upcase(int);
304 void      cathelp(const char *);
305 
306 /*
307  * from temp.c
308  */
309 void      tinit(void);
310 
311 /*
312  * from tty.c
313  */
314 int       grabh(struct header *, int);
315 
316 /*
317  * from vars.c
318  */
319 void      assign(const char [], const char []);
320 struct grouphead * findgroup(const char []);
321 int       hash(const char *);
322 struct var * lookup(const char []);
323 void      printgroup(const char []);
324 void      v_free(char *);
325 char *    value(const char []);
326 char *    vcopy(const char []);
327 
328 /*
329  * from v7.local.c
330  */
331 void      demail(void);
332 void      findmail(const char *, char *, size_t);
333 const char *username(void);
334 
335 /*
336  * from version.c
337  */
338 extern const char *version;
339 
340 
341 #ifndef   THREAD_SUPPORT
342 /*
343  * Specials from fio.c (if THREAD_SUPPORT is not defined).
344  * With THREAD_SUPPORT, they live in thread.c.
345  */
346 struct message *next_message(struct message *);
347 struct message *prev_message(struct message *);
348 struct message *get_message(int);
349 int       get_msgnum(struct message *);
350 int       get_msgCount(void);
351 
352 /* we remap these commands */
353 # define get_abs_msgCount     get_msgCount
354 # define get_abs_message(a)   get_message(a)
355 # define next_abs_message(a)  next_message(a)
356 
357 /* we trash these commands */
358 # define do_recursion()                           0
359 # define thread_recursion(mp,fn,args)   fn(mp,args)
360 # define thread_fix_old_links(nmessage,off,omsgCount)
361 # define thread_fix_new_links(message,omsgCount,msgCount)
362 #endif /* THREAD_SUPPORT */
363 
364 #endif /* __EXTERN_H__ */
365