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"
42 /* We need this for strstr */
43 #if !defined(HAVE_STRSTR) && !defined(strstr)
44 char *strstr(const char *, const char *);
49 /* constants designating the various supported protocols */
58 #define SMTP_PORT "smtp"
59 #define SMTP_PORT_NUM 25
60 #define KPOP_PORT "kpop"
63 #define SIMAP_PORT 993
64 #define SPOP3_PORT 995
68 * We need to distinguish between mailbox and mailbag protocols.
69 * Under a mailbox protocol wwe're pulling mail for a speecific user.
70 * Under a mailbag protocol we're fetching mail for an entire domain.
72 #define MAILBOX_PROTOCOL(ctl) ((ctl)->server.protocol < P_ETRN)
74 /* authentication types */
75 #define A_ANY 0 /* use the first method that works */
76 #define A_PASSWORD 1 /* password authentication */
77 #define A_NTLM 2 /* Microsoft NTLM protocol */
78 #define A_CRAM_MD5 3 /* CRAM-MD5 shrouding (RFC2195) */
79 #define A_OTP 4 /* One-time password (RFC1508) */
80 #define A_KERBEROS_V4 5 /* authenticate w/ Kerberos V4 */
81 #define A_KERBEROS_V5 6 /* authenticate w/ Kerberos V5 */
82 #define A_GSSAPI 7 /* authenticate with GSSAPI */
83 #define A_SSH 8 /* authentication at session level */
84 #define A_MSN 9 /* same as NTLM with keyword MSN */
85 #define A_EXTERNAL 10 /* external authentication (client cert) */
87 /* some protocols or authentication types (KERBEROS, GSSAPI, SSH) don't
88 * require a password */
89 #define NO_PASSWORD(ctl) \
90 ((ctl)->server.authenticate == A_OTP \
91 || (ctl)->server.authenticate == A_KERBEROS_V4 \
92 || (ctl)->server.authenticate == A_KERBEROS_V5 \
93 || (ctl)->server.authenticate == A_GSSAPI \
94 || (ctl)->server.authenticate == A_SSH \
95 || (ctl)->server.authenticate == A_EXTERNAL \
96 || (ctl)->server.protocol == P_ETRN)
99 * Definitions for buffer sizes. We get little help on setting maxima
100 * from IMAP RFCs up to 2060, so these are mostly from POP3.
102 #define HOSTLEN 635 /* max hostname length (RFC1123) */
103 #define POPBUFSIZE 512 /* max length of response (RFC1939) */
104 #define IDLEN 128 /* max length of UID (RFC1939) */
106 /* per RFC1939 this should be 40, but Microsoft Exchange ignores that limit */
107 #define USERNAMELEN 128 /* max POP3 arg length */
109 /* clear a netBSD kernel parameter out of the way */
113 * The RFC822 limit on message line size is just 998. But
114 * make this *way* oversized; idiot DOS-world mailers that
115 * don't line-wrap properly often ship entire paragraphs as
118 #define MSGBUFSIZE 8192
120 #define NAMELEN 64 /* max username length */
121 #define PASSWORDLEN 64 /* max password length */
122 #define DIGESTLEN 33 /* length of MD5 digest */
124 /* exit code values */
125 /* NOTE THAT PS_SUCCESS MUST ALWAYS BE 0 - SOME PARTS OF THE CODE
126 * RELY ON THIS VALUE! */
127 #define PS_SUCCESS 0 /* successful receipt of messages */
128 #define PS_NOMAIL 1 /* no mail available */
129 #define PS_SOCKET 2 /* socket I/O woes */
130 #define PS_AUTHFAIL 3 /* user authorization failed */
131 #define PS_PROTOCOL 4 /* protocol violation */
132 #define PS_SYNTAX 5 /* command-line syntax error */
133 #define PS_IOERR 6 /* bad permissions on rc file */
134 #define PS_ERROR 7 /* protocol error */
135 #define PS_EXCLUDE 8 /* client-side exclusion error */
136 #define PS_LOCKBUSY 9 /* server responded lock busy */
137 #define PS_SMTP 10 /* SMTP error */
138 #define PS_DNS 11 /* fatal DNS error */
139 #define PS_BSMTP 12 /* output batch could not be opened */
140 #define PS_MAXFETCH 13 /* poll ended by fetch limit */
141 #define PS_SERVBUSY 14 /* server is busy */
142 /* leave space for more codes */
143 #define PS_UNDEFINED 23 /* something I hadn't thought of */
144 #define PS_TRANSIENT 24 /* transient failure (internal use) */
145 #define PS_REFUSED 25 /* mail refused (internal use) */
146 #define PS_RETAINED 26 /* message retained (internal use) */
147 #define PS_REPOLL 28 /* repoll immediately with changed parameters (internal use) */
148 #define PS_IDLETIMEOUT 29 /* timeout on imap IDLE (internal use) */
149 #define PS_UNTAGGED 30 /* untagged response on imap command (internal use) */
151 /* output noise level */
152 #define O_SILENT 0 /* mute, max squelch, etc. */
153 #define O_NORMAL 1 /* user-friendly */
154 #define O_VERBOSE 2 /* chatty */
155 #define O_DEBUG 3 /* prolix */
156 #define O_MONITOR O_VERBOSE
158 #define SIZETICKER 1024 /* print 1 dot per this many bytes */
161 * We #ifdef this and use flag rather than bool
162 * to avoid a type clash with curses.h
170 /* we need to use zero as a flag-uninitialized value */
174 /** run control data */
177 char *logfile; /** where to write log information */
178 char *idfile; /** where to store UID data */
179 char *pidfile; /** where to record the PID of daemon mode processes */
180 const char *postmaster;
182 int poll_interval; /** poll interval in seconds (daemon mode, 0 == off) */
192 /** Dual-use entry of singly-linked list for storing id/status or id/id2
196 char *id; /**< key */
202 flag mark; /**< UID-index information */
204 status; /**< value for id/status pairs */
205 char *id2; /**< value for id/id2 pairs */
206 } val; /**< union to store value for key \a id */
207 struct idlist *next; /**< pointer to next list element */
210 /** List of possible values for idlist::mark */
212 UID_UNSEEN= 0, /**< id hasn't been seen */
213 UID_SEEN= 1, /**< id was seen, but not deleted */
214 UID_DELETED= 2, /**< this message has been marked deleted */
215 UID_EXPUNGED= 3 /**< this message has been expunged */
222 struct method /* describe methods for protocol state machine */
224 const char *name; /* protocol name */
225 const char *service; /* service port (unencrypted) */
226 const char *sslservice; /* service port (SSL) */
227 flag tagged; /* if true, generate & expect command tags */
228 flag delimited; /* if true, accept "." message delimiter */
229 int (*parse_response)(int, char *);
230 /* response_parsing function */
231 int (*getauth)(int, struct query *, char *);
232 /* authorization fetcher */
233 int (*getrange)(int, struct query *, const char *, int *, int *, int *);
234 /* get message range to fetch */
235 int (*getsizes)(int, int, int *);
236 /* get sizes of messages */
237 int (*getpartialsizes)(int, int, int, int *);
238 /* get sizes of subset of messages */
239 int (*is_old)(int, struct query *, int);
240 /* check for old message */
241 int (*fetch_headers)(int, struct query *, int, int *);
242 /* fetch header from a given message */
243 int (*fetch_body)(int, struct query *, int, int *);
244 /* fetch a given message */
245 int (*trail)(int, struct query *, const char *);
246 /* eat trailer of a message */
247 int (*delete_msg)(int, struct query *, int);
249 int (*mark_seen)(int, struct query *, int);
250 /* mark as seen method */
251 int (*end_mailbox_poll)(int, struct query *);
252 /* end-of-mailbox processing */
253 int (*logout_cmd)(int, struct query *);
255 flag retry; /* can getrange poll for new messages? */
258 enum badheader { BHREJECT = 0, BHACCEPT };
260 struct hostdata /* shared among all user connections to given server */
263 char *pollname; /* poll label of host */
264 char *via; /* "true" server name if non-NULL */
265 struct idlist *akalist; /* server name first, then akas */
266 struct idlist *localdomains; /* list of pass-through domains */
267 int protocol; /* protocol type */
268 const char *service; /* service name */
269 int interval; /* # cycles to skip between polls */
270 int authenticate; /* authentication mode to try */
271 int timeout; /* inactivity timout in seconds */
272 char *envelope; /* envelope address list header */
273 int envskip; /* skip to numbered envelope header */
274 char *qvirtual; /* prefix removed from local user id */
275 flag skip; /* suppress poll in implicit mode? */
276 flag dns; /* do DNS lookup on multidrop? */
277 flag uidl; /* use RFC1725 UIDLs? */
279 flag sdps; /* use Demon Internet SDPS *ENV */
280 #endif /* SDPS_ENABLE */
281 flag checkalias; /* resolve aliases by comparing IPs? */
282 flag tracepolls; /* if TRUE, add poll trace info to Received */
283 char *principal; /* Kerberos principal for mail service */
284 char *esmtp_name, *esmtp_password; /* ESMTP AUTH information */
285 enum badheader badheader; /* bad-header {pass|reject} */
287 #if defined(linux) || defined(__FreeBSD__)
295 struct interface_pair_s *interface_pair;
298 char *plugin,*plugout;
300 /* computed for internal use */
301 const struct method *base_protocol; /* relevant protocol method table */
302 int poll_count; /* count of polls so far */
303 char *queryname; /* name to attempt DNS lookup on */
304 char *truename; /* "true name" of server host */
305 struct sockaddr *trueaddr; /* IP address of truename */
306 size_t trueaddr_len; /* size of trueaddr data */
307 struct hostdata *lead_server; /* ptr to lead query for this server */
309 int workarounds; /* track which workarounds the user was warned about */
313 * bit flags to set in workarounds after the corresponding warning,
314 * which we assume to be server-specific, has been printed,
315 * so we don't spam our users in daemon mode.
317 #define WKA_TOP (1L << 0) /* Maillennium TOP -> RETR override warning */
321 /* mailserver connection controls */
322 struct hostdata server;
325 struct idlist *localnames; /* including calling user's name */
326 int wildcard; /* should unmatched names be passed through */
327 char *remotename; /* remote login name to use */
328 char *password; /* remote password to use */
329 struct idlist *mailboxes; /* list of mailboxes to check */
331 /* per-forwarding-target data */
332 struct idlist *smtphunt; /* list of SMTP hosts to try forwarding to */
333 struct idlist *domainlist; /* domainlist to fetch from */
334 char *smtpaddress; /* address to force in RCPT TO */
335 char *smtpname; /* full RCPT TO name, including domain */
336 struct idlist *antispam; /* list of listener's antispam response */
337 const char *mda; /* local MDA to pass mail to */
338 char *bsmtp; /* BSMTP output file */
339 char listener; /* what's the listener's wire protocol? */
340 #define SMTP_MODE 'S'
341 #define LMTP_MODE 'L'
342 char *preconnect; /* pre-connection command to execute */
343 char *postconnect; /* post-connection command to execute */
345 /* per-user control flags */
346 flag keep; /* if TRUE, leave messages undeleted */
347 flag fetchall; /* if TRUE, fetch all (not just unseen) */
348 flag flush; /* if TRUE, delete messages already seen */
349 flag limitflush; /* if TRUE, delete oversized mails */
350 flag rewrite; /* if TRUE, canonicalize recipient addresses */
351 flag stripcr; /* if TRUE, strip CRs in text */
352 flag forcecr; /* if TRUE, force CRs before LFs in text */
353 flag pass8bits; /* if TRUE, ignore Content-Transfer-Encoding */
354 flag dropstatus; /* if TRUE, drop Status lines in mail */
355 flag dropdelivered; /* if TRUE, drop Delivered-To lines in mail */
356 flag mimedecode; /* if TRUE, decode MIME-armored messages */
357 flag idle; /* if TRUE, idle after each poll */
358 int limit; /* limit size of retrieved messages */
359 int warnings; /* size warning interval */
360 int fetchlimit; /* max # msgs to get in single poll */
361 int fetchsizelimit; /* max # msg sizes to get in a request */
362 int fastuidl; /* do binary search for new UIDLs? */
363 int fastuidlcount; /* internal count for frequency of binary search */
364 int batchlimit; /* max # msgs to pass in single SMTP session */
365 int expunge; /* max # msgs to pass between expunges */
366 flag use_ssl; /* use SSL encrypted session */
367 char *sslkey; /* optional SSL private key file */
368 char *sslcert; /* optional SSL certificate file */
369 char *sslproto; /** force transport protocol (ssl2|ssl3|ssl23|tls1) - if NULL,
370 use ssl23 for SSL and opportunistic tls1 for non-SSL connections. */
371 char *sslcertfile; /* Trusted certificate file for checking the server cert */
372 char *sslcertpath; /* Trusted certificate directory for checking the server cert */
373 flag sslcertck; /* Strictly check the server cert. */
374 char *sslcommonname; /* CommonName to expect from server */
375 char *sslfingerprint; /* Fingerprint to check against */
376 char *properties; /* passthrough properties for extensions */
378 /* internal use -- per-poll state */
379 flag active; /* should we actually poll this server? */
380 char *destaddr; /* destination host for this query */
381 int errcount; /* count transient errors in last pass */
382 int authfailcount; /* count of authorization failures */
383 int wehaveauthed; /* We've managed to logon at least once! */
384 int wehavesentauthnote; /* We've sent an authorization failure note */
385 int wedged; /* wedged by auth failures or timeouts? */
386 char *smtphost; /* actual SMTP host we connected to */
387 char smtphostmode; /* what's the actual SMTP host's wire protocol? */
388 int smtp_socket; /* socket descriptor for SMTP connection */
389 unsigned int uid; /* UID of user to deliver to */
390 struct idlist *skipped; /* messages skipped on the mail server */
391 struct idlist *oldsaved, *newsaved;
392 struct idlist **oldsavedend;
393 char lastdigest[DIGESTLEN]; /* last MD5 hash seen on this connection */
394 char *folder; /* folder currently being polled */
396 /* internal use -- per-message state */
397 int mimemsg; /* bitmask indicating MIME body-type */
398 unsigned char digest[DIGESTLEN]; /* md5 digest buffer */
400 /* internal use -- housekeeping */
401 struct query *next; /* next query control block in chain */
404 struct msgblk /* message header parsed for open_sink() */
406 char *headers; /* raw message headers */
407 struct idlist *recipients; /* addressees */
408 char return_path[HOSTLEN + USERNAMELEN + 4];
415 * Numeric option handling. Numeric option value of zero actually means
416 * it's unspecified. Value less than zero is zero. The reason for this
417 * screwy encoding is so we can zero out an option block in order to set the
418 * numeric flags in it to unspecified.
420 #define NUM_VALUE_IN(n) (((n) == 0) ? -1 : (n))
421 #define NUM_VALUE_OUT(n) (((n) < 0) ? 0 : (n))
422 #define NUM_NONZERO(n) ((n) > 0)
423 #define NUM_ZERO(n) ((n) < 0)
424 #define NUM_SPECIFIED(n) ((n) != 0)
426 #define MULTIDROP(ctl) ((ctl)->wildcard || \
427 ((ctl)->localnames && (ctl)->localnames->next))
430 * Note: tags are generated with an a%04d format from a 1-origin
431 * integer sequence number. Length 4 permits transaction numbers
432 * up to 9999, so we force rollover with % 10000. There's no special
433 * reason for this format other than to look like the exmples in the
436 #define TAGLEN 6 /* 'a' + 4 digits + NUL */
437 extern char tag[TAGLEN];
440 /* list of hosts assembled from run control file and command line */
441 extern struct query cmd_opts, *querylist;
443 /* what's returned by envquery */
444 extern void envquery(int, char **);
446 /* controls the detail level of status/progress messages written to stderr */
447 extern int outlevel; /* see the O_.* constants above */
448 extern int yydebug; /* enable parse debugging */
450 /* these get computed */
451 extern int batchcount; /* count of messages sent in current batch */
452 extern flag peek_capable; /* can we read msgs without setting seen? */
454 /* miscellaneous global controls */
455 extern struct runctl run; /* global controls for this run */
456 extern flag nodetach; /* if TRUE, don't detach daemon process */
457 extern flag quitmode; /* if --quit was set */
458 extern int quitind; /* optind after position of last --quit option */
459 extern flag check_only; /* if --check was set */
460 extern char *rcfile; /* path name of rc file */
461 extern int linelimit; /* limit # lines retrieved per site */
462 extern flag versioninfo; /* emit only version info */
463 extern char *user; /* name of invoking user */
464 extern char *home; /* home directory of invoking user */
465 extern char *fmhome; /* fetchmail home directory */
466 extern int pass; /* number of re-polling pass */
467 extern flag configdump; /* dump control blocks as Python dictionary */
468 extern const char *fetchmailhost; /* either "localhost" or an FQDN */
469 extern int suppress_tags; /* suppress tags in tagged protocols? */
470 extern char shroud[PASSWORDLEN*2+3]; /* string to shroud in debug output */
472 extern char *sdps_envfrom;
473 extern char *sdps_envto;
474 #endif /* SDPS_ENABLE */
476 extern const char *iana_charset; /* IANA assigned charset name */
478 /* from/for ucs/norm_charmap.c */
479 #include "ucs/norm_charmap.h"
481 /* prototypes for globally callable functions */
483 /* from /usr/include/sys/cdefs.h */
484 #if !defined __GNUC__ || __GNUC__ < 2
485 # define __attribute__(xyz) /* Ignore. */
488 /* error.c: Error reporting */
489 #if defined(HAVE_STDARG_H)
490 void report_init(int foreground);
491 /** Flush partial message, suppress program name tag for next report printout. */
492 void report_flush(FILE *fp);
493 void report (FILE *fp, const char *format, ...)
494 __attribute__ ((format (printf, 2, 3)))
496 void report_build (FILE *fp, const char *format, ...)
497 __attribute__ ((format (printf, 2, 3)))
499 void report_complete (FILE *fp, const char *format, ...)
500 __attribute__ ((format (printf, 2, 3)))
502 void report_at_line (FILE *fp, int, const char *, unsigned int, const char *, ...)
503 __attribute__ ((format (printf, 5, 6)))
507 void report_build ();
508 void report_complete ();
509 void report_at_line ();
512 /* driver.c -- main driver loop */
513 void set_timeout(int);
514 int is_idletimeout(void);
515 void resetidletimeout(void);
516 int do_protocol(struct query *, const struct method *);
518 /* transact.c: transaction support */
519 void init_transact(const struct method *);
520 int readheaders(int sock,
525 flag *suppress_readbody);
526 int readbody(int sock, struct query *ctl, flag forward, int len);
527 #if defined(HAVE_STDARG_H)
528 void gen_send(int sock, const char *, ... )
529 __attribute__ ((format (printf, 2, 3)))
531 int gen_recv(int sock, char *buf, int size);
532 int gen_transact(int sock, const char *, ... )
533 __attribute__ ((format (printf, 2, 3)))
540 extern struct msgblk msgblk;
542 /* use these to track what was happening when the nonresponse timer fired */
543 #define GENERAL_WAIT 0 /* unknown wait type */
544 #define OPEN_WAIT 1 /* waiting from mailserver open */
545 #define SERVER_WAIT 2 /* waiting for mailserver response */
546 #define LISTENER_WAIT 3 /* waiting for listener initialization */
547 #define FORWARDING_WAIT 4 /* waiting for listener response */
550 /* response hooks can use this to identify the query stage */
551 #define STAGE_GETAUTH 0
552 #define STAGE_GETRANGE 1
553 #define STAGE_GETSIZES 2
554 #define STAGE_FETCH 3
556 #define STAGE_LOGOUT 5
559 extern int mytimeout;
561 /* mark values for name lists */
562 #define XMIT_ACCEPT 1 /* accepted; matches local domain or name */
563 #define XMIT_REJECT 2 /* rejected; no match */
564 #define XMIT_RCPTBAD 3 /* SMTP listener rejected the name */
567 int interruptible_idle(int interval);
568 extern volatile int lastsig;
570 /* sink.c: forwarding */
571 void smtp_close(struct query *, int);
572 int smtp_open(struct query *);
573 int smtp_setup(struct query *);
574 char *rcpt_address(struct query *, const char *, int);
575 int stuffline(struct query *, char *);
576 int open_sink(struct query*, struct msgblk *, int*, int*);
577 void release_sink(struct query *);
578 int close_sink(struct query *, struct msgblk *, flag);
579 int open_warning_by_mail(struct query *);
580 #if defined(HAVE_STDARG_H)
581 void stuff_warning(const char *, struct query *, const char *, ... )
582 __attribute__ ((format (printf, 3, 4)))
585 void stuff_warning();
587 void close_warning_by_mail(struct query *, struct msgblk *);
589 /* rfc822.c: RFC822 header parsing */
590 char *reply_hack(char *, const char *, size_t *);
591 char *nxtaddr(const char *);
593 /* uid.c: UID support */
594 extern int dofastuidl;
595 void initialize_saved_lists(struct query *hostlist, const char *idfile);
596 void expunge_uids(struct query *ctl);
597 void uid_swap_lists(struct query *ctl);
598 void uid_discard_new_list(struct query *ctl);
599 void uid_reset_num(struct query *ctl);
600 void write_saved_lists(struct query *hostlist, const char *idfile);
603 struct idlist *save_str(struct idlist **idl, const char *str, flag status);
604 void free_str_list(struct idlist **idl);
605 void save_str_pair(struct idlist **idl, const char *str1, const char *str2);
606 struct idlist *str_in_list(struct idlist **idl, const char *str, const flag caseblind);
607 int str_nr_in_list(struct idlist **idl, const char *str);
608 int str_nr_last_in_list(struct idlist **idl, const char *str);
609 void str_set_mark(struct idlist **idl, const char *str, const flag val);
610 int count_list(struct idlist **idl);
611 char *str_from_nr_list(struct idlist **idl, long number);
612 char *str_find(struct idlist **idl, long number);
613 struct idlist *id_find(struct idlist **idl, long number);
614 char *idpair_find(struct idlist **idl, const char *id);
615 int delete_str(struct idlist **idl, long num);
616 struct idlist *copy_str_list(struct idlist *idl);
617 void append_str_list(struct idlist **idl, struct idlist **nidl);
620 int prc_parse_file(const char *, const flag);
621 int prc_filecheck(const char *, const flag);
624 void to64frombits(char *, const void *, int);
625 int from64tobits(void *, const char *, int maxlen);
628 /* Bit-mask returned by MimeBodyType */
629 #define MSG_IS_7BIT 0x01
630 #define MSG_IS_8BIT 0x02
631 #define MSG_NEEDS_DECODE 0x80
632 extern void UnMimeHeader(char *buf);
633 extern int MimeBodyType(char *hdrs, int WantDecode);
634 extern int UnMimeBodyline(char **buf, flag delimited, flag issoftline);
637 void interface_init(void);
638 void interface_parse(char *, struct hostdata *);
639 void interface_note_activity(struct hostdata *);
640 int interface_approve(struct hostdata *, flag domonitor);
644 /* protocol driver and methods */
645 int doPOP3 (struct query *);
646 int doIMAP (struct query *);
647 int doETRN (struct query *);
648 int doODMR (struct query *);
650 /* authentication functions */
651 int do_cram_md5(int sock, const char *command, struct query *ctl, const char *strip);
652 int do_rfc1731(int sock, const char *command, const char *truename);
653 int check_gss_creds(const char *service, const char *hostname);
654 int do_gssauth(int sock, const char *command, const char *service, const char *hostname, const char *username);
655 int do_otp(int sock, const char *command, struct query *ctl);
659 /* these should be of size PATH_MAX */
660 extern char currentwd[1024], rcfiledir[1024];
662 struct query *hostalloc(struct query *);
663 int parsecmdline (int, char **, struct runctl *, struct query *);
664 char *prependdir (const char *, const char *);
665 char *MD5Digest (unsigned const char *);
666 void hmac_md5 (const unsigned char *, size_t, const unsigned char *, size_t, unsigned char *, size_t);
667 int POP3_auth_rpa(char *, char *, int socket);
668 typedef RETSIGTYPE (*SIGHANDLERTYPE) (int);
669 void deal_with_sigchld(void);
670 RETSIGTYPE null_signal_handler(int sig);
671 SIGHANDLERTYPE set_signal_handler(int sig, SIGHANDLERTYPE handler);
672 int daemonize(const char *);
673 char *fm_getpassword(char *);
674 void escapes(const char *, char *);
675 char *visbuf(const char *);
676 const char *showproto(int);
677 void dump_config(struct runctl *runp, struct query *querylist);
678 int is_host_alias(const char *, struct query *, struct addrinfo **);
680 extern struct addrinfo *ai0, *ai1;
682 /** Try to obtain fully qualified hostname of current host. Exit with
683 * PS_DNS if \a required is true and there is a DNS error. Exit with
684 * PS_DNS if gethostname() fails, independent of the value of \a
687 * - fully qualified hostname if \a required is non-zero.
688 * - unqualified or fully qualified hostname if \a required is zero (0).
690 char *host_fqdn(int required /** exit with PS_DNS if the name cannot be qualified */);
691 char *rfc822timestamp(void);
693 char *rfc2047e(const char*, const char *);
695 void yyerror(const char *);
699 # if !defined(strerror) && !defined(HAVE_DECL_STRERROR) /* On some systems, strerror is a macro */
700 char *strerror (int);
702 #endif /* HAVE_STRERROR */
704 #define STRING_DISABLED (char *)-1
705 #define STRING_DUMMY ""
709 #define S_IXGRP 0000010
714 char *stpcpy(char *, const char*);
719 #else /* !__CYGWIN__ */
721 #endif /* __CYGWIN__ */
723 extern int mailserver_socket_temp;
724 extern const char *program_name;
726 /* POSIX space characters,
727 * <tab>;<newline>;<vertical-tab>;<form-feed>;<carriage-return>;<space> */
728 #define POSIX_space "\t\n\v\f\r "
730 /** Resolve the a TCP service name or a string containing only a decimal
731 * positive integer to a port number. Returns -1 for error. */
732 int servport(const char *service);
734 #ifndef HAVE_GETNAMEINFO
735 # define NI_NUMERICHOST 1
736 # define NI_NUMERICSERV 2
738 # define NI_NAMEREQD 8
742 int fm_getaddrinfo(const char *node, const char *serv, const struct addrinfo *hints, struct addrinfo **res);
743 void fm_freeaddrinfo(struct addrinfo *ai);
745 /* prototypes from tls.c */
746 int maybe_tls(struct query *ctl);
747 int must_tls(struct query *ctl);
749 /* prototype from rfc822valid.c */
750 int rfc822_valid_msgid(const unsigned char *);
752 /* prototype from x509_name_match.c */
753 int name_match(const char *p1, const char *p2);
755 /* prototype from ntlmsubr.c */
757 int ntlm_helper(int sock, struct query *ctl, const char *protocol);
760 /* macro to determine if we want to spam progress to stdout */
761 #define want_progress() \
762 ((outlevel >= O_VERBOSE || (outlevel > O_SILENT && run.showdots)) \
764 && (run.showdots || !is_a_file(1)))
767 /* fetchmail.h ends here */