Improve config/make system, silence smake(1)..
[s-mailx.git] / extern.h
blobf34ca54e3dff56541260ea4ff81c66b0868defe2
1 /*
2 * S-nail - a mail user agent derived from Berkeley Mail.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 Steffen "Daode" Nurpmeso.
6 * All rights reserved.
7 */
8 /*-
9 * Copyright (c) 1992, 1993
10 * The Regents of the University of California. All rights reserved.
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 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
41 /* aux.c */
42 char *savestr(const char *str);
43 char *save2str(const char *str, const char *old);
44 char *savecat(const char *s1, const char *s2);
45 void panic(const char *format, ...);
46 void holdint(void);
47 void relseint(void);
48 void touch(struct message *mp);
49 int is_dir(char *name);
50 int argcount(char **argv);
51 void i_strcpy(char *dest, const char *src, int size);
52 char *i_strdup(const char *src);
53 void makelow(char *cp);
54 int substr(const char *str, const char *sub);
55 char *colalign(const char *cp, int col, int fill);
56 void try_pager(FILE *fp);
57 int source(void *v);
58 int unstack(void);
59 void alter(char *name);
60 int blankline(char *linebuf);
61 int anyof(char *s1, char *s2);
62 int is_prefix(const char *as1, const char *as2);
63 char *last_at_before_slash(const char *sp);
64 enum protocol which_protocol(const char *name);
65 const char *protfile(const char *xcp);
66 char *protbase(const char *cp);
67 int disconnected(const char *file);
68 unsigned pjw(const char *cp);
69 long nextprime(long n);
70 char *strenc(const char *cp);
71 char *strdec(const char *cp);
72 #ifdef USE_MD5
73 char *md5tohex(const void *vp);
74 char *cram_md5_string(const char *user, const char *pass, const char *b64);
75 #endif
76 char *getuser(void);
77 char *getpassword(struct termios *otio, int *reset_tio, const char *query);
78 void transflags(struct message *omessage, long omsgCount, int transparent);
79 char *getrandstring(size_t length);
80 void out_of_memory(void);
81 void *smalloc(size_t s);
82 void *srealloc(void *v, size_t s);
83 void *scalloc(size_t nmemb, size_t size);
84 char *sstpcpy(char *dst, const char *src);
85 char *sstrdup(const char *cp);
86 enum okay makedir(const char *name);
87 enum okay cwget(struct cw *cw);
88 enum okay cwret(struct cw *cw);
89 void cwrelse(struct cw *cw);
90 void makeprint(struct str *in, struct str *out);
91 char *prstr(const char *s);
92 int prout(const char *s, size_t sz, FILE *fp);
93 int putuc(int u, int c, FILE *fp);
94 int asccasecmp(const char *s1, const char *s2);
95 int ascncasecmp(const char *s1, const char *s2, size_t sz);
96 char *asccasestr(const char *haystack, const char *xneedle);
97 /* base64.c */
98 char *strtob64(const char *p);
99 char *memtob64(const void *vp, size_t isz);
100 size_t mime_write_tob64(struct str *in, FILE *fo, int is_header);
101 void mime_fromb64(struct str *in, struct str *out, int is_text);
102 void mime_fromb64_b(struct str *in, struct str *out, int is_text, FILE *f);
103 /* cache.c */
104 enum okay getcache1(struct mailbox *mp, struct message *m,
105 enum needspec need, int setflags);
106 enum okay getcache(struct mailbox *mp, struct message *m, enum needspec need);
107 void putcache(struct mailbox *mp, struct message *m);
108 void initcache(struct mailbox *mp);
109 void purgecache(struct mailbox *mp, struct message *m, long mc);
110 void delcache(struct mailbox *mp, struct message *m);
111 enum okay cache_setptr(int transparent);
112 enum okay cache_list(struct mailbox *mp, const char *base, int strip, FILE *fp);
113 enum okay cache_remove(const char *name);
114 enum okay cache_rename(const char *old, const char *new);
115 unsigned long cached_uidvalidity(struct mailbox *mp);
116 FILE *cache_queue(struct mailbox *mp);
117 enum okay cache_dequeue(struct mailbox *mp);
118 /* cmd1.c */
119 char *get_pager(void);
120 int headers(void *v);
121 int scroll(void *v);
122 int Scroll(void *v);
123 int screensize(void);
124 int from(void *v);
125 void printhead(int mesg, FILE *f, int threaded);
126 int pdot(void *v);
127 int pcmdlist(void *v);
128 char *laststring(char *linebuf, int *flag, int strip);
129 int more(void *v);
130 int More(void *v);
131 int type(void *v);
132 int Type(void *v);
133 int show(void *v);
134 int pipecmd(void *v);
135 int Pipecmd(void *v);
136 int top(void *v);
137 int stouch(void *v);
138 int mboxit(void *v);
139 int folders(void *v);
140 /* cmd2.c */
141 int next(void *v);
142 int save(void *v);
143 int Save(void *v);
144 int copycmd(void *v);
145 int Copycmd(void *v);
146 int cmove(void *v);
147 int cMove(void *v);
148 int cdecrypt(void *v);
149 int cDecrypt(void *v);
150 int cwrite(void *v);
151 int delete(void *v);
152 int deltype(void *v);
153 int undeletecmd(void *v);
154 int retfield(void *v);
155 int igfield(void *v);
156 int saveretfield(void *v);
157 int saveigfield(void *v);
158 int fwdretfield(void *v);
159 int fwdigfield(void *v);
160 int unignore(void *v);
161 int unretain(void *v);
162 int unsaveignore(void *v);
163 int unsaveretain(void *v);
164 int unfwdignore(void *v);
165 int unfwdretain(void *v);
166 /* cmd3.c */
167 int shell(void *v);
168 int dosh(void *v);
169 int help(void *v);
170 int schdir(void *v);
171 int respond(void *v);
172 int respondall(void *v);
173 int respondsender(void *v);
174 int followup(void *v);
175 int followupall(void *v);
176 int followupsender(void *v);
177 int preserve(void *v);
178 int unread(void *v);
179 int seen(void *v);
180 int messize(void *v);
181 int rexit(void *v);
182 int set(void *v);
183 int unset(void *v);
184 int group(void *v);
185 int ungroup(void *v);
186 int cfile(void *v);
187 int echo(void *v);
188 int Respond(void *v);
189 int Followup(void *v);
190 int forwardcmd(void *v);
191 int Forwardcmd(void *v);
192 int ifcmd(void *v);
193 int elsecmd(void *v);
194 int endifcmd(void *v);
195 int alternates(void *v);
196 int resendcmd(void *v);
197 int Resendcmd(void *v);
198 int newmail(void *v);
199 int shortcut(void *v);
200 struct shortcut *get_shortcut(const char *str);
201 int unshortcut(void *v);
202 struct oldaccount *get_oldaccount(const char *name);
203 int account(void *v);
204 int cflag(void *v);
205 int cunflag(void *v);
206 int canswered(void *v);
207 int cunanswered(void *v);
208 int cdraft(void *v);
209 int cundraft(void *v);
210 int ckill(void *v);
211 int cunkill(void *v);
212 int cscore(void *v);
213 int cnoop(void *v);
214 int cremove(void *v);
215 int crename(void *v);
216 /* cmdtab.c */
217 /* collect.c */
218 struct attachment *edit_attachments(struct attachment *attach);
219 struct attachment *add_attachment(struct attachment *attach, char *file,
220 int expand_file);
221 FILE *collect(struct header *hp, int printheaders, struct message *mp,
222 char *quotefile, int doprefix, int tflag);
223 void savedeadletter(FILE *fp);
224 /* dotlock.c */
225 int fcntl_lock(int fd, int type);
226 int dot_lock(const char *fname, int fd, int pollinterval, FILE *fp,
227 const char *msg);
228 void dot_unlock(const char *fname);
229 /* edit.c */
230 int editor(void *v);
231 int visual(void *v);
232 FILE *run_editor(FILE *fp, off_t size, int type, int readonly,
233 struct header *hp, struct message *mp, enum sendaction action,
234 sighandler_type oldint);
235 /* fio.c */
236 void setptr(FILE *ibuf, off_t offset);
237 int putline(FILE *obuf, char *linebuf, size_t count);
238 #define readline(a, b, c) readline_restart(a, b, c, 0)
239 int readline_restart(FILE *ibuf, char **linebuf, size_t *linesize, size_t n);
240 FILE *setinput(struct mailbox *mp, struct message *m, enum needspec need);
241 struct message *setdot(struct message *mp);
242 int rm(char *name);
243 void holdsigs(void);
244 void relsesigs(void);
245 off_t fsize(FILE *iob);
246 char *expand(char *name);
247 int getfold(char *name, int size);
248 char *getdeadletter(void);
249 char *fgetline(char **line, size_t *linesize, size_t *count,
250 size_t *llen, FILE *fp, int appendnl);
251 void newline_appended(void);
252 enum okay get_body(struct message *mp);
253 int sclose(struct sock *sp);
254 enum okay swrite(struct sock *sp, const char *data);
255 enum okay swrite1(struct sock *sp, const char *data, int sz, int use_buffer);
256 int sgetline(char **line, size_t *linesize, size_t *linelen, struct sock *sp);
257 enum okay sopen(const char *xserver, struct sock *sp, int use_ssl,
258 const char *uhp, const char *portstr, int verbose);
259 /* getname.c */
260 char *getname(int uid);
261 int getuserid(char *name);
262 /* getopt.c */
263 int getopt(int argc, char *const argv[], const char *optstring);
264 /* head.c */
265 int is_head(char *linebuf, size_t linelen);
266 void parse(char *line, size_t linelen, struct headline *hl, char *pbuf);
267 void extract_header(FILE *fp, struct header *hp);
268 #define hfield(a, b) hfield_mult(a, b, 1)
269 char *hfield_mult(char *field, struct message *mp, int mult);
270 char *thisfield(const char *linebuf, const char *field);
271 char *nameof(struct message *mp, int reptype);
272 char *skip_comment(const char *cp);
273 char *routeaddr(const char *name);
274 char *skin(char *name);
275 char *realname(char *name);
276 char *name1(struct message *mp, int reptype);
277 int msgidcmp(const char *s1, const char *s2);
278 int is_ign(char *field, size_t fieldlen, struct ignoretab ignore[2]);
279 int member(char *realfield, struct ignoretab *table);
280 char *fakefrom(struct message *mp);
281 char *fakedate(time_t t);
282 char *nexttoken(char *cp);
283 time_t unixtime(char *from);
284 time_t rfctime(char *date);
285 time_t combinetime(int year, int month, int day,
286 int hour, int minute, int second);
287 void substdate(struct message *m);
288 int check_from_and_sender(struct name *fromfield, struct name *senderfield);
289 char *getsender(struct message *m);
290 /* imap.c */
291 enum okay imap_noop(void);
292 enum okay imap_select(struct mailbox *mp, off_t *size, int *count,
293 const char *mbx);
294 int imap_setfile(const char *xserver, int newmail, int isedit);
295 enum okay imap_header(struct message *m);
296 enum okay imap_body(struct message *m);
297 void imap_getheaders(int bot, int top);
298 void imap_quit(void);
299 enum okay imap_undelete(struct message *m, int n);
300 enum okay imap_unread(struct message *m, int n);
301 int imap_imap(void *vp);
302 int imap_newmail(int autoinc);
303 enum okay imap_append(const char *xserver, FILE *fp);
304 void imap_folders(const char *name, int strip);
305 enum okay imap_copy(struct message *m, int n, const char *name);
306 enum okay imap_search1(const char *spec, int f);
307 int imap_thisaccount(const char *cp);
308 enum okay imap_remove(const char *name);
309 enum okay imap_rename(const char *old, const char *new);
310 enum okay imap_dequeue(struct mailbox *mp, FILE *fp);
311 int cconnect(void *vp);
312 int cdisconnect(void *vp);
313 int ccache(void *vp);
314 time_t imap_read_date_time(const char *cp);
315 time_t imap_read_date(const char *cp);
316 const char *imap_make_date_time(time_t t);
317 char *imap_quotestr(const char *s);
318 char *imap_unquotestr(const char *s);
319 /* imap_gssapi.c */
320 /* imap_search.c */
321 enum okay imap_search(const char *spec, int f);
322 /* junk.c */
323 int cgood(void *v);
324 int cjunk(void *v);
325 int cungood(void *v);
326 int cunjunk(void *v);
327 int cclassify(void *v);
328 int cprobability(void *v);
329 /* lex.c */
330 int setfile(char *name, int newmail);
331 int newmailinfo(int omsgCount);
332 void commands(void);
333 int execute(char *linebuf, int contxt, size_t linesize);
334 void setmsize(int sz);
335 void onintr(int s);
336 void announce(int printheaders);
337 int newfileinfo(void);
338 int getmdot(int newmail);
339 int pversion(void *v);
340 void load(char *name);
341 void initbox(const char *name);
342 /* list.c */
343 int getmsglist(char *buf, int *vector, int flags);
344 int getrawlist(const char *line, size_t linesize,
345 char **argv, int argc, int echolist);
346 int first(int f, int m);
347 void mark(int mesg, int f);
348 /* lzw.c */
349 int zwrite(void *cookie, const char *wbp, int num);
350 int zfree(void *cookie);
351 int zread(void *cookie, char *rbp, int num);
352 void *zalloc(FILE *fp);
353 /* macro.c */
354 int cdefine(void *v);
355 int define1(const char *name, int account);
356 int cundef(void *v);
357 int ccall(void *v);
358 int callaccount(const char *name);
359 int callhook(const char *name, int newmail);
360 int listaccounts(FILE *fp);
361 int cdefines(void *v);
362 void delaccount(const char *name);
363 /* maildir.c */
364 int maildir_setfile(const char *name, int newmail, int isedit);
365 void maildir_quit(void);
366 enum okay maildir_append(const char *name, FILE *fp);
367 enum okay maildir_remove(const char *name);
368 /* main.c */
369 int main(int argc, char *argv[]);
370 /* mime.c */
371 int mime_name_invalid(struct name *np, int putmsg);
372 struct name *checkaddrs(struct name *np);
373 char *gettcharset(void);
374 char *need_hdrconv(struct header *hp, enum gfield w);
375 #ifdef HAVE_ICONV
376 iconv_t iconv_open_ft(const char *tocode, const char *fromcode);
377 size_t iconv_ft(iconv_t cd, char **inb, size_t *inbleft,
378 char **outb, size_t *outbleft, int tolerant);
379 #endif /* HAVE_ICONV */
380 enum mimeenc mime_getenc(char *h);
381 int mime_getcontent(char *h);
382 char *mime_getparam(char *param, char *h);
383 char *mime_getboundary(char *h);
384 char *mime_filecontent(char *name);
385 int get_mime_convert(FILE *fp, char **contenttype, char **charset,
386 enum mimeclean *isclean, int dosign);
387 void mime_fromhdr(struct str *in, struct str *out, enum tdflags flags);
388 char *mime_fromaddr(char *name);
389 size_t prefixwrite(void *ptr, size_t size, size_t nmemb, FILE *f,
390 char *prefix, size_t prefixlen);
391 size_t mime_write(void *ptr, size_t size, FILE *f,
392 enum conversion convert, enum tdflags dflags,
393 char *prefix, size_t prefixlen,
394 char **rest, size_t *restsize);
395 /* names.c */
396 struct name *nalloc(char *str, enum gfield ntype);
397 struct name *ndup(struct name *np, enum gfield addtype);
398 struct name *extract(char *line, enum gfield ntype);
399 struct name *sextract(char *line, enum gfield ntype);
400 char *detract(struct name *np, enum gfield ntype);
401 struct name *outof(struct name *names, FILE *fo, struct header *hp);
402 int is_fileaddr(char *name);
403 struct name *usermap(struct name *names);
404 struct name *cat(struct name *n1, struct name *n2);
405 char **unpack(struct name *np);
406 struct name *elide(struct name *names);
407 int count(struct name *np);
408 struct name *delete_alternates(struct name *np);
409 int is_myname(char *name);
410 /* nss.c */
411 #ifdef USE_NSS
412 enum okay ssl_open(const char *server, struct sock *sp, const char *uhp);
413 void nss_gen_err(const char *fmt, ...);
414 #endif /* USE_NSS */
415 /* openssl.c */
416 #ifdef USE_OPENSSL
417 enum okay ssl_open(const char *server, struct sock *sp, const char *uhp);
418 void ssl_gen_err(const char *fmt, ...);
419 #endif /* USE_OPENSSL */
420 int cverify(void *vp);
421 FILE *smime_sign(FILE *ip, struct header *);
422 FILE *smime_encrypt(FILE *ip, const char *certfile, const char *to);
423 struct message *smime_decrypt(struct message *m, const char *to,
424 const char *cc, int signcall);
425 enum okay smime_certsave(struct message *m, int n, FILE *op);
426 /* pop3.c */
427 enum okay pop3_noop(void);
428 int pop3_setfile(const char *server, int newmail, int isedit);
429 enum okay pop3_header(struct message *m);
430 enum okay pop3_body(struct message *m);
431 void pop3_quit(void);
432 /* popen.c */
433 sighandler_type safe_signal(int signum, sighandler_type handler);
434 FILE *safe_fopen(const char *file, const char *mode, int *omode);
435 FILE *Fopen(const char *file, const char *mode);
436 FILE *Fdopen(int fd, const char *mode);
437 int Fclose(FILE *fp);
438 FILE *Zopen(const char *file, const char *mode, int *compression);
439 FILE *Popen(const char *cmd, const char *mode, const char *shell, int newfd1);
440 int Pclose(FILE *ptr);
441 void close_all_files(void);
442 int run_command(char *cmd, sigset_t *mask, int infd, int outfd,
443 char *a0, char *a1, char *a2);
444 int start_command(const char *cmd, sigset_t *mask, int infd, int outfd,
445 const char *a0, const char *a1, const char *a2);
446 void prepare_child(sigset_t *nset, int infd, int outfd);
447 void sigchild(int signo);
448 void free_child(int pid);
449 int wait_child(int pid);
450 /* quit.c */
451 int quitcmd(void *v);
452 void quit(void);
453 int holdbits(void);
454 enum okay makembox(void);
455 int savequitflags(void);
456 void restorequitflags(int);
457 /* send.c */
458 char *foldergets(char **s, size_t *size, size_t *count, size_t *llen,
459 FILE *stream);
460 #undef send
461 #define send(a, b, c, d, e, f) xsend(a, b, c, d, e, f)
462 int send(struct message *mp, FILE *obuf, struct ignoretab *doign,
463 char *prefix, enum sendaction action, off_t *stats);
464 /* sendout.c */
465 char *makeboundary(void);
466 int mail(struct name *to, struct name *cc, struct name *bcc,
467 struct name *smopts, char *subject, struct attachment *attach,
468 char *quotefile, int recipient_record, int tflag, int Eflag);
469 int sendmail(void *v);
470 int Sendmail(void *v);
471 enum okay mail1(struct header *hp, int printheaders, struct message *quote,
472 char *quotefile, int recipient_record, int doprefix, int tflag,
473 int Eflag);
474 int mkdate(FILE *fo, const char *field);
475 int puthead(struct header *hp, FILE *fo, enum gfield w,
476 enum sendaction action, enum conversion convert,
477 char *contenttype, char *charset);
478 enum okay resend_msg(struct message *mp, struct name *to, int add_resent);
479 /* smtp.c */
480 char *nodename(int mayoverride);
481 char *myaddrs(struct header *hp);
482 char *myorigin(struct header *hp);
483 char *smtp_auth_var(const char *type, const char *addr);
484 int smtp_mta(char *server, struct name *to, FILE *fi, struct header *hp,
485 const char *user, const char *password, const char *skinned);
486 /* ssl.c */
487 void ssl_set_vrfy_level(const char *uhp);
488 enum okay ssl_vrfy_decide(void);
489 char *ssl_method_string(const char *uhp);
490 enum okay smime_split(FILE *ip, FILE **hp, FILE **bp, long xcount, int keep);
491 FILE *smime_sign_assemble(FILE *hp, FILE *bp, FILE *sp);
492 FILE *smime_encrypt_assemble(FILE *hp, FILE *yp);
493 struct message *smime_decrypt_assemble(struct message *m, FILE *hp, FILE *bp);
494 int ccertsave(void *v);
495 enum okay rfc2595_hostname_match(const char *host, const char *pattern);
496 /* strings.c */
497 void *salloc(size_t size);
498 void *csalloc(size_t nmemb, size_t size);
499 void sreset(void);
500 void spreserve(void);
501 /* temp.c */
502 FILE *Ftemp(char **fn, char *prefix, char *mode, int bits, int register_file);
503 void Ftfree(char **fn);
504 void tinit(void);
505 /* thread.c */
506 int thread(void *vp);
507 int unthread(void *vp);
508 struct message *next_in_thread(struct message *mp);
509 struct message *prev_in_thread(struct message *mp);
510 struct message *this_in_thread(struct message *mp, long n);
511 int sort(void *vp);
512 int ccollapse(void *v);
513 int cuncollapse(void *v);
514 void uncollapse1(struct message *m, int always);
515 /* tty.c */
516 int grabh(struct header *hp, enum gfield gflags, int subjfirst);
517 char *readtty(char *prefix, char *string);
518 int yorn(char *msg);
519 /* v7.local.c */
520 void findmail(char *user, int force, char *buf, int size);
521 void demail(void);
522 char *username(void);
523 /* vars.c */
524 void assign(const char *name, const char *value);
525 char *vcopy(const char *str);
526 char *value(const char *name);
527 struct grouphead *findgroup(char *name);
528 void printgroup(char *name);
529 int hash(const char *name);
530 int unset_internal(const char *name);
531 void remove_group(const char *name);