]> Pileus Git - ~andy/fetchmail/blob - fetchmail.h
Explicit option is documented and set up in the data structure,
[~andy/fetchmail] / fetchmail.h
1 /* Copyright 1993-95 by Carl Harris, Jr. Copyright 1996 by Eric S. Raymond
2  * All rights reserved.
3  * For license terms, see the file COPYING in this directory.
4  */
5
6 /***********************************************************************
7   module:       fetchmail.h
8   project:      fetchmail
9   programmer:   Carl Harris, ceharris@mal.com
10   description:  global constant, type, and variable definitions.
11
12  ***********************************************************************/
13
14 /* constants designating the various supported protocols */
15 #define         P_AUTO  0
16 #define         P_POP2  2
17 #define         P_POP3  3
18 #define         P_IMAP  4
19 #define         P_APOP  5
20 #define         P_RPOP  6
21
22 /* definitions for buffer sizes -- somewhat arbitrary */
23 #define         POPBUFSIZE      512     /* per RFC 937 */
24 #define         MSGBUFSIZE      2048    /* size of message read buffer */
25 #define         HOSTLEN         128     /* max hostname length */
26 #define         USERNAMELEN     32      /* max user-length */
27 #define         PASSWORDLEN     MAX_PASSWORD_LENGTH
28 #define         FOLDERLEN       256     /* max folder name length */
29 #define         DIGESTLEN       33      /* length of MD5 digest */
30 #define         MDALEN          256     /* length of delivery agent command */
31 #define         IDLEN           128     /* length of UIDL message ID */
32
33 /* exit code values */
34 #define         PS_SUCCESS      0       /* successful receipt of messages */
35 #define         PS_NOMAIL       1       /* no mail available */
36 #define         PS_SOCKET       2       /* socket I/O woes */
37 #define         PS_AUTHFAIL     3       /* user authorization failed */
38 #define         PS_PROTOCOL     4       /* protocol violation */
39 #define         PS_SYNTAX       5       /* command-line syntax error */
40 #define         PS_IOERR        6       /* local folder I/O woes */
41 #define         PS_ERROR        7       /* some kind of POP3 error condition */
42 #define         PS_EXCLUDE      8       /* exclusion error */
43 #define         PS_SMTP         9       /* SMTP error */
44 #define         PS_UNDEFINED    10      /* something I hadn't thought of */
45
46 /* output noise level */
47 #define         O_SILENT        0       /* mute, max squelch, etc. */
48 #define         O_NORMAL        1       /* user-friendly */
49 #define         O_VERBOSE       2       /* excessive */
50
51 /* output sink type */
52 #define         TO_SMTP         1       /* use SMTP forwarding */
53 #define         TO_FOLDER       2       /* use a mailbox */
54 #define         TO_STDOUT       3       /* use stdout */
55 #define         TO_MDA          4       /* use agent */
56
57 struct hostrec
58 {
59   char servername [HOSTLEN+1];
60   char localname [USERNAMELEN+1];
61   char remotename [USERNAMELEN+1];
62   char password [PASSWORDLEN+1];
63   char rpopid [PASSWORDLEN+1];
64   char userfolder [FOLDERLEN+1];
65   char remotefolder [FOLDERLEN];
66   char smtphost[HOSTLEN+1];
67   char mda [MDALEN+1];
68   int keep;
69   int protocol;
70   int fetchall;
71   int flush;
72   int norewrite;
73   int explicit;
74   int port;
75
76   /* state used for tracking UIDL ids */
77   char lastid [IDLEN+1];
78
79   /* dependent on the above members */
80   int output;
81   struct hostrec *next;
82
83   /* internal use only */ 
84 #if defined(HAVE_APOP_SUPPORT)
85   char digest [DIGESTLEN];
86 #endif
87 };
88
89 struct method
90 {
91     char *name;                 /* protocol name */
92     int port;                   /* service port */
93     int tagged;                 /* if true, generate & expect command tags */
94     int delimited;              /* if true, accept "." message delimiter */
95     int (*parse_response)();    /* response_parsing function */
96     int (*getauth)();           /* authorization fetcher */
97     int (*getrange)();          /* get message range to fetch */
98     int (*fetch)();             /* fetch a given message */
99     int (*trail)();             /* eat trailer of a message */
100     char *delete_cmd;           /* delete command */
101     char *expunge_cmd;          /* expunge command */
102     char *exit_cmd;             /* exit command */
103 };
104
105 #define TAGLEN  6
106 extern char tag[TAGLEN];
107
108 /* controls the detail level of status/progress messages written to stderr */
109 extern int outlevel;            /* see the O_.* constants above */
110 extern int yydebug;             /* enable parse debugging */
111
112 /* daemon mode control */
113 extern int poll_interval;       /* poll interval in seconds */
114 extern char *logfile;           /* log file for daemon mode */
115 extern int quitmode;            /* if --quit was set */
116
117 /* miscellaneous global controls */
118 extern char *rcfile;            /* path name of rc file */
119 extern char *idfile;            /* path name of id file */
120 extern int linelimit;           /* limit # lines retrieved per site */
121 extern int versioninfo;         /* emit only version info */
122
123 #ifdef HAVE_PROTOTYPES
124
125 int gen_ok (char *buf, int socket);
126 void gen_send ();
127 int gen_transact ();
128
129 /* prototypes for globally callable functions */
130 int doPOP2 (struct hostrec *); 
131 int doPOP3 (struct hostrec *);
132 int doIMAP (struct hostrec *);
133 int parsecmdline (int, char **, struct hostrec *);
134 int setdefaults (struct hostrec *);
135 char *getnextserver (int argc, char **, int *);
136 int openuserfolder (struct hostrec *);
137 int closeuserfolder (int);
138 int openmailpipe (struct hostrec *);
139 int closemailpipe (int);
140 char *MD5Digest (char *);
141 void append_server_names(int *, char **, int);
142 int daemonize(const char *, void (*)(int));
143
144 #else
145
146 char *getnextserver();
147 char *MD5Digest ();
148 void append_server_names ();
149 int daemonize ();
150
151 #endif
152