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