1 /** \file fetchmail.h header file for fetchmail */
5 * For license terms, see the file COPYING in this directory.
11 #define _NETBSD_SOURCE 1
16 /* We need this for size_t */
17 #include <sys/types.h>
22 #include <sys/socket.h>
34 /* constants designating the various supported protocols */
42 #define SMTP_PORT "smtp"
43 #define SMTP_PORT_NUM 25
44 #define KPOP_PORT "kpop"
47 #define SIMAP_PORT 993
48 #define SPOP3_PORT 995
52 * We need to distinguish between mailbox and mailbag protocols.
53 * Under a mailbox protocol wwe're pulling mail for a speecific user.
54 * Under a mailbag protocol we're fetching mail for an entire domain.
56 #define MAILBOX_PROTOCOL(ctl) ((ctl)->server.protocol < P_ETRN)
58 /* authentication types */
59 #define A_ANY 0 /* use the first method that works */
60 #define A_PASSWORD 1 /* password authentication */
61 #define A_NTLM 2 /* Microsoft NTLM protocol */
62 #define A_CRAM_MD5 3 /* CRAM-MD5 shrouding (RFC2195) */
63 #define A_OTP 4 /* One-time password (RFC1508) */
64 #define A_KERBEROS_V5 6 /* authenticate w/ Kerberos V5 */
65 #define A_GSSAPI 7 /* authenticate with GSSAPI */
66 #define A_SSH 8 /* authentication at session level */
67 #define A_MSN 9 /* same as NTLM with keyword MSN */
68 #define A_EXTERNAL 10 /* external authentication (client cert) */
70 /* some protocols or authentication types (KERBEROS, GSSAPI, SSH) don't
71 * require a password */
72 #define NO_PASSWORD(ctl) \
73 ((ctl)->server.authenticate == A_OTP \
74 || (ctl)->server.authenticate == A_KERBEROS_V5 \
75 || (ctl)->server.authenticate == A_GSSAPI \
76 || (ctl)->server.authenticate == A_SSH \
77 || (ctl)->server.authenticate == A_EXTERNAL \
78 || (ctl)->server.protocol == P_ETRN)
81 * Definitions for buffer sizes. We get little help on setting maxima
82 * from IMAP RFCs up to 2060, so these are mostly from POP3.
84 #define HOSTLEN 635 /* max hostname length (RFC1123) */
85 #define POPBUFSIZE 512 /* max length of response (RFC1939) */
86 #define IDLEN 128 /* max length of UID (RFC1939) */
88 /* per RFC1939 this should be 40, but Microsoft Exchange ignores that limit */
89 #define USERNAMELEN 128 /* max POP3 arg length */
91 /* clear a netBSD kernel parameter out of the way */
95 * The RFC822 limit on message line size is just 998. But
96 * make this *way* oversized; idiot DOS-world mailers that
97 * don't line-wrap properly often ship entire paragraphs as
100 #define MSGBUFSIZE 8192
102 #define NAMELEN 64 /* max username length */
103 #define PASSWORDLEN 64 /* max password length */
104 #define DIGESTLEN 33 /* length of MD5 digest */
106 /* exit code values */
107 /* NOTE THAT PS_SUCCESS MUST ALWAYS BE 0 - SOME PARTS OF THE CODE
108 * RELY ON THIS VALUE! */
109 #define PS_SUCCESS 0 /* successful receipt of messages */
110 #define PS_NOMAIL 1 /* no mail available */
111 #define PS_SOCKET 2 /* socket I/O woes */
112 #define PS_AUTHFAIL 3 /* user authorization failed */
113 #define PS_PROTOCOL 4 /* protocol violation */
114 #define PS_SYNTAX 5 /* command-line syntax error */
115 #define PS_IOERR 6 /* bad permissions on rc file */
116 #define PS_ERROR 7 /* protocol error */
117 #define PS_EXCLUDE 8 /* client-side exclusion error */
118 #define PS_LOCKBUSY 9 /* server responded lock busy */
119 #define PS_SMTP 10 /* SMTP error */
120 #define PS_DNS 11 /* fatal DNS error */
121 #define PS_BSMTP 12 /* output batch could not be opened */
122 #define PS_MAXFETCH 13 /* poll ended by fetch limit */
123 #define PS_SERVBUSY 14 /* server is busy */
124 /* leave space for more codes */
125 #define PS_UNDEFINED 23 /* something I hadn't thought of */
126 #define PS_TRANSIENT 24 /* transient failure (internal use) */
127 #define PS_REFUSED 25 /* mail refused (internal use) */
128 #define PS_RETAINED 26 /* message retained (internal use) */
129 #define PS_REPOLL 28 /* repoll immediately with changed parameters (internal use) */
130 #define PS_IDLETIMEOUT 29 /* timeout on imap IDLE (internal use) */
131 #define PS_UNTAGGED 30 /* untagged response on imap command (internal use) */
133 /* output noise level */
134 #define O_SILENT 0 /* mute, max squelch, etc. */
135 #define O_NORMAL 1 /* user-friendly */
136 #define O_VERBOSE 2 /* chatty */
137 #define O_DEBUG 3 /* prolix */
138 #define O_MONITOR O_VERBOSE
140 #define SIZETICKER 1024 /* print 1 dot per this many bytes */
143 * We #ifdef this and use flag rather than bool
144 * to avoid a type clash with curses.h
152 /* we need to use zero as a flag-uninitialized value */
156 /** run control data */
159 char *logfile; /** where to write log information */
160 char *idfile; /** where to store UID data */
161 char *pidfile; /** where to record the PID of daemon mode processes */
162 const char *postmaster;
165 int pinentry_timeout;
167 int poll_interval; /** poll interval in seconds (daemon mode, 0 == off) */
177 /** Dual-use entry of singly-linked list for storing id/status or id/id2
181 char *id; /**< key */
187 flag mark; /**< UID-index information */
189 status; /**< value for id/status pairs */
190 char *id2; /**< value for id/id2 pairs */
191 } val; /**< union to store value for key \a id */
192 struct idlist *next; /**< pointer to next list element */
195 /** List of possible values for idlist::mark */
197 UID_UNSEEN= 0, /**< id hasn't been seen */
198 UID_SEEN= 1, /**< id was seen, but not deleted */
199 UID_DELETED= 2, /**< this message has been marked deleted */
200 UID_EXPUNGED= 3 /**< this message has been expunged */
207 struct method /* describe methods for protocol state machine */
209 const char *name; /* protocol name */
210 const char *service; /* service port (unencrypted) */
211 const char *sslservice; /* service port (SSL) */
212 flag tagged; /* if true, generate & expect command tags */
213 flag delimited; /* if true, accept "." message delimiter */
214 int (*parse_response)(int, char *);
215 /* response_parsing function */
216 int (*getauth)(int, struct query *, char *);
217 /* authorization fetcher */
218 int (*getrange)(int, struct query *, const char *, int *, int *, int *);
219 /* get message range to fetch */
220 int (*getsizes)(int, int, int *);
221 /* get sizes of messages */
222 int (*getpartialsizes)(int, int, int, int *);
223 /* get sizes of subset of messages */
224 int (*is_old)(int, struct query *, int);
225 /* check for old message */
226 int (*fetch_headers)(int, struct query *, int, int *);
227 /* fetch header from a given message */
228 int (*fetch_body)(int, struct query *, int, int *);
229 /* fetch a given message */
230 int (*trail)(int, struct query *, const char *);
231 /* eat trailer of a message */
232 int (*delete_msg)(int, struct query *, int);
234 int (*mark_seen)(int, struct query *, int);
235 /* mark as seen method */
236 int (*end_mailbox_poll)(int, struct query *);
237 /* end-of-mailbox processing */
238 int (*logout_cmd)(int, struct query *);
240 flag retry; /* can getrange poll for new messages? */
243 enum badheader { BHREJECT = 0, BHACCEPT };
245 /* Message retrieval error mode */
246 enum retrieveerror { RE_ABORT = 0, RE_CONTINUE, RE_MARKSEEN };
248 struct hostdata /* shared among all user connections to given server */
251 char *pollname; /* poll label of host */
252 char *via; /* "true" server name if non-NULL */
253 struct idlist *akalist; /* server name first, then akas */
254 struct idlist *localdomains; /* list of pass-through domains */
255 int protocol; /* protocol type */
256 char *service; /* service name */
257 int interval; /* # cycles to skip between polls */
258 int authenticate; /* authentication mode to try */
259 int timeout; /* inactivity timout in seconds */
260 char *envelope; /* envelope address list header */
261 int envskip; /* skip to numbered envelope header */
262 char *qvirtual; /* prefix removed from local user id */
263 flag skip; /* suppress poll in implicit mode? */
264 flag dns; /* do DNS lookup on multidrop? */
266 flag sdps; /* use Demon Internet SDPS *ENV */
267 #endif /* SDPS_ENABLE */
268 flag checkalias; /* resolve aliases by comparing IPs? */
269 flag tracepolls; /* if TRUE, add poll trace info to Received */
270 char *principal; /* Kerberos principal for mail service */
271 char *esmtp_name, *esmtp_password; /* ESMTP AUTH information */
272 enum badheader badheader; /* bad-header {pass|reject} */
273 enum retrieveerror retrieveerror; /* retrieve-error (abort|continue|markseen) */
275 #if defined(linux) || defined(__FreeBSD__)
283 struct interface_pair_s *interface_pair;
286 char *plugin,*plugout;
288 /* computed for internal use */
289 const struct method *base_protocol; /* relevant protocol method table */
290 int poll_count; /* count of polls so far */
291 char *queryname; /* name to attempt DNS lookup on */
292 char *truename; /* "true name" of server host */
293 struct sockaddr *trueaddr; /* IP address of truename */
294 size_t trueaddr_len; /* size of trueaddr data */
295 struct hostdata *lead_server; /* ptr to lead query for this server */
297 int workarounds; /* track which workarounds the user was warned about */
301 * bit flags to set in workarounds after the corresponding warning,
302 * which we assume to be server-specific, has been printed,
303 * so we don't spam our users in daemon mode.
305 #define WKA_TOP (1L << 0) /* Maillennium TOP -> RETR override warning */
309 /* mailserver connection controls */
310 struct hostdata server;
313 struct idlist *localnames; /* including calling user's name */
314 int wildcard; /* should unmatched names be passed through */
315 char *remotename; /* remote login name to use */
316 char *password; /* remote password to use */
317 struct idlist *mailboxes; /* list of mailboxes to check */
320 char *pwmd_socket; /* socket to connect to */
321 char *pwmd_file; /* file to open on the server */
324 /* per-forwarding-target data */
325 struct idlist *smtphunt; /* list of SMTP hosts to try forwarding to */
326 struct idlist *domainlist; /* domainlist to fetch from */
327 char *smtpaddress; /* address to force in RCPT TO */
328 char *smtpname; /* full RCPT TO name, including domain */
329 struct idlist *antispam; /* list of listener's antispam response */
330 const char *mda; /* local MDA to pass mail to */
331 char *bsmtp; /* BSMTP output file */
332 char listener; /* what's the listener's wire protocol? */
333 #define SMTP_MODE 'S'
334 #define LMTP_MODE 'L'
335 char *preconnect; /* pre-connection command to execute */
336 char *postconnect; /* post-connection command to execute */
338 /* per-user control flags */
339 flag keep; /* if TRUE, leave messages undeleted */
340 flag fetchall; /* if TRUE, fetch all (not just unseen) */
341 flag flush; /* if TRUE, delete messages already seen */
342 flag limitflush; /* if TRUE, delete oversized mails */
343 flag rewrite; /* if TRUE, canonicalize recipient addresses */
344 flag stripcr; /* if TRUE, strip CRs in text */
345 flag forcecr; /* if TRUE, force CRs before LFs in text */
346 flag pass8bits; /* if TRUE, ignore Content-Transfer-Encoding */
347 flag dropstatus; /* if TRUE, drop Status lines in mail */
348 flag dropdelivered; /* if TRUE, drop Delivered-To lines in mail */
349 flag mimedecode; /* if TRUE, decode MIME-armored messages */
350 flag idle; /* if TRUE, idle after each poll */
351 int limit; /* limit size of retrieved messages */
352 int warnings; /* size warning interval */
353 int fetchlimit; /* max # msgs to get in single poll */
354 int fetchsizelimit; /* max # msg sizes to get in a request */
355 int fastuidl; /* do binary search for new UIDLs? */
356 int fastuidlcount; /* internal count for frequency of binary search */
357 int batchlimit; /* max # msgs to pass in single SMTP session */
358 int expunge; /* max # msgs to pass between expunges */
359 flag use_ssl; /* use SSL encrypted session */
360 char *sslkey; /* optional SSL private key file */
361 char *sslcert; /* optional SSL certificate file */
362 char *sslproto; /** force transport protocol (ssl2|ssl3|ssl23|tls1) - if NULL,
363 use ssl23 for SSL and opportunistic tls1 for non-SSL connections. */
364 char *sslcertfile; /* Trusted certificate file for checking the server cert */
365 char *sslcertpath; /* Trusted certificate directory for checking the server cert */
366 flag sslcertck; /* Strictly check the server cert. */
367 char *sslcommonname; /* CommonName to expect from server */
368 char *sslfingerprint; /* Fingerprint to check against */
369 char *properties; /* passthrough properties for extensions */
371 /* internal use -- per-poll state */
372 flag active; /* should we actually poll this server? */
373 char *destaddr; /* destination host for this query */
374 int errcount; /* count transient errors in last pass */
375 int authfailcount; /* count of authorization failures */
376 int wehaveauthed; /* We've managed to logon at least once! */
377 int wehavesentauthnote; /* We've sent an authorization failure note */
378 int wedged; /* wedged by auth failures or timeouts? */
379 char *smtphost; /* actual SMTP host we connected to */
380 char smtphostmode; /* what's the actual SMTP host's wire protocol? */
381 int smtp_socket; /* socket descriptor for SMTP connection */
382 unsigned int uid; /* UID of user to deliver to */
383 struct idlist *skipped; /* messages skipped on the mail server */
384 struct uid_db oldsaved, newsaved;
385 char lastdigest[DIGESTLEN]; /* last MD5 hash seen on this connection */
386 char *folder; /* folder currently being polled */
388 /* internal use -- per-message state */
389 int mimemsg; /* bitmask indicating MIME body-type */
390 unsigned char digest[DIGESTLEN]; /* md5 digest buffer */
392 /* internal use -- housekeeping */
393 struct query *next; /* next query control block in chain */
396 struct msgblk /** message header parsed for open_sink() */
398 char *headers; /**< raw message headers */
399 struct idlist *recipients; /**< addressees */
400 char return_path[HOSTLEN + USERNAMELEN + 4]; /**< envelope sender */
407 * Numeric option handling. Numeric option value of zero actually means
408 * it's unspecified. Value less than zero is zero. The reason for this
409 * screwy encoding is so we can zero out an option block in order to set the
410 * numeric flags in it to unspecified.
412 #define NUM_VALUE_IN(n) (((n) == 0) ? -1 : (n))
413 #define NUM_VALUE_OUT(n) (((n) < 0) ? 0 : (n))
414 #define NUM_NONZERO(n) ((n) > 0)
415 #define NUM_ZERO(n) ((n) < 0)
416 #define NUM_SPECIFIED(n) ((n) != 0)
418 #define MULTIDROP(ctl) ((ctl)->wildcard || \
419 ((ctl)->localnames && (ctl)->localnames->next))
422 * Note: tags are generated with an a%04d format from a 1-origin
423 * integer sequence number. Length 4 permits transaction numbers
424 * up to 9999, so we force rollover with % 10000. There's no special
425 * reason for this format other than to look like the exmples in the
428 #define TAGLEN 6 /* 'a' + 4 digits + NUL */
429 extern char tag[TAGLEN];
432 /* list of hosts assembled from run control file and command line */
433 extern struct query cmd_opts, *querylist;
435 /* what's returned by envquery */
436 extern void envquery(int, char **);
438 /* controls the detail level of status/progress messages written to stderr */
439 extern int outlevel; /* see the O_.* constants above */
440 extern int yydebug; /* enable parse debugging */
442 /* these get computed */
443 extern int batchcount; /* count of messages sent in current batch */
444 extern flag peek_capable; /* can we read msgs without setting seen? */
446 /* miscellaneous global controls */
447 extern struct runctl run; /* global controls for this run */
448 extern flag nodetach; /* if TRUE, don't detach daemon process */
449 extern flag quitmode; /* if --quit was set */
450 extern int quitind; /* optind after position of last --quit option */
451 extern flag check_only; /* if --check was set */
452 extern char *rcfile; /* path name of rc file */
453 extern int linelimit; /* limit # lines retrieved per site */
454 extern flag versioninfo; /* emit only version info */
455 extern char *user; /* name of invoking user */
456 extern char *home; /* home directory of invoking user */
457 extern char *fmhome; /* fetchmail home directory */
458 extern int pass; /* number of re-polling pass */
459 extern flag configdump; /* dump control blocks as Python dictionary */
460 extern const char *fetchmailhost; /* either "localhost" or an FQDN */
461 extern int suppress_tags; /* suppress tags in tagged protocols? */
462 extern char shroud[PASSWORDLEN*2+3]; /* string to shroud in debug output */
464 extern char *sdps_envfrom;
465 extern char *sdps_envto;
466 #endif /* SDPS_ENABLE */
468 extern const char *iana_charset; /* IANA assigned charset name */
470 /* from/for ucs/norm_charmap.c */
471 #include "ucs/norm_charmap.h"
473 /* prototypes for globally callable functions */
475 /* from /usr/include/sys/cdefs.h */
476 #if !defined __GNUC__
477 # define __attribute__(xyz) /* Ignore. */
480 /* error.c: Error reporting */
481 void report_init(int foreground);
482 /** Flush partial message, suppress program name tag for next report printout. */
483 void report_flush(FILE *fp);
484 void report (FILE *fp, const char *format, ...)
485 __attribute__ ((format (printf, 2, 3)))
487 void report_build (FILE *fp, const char *format, ...)
488 __attribute__ ((format (printf, 2, 3)))
490 void report_complete (FILE *fp, const char *format, ...)
491 __attribute__ ((format (printf, 2, 3)))
493 void report_at_line (FILE *fp, int, const char *, unsigned int, const char *, ...)
494 __attribute__ ((format (printf, 5, 6)))
497 /* driver.c -- main driver loop */
498 void set_timeout(int);
499 int is_idletimeout(void);
500 void resetidletimeout(void);
501 int do_protocol(struct query *, const struct method *);
503 /* transact.c: transaction support */
504 /** \ingroup gen_recv_split
505 * Data structure to cache data between \func gen_recv_split calls,
506 * must be initialized before use by calling \func gen_recv_split_init. */
509 char prefix[100]; /**< prefix to match/repeat when splitting lines */
510 int cached; /**< flag to record if we have data cached in \a buf */
511 char buf[MSGBUFSIZE]; /**< buffer for cached data */
514 void init_transact(const struct method *);
515 int readheaders(int sock,
520 flag *suppress_readbody);
521 int readbody(int sock, struct query *ctl, flag forward, int len);
522 void gen_send(int sock, const char *, ... )
523 __attribute__ ((format (printf, 2, 3)))
525 int gen_recv(int sock, char *buf, int size);
526 void gen_recv_split_init(const char *prefix, struct RecvSplit *rs);
527 int gen_recv_split(int sock, char *buf, int size, struct RecvSplit *rs);
528 int gen_transact(int sock, const char *, ... )
529 __attribute__ ((format (printf, 2, 3)))
531 extern struct msgblk msgblk;
533 /* use these to track what was happening when the nonresponse timer fired */
534 #define GENERAL_WAIT 0 /* unknown wait type */
535 #define OPEN_WAIT 1 /* waiting from mailserver open */
536 #define SERVER_WAIT 2 /* waiting for mailserver response */
537 #define LISTENER_WAIT 3 /* waiting for listener initialization */
538 #define FORWARDING_WAIT 4 /* waiting for listener response */
541 /* response hooks can use this to identify the query stage */
542 #define STAGE_GETAUTH 0
543 #define STAGE_GETRANGE 1
544 #define STAGE_GETSIZES 2
545 #define STAGE_FETCH 3
547 #define STAGE_LOGOUT 5
550 extern int mytimeout;
552 /* mark values for name lists */
553 #define XMIT_ACCEPT 1 /* accepted; matches local domain or name */
554 #define XMIT_REJECT 2 /* rejected; no match */
555 #define XMIT_RCPTBAD 3 /* SMTP listener rejected the name */
558 int interruptible_idle(int interval);
559 extern volatile int lastsig;
561 /* sink.c: forwarding */
562 void smtp_close(struct query *, int);
563 int smtp_open(struct query *);
564 int smtp_setup(struct query *);
565 char *rcpt_address(struct query *, const char *, int);
566 int stuffline(struct query *, char *);
567 int open_sink(struct query*, struct msgblk *, int*, int*);
568 void release_sink(struct query *);
569 int close_sink(struct query *, struct msgblk *, flag);
570 int open_warning_by_mail(struct query *);
571 void stuff_warning(const char *, struct query *, const char *, ... )
572 __attribute__ ((format (printf, 3, 4)))
574 void close_warning_by_mail(struct query *, struct msgblk *);
575 void abort_message_sink(struct query *ctl);
577 /* rfc822.c: RFC822 header parsing */
578 char *reply_hack(char *, const char *, size_t *);
579 char *nxtaddr(const char *);
581 /* uid.c: UID support */
582 extern int dofastuidl;
583 void initialize_saved_lists(struct query *hostlist, const char *idfile);
584 void expunge_uids(struct query *ctl);
585 void uid_swap_lists(struct query *ctl);
586 void uid_discard_new_list(struct query *ctl);
587 void uid_reset_num(struct query *ctl);
588 void write_saved_lists(struct query *hostlist, const char *idfile);
591 struct idlist *save_str(struct idlist **idl, const char *str, flag status);
592 void free_str_list(struct idlist **idl);
593 void save_str_pair(struct idlist **idl, const char *str1, const char *str2);
594 struct idlist *str_in_list(struct idlist **idl, const char *str, const flag caseblind);
595 int str_nr_in_list(struct idlist **idl, const char *str);
596 int str_nr_last_in_list(struct idlist **idl, const char *str);
597 void str_set_mark(struct idlist **idl, const char *str, const flag val);
598 int count_list(struct idlist **idl);
599 char *str_from_nr_list(struct idlist **idl, long number);
600 char *str_find(struct idlist **idl, long number);
601 struct idlist *id_find(struct idlist **idl, long number);
602 char *idpair_find(struct idlist **idl, const char *id);
603 int delete_str(struct idlist **idl, long num);
604 struct idlist *copy_str_list(struct idlist *idl);
605 void append_str_list(struct idlist **idl, struct idlist **nidl);
608 int prc_parse_file(const char *, const flag);
609 int prc_filecheck(const char *, const flag);
612 void to64frombits(char *, const void *, int);
613 int from64tobits(void *, const char *, int maxlen);
616 /* Bit-mask returned by MimeBodyType */
617 #define MSG_IS_7BIT 0x01
618 #define MSG_IS_8BIT 0x02
619 #define MSG_NEEDS_DECODE 0x80
620 extern void UnMimeHeader(char *buf);
621 extern int MimeBodyType(char *hdrs, int WantDecode);
622 extern int UnMimeBodyline(char **buf, flag delimited, flag issoftline);
625 void interface_init(void);
626 void interface_parse(char *, struct hostdata *);
627 void interface_note_activity(struct hostdata *);
628 int interface_approve(struct hostdata *, flag domonitor);
632 /* protocol driver and methods */
633 int doPOP3 (struct query *);
634 int doIMAP (struct query *);
635 int doETRN (struct query *);
636 int doODMR (struct query *);
638 /* authentication functions */
639 int do_cram_md5(int sock, const char *command, struct query *ctl, const char *strip);
640 int check_gss_creds(const char *service, const char *hostname);
641 int do_gssauth(int sock, const char *command, const char *service, const char *hostname, const char *username);
642 int do_otp(int sock, const char *command, struct query *ctl);
646 /* these should be of size PATH_MAX */
647 extern char currentwd[1024], rcfiledir[1024];
649 struct query *hostalloc(struct query *);
650 int parsecmdline (int, char **, struct runctl *, struct query *, flag *);
651 char *prependdir (const char *, const char *);
652 char *MD5Digest (unsigned const char *);
653 void hmac_md5 (const unsigned char *, size_t, const unsigned char *, size_t, unsigned char *, size_t);
654 int POP3_auth_rpa(char *, char *, int socket);
655 typedef void (*SIGHANDLERTYPE) (int);
656 void deal_with_sigchld(void);
657 void null_signal_handler(int sig);
658 SIGHANDLERTYPE set_signal_handler(int sig, SIGHANDLERTYPE handler);
659 int daemonize(const char *);
660 char *fm_getpassword(char *);
661 void escapes(const char *, char *);
662 char *visbuf(const char *);
663 const char *showproto(int);
664 void dump_config(struct runctl *runp, struct query *querylist);
665 int is_host_alias(const char *, struct query *, struct addrinfo **);
667 extern struct addrinfo *ai0, *ai1;
669 /** Try to obtain fully qualified hostname of current host. Exit with
670 * PS_DNS if \a required is true and there is a DNS error. Exit with
671 * PS_DNS if gethostname() fails, independent of the value of \a
674 * - fully qualified hostname if \a required is non-zero.
675 * - unqualified or fully qualified hostname if \a required is zero (0).
677 char *host_fqdn(int required /** exit with PS_DNS if the name cannot be qualified */);
678 char *rfc822timestamp(void);
680 char *rfc2047e(const char*, const char *);
682 void yyerror(const char *);
685 #define STRING_DISABLED (char *)-1
686 #define STRING_DUMMY ""
689 char *stpcpy(char *, const char*);
694 #else /* !__CYGWIN__ */
696 #endif /* __CYGWIN__ */
698 extern int mailserver_socket_temp;
699 extern const char *program_name;
701 /* POSIX space characters,
702 * <tab>;<newline>;<vertical-tab>;<form-feed>;<carriage-return>;<space> */
703 #define POSIX_space "\t\n\v\f\r "
705 /** Resolve the a TCP service name or a string containing only a decimal
706 * positive integer to a port number. Returns -1 for error. */
707 int servport(const char *service);
709 #ifndef HAVE_GETNAMEINFO
710 # define NI_NUMERICHOST 1
711 # define NI_NUMERICSERV 2
713 # define NI_NAMEREQD 8
717 int fm_getaddrinfo(const char *node, const char *serv, const struct addrinfo *hints, struct addrinfo **res);
718 void fm_freeaddrinfo(struct addrinfo *ai);
720 /* prototypes from tls.c */
721 int maybe_tls(struct query *ctl);
722 int must_tls(struct query *ctl);
724 /* prototype from rfc822valid.c */
725 int rfc822_valid_msgid(const unsigned char *);
727 /* prototype from x509_name_match.c */
728 int name_match(const char *p1, const char *p2);
730 /* prototype from ntlmsubr.c */
732 int ntlm_helper(int sock, struct query *ctl, const char *protocol);
735 /* macro to determine if we want to spam progress to stdout */
736 #define want_progress() \
737 ((outlevel >= O_VERBOSE || (outlevel > O_SILENT && run.showdots)) \
739 && (run.showdots || !is_a_file(1)))
742 /* fetchmail.h ends here */