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