2 * For license terms, see the file COPYING in this directory.
5 /* constants designating the various supported protocols */
15 #define KPOP_PORT 1109
17 /* preauthentication types */
18 #define A_PASSWORD 0 /* password or inline authentication */
19 #define A_KERBEROS_V4 1 /* preauthenticate w/ Kerberos V4 */
21 /* definitions for buffer sizes -- somewhat arbitrary */
22 #define POPBUFSIZE 512 /* per RFC 937 */
23 #define MSGBUFSIZE 2048 /* size of message read buffer */
24 #define HOSTLEN 128 /* max hostname length */
25 #define USERNAMELEN 32 /* max user-name length */
26 #define PASSWORDLEN 64 /* max password length */
27 #define DIGESTLEN 33 /* length of MD5 digest */
28 #define IDLEN 128 /* length of UIDL message ID */
30 /* exit code values */
31 #define PS_SUCCESS 0 /* successful receipt of messages */
32 #define PS_NOMAIL 1 /* no mail available */
33 #define PS_SOCKET 2 /* socket I/O woes */
34 #define PS_AUTHFAIL 3 /* user authorization failed */
35 #define PS_PROTOCOL 4 /* protocol violation */
36 #define PS_SYNTAX 5 /* command-line syntax error */
37 #define PS_IOERR 6 /* bad permissions on rc file */
38 #define PS_ERROR 7 /* protocol error */
39 #define PS_EXCLUDE 8 /* client-side exclusion error */
40 #define PS_LOCKBUSY 9 /* server responded lock busy */
41 #define PS_SMTP 10 /* SMTP error */
42 #define PS_DNS 11 /* fatal DNS error */
43 #define PS_UNDEFINED 12 /* something I hadn't thought of */
44 #define PS_TRANSIENT 13 /* transient failure (internal use) */
45 #define PS_REFUSED 14 /* mail refused (internal use) */
46 #define PS_RETAINED 15 /* message retained (internal use) */
48 /* output noise level */
49 #define O_SILENT 0 /* mute, max squelch, etc. */
50 #define O_NORMAL 1 /* user-friendly */
51 #define O_VERBOSE 2 /* excessive */
53 #define SIZETICKER 1024 /* print 1 dot per this many bytes */
55 /* we need to use zero as a flag-uninitialized value */
71 * We #ifdef this and use flag rather than bool
72 * to avoid a type clash with curses.h
80 struct hostdata /* shared among all user connections to given server */
83 char *pollname; /* poll label of host */
84 char *via; /* "true" server name if non-NULL */
85 struct idlist *akalist; /* server name first, then akas */
86 struct idlist *localdomains; /* list of pass-through domains */
87 int protocol; /* protocol type */
88 int port; /* TCP/IP service port number */
89 int interval; /* # cycles to skip between polls */
90 int preauthenticate; /* preauthentication mode to try */
91 int timeout; /* inactivity timout in seconds */
92 char *envelope; /* envelope address list header */
93 flag skip; /* suppress poll in implicit mode? */
94 flag dns; /* do DNS lookup on multidrop? */
95 flag uidl; /* use RFC1725 UIDLs? */
101 struct interface_pair_s *interface_pair;
104 /* computed for internal use */
105 int poll_count; /* count of polls so far */
106 char *queryname; /* name to attempt DNS lookup on */
107 char *truename; /* "true name" of server host */
108 struct hostdata *lead_server; /* ptr to lead query for this server */
114 /* mailserver connection controls */
115 struct hostdata server;
118 struct idlist *localnames; /* including calling user's name */
119 int wildcard; /* should unmatched names be passed through */
120 char *remotename; /* remote login name to use */
121 char *password; /* remote password to use */
122 struct idlist *mailboxes; /* list of mailboxes to check */
123 struct idlist *smtphunt; /* list of SMTP hosts to try forwarding to */
124 char *smtphost; /* actual SMTP host to point to */
125 char *mda; /* local MDA to pass mail to */
126 char *preconnect; /* pre-connection command to execute */
127 char *postconnect; /* post-connection command to execute */
129 /* per-user control flags */
130 flag keep; /* if TRUE, leave messages undeleted */
131 flag fetchall; /* if TRUE, fetch all (not just unseen) */
132 flag flush; /* if TRUE, delete messages already seen */
133 flag rewrite; /* if TRUE, canonicalize recipient addresses */
134 flag stripcr; /* if TRUE, strip CRs in text */
135 flag forcecr; /* if TRUE, force CRs before LFs in text */
136 flag pass8bits; /* if TRUE, ignore Content-Transfer-Encoding */
137 flag dropstatus; /* if TRUE, drop Status lines in mail */
138 int limit; /* limit size of retrieved messages */
139 int fetchlimit; /* max # msgs to get in single poll */
140 int batchlimit; /* max # msgs to pass in single SMTP session */
142 /* unseen, previous state of mailbox (initially from .fetchids) */
143 struct idlist *oldsaved, *newsaved;
146 flag active; /* should we actually poll this server? */
147 int errcount; /* count transient errors in last pass */
148 int smtp_socket; /* socket descriptor for SMTP connection */
149 unsigned int uid; /* UID of user to deliver to */
150 char digest [DIGESTLEN]; /* md5 digest buffer */
151 struct query *next; /* next query control block in chain */
154 #define MULTIDROP(ctl) (ctl->wildcard || \
155 ((ctl)->localnames && (ctl)->localnames->next))
159 char *name; /* protocol name */
160 int port; /* service port */
161 flag tagged; /* if true, generate & expect command tags */
162 flag delimited; /* if true, accept "." message delimiter */
163 int (*parse_response)(); /* response_parsing function */
164 int (*getauth)(); /* authorization fetcher */
165 int (*getrange)(); /* get message range to fetch */
166 int (*getsizes)(); /* get sizes of messages */
167 int (*is_old)(); /* check for old message */
168 int (*fetch_headers)(); /* fetch FROM headera given message */
169 int (*fetch_body)(); /* fetch a given message */
170 int (*trail)(); /* eat trailer of a message */
171 int (*delete)(); /* delete method */
172 char *exit_cmd; /* exit command */
176 extern char tag[TAGLEN];
178 /* list of hosts assembled from run control file and command line */
179 extern struct query cmd_opts, *querylist;
181 /* what's returned by envquery */
182 extern void envquery(int, char **);
184 /* controls the detail level of status/progress messages written to stderr */
185 extern int outlevel; /* see the O_.* constants above */
186 extern int yydebug; /* enable parse debugging */
188 /* daemon mode control */
189 extern int poll_interval; /* poll interval in seconds */
190 extern flag nodetach; /* if TRUE, don't detach daemon process */
191 extern char *logfile; /* log file for daemon mode */
192 extern flag use_syslog; /* if --syslog was set */
193 extern flag quitmode; /* if --quit was set */
194 extern flag check_only; /* if --check was set */
195 extern char *cmd_logfile; /* if --logfile was set */
196 extern int cmd_daemon; /* if --daemon was set */
198 /* these get computed */
199 extern int batchcount; /* count of messages sent in current batch */
200 extern flag peek_capable; /* can we read msgs without setting seen? */
202 /* miscellaneous global controls */
203 extern char *rcfile; /* path name of rc file */
204 extern char *idfile; /* path name of UID file */
205 extern int linelimit; /* limit # lines retrieved per site */
206 extern flag versioninfo; /* emit only version info */
207 extern char *user; /* name of invoking user */
208 extern char *home; /* home directory of invoking user */
209 extern char *fetchmailhost; /* the name of the host running fetchmail */
211 /* prototypes for globally callable functions */
213 /* error.c: Error reporting */
214 #if defined(HAVE_STDARG_H)
215 void error_init(int foreground);
216 void error (int status, int errnum, const char *format, ...);
217 void error_build (const char *format, ...);
218 void error_complete (int status, int errnum, const char *format, ...);
219 void error_at_line (int, int, const char *, unsigned int, const char *, ...);
223 void error_complete ();
224 void error_at_line ();
227 /* driver.c: transaction support */
228 #if defined(HAVE_STDARG_H)
229 void gen_send (int sock, char *, ... );
230 int gen_recv(int sock, char *buf, int size);
231 int gen_transact (int sock, char *, ... );
238 /* rfc822.c: RFC822 header parsing */
239 char *reply_hack(char *, const char *);
240 char *nxtaddr(const char *);
242 /* uid.c: UID support */
243 void initialize_saved_lists(struct query *, const char *);
244 struct idlist *save_str(struct idlist **, int, const char *);
245 void free_str_list(struct idlist **);
246 void save_str_pair(struct idlist **, const char *, const char *);
247 void free_str_pair_list(struct idlist **);
248 int delete_str(struct idlist **, int);
249 int str_in_list(struct idlist **, const char *);
250 int str_nr_in_list(struct idlist **, const char *);
251 int count_list( struct idlist **idl );
252 char *str_from_nr_list( struct idlist **idl, int number );
253 char *str_find(struct idlist **, int);
254 char *idpair_find(struct idlist **, const char *);
255 void append_str_list(struct idlist **, struct idlist **);
256 void update_str_lists(struct query *);
257 void write_saved_lists(struct query *, const char *);
260 int prc_parse_file(const char *, const flag);
261 int prc_filecheck(const char *);
264 void to64frombits(unsigned char *, const unsigned char *, int);
265 int from64tobits(char *, const char *);
268 void interface_parse(char *, struct hostdata *);
269 void interface_note_activity(struct hostdata *);
270 int interface_approve(struct hostdata *);
273 #if defined(HAVE_VOIDPOINTER)
274 #define XMALLOCTYPE void
276 #define XMALLOCTYPE char
278 XMALLOCTYPE *xmalloc(int);
279 XMALLOCTYPE *xrealloc(XMALLOCTYPE *, int);
280 char *xstrdup(const char *);
282 /* protocol driver and methods */
283 int do_protocol(struct query *, const struct method *);
284 int doPOP2 (struct query *);
285 int doPOP3 (struct query *);
286 int doIMAP (struct query *);
287 int doETRN (struct query *);
290 struct query *hostalloc(struct query *);
291 int parsecmdline (int, char **, struct query *);
292 void optmerge(struct query *, struct query *);
293 char *MD5Digest (unsigned char *);
294 int daemonize(const char *, void (*)(int));
295 char *getpassword(char *);
296 void escapes(const char *, char *);
297 char *visbuf(const char *);
298 char *showproto(int);
300 void yyerror(const char *);
303 #define STRING_DISABLED (char *)-1
305 /* fetchmail.h ends here */