1 /** \file fetchmail.h header file for fetchmail */
5 * For license terms, see the file COPYING in this directory.
8 /* We need this for HAVE_STDARG_H, etc */
13 /* We need this for size_t */
14 #include <sys/types.h>
16 /* We need this for time_t */
17 #if TIME_WITH_SYS_TIME
18 # include <sys/time.h>
22 # include <sys/time.h>
28 #ifdef HAVE_SYS_SOCKET_H
29 #include <sys/socket.h>
31 #ifdef HAVE_NET_SOCKET_H
32 #include <net/socket.h>
37 /* Import Trio if needed */
38 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
39 # include "trio/trio.h"
46 /* We need this for strstr */
47 #if !defined(HAVE_STRSTR) && !defined(strstr)
48 char *strstr(const char *, const char *);
51 /* constants designating the various supported protocols */
61 #define SMTP_PORT "smtp"
62 #define SMTP_PORT_NUM 25
63 #define KPOP_PORT "kpop"
66 #define SIMAP_PORT 993
67 #define SPOP3_PORT 995
71 * We need to distinguish between mailbox and mailbag protocols.
72 * Under a mailbox protocol wwe're pulling mail for a speecific user.
73 * Under a mailbag protocol we're fetching mail for an entire domain.
75 #define MAILBOX_PROTOCOL(ctl) ((ctl)->server.protocol < P_ETRN)
77 /* authentication types */
78 #define A_ANY 0 /* use the first method that works */
79 #define A_PASSWORD 1 /* password authentication */
80 #define A_NTLM 2 /* Microsoft NTLM protocol */
81 #define A_CRAM_MD5 3 /* CRAM-MD5 shrouding (RFC2195) */
82 #define A_OTP 4 /* One-time password (RFC1508) */
83 #define A_KERBEROS_V4 5 /* authenticate w/ Kerberos V4 */
84 #define A_KERBEROS_V5 6 /* authenticate w/ Kerberos V5 */
85 #define A_GSSAPI 7 /* authenticate with GSSAPI */
86 #define A_SSH 8 /* authentication at session level */
87 #define A_MSN 9 /* same as NTLM with keyword MSN */
88 #define A_EXTERNAL 10 /* external authentication (client cert) */
90 /* some protocols or authentication types (KERBEROS, GSSAPI, SSH) don't
91 * require a password */
92 #define NO_PASSWORD(ctl) \
93 ((ctl)->server.authenticate == A_OTP \
94 || (ctl)->server.authenticate == A_KERBEROS_V4 \
95 || (ctl)->server.authenticate == A_KERBEROS_V5 \
96 || (ctl)->server.authenticate == A_GSSAPI \
97 || (ctl)->server.authenticate == A_SSH \
98 || (ctl)->server.authenticate == A_EXTERNAL \
99 || (ctl)->server.protocol == P_ETRN)
102 * Definitions for buffer sizes. We get little help on setting maxima
103 * from IMAP RFCs up to 2060, so these are mostly from POP3.
105 #define HOSTLEN 635 /* max hostname length (RFC1123) */
106 #define POPBUFSIZE 512 /* max length of response (RFC1939) */
107 #define IDLEN 128 /* max length of UID (RFC1939) */
109 /* per RFC1939 this should be 40, but Microsoft Exchange ignores that limit */
110 #define USERNAMELEN 128 /* max POP3 arg length */
112 /* clear a netBSD kernel parameter out of the way */
116 * The RFC822 limit on message line size is just 998. But
117 * make this *way* oversized; idiot DOS-world mailers that
118 * don't line-wrap properly often ship entire paragraphs as
121 #define MSGBUFSIZE 8192
123 #define NAMELEN 64 /* max username length */
124 #define PASSWORDLEN 64 /* max password length */
125 #define DIGESTLEN 33 /* length of MD5 digest */
127 /* exit code values */
128 /* NOTE THAT PS_SUCCESS MUST ALWAYS BE 0 - SOME PARTS OF THE CODE
129 * RELY ON THIS VALUE! */
130 #define PS_SUCCESS 0 /* successful receipt of messages */
131 #define PS_NOMAIL 1 /* no mail available */
132 #define PS_SOCKET 2 /* socket I/O woes */
133 #define PS_AUTHFAIL 3 /* user authorization failed */
134 #define PS_PROTOCOL 4 /* protocol violation */
135 #define PS_SYNTAX 5 /* command-line syntax error */
136 #define PS_IOERR 6 /* bad permissions on rc file */
137 #define PS_ERROR 7 /* protocol error */
138 #define PS_EXCLUDE 8 /* client-side exclusion error */
139 #define PS_LOCKBUSY 9 /* server responded lock busy */
140 #define PS_SMTP 10 /* SMTP error */
141 #define PS_DNS 11 /* fatal DNS error */
142 #define PS_BSMTP 12 /* output batch could not be opened */
143 #define PS_MAXFETCH 13 /* poll ended by fetch limit */
144 #define PS_SERVBUSY 14 /* server is busy */
145 /* leave space for more codes */
146 #define PS_UNDEFINED 23 /* something I hadn't thought of */
147 #define PS_TRANSIENT 24 /* transient failure (internal use) */
148 #define PS_REFUSED 25 /* mail refused (internal use) */
149 #define PS_RETAINED 26 /* message retained (internal use) */
150 #define PS_REPOLL 28 /* repoll immediately with changed parameters (internal use) */
151 #define PS_IDLETIMEOUT 29 /* timeout on imap IDLE (internal use) */
152 #define PS_UNTAGGED 30 /* untagged response on imap command (internal use) */
154 /* output noise level */
155 #define O_SILENT 0 /* mute, max squelch, etc. */
156 #define O_NORMAL 1 /* user-friendly */
157 #define O_VERBOSE 2 /* chatty */
158 #define O_DEBUG 3 /* prolix */
159 #define O_MONITOR O_VERBOSE
161 #define SIZETICKER 1024 /* print 1 dot per this many bytes */
164 * We #ifdef this and use flag rather than bool
165 * to avoid a type clash with curses.h
173 /* we need to use zero as a flag-uninitialized value */
177 /** run control data */
180 char *logfile; /** where to write log information */
181 char *idfile; /** where to store UID data */
182 char *pidfile; /** where to record the PID of daemon mode processes */
186 int pinentry_timeout;
188 int poll_interval; /** poll interval in seconds (daemon mode, 0 == off) */
205 flag mark; /* UID-index information */
206 #define UID_UNSEEN 0 /* hasn't been seen */
207 #define UID_SEEN 1 /* seen, but not deleted */
208 #define UID_DELETED 2 /* this message has been marked deleted */
209 #define UID_EXPUNGED 3 /* this message has been expunged */
219 struct method /* describe methods for protocol state machine */
221 const char *name; /* protocol name */
222 const char *service; /* service port (unencrypted) */
223 const char *sslservice; /* service port (SSL) */
224 flag tagged; /* if true, generate & expect command tags */
225 flag delimited; /* if true, accept "." message delimiter */
226 int (*parse_response)(int, char *);
227 /* response_parsing function */
228 int (*getauth)(int, struct query *, char *);
229 /* authorization fetcher */
230 int (*getrange)(int, struct query *, const char *, int *, int *, int *);
231 /* get message range to fetch */
232 int (*getsizes)(int, int, int *);
233 /* get sizes of messages */
234 int (*getpartialsizes)(int, int, int, int *);
235 /* get sizes of subset of messages */
236 int (*is_old)(int, struct query *, int);
237 /* check for old message */
238 int (*fetch_headers)(int, struct query *, int, int *);
239 /* fetch header from a given message */
240 int (*fetch_body)(int, struct query *, int, int *);
241 /* fetch a given message */
242 int (*trail)(int, struct query *, const char *);
243 /* eat trailer of a message */
244 int (*delete_msg)(int, struct query *, int);
246 int (*mark_seen)(int, struct query *, int);
247 /* mark as seen method */
248 int (*end_mailbox_poll)(int, struct query *);
249 /* end-of-mailbox processing */
250 int (*logout_cmd)(int, struct query *);
252 flag retry; /* can getrange poll for new messages? */
255 struct hostdata /* shared among all user connections to given server */
258 char *pollname; /* poll label of host */
259 char *via; /* "true" server name if non-NULL */
260 struct idlist *akalist; /* server name first, then akas */
261 struct idlist *localdomains; /* list of pass-through domains */
262 int protocol; /* protocol type */
263 char *service; /* service name */
264 int interval; /* # cycles to skip between polls */
265 int authenticate; /* authentication mode to try */
266 int timeout; /* inactivity timout in seconds */
267 char *envelope; /* envelope address list header */
268 int envskip; /* skip to numbered envelope header */
269 char *qvirtual; /* prefix removed from local user id */
270 flag skip; /* suppress poll in implicit mode? */
271 flag dns; /* do DNS lookup on multidrop? */
272 flag uidl; /* use RFC1725 UIDLs? */
274 flag sdps; /* use Demon Internet SDPS *ENV */
275 #endif /* SDPS_ENABLE */
276 flag checkalias; /* resolve aliases by comparing IPs? */
277 flag tracepolls; /* if TRUE, add poll trace info to Received */
278 char *principal; /* Kerberos principal for mail service */
279 char *esmtp_name, *esmtp_password; /* ESMTP AUTH information */
281 #if defined(linux) || defined(__FreeBSD__)
289 struct interface_pair_s *interface_pair;
292 char *plugin,*plugout;
294 /* computed for internal use */
295 const struct method *base_protocol; /* relevant protocol method table */
296 int poll_count; /* count of polls so far */
297 char *queryname; /* name to attempt DNS lookup on */
298 char *truename; /* "true name" of server host */
299 struct sockaddr *trueaddr; /* IP address of truename */
300 size_t trueaddr_len; /* size of trueaddr data */
301 struct hostdata *lead_server; /* ptr to lead query for this server */
303 int workarounds; /* track which workarounds the user was warned about */
307 * bit flags to set in workarounds after the corresponding warning,
308 * which we assume to be server-specific, has been printed,
309 * so we don't spam our users in daemon mode.
311 #define WKA_TOP (1L << 0) /* Maillennium TOP -> RETR override warning */
315 /* mailserver connection controls */
316 struct hostdata server;
319 struct idlist *localnames; /* including calling user's name */
320 int wildcard; /* should unmatched names be passed through */
321 char *remotename; /* remote login name to use */
322 char *password; /* remote password to use */
323 struct idlist *mailboxes; /* list of mailboxes to check */
326 char *pwmd_socket; /* socket to connect to */
327 char *pwmd_file; /* file to open on the server */
330 /* per-forwarding-target data */
331 struct idlist *smtphunt; /* list of SMTP hosts to try forwarding to */
332 struct idlist *domainlist; /* domainlist to fetch from */
333 char *smtpaddress; /* address to force in RCPT TO */
334 char *smtpname; /* full RCPT TO name, including domain */
335 struct idlist *antispam; /* list of listener's antispam response */
336 char *mda; /* local MDA to pass mail to */
337 char *bsmtp; /* BSMTP output file */
338 char listener; /* what's the listener's wire protocol? */
339 #define SMTP_MODE 'S'
340 #define LMTP_MODE 'L'
341 char *preconnect; /* pre-connection command to execute */
342 char *postconnect; /* post-connection command to execute */
344 /* per-user control flags */
345 flag keep; /* if TRUE, leave messages undeleted */
346 flag fetchall; /* if TRUE, fetch all (not just unseen) */
347 flag flush; /* if TRUE, delete messages already seen */
348 flag limitflush; /* if TRUE, delete oversized mails */
349 flag rewrite; /* if TRUE, canonicalize recipient addresses */
350 flag stripcr; /* if TRUE, strip CRs in text */
351 flag forcecr; /* if TRUE, force CRs before LFs in text */
352 flag pass8bits; /* if TRUE, ignore Content-Transfer-Encoding */
353 flag dropstatus; /* if TRUE, drop Status lines in mail */
354 flag dropdelivered; /* if TRUE, drop Delivered-To lines in mail */
355 flag mimedecode; /* if TRUE, decode MIME-armored messages */
356 flag idle; /* if TRUE, idle after each poll */
357 int limit; /* limit size of retrieved messages */
358 int warnings; /* size warning interval */
359 int fetchlimit; /* max # msgs to get in single poll */
360 int fetchsizelimit; /* max # msg sizes to get in a request */
361 int fastuidl; /* do binary search for new UIDLs? */
362 int fastuidlcount; /* internal count for frequency of binary search */
363 int batchlimit; /* max # msgs to pass in single SMTP session */
364 int expunge; /* max # msgs to pass between expunges */
365 flag use_ssl; /* use SSL encrypted session */
366 char *sslkey; /* optional SSL private key file */
367 char *sslcert; /* optional SSL certificate file */
368 char *sslproto; /** force transport protocol (ssl2|ssl3|ssl23|tls1) - if NULL,
369 use ssl23 for SSL and opportunistic tls1 for non-SSL connections. */
370 char *sslcertpath; /* Trusted certificate directory for checking the server cert */
371 flag sslcertck; /* Strictly check the server cert. */
372 char *sslcommonname; /* CommonName to expect from server */
373 char *sslfingerprint; /* Fingerprint to check against */
374 char *properties; /* passthrough properties for extensions */
376 /* internal use -- per-poll state */
377 flag active; /* should we actually poll this server? */
378 char *destaddr; /* destination host for this query */
379 int errcount; /* count transient errors in last pass */
380 int authfailcount; /* count of authorization failures */
381 int wehaveauthed; /* We've managed to logon at least once! */
382 int wehavesentauthnote; /* We've sent an authorization failure note */
383 int wedged; /* wedged by auth failures or timeouts? */
384 char *smtphost; /* actual SMTP host we connected to */
385 char smtphostmode; /* what's the actual SMTP host's wire protocol? */
386 int smtp_socket; /* socket descriptor for SMTP connection */
387 unsigned int uid; /* UID of user to deliver to */
388 struct idlist *skipped; /* messages skipped on the mail server */
389 struct idlist *oldsaved, *newsaved;
390 struct idlist **oldsavedend;
391 char lastdigest[DIGESTLEN]; /* last MD5 hash seen on this connection */
392 char *folder; /* folder currently being polled */
394 /* internal use -- per-message state */
395 int mimemsg; /* bitmask indicating MIME body-type */
396 char digest[DIGESTLEN]; /* md5 digest buffer */
398 /* internal use -- housekeeping */
399 struct query *next; /* next query control block in chain */
402 struct msgblk /* message header parsed for open_sink() */
404 char *headers; /* raw message headers */
405 struct idlist *recipients; /* addressees */
406 char return_path[HOSTLEN + USERNAMELEN + 4];
413 * Numeric option handling. Numeric option value of zero actually means
414 * it's unspecified. Value less than zero is zero. The reason for this
415 * screwy encoding is so we can zero out an option block in order to set the
416 * numeric flags in it to unspecified.
418 #define NUM_VALUE_IN(n) (((n) == 0) ? -1 : (n))
419 #define NUM_VALUE_OUT(n) (((n) < 0) ? 0 : (n))
420 #define NUM_NONZERO(n) ((n) > 0)
421 #define NUM_ZERO(n) ((n) < 0)
422 #define NUM_SPECIFIED(n) ((n) != 0)
424 #define MULTIDROP(ctl) (ctl->wildcard || \
425 ((ctl)->localnames && (ctl)->localnames->next))
428 * Note: tags are generated with an a%04d format from a 1-origin
429 * integer sequence number. Length 4 permits transaction numbers
430 * up to 9999, so we force rollover with % 10000. There's no special
431 * reason for this format other than to look like the exmples in the
434 #define TAGLEN 6 /* 'a' + 4 digits + NUL */
435 extern char tag[TAGLEN];
438 /* list of hosts assembled from run control file and command line */
439 extern struct query cmd_opts, *querylist;
441 /* what's returned by envquery */
442 extern void envquery(int, char **);
444 /* controls the detail level of status/progress messages written to stderr */
445 extern int outlevel; /* see the O_.* constants above */
446 extern int yydebug; /* enable parse debugging */
448 /* these get computed */
449 extern int batchcount; /* count of messages sent in current batch */
450 extern flag peek_capable; /* can we read msgs without setting seen? */
452 /* miscellaneous global controls */
453 extern struct runctl run; /* global controls for this run */
454 extern flag nodetach; /* if TRUE, don't detach daemon process */
455 extern flag quitmode; /* if --quit was set */
456 extern int quitind; /* optind after position of last --quit option */
457 extern flag check_only; /* if --check was set */
458 extern char *rcfile; /* path name of rc file */
459 extern int linelimit; /* limit # lines retrieved per site */
460 extern flag versioninfo; /* emit only version info */
461 extern char *user; /* name of invoking user */
462 extern char *home; /* home directory of invoking user */
463 extern char *fmhome; /* fetchmail home directory */
464 extern int pass; /* number of re-polling pass */
465 extern flag configdump; /* dump control blocks as Python dictionary */
466 extern char *fetchmailhost; /* either "localhost" or an FQDN */
467 extern int suppress_tags; /* suppress tags in tagged protocols? */
468 extern char shroud[PASSWORDLEN*2+3]; /* string to shroud in debug output */
470 extern char *sdps_envfrom;
471 extern char *sdps_envto;
472 #endif /* SDPS_ENABLE */
474 extern const char *iana_charset; /* IANA assigned charset name */
476 /* from ucs/norm_charmap.c */
477 const char *norm_charmap(const char *name);
479 /* prototypes for globally callable functions */
481 /* from /usr/include/sys/cdefs.h */
482 #if !defined __GNUC__ || __GNUC__ < 2
483 # define __attribute__(xyz) /* Ignore. */
486 /* error.c: Error reporting */
487 #if defined(HAVE_STDARG_H)
488 void report_init(int foreground);
489 /** Flush partial message, suppress program name tag for next report printout. */
490 void report_flush(FILE *fp);
491 void report (FILE *fp, const char *format, ...)
492 __attribute__ ((format (printf, 2, 3)))
494 void report_build (FILE *fp, const char *format, ...)
495 __attribute__ ((format (printf, 2, 3)))
497 void report_complete (FILE *fp, const char *format, ...)
498 __attribute__ ((format (printf, 2, 3)))
500 void report_at_line (FILE *fp, int, const char *, unsigned int, const char *, ...)
501 __attribute__ ((format (printf, 5, 6)))
505 void report_build ();
506 void report_complete ();
507 void report_at_line ();
510 /* driver.c -- main driver loop */
511 void set_timeout(int);
512 int is_idletimeout(void);
513 void resetidletimeout(void);
514 int do_protocol(struct query *, const struct method *);
516 /* transact.c: transaction support */
517 void init_transact(const struct method *);
518 int readheaders(int sock,
523 flag *suppress_readbody);
524 int readbody(int sock, struct query *ctl, flag forward, int len);
525 #if defined(HAVE_STDARG_H)
526 void gen_send(int sock, const char *, ... )
527 __attribute__ ((format (printf, 2, 3)))
529 int gen_recv(int sock, char *buf, int size);
530 int gen_transact(int sock, const char *, ... )
531 __attribute__ ((format (printf, 2, 3)))
538 extern struct msgblk msgblk;
540 /* use these to track what was happening when the nonresponse timer fired */
541 #define GENERAL_WAIT 0 /* unknown wait type */
542 #define OPEN_WAIT 1 /* waiting from mailserver open */
543 #define SERVER_WAIT 2 /* waiting for mailserver response */
544 #define LISTENER_WAIT 3 /* waiting for listener initialization */
545 #define FORWARDING_WAIT 4 /* waiting for listener response */
548 /* response hooks can use this to identify the query stage */
549 #define STAGE_GETAUTH 0
550 #define STAGE_GETRANGE 1
551 #define STAGE_GETSIZES 2
552 #define STAGE_FETCH 3
554 #define STAGE_LOGOUT 5
557 extern int mytimeout;
559 /* mark values for name lists */
560 #define XMIT_ACCEPT 1 /* accepted; matches local domain or name */
561 #define XMIT_REJECT 2 /* rejected; no match */
562 #define XMIT_RCPTBAD 3 /* SMTP listener rejected the name */
565 int interruptible_idle(int interval);
566 extern volatile int lastsig;
568 /* sink.c: forwarding */
569 void smtp_close(struct query *, int);
570 int smtp_open(struct query *);
571 int smtp_setup(struct query *);
572 char *rcpt_address(struct query *, const char *, int);
573 int stuffline(struct query *, char *);
574 int open_sink(struct query*, struct msgblk *, int*, int*);
575 void release_sink(struct query *);
576 int close_sink(struct query *, struct msgblk *, flag);
577 int open_warning_by_mail(struct query *);
578 #if defined(HAVE_STDARG_H)
579 void stuff_warning(const char *, struct query *, const char *, ... )
580 __attribute__ ((format (printf, 3, 4)))
583 void stuff_warning();
585 void close_warning_by_mail(struct query *, struct msgblk *);
587 /* rfc822.c: RFC822 header parsing */
588 char *reply_hack(char *, const char *, size_t *);
589 char *nxtaddr(const char *);
591 /* uid.c: UID support */
592 extern int dofastuidl;
594 void initialize_saved_lists(struct query *, const char *);
595 struct idlist *save_str(struct idlist **, const char *, flag);
596 void free_str_list(struct idlist **);
597 struct idlist *copy_str_list(struct idlist *idl);
598 void save_str_pair(struct idlist **, const char *, const char *);
599 void free_str_pair_list(struct idlist **);
600 int delete_str(struct idlist **, long);
601 struct idlist *str_in_list(struct idlist **, const char *, const flag);
602 int str_nr_in_list(struct idlist **, const char *);
603 int str_nr_last_in_list(struct idlist **, const char *);
604 void str_set_mark( struct idlist **, const char *, const flag);
605 int count_list( struct idlist **idl );
606 char *str_from_nr_list( struct idlist **idl, long number );
607 char *str_find(struct idlist **, long);
608 struct idlist *id_find(struct idlist **idl, long);
609 char *idpair_find(struct idlist **, const char *);
610 void append_str_list(struct idlist **, struct idlist **);
611 void expunge_uids(struct query *);
612 void uid_swap_lists(struct query *);
613 void uid_discard_new_list(struct query *ctl);
614 void uid_reset_num(struct query *ctl);
615 void write_saved_lists(struct query *, const char *);
618 int prc_parse_file(const char *, const flag);
619 int prc_filecheck(const char *, const flag);
622 void to64frombits(char *, const void *, int);
623 int from64tobits(void *, const char *, int maxlen);
626 /* Bit-mask returned by MimeBodyType */
627 #define MSG_IS_7BIT 0x01
628 #define MSG_IS_8BIT 0x02
629 #define MSG_NEEDS_DECODE 0x80
630 extern void UnMimeHeader(char *buf);
631 extern int MimeBodyType(char *hdrs, int WantDecode);
632 extern int UnMimeBodyline(char **buf, flag delimited, flag issoftline);
635 void interface_init(void);
636 void interface_parse(char *, struct hostdata *);
637 void interface_note_activity(struct hostdata *);
638 int interface_approve(struct hostdata *, flag domonitor);
642 /* protocol driver and methods */
643 int doPOP2 (struct query *);
644 int doPOP3 (struct query *);
645 int doIMAP (struct query *);
646 int doETRN (struct query *);
647 int doODMR (struct query *);
649 /* authentication functions */
650 int do_cram_md5(int sock, char *command, struct query *ctl, char *strip);
651 int do_rfc1731(int sock, char *command, char *truename);
652 int do_gssauth(int sock, char *command, char *service, char *hostname, char *username);
653 int do_otp(int sock, char *command, struct query *ctl);
657 /* these should be of size PATH_MAX */
658 extern char currentwd[1024], rcfiledir[1024];
660 struct query *hostalloc(struct query *);
661 int parsecmdline (int, char **, struct runctl *, struct query *);
662 char *prependdir (const char *, const char *);
663 char *MD5Digest (unsigned const char *);
664 void hmac_md5 (char *, size_t, char *, size_t, unsigned char *, size_t);
665 int POP3_auth_rpa(char *, char *, int socket);
666 typedef RETSIGTYPE (*SIGHANDLERTYPE) (int);
667 void deal_with_sigchld(void);
668 RETSIGTYPE null_signal_handler(int sig);
669 SIGHANDLERTYPE set_signal_handler(int sig, SIGHANDLERTYPE handler);
670 int daemonize(const char *);
671 char *fm_getpassword(char *);
672 void escapes(const char *, char *);
673 char *visbuf(const char *);
674 const char *showproto(int);
675 void dump_config(struct runctl *runp, struct query *querylist);
676 int is_host_alias(const char *, struct query *, struct addrinfo **);
678 extern struct addrinfo *ai0, *ai1;
680 /** Try to obtain fully qualified hostname of current host. Exit with
681 * PS_DNS if \a required is true and there is a DNS error. Exit with
682 * PS_DNS if gethostname() fails, independent of the value of \a
685 * - fully qualified hostname if \a required is non-zero.
686 * - unqualified or fully qualified hostname if \a required is zero (0).
688 char *host_fqdn(int required /** exit with PS_DNS if the name cannot be qualified */);
689 char *rfc822timestamp(void);
691 char *rfc2047e(const char*, const char *);
693 void yyerror(const char *);
697 void itimerthread(void*);
698 /* Have to include these first to avoid errors from redefining getcwd
699 and chdir. They're re-include protected in EMX, so it's okay, I
703 /* Redefine getcwd and chdir to get drive-letter support so we can
704 find all of our lock files and stuff. */
705 #define getcwd _getcwd2
706 #define chdir _chdir2
710 # if !defined(strerror) && !defined(HAVE_DECL_STRERROR) /* On some systems, strerror is a macro */
711 char *strerror (int);
713 #endif /* HAVE_STRERROR */
715 #define STRING_DISABLED (char *)-1
716 #define STRING_DUMMY ""
720 #define S_IXGRP 0000010
725 char *stpcpy(char *, const char*);
730 #else /* !__CYGWIN__ */
732 #endif /* __CYGWIN__ */
734 extern int mailserver_socket_temp;
735 extern char *program_name;
737 /* POSIX space characters,
738 * <tab>;<newline>;<vertical-tab>;<form-feed>;<carriage-return>;<space> */
739 #define POSIX_space "\t\n\v\f\r "
741 /* strlcpy/strlcat prototypes */
744 strlcat(char *dst, const char *src, size_t siz);
748 strlcpy(char *dst, const char *src, size_t siz);
751 /** Resolve the a TCP service name or a string containing only a decimal
752 * positive integer to a port number. Returns -1 for error. */
753 int servport(const char *service);
755 #ifndef HAVE_GETNAMEINFO
756 # define NI_NUMERICHOST 1
757 # define NI_NUMERICSERV 2
759 # define NI_NAMEREQD 8
763 int fm_getaddrinfo(const char *node, const char *serv, const struct addrinfo *hints, struct addrinfo **res);
764 void fm_freeaddrinfo(struct addrinfo *ai);
766 /* prototypes from tls.c */
767 int maybe_tls(struct query *ctl);
768 int must_tls(struct query *ctl);
770 /* prototype from rfc822valid.c */
771 int rfc822_valid_msgid(const unsigned char *);
773 /* macro to determine if we want to spam progress to stdout */
774 #define want_progress() \
775 ((outlevel >= O_VERBOSE || (outlevel > O_SILENT && run.showdots)) \
777 && (run.showdots || !is_a_file(1)))
780 /* fetchmail.h ends here */