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