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