2 * For license terms, see the file COPYING in this directory.
5 /* constants designating the various supported protocols */
13 #define KPOP_PORT 1109
15 /* authentication types */
16 #define A_PASSWORD 0 /* passwords in cleartext */
17 #define A_KERBEROS 1 /* get Kerberos V4 ticket */
19 /* definitions for buffer sizes -- somewhat arbitrary */
20 #define POPBUFSIZE 512 /* per RFC 937 */
21 #define MSGBUFSIZE 2048 /* size of message read buffer */
22 #define HOSTLEN 128 /* max hostname length */
23 #define USERNAMELEN 32 /* max user-name length */
24 #define PASSWORDLEN 64 /* max password length */
25 #define DIGESTLEN 33 /* length of MD5 digest */
26 #define IDLEN 128 /* length of UIDL message ID */
28 /* exit code values */
29 #define PS_SUCCESS 0 /* successful receipt of messages */
30 #define PS_NOMAIL 1 /* no mail available */
31 #define PS_SOCKET 2 /* socket I/O woes */
32 #define PS_AUTHFAIL 3 /* user authorization failed */
33 #define PS_PROTOCOL 4 /* protocol violation */
34 #define PS_SYNTAX 5 /* command-line syntax error */
35 #define PS_IOERR 6 /* bad permissions on rc file */
36 #define PS_ERROR 7 /* protocol error */
37 #define PS_EXCLUDE 8 /* exclusion error */
38 #define PS_SMTP 9 /* SMTP error */
39 #define PS_UNDEFINED 10 /* something I hadn't thought of */
40 #define PS_TRANSIENT 11 /* transient failure (internal use) */
42 /* output noise level */
43 #define O_SILENT 0 /* mute, max squelch, etc. */
44 #define O_NORMAL 1 /* user-friendly */
45 #define O_VERBOSE 2 /* excessive */
47 #define SIZETICKER 1024 /* print 1 dot per this many bytes */
61 struct hostdata /* shared among all user connections to given server */
64 struct idlist *names; /* server name first, then akas */
65 struct idlist *localdomains; /* list of pass-through domains */
78 struct interface_pair_s *interface_pair;
81 /* computed for internal use */
82 #ifdef HAVE_GETHOSTBYNAME
83 char *canonical_name; /* DNS canonical name of server host */
84 #endif /* HAVE_GETHOSTBYNAME */
85 struct hostdata *lead_server; /* ptr to lead query for this server */
91 /* mailserver connection controls */
92 struct hostdata server;
95 struct idlist *localnames; /* including calling user's name */
96 int wildcard; /* should unmatched names be passed through */
104 /* per-user control flags */
113 /* unseen, previous state of mailbox (initially from .fetchids) */
114 struct idlist *oldsaved, *newsaved;
118 int errcount; /* count transient errors in last pass */
119 struct query *next; /* next query control block in chain */
120 struct query *lead_smtp; /* pointer to this query's SMTP leader */
121 FILE *smtp_sockfp; /* socket descriptor for SMTP connection */
122 unsigned int uid; /* UID of user to deliver to */
123 char digest [DIGESTLEN]; /* md5 digest buffer */
126 #define MULTIDROP(ctl) (ctl->wildcard || \
127 ((ctl)->localnames && (ctl)->localnames->next))
131 char *name; /* protocol name */
132 int port; /* service port */
133 int tagged; /* if true, generate & expect command tags */
134 int delimited; /* if true, accept "." message delimiter */
135 int (*parse_response)(); /* response_parsing function */
136 int (*getauth)(); /* authorization fetcher */
137 int (*getrange)(); /* get message range to fetch */
138 int (*getsizes)(); /* get sizes of messages */
139 int (*is_old)(); /* check for old message */
140 int (*fetch)(); /* fetch a given message */
141 int (*trail)(); /* eat trailer of a message */
142 int (*delete)(); /* delete method */
143 char *exit_cmd; /* exit command */
147 extern char tag[TAGLEN];
149 /* list of hosts assembled from run control file and command line */
150 extern struct query cmd_opts, *querylist;
152 /* controls the detail level of status/progress messages written to stderr */
153 extern int outlevel; /* see the O_.* constants above */
154 extern int yydebug; /* enable parse debugging */
156 /* daemon mode control */
157 extern int poll_interval; /* poll interval in seconds */
158 extern int nodetach; /* if TRUE, don't detach daemon process */
159 extern char *logfile; /* log file for daemon mode */
160 extern int use_syslog; /* if --syslog was set */
161 extern int quitmode; /* if --quit was set */
162 extern int check_only; /* if --check was set */
163 extern char *cmd_logfile; /* if --logfile was set */
165 /* these get computed */
166 extern int batchcount; /* count of messages sent in current batch */
167 extern int peek_capable; /* can we read msgs without setting seen? */
169 /* miscellaneous global controls */
170 extern char *rcfile; /* path name of rc file */
171 extern char *idfile; /* path name of UID file */
172 extern int linelimit; /* limit # lines retrieved per site */
173 extern int versioninfo; /* emit only version info */
174 extern char *user; /* name of invoking user */
176 /* prototypes for globally callable functions */
177 #if defined(HAVE_STDARG_H)
178 void error_init(int foreground);
179 void error (int status, int errnum, const char *format, ...);
180 void error_build (const char *format, ...);
181 void error_complete (int status, int errnum, const char *format, ...);
182 void gen_send (FILE *sockfp, char *, ... );
183 int gen_recv(FILE *sockfp, char *buf, int size);
184 int gen_transact (FILE *sockfp, char *, ... );
188 void error_complete ();
194 void *xrealloc(void *, int);
195 char *xstrdup(const char *);
197 int do_protocol(struct query *, const struct method *);
198 int doPOP2 (struct query *);
199 int doPOP3 (struct query *);
200 int doIMAP (struct query *);
202 void reply_hack(char *, const char *);
203 char *nxtaddr(const char *);
205 void initialize_saved_lists(struct query *, const char *);
206 struct idlist *save_str(struct idlist **, int, const char *);
207 void free_str_list(struct idlist **);
208 void save_str_pair(struct idlist **, const char *, const char *);
209 void free_str_pair_list(struct idlist **);
210 int delete_str(struct idlist **, int);
211 int str_in_list(struct idlist **, const char *);
212 char *str_find(struct idlist **, int);
213 char *idpair_find(struct idlist **, const char *);
214 void append_str_list(struct idlist **, struct idlist **);
215 void update_str_lists(struct query *);
216 void write_saved_lists(struct query *, const char *);
218 struct query *hostalloc(struct query *);
219 int parsecmdline (int, char **, struct query *);
220 void optmerge(struct query *, struct query *);
221 char *MD5Digest (char *);
222 int daemonize(const char *, void (*)(int));
224 int prc_parse_file(const char *);
225 int prc_filecheck(const char *);
227 void interface_parse(struct hostdata *);
228 void interface_note_activity(struct hostdata *);
229 int interface_approve(struct hostdata *);
231 char *getpassword(char *);
233 void escapes(const char *, char *);
235 void yyerror(const char *);