]> Pileus Git - ~andy/fetchmail/blobdiff - fetchmail.h
Add parameter to host_fqdn() to state if the domain name is required, i. e.
[~andy/fetchmail] / fetchmail.h
index ac89f42c8fcc4522a88e9a80d701ea6cd1b2e4fd..257d84cda73cc22e476724a46fc90a61129436a8 100644 (file)
@@ -1,3 +1,5 @@
+#ifndef _FETCHMAIL_H
+#define _FETCHMAIL_H
 /*
  * For license terms, see the file COPYING in this directory.
  */
@@ -8,6 +10,30 @@
 /* We need this for size_t */
 #include <sys/types.h>
 
+/* We need this for time_t */
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+#include <stdio.h>
+
+/* Import Trio if needed */
+#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
+#  include "trio/trio.h"
+#endif
+
+/* We need this for strstr */
+#if !defined(HAVE_STRSTR) && !defined(strstr)
+char *strstr(const char *, const char *);
+#endif
+
 /* constants designating the various supported protocols */
 #define                P_AUTO          1
 #define                P_POP2          2
 #define                P_ETRN          7
 #define                P_ODMR          8
 
-#if INET6_ENABLE
 #define                SMTP_PORT       "smtp"
+#define                SMTP_PORT_NUM   25
 #define                KPOP_PORT       "kpop"
-#else /* INET6_ENABLE */
-#define                SMTP_PORT       25
-#define                KPOP_PORT       1109
-#endif /* INET6_ENABLE */
 
 #ifdef SSL_ENABLE
 #define                SIMAP_PORT      993
 #define                A_KERBEROS_V5   6       /* authenticate w/ Kerberos V5 */
 #define        A_GSSAPI        7       /* authenticate with GSSAPI */
 #define                A_SSH           8       /* authentication at session level */
-
-/* some protocols (KERBEROS, GSSAPI, SSH) don't require a password */
-#define NO_PASSWORD(ctl)       ((ctl)->server.authenticate > A_OTP || (ctl)->server.protocol == P_ETRN)
+#define                A_MSN           9       /* same as NTLM with keyword MSN */
+
+/* some protocols or authentication types (KERBEROS, GSSAPI, SSH) don't
+ * require a password */
+#define NO_PASSWORD(ctl) \
+    ((ctl)->server.authenticate == A_OTP \
+     || (ctl)->server.authenticate == A_KERBEROS_V4 \
+     || (ctl)->server.authenticate == A_KERBEROS_V5 \
+     || (ctl)->server.authenticate == A_GSSAPI \
+     || (ctl)->server.authenticate == A_SSH \
+     || (ctl)->server.protocol == P_ETRN)
 
 /*
  * Definitions for buffer sizes.  We get little help on setting maxima
@@ -165,13 +195,8 @@ struct query;
 struct method          /* describe methods for protocol state machine */
 {
     const char *name;          /* protocol name */
-#if INET6_ENABLE
-    const char *service;
-    const char *sslservice;
-#else /* INET6_ENABLE */
-    int        port;                   /* service port */
-    int        sslport;                /* service port for ssl */
-#endif /* INET6_ENABLE */
+    const char *service;       /* service port (unencrypted) */
+    const char *sslservice;    /* service port (SSL) */
     flag tagged;               /* if true, generate & expect command tags */
     flag delimited;            /* if true, accept "." message delimiter */
     int (*parse_response)(int, char *);
@@ -196,6 +221,8 @@ struct method               /* describe methods for protocol state machine */
                                /* delete method */
     int (*mark_seen)(int, struct query *, int);
                                /* mark as seen method */
+    int (*end_mailbox_poll)(int, struct query *);
+                               /* end-of-mailbox processing */
     int (*logout_cmd)(int, struct query *);
                                /* logout command */
     flag retry;                        /* can getrange poll for new messages? */
@@ -209,12 +236,7 @@ struct hostdata            /* shared among all user connections to given server */
     struct idlist *akalist;            /* server name first, then akas */
     struct idlist *localdomains;       /* list of pass-through domains */
     int protocol;                      /* protocol type */
-#if INET6_ENABLE
-    char *service;                     /* IPv6 service name */
-    void *netsec;                      /* IPv6 security request */
-#else /* INET6_ENABLE */
-    int port;                          /* TCP/IP service port number */
-#endif /* INET6_ENABLE */
+    char *service;                     /* service name */
     int interval;                      /* # cycles to skip between polls */
     int authenticate;                  /* authentication mode to try */
     int timeout;                       /* inactivity timout in seconds */
@@ -227,16 +249,21 @@ struct hostdata           /* shared among all user connections to given server */
 #ifdef SDPS_ENABLE
     flag sdps;                         /* use Demon Internet SDPS *ENV */
 #endif /* SDPS_ENABLE */
-    flag checkalias;                   /* resolve aliases by comparing IPs? */
+    flag checkalias;                   /* resolve aliases by comparing IPs? */
+    flag tracepolls;                   /* if TRUE, add poll trace info to Received */
     char *principal;                   /* Kerberos principal for mail service */
     char *esmtp_name, *esmtp_password; /* ESMTP AUTH information */
 
 #if defined(linux) || defined(__FreeBSD__)
+#define CAN_MONITOR
+#endif
+
+#ifdef CAN_MONITOR
     char *interface;
     char *monitor;
     int  monitor_io;
     struct interface_pair_s *interface_pair;
-#endif /* linux */
+#endif
 
     char *plugin,*plugout;
 
@@ -245,7 +272,8 @@ struct hostdata             /* shared among all user connections to given server */
     int poll_count;                    /* count of polls so far */
     char *queryname;                   /* name to attempt DNS lookup on */
     char *truename;                    /* "true name" of server host */
-    char *trueaddr;                     /* IP address of truename, as char */
+    struct sockaddr *trueaddr;         /* IP address of truename */
+    size_t trueaddr_len;               /* size of trueaddr data */
     struct hostdata *lead_server;      /* ptr to lead query for this server */
     int esmtp_options;
 };
@@ -280,6 +308,7 @@ struct query
     flag keep;                 /* if TRUE, leave messages undeleted */
     flag fetchall;             /* if TRUE, fetch all (not just unseen) */
     flag flush;                        /* if TRUE, delete messages already seen */
+    flag limitflush;           /* if TRUE, delete oversized mails */
     flag rewrite;              /* if TRUE, canonicalize recipient addresses */
     flag stripcr;              /* if TRUE, strip CRs in text */
     flag forcecr;              /* if TRUE, force CRs before LFs in text */
@@ -304,7 +333,6 @@ struct query
     flag sslcertck;            /* Strictly check the server cert. */
     char *sslfingerprint;      /* Fingerprint to check against */
     char *properties;          /* passthrough properties for extensions */
-    flag tracepolls;           /* if TRUE, add poll trace info to Received */
 
     /* internal use -- per-poll state */
     flag active;               /* should we actually poll this server? */
@@ -384,6 +412,7 @@ extern flag peek_capable;   /* can we read msgs without setting seen? */
 extern struct runctl run;      /* global controls for this run */
 extern flag nodetach;          /* if TRUE, don't detach daemon process */
 extern flag quitmode;          /* if --quit was set */
+extern int  quitind;           /* optind after position of last --quit option */
 extern flag check_only;                /* if --check was set */
 extern char *rcfile;           /* path name of rc file */
 extern int linelimit;          /* limit # lines retrieved per site */
@@ -401,6 +430,11 @@ extern char *sdps_envfrom;
 extern char *sdps_envto;
 #endif /* SDPS_ENABLE */
 
+extern const char *iana_charset;       /* IANA assigned charset name */
+
+/* from ucs/norm_charmap.c */
+const char *norm_charmap(const char *name);
+
 /* prototypes for globally callable functions */
 
 /* from /usr/include/sys/cdefs.h */
@@ -432,7 +466,7 @@ void report_at_line ();
 
 /* driver.c -- main driver loop */
 void set_timeout(int);
-int isidletimeout(void);
+int is_idletimeout(void);
 void resetidletimeout(void);
 int do_protocol(struct query *, const struct method *);
 
@@ -461,8 +495,10 @@ int gen_transact();
 extern struct msgblk msgblk;
 
 /* lock.c: concurrency locking */
-void lock_setup(void), lock_assert(void);
-void lock_or_die(void), lock_release(void);
+void lock_setup(void);
+void lock_assert(void);
+void lock_or_die(void);
+void fm_lock_release(void);
 int lock_state(void);
 void lock_dispose(void);
 
@@ -492,6 +528,7 @@ extern int mytimeout;
 
 /* idle.c */
 int interruptible_idle(int interval);
+extern volatile int lastsig;
 
 /* sink.c: forwarding */
 void smtp_close(struct query *, int);
@@ -503,8 +540,8 @@ void release_sink(struct query *);
 int close_sink(struct query *, struct msgblk *, flag);
 int open_warning_by_mail(struct query *, struct msgblk *);
 #if defined(HAVE_STDARG_H)
-void stuff_warning(struct query *, const char *, ... )
-    __attribute__ ((format (printf, 2, 3)))
+void stuff_warning(const char *, struct query *, const char *, ... )
+    __attribute__ ((format (printf, 3, 4)))
     ;
 #else
 void stuff_warning();
@@ -512,7 +549,7 @@ void stuff_warning();
 void close_warning_by_mail(struct query *, struct msgblk *);
 
 /* rfc822.c: RFC822 header parsing */
-unsigned char *reply_hack(unsigned char *, const unsigned char *, int *);
+unsigned char *reply_hack(unsigned char *, const unsigned char *, size_t *);
 unsigned char *nxtaddr(const unsigned char *);
 
 /* uid.c: UID support */
@@ -572,23 +609,8 @@ int interface_approve(struct hostdata *, flag domonitor);
 #endif
 XMALLOCTYPE *xmalloc(size_t);
 XMALLOCTYPE *xrealloc(/*@null@*/ XMALLOCTYPE *, size_t);
+#define xfree(p) { if (p) { free(p); } (p) = 0; }
 char *xstrdup(const char *);
-#if defined(HAVE_ALLOCA_H)
-#include <alloca.h>
-#else
-#ifdef _AIX
-#pragma alloca
-#endif
-#endif
-#define        xalloca(ptr, t, n)      if (!(ptr = (t) alloca(n)))\
-       {report(stderr, GT_("alloca failed")); exit(PS_UNDEFINED);}
-#if 0
-/*
- * This is a hack to help xgettext which cannot find strings in
- * macro definitions like the one for xalloca above.
- */
-static char *dummy = gettext_noop("alloca failed");
-#endif
 
 /* protocol driver and methods */
 int doPOP2 (struct query *); 
@@ -600,7 +622,7 @@ int doODMR (struct query *);
 /* authentication functions */
 int do_cram_md5(int sock, char *command, struct query *ctl, char *strip);
 int do_rfc1731(int sock, char *command, char *truename);
-int do_gssauth(int sock, char *command, char *hostname, char *username);
+int do_gssauth(int sock, char *command, char *service, char *hostname, char *username);
 int do_otp(int sock, char *command, struct query *ctl);
 
 /* miscellanea */
@@ -625,9 +647,10 @@ char *visbuf(const char *);
 const char *showproto(int);
 void dump_config(struct runctl *runp, struct query *querylist);
 int is_host_alias(const char *, struct query *);
-char *host_fqdn(void);
+char *host_fqdn(int required);
 char *rfc822timestamp(void);
-flag isafile(int);
+flag is_a_file(int);
+char *rfc2047e(const char*, const char *);
 
 void yyerror(const char *);
 int yylex(void);
@@ -647,7 +670,7 @@ void itimerthread(void*);
 
 # if HAVE_STRERROR
 #  ifndef strerror             /* On some systems, strerror is a macro */
-char *strerror ();
+char *strerror (int);
 #  endif
 # endif /* HAVE_STRERROR */
 
@@ -660,6 +683,10 @@ char *strerror ();
 #endif
 #endif
 
+#ifndef HAVE_STPCPY
+char *stpcpy(char *, const char*);
+#endif
+
 #ifdef FETCHMAIL_DEBUG
 #define exit(e) do { \
        FILE *out; \
@@ -678,4 +705,34 @@ char *strerror ();
 #define ROOT_UID 0
 #endif /* __CYGWIN__ */
 
+extern int mailserver_socket_temp;
+extern char *program_name;
+
+/* POSIX space characters,
+ * <tab>;<newline>;<vertical-tab>;<form-feed>;<carriage-return>;<space> */
+#define POSIX_space "\t\n\v\f\r "
+
+/* strlcpy/strlcat prototypes */
+#ifndef HAVE_STRLCAT
+size_t
+strlcat(char *dst, const char *src, size_t siz);
+#endif
+#ifndef HAVE_STRLCPY
+size_t
+strlcpy(char *dst, const char *src, size_t siz);
+#endif
+
+/** Resolve the a TCP service name or a string containing only a decimal
+ * positive integer to a port number. Returns -1 for error. */
+int servport(const char *service);
+
+#ifndef HAVE_GETNAMEINFO
+# define NI_NUMERICHOST        1
+# define NI_NUMERICSERV        2
+# define NI_NOFQDN     4
+# define NI_NAMEREQD   8
+# define NI_DGRAM      16
+#endif
+
+#endif
 /* fetchmail.h ends here */