2 * For license terms, see the file COPYING in this directory.
5 /* constants designating the various supported protocols */
14 #define KPOP_PORT 1109
16 /* authentication types */
17 #define A_PASSWORD 0 /* passwords in cleartext */
18 #define A_KERBEROS 1 /* get Kerberos V4 ticket */
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 */
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) */
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 */
48 #define SIZETICKER 1024 /* print 1 dot per this many bytes */
50 /* we need to use zero as a flag-uninitialized value */
66 struct hostdata /* shared among all user connections to given server */
69 struct idlist *names; /* server name first, then akas */
70 struct idlist *localdomains; /* list of pass-through domains */
83 struct interface_pair_s *interface_pair;
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 */
96 /* mailserver connection controls */
97 struct hostdata server;
100 struct idlist *localnames; /* including calling user's name */
101 int wildcard; /* should unmatched names be passed through */
105 struct idlist *smtphunt;
110 /* per-user control flags */
120 /* unseen, previous state of mailbox (initially from .fetchids) */
121 struct idlist *oldsaved, *newsaved;
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 */
132 #define MULTIDROP(ctl) (ctl->wildcard || \
133 ((ctl)->localnames && (ctl)->localnames->next))
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 */
153 extern char tag[TAGLEN];
155 /* list of hosts assembled from run control file and command line */
156 extern struct query cmd_opts, *querylist;
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 */
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 */
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? */
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 */
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 *, ... );
195 void error_complete ();
201 void *xrealloc(void *, int);
202 char *xstrdup(const char *);
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 *);
210 void reply_hack(char *, const char *);
211 char *nxtaddr(const char *);
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 *);
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));
232 int prc_parse_file(const char *);
233 int prc_filecheck(const char *);
235 void interface_parse(char *, struct hostdata *);
236 void interface_note_activity(struct hostdata *);
237 int interface_approve(struct hostdata *);
239 char *getpassword(char *);
241 void escapes(const char *, char *);
243 void yyerror(const char *);
249 #define STRING_DISABLED (char *)-1