]> Pileus Git - ~andy/fetchmail/blob - fetchmail.h
Avoid conf\using log message.
[~andy/fetchmail] / fetchmail.h
1 /*
2  * For license terms, see the file COPYING in this directory.
3  */
4
5 /* constants designating the various supported protocols */
6 #define         P_AUTO          0
7 #define         P_POP2          2
8 #define         P_POP3          3
9 #define         P_IMAP          4
10 #define         P_APOP          5
11 #define         P_RPOP          6
12 #define         P_ETRN          7
13
14 #define         KPOP_PORT       1109
15
16 /* authentication types */
17 #define         A_PASSWORD      0       /* passwords in cleartext */
18 #define         A_KERBEROS      1       /* get Kerberos V4 ticket */
19
20 /* definitions for buffer sizes -- somewhat arbitrary */
21 #define         POPBUFSIZE      512     /* per RFC 937 */
22 #define         MSGBUFSIZE      2048    /* size of message read buffer */
23 #define         HOSTLEN         128     /* max hostname length */
24 #define         USERNAMELEN     32      /* max user-name length */
25 #define         PASSWORDLEN     64      /* max password length */
26 #define         DIGESTLEN       33      /* length of MD5 digest */
27 #define         IDLEN           128     /* length of UIDL message ID */
28
29 /* exit code values */
30 #define         PS_SUCCESS      0       /* successful receipt of messages */
31 #define         PS_NOMAIL       1       /* no mail available */
32 #define         PS_SOCKET       2       /* socket I/O woes */
33 #define         PS_AUTHFAIL     3       /* user authorization failed */
34 #define         PS_PROTOCOL     4       /* protocol violation */
35 #define         PS_SYNTAX       5       /* command-line syntax error */
36 #define         PS_IOERR        6       /* bad permissions on rc file */
37 #define         PS_ERROR        7       /* protocol error */
38 #define         PS_EXCLUDE      8       /* exclusion error */
39 #define         PS_SMTP         9       /* SMTP error */
40 #define         PS_UNDEFINED    10      /* something I hadn't thought of */
41 #define         PS_TRANSIENT    11      /* transient failure (internal use) */
42
43 /* output noise level */
44 #define         O_SILENT        0       /* mute, max squelch, etc. */
45 #define         O_NORMAL        1       /* user-friendly */
46 #define         O_VERBOSE       2       /* excessive */
47
48 #define         SIZETICKER      1024    /* print 1 dot per this many bytes */
49
50 /* we need to use zero as a flag-uninitialized value */
51 #define FLAG_TRUE       2
52 #define FLAG_FALSE      1
53
54 struct idlist
55 {
56     char *id;
57     union
58     {
59         int num;
60         char *id2;
61     } val;
62     struct idlist *next;
63 };
64
65
66 struct hostdata         /* shared among all user connections to given server */
67 {
68     /* rc file data */
69     struct idlist *names;               /* server name first, then akas */
70     struct idlist *localdomains;        /* list of pass-through domains */
71     int protocol;
72     int port;
73     int authenticate;
74     int timeout;
75     char *envelope;
76     int skip;
77     int dns;
78
79 #ifdef linux
80     char *interface;
81     char *monitor;
82     int  monitor_io;
83     struct interface_pair_s *interface_pair;
84 #endif /* linux */
85
86     /* computed for internal use */
87 #ifdef HAVE_GETHOSTBYNAME
88     char *canonical_name;               /* DNS canonical name of server host */
89 #endif /* HAVE_GETHOSTBYNAME */
90     struct hostdata *lead_server;       /* ptr to lead query for this server */
91     int esmtp_options;
92 };
93
94 struct query
95 {
96     /* mailserver connection controls */
97     struct hostdata server;
98
99     /* per-user data */
100     struct idlist *localnames;          /* including calling user's name */
101     int wildcard;               /* should unmatched names be passed through */
102     char *remotename;
103     char *password;
104     char *mailbox;
105     struct idlist *smtphunt;
106     char *smtphost;
107     char *mda;
108     char *preconnect;
109
110     /* per-user control flags */
111     int keep;
112     int fetchall;
113     int flush;
114     int rewrite;
115     int stripcr;
116     int limit;
117     int fetchlimit;
118     int batchlimit;
119
120     /* unseen, previous state of mailbox (initially from .fetchids) */
121     struct idlist *oldsaved, *newsaved;
122
123     /* internal use */
124     int active;
125     int errcount;               /* count transient errors in last pass */
126     struct query *next;         /* next query control block in chain */
127     FILE *smtp_sockfp;          /* socket descriptor for SMTP connection */
128     unsigned int uid;           /* UID of user to deliver to */
129     char digest [DIGESTLEN];    /* md5 digest buffer */
130 };
131
132 #define MULTIDROP(ctl)  (ctl->wildcard || \
133                                 ((ctl)->localnames && (ctl)->localnames->next))
134
135 struct method
136 {
137     char *name;                 /* protocol name */
138     int port;                   /* service port */
139     int tagged;                 /* if true, generate & expect command tags */
140     int delimited;              /* if true, accept "." message delimiter */
141     int (*parse_response)();    /* response_parsing function */
142     int (*getauth)();           /* authorization fetcher */
143     int (*getrange)();          /* get message range to fetch */
144     int (*getsizes)();          /* get sizes of messages */
145     int (*is_old)();            /* check for old message */
146     int (*fetch)();             /* fetch a given message */
147     int (*trail)();             /* eat trailer of a message */
148     int (*delete)();            /* delete method */
149     char *exit_cmd;             /* exit command */
150 };
151
152 #define TAGLEN  6
153 extern char tag[TAGLEN];
154
155 /* list of hosts assembled from run control file and command line */
156 extern struct query cmd_opts, *querylist;
157
158 /* controls the detail level of status/progress messages written to stderr */
159 extern int outlevel;            /* see the O_.* constants above */
160 extern int yydebug;             /* enable parse debugging */
161
162 /* daemon mode control */
163 extern int poll_interval;       /* poll interval in seconds */
164 extern int nodetach;            /* if TRUE, don't detach daemon process */
165 extern char *logfile;           /* log file for daemon mode */
166 extern int use_syslog;          /* if --syslog was set */
167 extern int quitmode;            /* if --quit was set */
168 extern int check_only;          /* if --check was set */
169 extern char *cmd_logfile;       /* if --logfile was set */
170
171 /* these get computed */
172 extern int batchcount;          /* count of messages sent in current batch */
173 extern int peek_capable;        /* can we read msgs without setting seen? */
174
175 /* miscellaneous global controls */
176 extern char *rcfile;            /* path name of rc file */
177 extern char *idfile;            /* path name of UID file */
178 extern int linelimit;           /* limit # lines retrieved per site */
179 extern int versioninfo;         /* emit only version info */
180 extern char *user;              /* name of invoking user */
181 extern char *fetchmailhost;     /* the name of the host running fetchmail */
182
183 /* prototypes for globally callable functions */
184 #if defined(HAVE_STDARG_H)
185 void error_init(int foreground);
186 void error (int status, int errnum, const char *format, ...);
187 void error_build (const char *format, ...);
188 void error_complete (int status, int errnum, const char *format, ...);
189 void gen_send (FILE *sockfp, char *, ... );
190 int gen_recv(FILE *sockfp, char *buf, int size);
191 int gen_transact (FILE *sockfp, char *, ... );
192 #else
193 void error ();
194 void error_build ();
195 void error_complete ();
196 void gen_send ();
197 int gen_transact ();
198 #endif
199
200 void *xmalloc(int);
201 void *xrealloc(void *, int);
202 char *xstrdup(const char *);
203
204 int do_protocol(struct query *, const struct method *);
205 int doPOP2 (struct query *); 
206 int doPOP3 (struct query *);
207 int doIMAP (struct query *);
208 int doETRN (struct query *);
209
210 void reply_hack(char *, const char *);
211 char *nxtaddr(const char *);
212
213 void initialize_saved_lists(struct query *, const char *);
214 struct idlist *save_str(struct idlist **, int, const char *);
215 void free_str_list(struct idlist **);
216 void save_str_pair(struct idlist **, const char *, const char *);
217 void free_str_pair_list(struct idlist **);
218 int delete_str(struct idlist **, int);
219 int str_in_list(struct idlist **, const char *);
220 char *str_find(struct idlist **, int);
221 char *idpair_find(struct idlist **, const char *);
222 void append_str_list(struct idlist **, struct idlist **);
223 void update_str_lists(struct query *);
224 void write_saved_lists(struct query *, const char *);
225
226 struct query *hostalloc(struct query *); 
227 int parsecmdline (int, char **, struct query *);
228 void optmerge(struct query *, struct query *);
229 char *MD5Digest (char *);
230 int daemonize(const char *, void (*)(int));
231
232 int prc_parse_file(const char *);
233 int prc_filecheck(const char *);
234
235 void interface_parse(char *, struct hostdata *);
236 void interface_note_activity(struct hostdata *);
237 int interface_approve(struct hostdata *);
238
239 char *getpassword(char *);
240
241 void escapes(const char *, char *);
242
243 void yyerror(const char *);
244 int yylex(void);
245
246 #define FALSE   0
247 #define TRUE    1
248
249 #define STRING_DISABLED (char *)-1