]> Pileus Git - ~andy/fetchmail/blob - fetchmail.h
Various cleanup patches.
[~andy/fetchmail] / fetchmail.h
1 /*
2  * For license terms, see the file COPYING in this directory.
3  */
4
5 /* We need this for HAVE_STDARG_H, etc */
6 #include "config.h"
7
8 /* constants designating the various supported protocols */
9 #define         P_AUTO          1
10 #define         P_POP2          2
11 #define         P_POP3          3
12 #define         P_APOP          4
13 #define         P_RPOP          5
14 #define         P_IMAP          6
15 #define         P_ETRN          7
16 #define         P_ODMR          8
17
18 #if INET6_ENABLE
19 #define         SMTP_PORT       "smtp"
20 #define         KPOP_PORT       "kpop"
21 #else /* INET6_ENABLE */
22 #define         SMTP_PORT       25
23 #define         KPOP_PORT       1109
24 #endif /* INET6_ENABLE */
25
26 #ifdef SSL_ENABLE
27 #define         SIMAP_PORT      993
28 #define         SPOP3_PORT      995
29 #endif
30
31 /* 
32  * We need to distinguish between mailbox and mailbag protocols.
33  * Under a mailbox protocol wwe're pulling mail for a speecific user.
34  * Under a mailbag protocol we're fetching mail for an entire domain.
35  */
36 #define MAILBOX_PROTOCOL(ctl)   ((ctl)->server.protocol < P_ETRN)
37
38 /* authentication types */
39 #define         A_ANY           0       /* use the first method that works */
40 #define         A_PASSWORD      1       /* password authentication */
41 #define         A_NTLM          2       /* Microsoft NTLM protocol */
42 #define         A_CRAM_MD5      3       /* CRAM-MD5 shrouding (RFC2195) */
43 #define         A_OTP           4       /* One-time password (RFC1508) */
44 #define         A_KERBEROS_V4   5       /* authenticate w/ Kerberos V4 */
45 #define         A_KERBEROS_V5   6       /* authenticate w/ Kerberos V5 */
46 #define         A_GSSAPI        7       /* authenticate with GSSAPI */
47 #define         A_SSH           8       /* authentication at session level */
48
49 /* some protocols (KERBEROS, GSSAPI, SSH) don't require a password */
50 #define NO_PASSWORD(ctl)        ((ctl)->server.authenticate > A_OTP || (ctl)->server.protocol == P_ETRN)
51
52 /*
53  * Definitions for buffer sizes.  We get little help on setting maxima
54  * from IMAP RFCs up to 2060, so these are mostly from POP3.
55  */
56 #define         HOSTLEN         635     /* max hostname length (RFC1123) */
57 #define         POPBUFSIZE      512     /* max length of response (RFC1939) */
58 #define         IDLEN           128     /* max length of UID (RFC1939) */
59
60 /* per RFC1939 this should be 40, but Microsoft Exchange ignores that limit */
61 #define         USERNAMELEN     128     /* max POP3 arg length */
62
63 /* clear a netBSD kernel parameter out of the way */ 
64 #undef          MSGBUFSIZE
65
66 /*
67  * The RFC822 limit on message line size is just 998.  But
68  * make this *way* oversized; idiot DOS-world mailers that
69  * don't line-wrap properly often ship entire paragraphs as
70  * lines.
71  */
72 #define         MSGBUFSIZE      8192
73
74 #define         NAMELEN         64      /* max username length */
75 #define         PASSWORDLEN     64      /* max password length */
76 #define         DIGESTLEN       33      /* length of MD5 digest */
77
78 /* exit code values */
79 #define         PS_SUCCESS      0       /* successful receipt of messages */
80 #define         PS_NOMAIL       1       /* no mail available */
81 #define         PS_SOCKET       2       /* socket I/O woes */
82 #define         PS_AUTHFAIL     3       /* user authorization failed */
83 #define         PS_PROTOCOL     4       /* protocol violation */
84 #define         PS_SYNTAX       5       /* command-line syntax error */
85 #define         PS_IOERR        6       /* bad permissions on rc file */
86 #define         PS_ERROR        7       /* protocol error */
87 #define         PS_EXCLUDE      8       /* client-side exclusion error */
88 #define         PS_LOCKBUSY     9       /* server responded lock busy */
89 #define         PS_SMTP         10      /* SMTP error */
90 #define         PS_DNS          11      /* fatal DNS error */
91 #define         PS_BSMTP        12      /* output batch could not be opened */
92 #define         PS_MAXFETCH     13      /* poll ended by fetch limit */
93 #define         PS_SERVBUSY     14      /* server is busy */
94 /* leave space for more codes */
95 #define         PS_UNDEFINED    23      /* something I hadn't thought of */
96 #define         PS_TRANSIENT    24      /* transient failure (internal use) */
97 #define         PS_REFUSED      25      /* mail refused (internal use) */
98 #define         PS_RETAINED     26      /* message retained (internal use) */
99 #define         PS_TRUNCATED    27      /* headers incomplete (internal use) */
100
101 /* output noise level */
102 #define         O_SILENT        0       /* mute, max squelch, etc. */
103 #define         O_NORMAL        1       /* user-friendly */
104 #define         O_VERBOSE       2       /* chatty */
105 #define         O_DEBUG         3       /* prolix */
106 #define         O_MONITOR       O_VERBOSE
107
108 #define         SIZETICKER      1024    /* print 1 dot per this many bytes */
109
110 /*
111  * We #ifdef this and use flag rather than bool
112  * to avoid a type clash with curses.h
113  */
114 #ifndef TRUE
115 #define FALSE   0
116 #define TRUE    1
117 #endif /* TRUE */
118 typedef char    flag;
119
120 /* we need to use zero as a flag-uninitialized value */
121 #define FLAG_TRUE       2
122 #define FLAG_FALSE      1
123
124 struct runctl
125 {
126     char        *logfile;
127     char        *idfile;
128     int         poll_interval;
129     char        *postmaster;
130     flag        bouncemail;
131     flag        spambounce;
132     char        *properties;
133     flag        use_syslog;
134     flag        invisible;
135     flag        showdots;
136 };
137
138 struct idlist
139 {
140     unsigned char *id;
141     union
142     {
143         struct
144         {
145             short       num;
146             flag        mark;           /* UID-index information */
147 #define UID_UNSEEN      0               /* hasn't been seen */
148 #define UID_SEEN        1               /* seen, but not deleted */
149 #define UID_DELETED     2               /* this message has been deleted */
150 #define UID_EXPUNGED    3               /* this message has been expunged */ 
151         }
152         status;
153         unsigned char *id2;
154     } val;
155     struct idlist *next;
156 };
157
158 struct query;
159
160 struct method           /* describe methods for protocol state machine */
161 {
162     const char *name;           /* protocol name */
163 #if INET6_ENABLE
164     const char *service;
165     const char *sslservice;
166 #else /* INET6_ENABLE */
167     int port;                   /* service port */
168     int sslport;                /* service port for ssl */
169 #endif /* INET6_ENABLE */
170     flag tagged;                /* if true, generate & expect command tags */
171     flag delimited;             /* if true, accept "." message delimiter */
172     int (*parse_response)(int, char *);
173                                 /* response_parsing function */
174     int (*getauth)(int, struct query *, char *);
175                                 /* authorization fetcher */
176     int (*getrange)(int, struct query *, const char *, int *, int *, int *);
177                                 /* get message range to fetch */
178     int (*getsizes)(int, int, int *);
179                                 /* get sizes of messages */
180     int (*is_old)(int, struct query *, int);
181                                 /* check for old message */
182     int (*fetch_headers)(int, struct query *, int, int *);
183                                 /* fetch FROM headera given message */
184     int (*fetch_body)(int, struct query *, int, int *);
185                                 /* fetch a given message */
186     int (*trail)(int, struct query *, int);
187                                 /* eat trailer of a message */
188     int (*delete)(int, struct query *, int);
189                                 /* delete method */
190     int (*logout_cmd)(int, struct query *);
191                                 /* logout command */
192     flag retry;                 /* can getrange poll for new messages? */
193 };
194
195 struct hostdata         /* shared among all user connections to given server */
196 {
197     /* rc file data */
198     char *pollname;                     /* poll label of host */
199     char *via;                          /* "true" server name if non-NULL */
200     struct idlist *akalist;             /* server name first, then akas */
201     struct idlist *localdomains;        /* list of pass-through domains */
202     int protocol;                       /* protocol type */
203 #if INET6_ENABLE
204     char *service;                      /* IPv6 service name */
205     void *netsec;                       /* IPv6 security request */
206 #else /* INET6_ENABLE */
207     int port;                           /* TCP/IP service port number */
208 #endif /* INET6_ENABLE */
209     int interval;                       /* # cycles to skip between polls */
210     int authenticate;                   /* authentication mode to try */
211     int timeout;                        /* inactivity timout in seconds */
212     char *envelope;                     /* envelope address list header */
213     int envskip;                        /* skip to numbered envelope header */
214     char *qvirtual;                     /* prefix removed from local user id */
215     flag skip;                          /* suppress poll in implicit mode? */
216     flag dns;                           /* do DNS lookup on multidrop? */
217     flag uidl;                          /* use RFC1725 UIDLs? */
218 #ifdef SDPS_ENABLE
219     flag sdps;                          /* use Demon Internet SDPS *ENV */
220 #endif /* SDPS_ENABLE */
221     flag checkalias;                    /* resolve aliases by comparing IPs? */
222     char *principal;                    /* Kerberos principal for mail service */
223     char *esmtp_name, *esmtp_password;  /* ESMTP AUTH information */
224
225 #if defined(linux) || defined(__FreeBSD__)
226     char *interface;
227     char *monitor;
228     int  monitor_io;
229     struct interface_pair_s *interface_pair;
230 #endif /* linux */
231
232     char *plugin,*plugout;
233
234     /* computed for internal use */
235     const struct method *base_protocol; /* relevant protocol method table */
236     int poll_count;                     /* count of polls so far */
237     char *queryname;                    /* name to attempt DNS lookup on */
238     char *truename;                     /* "true name" of server host */
239     char *trueaddr;                     /* IP address of truename, as char */
240     struct hostdata *lead_server;       /* ptr to lead query for this server */
241     int esmtp_options;
242 };
243
244 struct query
245 {
246     /* mailserver connection controls */
247     struct hostdata server;
248
249     /* per-user data */
250     struct idlist *localnames;  /* including calling user's name */
251     int wildcard;               /* should unmatched names be passed through */
252     char *remotename;           /* remote login name to use */
253     char *password;             /* remote password to use */
254     struct idlist *mailboxes;   /* list of mailboxes to check */
255
256     /* per-forwarding-target data */
257     struct idlist *smtphunt;    /* list of SMTP hosts to try forwarding to */
258     struct idlist *domainlist;  /* domainlist to fetch from */
259     char *smtpaddress;          /* address to force in RCPT TO */ 
260     char *smtpname;             /* full RCPT TO name, including domain */
261     struct idlist *antispam;    /* list of listener's antispam response */
262     char *mda;                  /* local MDA to pass mail to */
263     char *bsmtp;                /* BSMTP output file */
264     char listener;              /* what's the listener's wire protocol? */
265 #define SMTP_MODE       'S'
266 #define LMTP_MODE       'L'
267     char *preconnect;           /* pre-connection command to execute */
268     char *postconnect;          /* post-connection command to execute */
269
270     /* per-user control flags */
271     flag keep;                  /* if TRUE, leave messages undeleted */
272     flag fetchall;              /* if TRUE, fetch all (not just unseen) */
273     flag flush;                 /* if TRUE, delete messages already seen */
274     flag rewrite;               /* if TRUE, canonicalize recipient addresses */
275     flag stripcr;               /* if TRUE, strip CRs in text */
276     flag forcecr;               /* if TRUE, force CRs before LFs in text */
277     flag pass8bits;             /* if TRUE, ignore Content-Transfer-Encoding */
278     flag dropstatus;            /* if TRUE, drop Status lines in mail */
279     flag dropdelivered;         /* if TRUE, drop Delivered-To lines in mail */
280     flag mimedecode;            /* if TRUE, decode MIME-armored messages */
281     flag idle;                  /* if TRUE, idle after each poll */
282     int limit;                  /* limit size of retrieved messages */
283     int warnings;               /* size warning interval */
284     int fetchlimit;             /* max # msgs to get in single poll */
285     int batchlimit;             /* max # msgs to pass in single SMTP session */
286     int expunge;                /* max # msgs to pass between expunges */
287     flag use_ssl;               /* use SSL encrypted session */
288     char *sslkey;               /* optional SSL private key file */
289     char *sslcert;              /* optional SSL certificate file */
290         char *sslproto;         /* force usage of protocol (ssl2|ssl3|tls1) - defaults to ssl23 */
291     char *sslcertpath;          /* Trusted certificate directory for checking the server cert */
292     flag sslcertck;             /* Strictly check the server cert. */
293     char *sslfingerprint;       /* Fingerprint to check against */
294     char *properties;           /* passthrough properties for extensions */
295     flag tracepolls;            /* if TRUE, add poll trace info to Received */
296
297     /* internal use -- per-poll state */
298     flag active;                /* should we actually poll this server? */
299     const char *destaddr;       /* destination host for this query */
300     int errcount;               /* count transient errors in last pass */
301     int authfailcount;          /* count of authorization failures */
302     int wehaveauthed;           /* We've managed to logon at least once! */
303     int wehavesentauthnote;     /* We've sent an authorization failure note */
304     int wedged;                 /* wedged by auth failures or timeouts? */
305     char *smtphost;             /* actual SMTP host we connected to */
306     int smtp_socket;            /* socket descriptor for SMTP connection */
307     unsigned int uid;           /* UID of user to deliver to */
308     struct idlist *skipped;     /* messages skipped on the mail server */
309     struct idlist *oldsaved, *newsaved;
310     char *lastid;               /* last Message-ID seen on this connection */
311     char *thisid;               /* Message-ID of current message */
312
313     /* internal use -- per-message state */
314     int mimemsg;                /* bitmask indicating MIME body-type */
315     char digest [DIGESTLEN];    /* md5 digest buffer */
316
317     /* internal use -- housekeeping */
318     struct query *next;         /* next query control block in chain */
319 };
320
321 struct msgblk                   /* message header parsed for open_sink() */
322 {
323     char                *headers;       /* raw message headers */
324     struct idlist       *recipients;    /* addressees */
325     char                return_path[HOSTLEN + USERNAMELEN + 4]; 
326     int                 msglen;
327     int                 reallen;
328 };
329
330
331 /*
332  * Numeric option handling.  Numeric option value of zero actually means
333  * it's unspecified.  Value less than zero is zero.  The reason for this
334  * screwy encoding is so we can zero out an option block in order to set the
335  * numeric flags in it to unspecified.
336  */
337 #define NUM_VALUE_IN(n)         (((n) == 0) ? -1 : (n))
338 #define NUM_VALUE_OUT(n)        (((n) < 0) ? 0 : (n))
339 #define NUM_NONZERO(n)          ((n) > 0)
340 #define NUM_ZERO(n)             ((n) < 0)
341 #define NUM_SPECIFIED(n)        ((n) != 0)
342
343 #define MULTIDROP(ctl)  (ctl->wildcard || \
344                                 ((ctl)->localnames && (ctl)->localnames->next))
345
346 /*
347  * Note: tags are generated with an a%04d format from a 1-origin
348  * integer sequence number.  Length 4 permits transaction numbers
349  * up to 9999, so we force rollover with % 10000.  There's no special
350  * reason for this format other than to look like the exmples in the
351  * IMAP RFCs.
352  */
353 #define TAGLEN  6               /* 'a' + 4 digits + NUL */
354 extern char tag[TAGLEN];
355 #define TAGMOD  10000
356
357 /* list of hosts assembled from run control file and command line */
358 extern struct query cmd_opts, *querylist;
359
360 /* what's returned by envquery */
361 extern void envquery(int, char **);
362
363 /* controls the detail level of status/progress messages written to stderr */
364 extern int outlevel;            /* see the O_.* constants above */
365 extern int yydebug;             /* enable parse debugging */
366
367 /* these get computed */
368 extern int batchcount;          /* count of messages sent in current batch */
369 extern flag peek_capable;       /* can we read msgs without setting seen? */
370
371 /* miscellaneous global controls */
372 extern struct runctl run;       /* global controls for this run */
373 extern flag nodetach;           /* if TRUE, don't detach daemon process */
374 extern flag quitmode;           /* if --quit was set */
375 extern flag check_only;         /* if --check was set */
376 extern char *rcfile;            /* path name of rc file */
377 extern int linelimit;           /* limit # lines retrieved per site */
378 extern flag versioninfo;        /* emit only version info */
379 extern char *user;              /* name of invoking user */
380 extern char *home;              /* home directory of invoking user */
381 extern char *fmhome;            /* fetchmail home directory */
382 extern int pass;                /* number of re-polling pass */
383 extern flag configdump;         /* dump control blocks as Python dictionary */
384 extern char *fetchmailhost;     /* either "localhost" or an FQDN */
385 extern int suppress_tags;       /* suppress tags in tagged protocols? */
386 extern char shroud[PASSWORDLEN];        /* string to shroud in debug output */
387 #ifdef SDPS_ENABLE
388 extern char *sdps_envfrom;
389 extern char *sdps_envto;
390 #endif /* SDPS_ENABLE */
391
392 /* prototypes for globally callable functions */
393
394 /* from /usr/include/sys/cdefs.h */
395 #if !defined __GNUC__ || __GNUC__ < 2
396 # define __attribute__(xyz)    /* Ignore. */
397 #endif
398
399 /* error.c: Error reporting */
400 #if defined(HAVE_STDARG_H)
401 void report_init(int foreground);
402 void report (FILE *fp, const char *format, ...)
403     __attribute__ ((format (printf, 2, 3)))
404     ;
405 void report_build (FILE *fp, const char *format, ...)
406     __attribute__ ((format (printf, 2, 3)))
407     ;
408 void report_complete (FILE *fp, const char *format, ...)
409     __attribute__ ((format (printf, 2, 3)))
410     ;
411 void report_at_line (FILE *fp, int, const char *, unsigned int, const char *, ...)
412     __attribute__ ((format (printf, 5, 6)))
413     ;
414 #else
415 void report ();
416 void report_build ();
417 void report_complete ();
418 void report_at_line ();
419 #endif
420
421 /* driver.c -- main driver loop */
422 void set_timeout(int);
423 int do_protocol(struct query *, const struct method *);
424
425 /* transact.c: transaction support */
426 void init_transact(const struct method *);
427 int readheaders(int sock,
428                        long fetchlen,
429                        long reallen,
430                        struct query *ctl,
431                 int num);
432 int readbody(int sock, struct query *ctl, flag forward, int len);
433 #if defined(HAVE_STDARG_H)
434 void gen_send(int sock, const char *, ... )
435     __attribute__ ((format (printf, 2, 3)))
436     ;
437 int gen_recv(int sock, char *buf, int size);
438 int gen_transact(int sock, const char *, ... )
439     __attribute__ ((format (printf, 2, 3)))
440     ;
441 #else
442 void gen_send();
443 int gen_recv();
444 int gen_transact();
445 #endif
446 extern struct msgblk msgblk;
447
448 /* lock.c: concurrency locking */
449 void lock_setup(void), lock_assert(void);
450 void lock_or_die(void), lock_release(void);
451 int lock_state(void);
452 void lock_dispose(void);
453
454 /* use these to track what was happening when the nonresponse timer fired */
455 #define GENERAL_WAIT    0       /* unknown wait type */
456 #define OPEN_WAIT       1       /* waiting from mailserver open */
457 #define SERVER_WAIT     2       /* waiting for mailserver response */
458 #define LISTENER_WAIT   3       /* waiting for listener initialization */
459 #define FORWARDING_WAIT 4       /* waiting for listener response */
460 extern int phase;
461
462 /* response hooks can use this to identify the query stage */
463 #define STAGE_GETAUTH   0
464 #define STAGE_GETRANGE  1
465 #define STAGE_GETSIZES  2
466 #define STAGE_FETCH     3
467 #define STAGE_IDLE      4
468 #define STAGE_LOGOUT    5
469 extern int stage;
470
471 extern int mytimeout;
472
473 /* mark values for name lists */
474 #define XMIT_ACCEPT     1       /* accepted; matches local domain or name */
475 #define XMIT_REJECT     2       /* rejected; no match */
476 #define XMIT_RCPTBAD    3       /* SMTP listener rejected the name */ 
477
478 /* idle.c */
479 int interruptible_idle(int interval);
480
481 /* sink.c: forwarding */
482 void smtp_close(struct query *, int);
483 int smtp_open(struct query *);
484 int stuffline(struct query *, char *);
485 int open_sink(struct query*, struct msgblk *, int*, int*);
486 void release_sink(struct query *);
487 int close_sink(struct query *, struct msgblk *, flag);
488 int open_warning_by_mail(struct query *, struct msgblk *);
489 #if defined(HAVE_STDARG_H)
490 void stuff_warning(struct query *, const char *, ... )
491     __attribute__ ((format (printf, 2, 3)))
492     ;
493 #else
494 void stuff_warning();
495 #endif
496 void close_warning_by_mail(struct query *, struct msgblk *);
497
498 /* rfc822.c: RFC822 header parsing */
499 unsigned char *reply_hack(unsigned char *, const unsigned char *);
500 unsigned char *nxtaddr(const unsigned char *);
501
502 /* uid.c: UID support */
503 void initialize_saved_lists(struct query *, const char *);
504 struct idlist *save_str(struct idlist **, const char *, flag);
505 void free_str_list(struct idlist **);
506 struct idlist *copy_str_list(struct idlist *idl);
507 void save_str_pair(struct idlist **, const char *, const char *);
508 void free_str_pair_list(struct idlist **);
509 int delete_str(struct idlist **, int);
510 int str_in_list(struct idlist **, const char *, const flag);
511 int str_nr_in_list(struct idlist **, const char *);
512 int str_nr_last_in_list(struct idlist **, const char *);
513 void str_set_mark( struct idlist **, const char *, const flag);
514 int count_list( struct idlist **idl );
515 char *str_from_nr_list( struct idlist **idl, int number );
516 char *str_find(struct idlist **, int);
517 char *idpair_find(struct idlist **, const char *);
518 void append_str_list(struct idlist **, struct idlist **);
519 void expunge_uids(struct query *);
520 void uid_swap_lists(struct query *);
521 void write_saved_lists(struct query *, const char *);
522
523 /* rcfile_y.y */
524 int prc_parse_file(const char *, const flag);
525 int prc_filecheck(const char *, const flag);
526
527 /* base64.c */
528 void to64frombits(unsigned char *, const unsigned char *, int);
529 int from64tobits(char *, const char *, int maxlen);
530
531 /* unmime.c */
532 /* Bit-mask returned by MimeBodyType */
533 #define MSG_IS_7BIT       0x01
534 #define MSG_IS_8BIT       0x02
535 #define MSG_NEEDS_DECODE  0x80
536 extern void UnMimeHeader(unsigned char *buf);
537 extern int  MimeBodyType(unsigned char *hdrs, int WantDecode);
538 extern int  UnMimeBodyline(unsigned char **buf, flag delimited, flag issoftline);
539
540 /* interface.c */
541 void interface_init(void);
542 void interface_parse(char *, struct hostdata *);
543 void interface_note_activity(struct hostdata *);
544 int interface_approve(struct hostdata *, flag domonitor);
545
546 /* xmalloc.c */
547 #if defined(HAVE_VOIDPOINTER)
548 #define XMALLOCTYPE void
549 #else
550 #define XMALLOCTYPE char
551 #endif
552 XMALLOCTYPE *xmalloc(int);
553 XMALLOCTYPE *xrealloc(XMALLOCTYPE *, int);
554 char *xstrdup(const char *);
555 #if defined(HAVE_ALLOCA_H)
556 #include <alloca.h>
557 #else
558 #ifdef _AIX
559  #pragma alloca
560 #endif
561 #endif
562 #define xalloca(ptr, t, n)      if (!(ptr = (t) alloca(n)))\
563        {report(stderr, GT_("alloca failed")); exit(PS_UNDEFINED);}
564 #if 0
565 /*
566  * This is a hack to help xgettext which cannot find strings in
567  * macro definitions like the one for xalloca above.
568  */
569 static char *dummy = gettext_noop("alloca failed");
570 #endif
571
572 /* protocol driver and methods */
573 int doPOP2 (struct query *); 
574 int doPOP3 (struct query *);
575 int doIMAP (struct query *);
576 int doETRN (struct query *);
577 int doODMR (struct query *);
578
579 /* authentication functions */
580 int do_cram_md5(int sock, char *command, struct query *ctl, char *strip);
581 int do_rfc1731(int sock, char *command, char *truename);
582 int do_gssauth(int sock, char *command, char *hostname, char *username);
583 int do_otp(int sock, char *command, struct query *ctl);
584
585 /* miscellanea */
586 struct query *hostalloc(struct query *); 
587 int parsecmdline (int, char **, struct runctl *, struct query *);
588 char *MD5Digest (unsigned char *);
589 void hmac_md5 (unsigned char *, size_t, unsigned char *, size_t, unsigned char *, size_t);
590 int POP3_auth_rpa(unsigned char *, unsigned char *, int socket);
591 void deal_with_sigchld(void);
592 int daemonize(const char *, void (*)(int));
593 char *fm_getpassword(char *);
594 void escapes(const char *, char *);
595 char *visbuf(const char *);
596 const char *showproto(int);
597 void dump_config(struct runctl *runp, struct query *querylist);
598 int is_host_alias(const char *, struct query *);
599 char *host_fqdn(void);
600 char *rfc822timestamp(void);
601 flag isafile(int);
602
603 void yyerror(const char *);
604 int yylex(void);
605
606 #ifdef __EMX__
607 void itimerthread(void*);
608 /* Have to include these first to avoid errors from redefining getcwd
609    and chdir.  They're re-include protected in EMX, so it's okay, I
610    guess.  */
611 #include <stdlib.h>
612 #include <unistd.h>
613 /* Redefine getcwd and chdir to get drive-letter support so we can
614    find all of our lock files and stuff. */
615 #define getcwd _getcwd2
616 #define chdir _chdir2
617 #endif /* _EMX_ */
618
619 # if HAVE_STRERROR
620 #  ifndef strerror              /* On some systems, strerror is a macro */
621 char *strerror ();
622 #  endif
623 # endif /* HAVE_STRERROR */
624
625 #define STRING_DISABLED (char *)-1
626 #define STRING_DUMMY    ""
627
628 #ifdef NeXT
629 #ifndef S_IXGRP
630 #define S_IXGRP 0000010
631 #endif
632 #endif
633
634 #ifdef FETCHMAIL_DEBUG
635 #define exit(e) do { \
636        FILE *out; \
637        out = fopen("/tmp/fetchmail.log", "a"); \
638        fprintf(out, \
639                "Exiting fetchmail from file %s, line %d with status %d\n", \
640                __FILE__, __LINE__, e); \
641        fclose(out); \
642        _exit(e); \
643        } while(0)
644 #endif /* FETCHMAIL_DEBUG */
645
646 /* fetchmail.h ends here */