1 /* Copyright 1993-95 by Carl Harris, Jr.
4 * Distribute freely, except: don't remove my name from the source or
5 * documentation (don't take credit for my work), mark your changes (don't
6 * get me blamed for your possible bugs), don't alter or remove this
7 * notice. May be sold if buildable source is provided to buyer. No
8 * warrantee of any kind, express or implied, is included with this
9 * software; use at your own risk, responsibility for damages (if any) to
10 * anyone resulting from the use of this software rests entirely with the
13 * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
14 * I'll try to keep a version up to date. I can be reached as follows:
15 * Carl Harris <ceharris@mal.com>
19 /***********************************************************************
22 programmer: Carl Harris, ceharris@mal.com
23 description: global constant, type, and variable definitions.
26 Revision 1.2 1996/06/26 19:08:59 esr
27 This is what I sent Harris.
29 Revision 1.1 1996/06/24 18:14:08 esr
32 Revision 1.6 1995/09/07 22:37:35 ceharris
33 Preparation for 3.0b4 release.
35 Revision 1.5 1995/08/14 18:36:44 ceharris
36 Patches to support POP3's LAST command.
37 Final revisions for beta3 release.
39 Revision 1.4 1995/08/10 00:32:40 ceharris
40 Preparation for 3.0b3 beta release:
41 - added code for --kill/--keep, --limit, --protocol, --flush
42 options; --pop2 and --pop3 options now obsoleted by --protocol.
43 - added support for APOP authentication, including --with-APOP
44 argument for configure.
45 - provisional and broken support for RPOP
46 - added buffering to SockGets and SockRead functions.
47 - fixed problem of command-line options not being correctly
48 carried into the merged options record.
50 Revision 1.3 1995/08/09 01:32:57 ceharris
51 Version 3.0 beta 2 release.
53 - .poprc functionality
55 - multiple servers on the command line.
57 - Passwords showing up in ps output.
59 Revision 1.2 1995/08/08 01:01:27 ceharris
60 Added GNU-style long options processing.
61 Fixed password in 'ps' output problem.
62 Fixed various RCS tag blunders.
63 Integrated .poprc parser, lexer, etc into Makefile processing.
65 ***********************************************************************/
69 /* definitions for buffer sizes -- somewhat arbitrary */
70 #define POPBUFSIZE 512 /* per RFC 937 */
71 #define MSGBUFSIZE 1024 /* size of message read buffer */
72 #define HOSTLEN 128 /* max hostname length */
73 #define USERNAMELEN 32 /* max user-length */
74 #define PASSWORDLEN MAX_PASSWORD_LENGTH
75 #define FOLDERLEN 256 /* max folder name length */
76 #define DIGESTLEN 33 /* length of MD5 digest */
77 #define MDALEN 33 /* length of delivery agent command */
79 /* exit code values */
80 #define PS_SUCCESS 0 /* successful receipt of messages */
81 #define PS_NOMAIL 1 /* no mail available */
82 #define PS_SOCKET 2 /* socket I/O woes */
83 #define PS_AUTHFAIL 3 /* user authorization failed */
84 #define PS_PROTOCOL 4 /* protocol violation */
85 #define PS_SYNTAX 5 /* command-line syntax error */
86 #define PS_IOERR 6 /* local folder I/O woes */
87 #define PS_ERROR 7 /* some kind of POP3 error condition */
88 #define PS_UNDEFINED 9 /* something I hadn't thought of */
90 /* output noise level */
91 #define O_SILENT 0 /* mute, max squelch, etc. */
92 #define O_NORMAL 1 /* user-friendly */
93 #define O_VERBOSE 2 /* excessive */
95 /* output sink type */
96 #define TO_FOLDER 1 /* use a mailbox */
97 #define TO_STDOUT 2 /* use stdout */
98 #define TO_MDA 3 /* use agent */
100 /* Command-line arguments are passed in this structure type */
111 char loginid [USERNAMELEN];
113 char username [USERNAMELEN];
114 char password [PASSWORDLEN];
115 #if defined(HAVE_APOP_SUPPORT)
116 char digest [DIGESTLEN];
118 char userfolder [FOLDERLEN];
119 char remotefolder [FOLDERLEN];
124 /* .poprc records are passed in this structure type */
139 /* Controls the detail of status/progress messages written to stderr */
140 extern int outlevel; /* see the O_.* constants above */
141 extern int yydebug; /* enable parse debugging */
143 /* daemon mode control */
144 extern int poll_interval; /* poll interval in seconds */
145 extern char *logfile; /* log file for daemon mode */
147 extern char *prc_pathname; /* path name of rc file */
149 #ifdef HAVE_PROTOTYPES
151 /* prototypes for globally callable functions */
152 int doPOP2 (char *servername, struct optrec *options);
153 int doPOP3 (char *servername, struct optrec *options);
155 int parsecmdline (int argc, char **argv, struct optrec *options);
156 int setdefaults (struct optrec *options);
157 char *getnextserver (int argc, char **argv, int *optind);
158 int openuserfolder (struct optrec *options);
159 int closeuserfolder (int fd);
160 int openmailpipe (struct optrec *options);
161 int closemailpipe (int fd);
162 char *MD5Digest (char *);
163 char *prc_getpathname (struct optrec *cmd_opts, struct optrec *def_opts);
164 void reply_hack(char *buf, const char *host);
165 void append_server_names(int *pargc, char **argv);
166 int daemonize(const char *logfile);
170 char *getnextserver();
172 char *prc_getpathname();
174 void append_server_names ();