]> Pileus Git - ~andy/fetchmail/blob - fetchmail.h
gcc -Wall cleanup.
[~andy/fetchmail] / fetchmail.h
1 /*
2  * For license terms, see the file COPYING in this directory.
3  */
4
5 /* constants designating the various supported protocols */
6 #define         P_AUTO          0
7 #define         P_POP2          2
8 #define         P_POP3          3
9 #define         P_IMAP          4
10 #define         P_APOP          5
11
12 #define         KPOP_PORT       1109
13
14 /* authentication types */
15 #define         A_PASSWORD      0       /* passwords in cleartext */
16 #define         A_KERBEROS      1       /* get Kerberos V4 ticket */
17
18 /* definitions for buffer sizes -- somewhat arbitrary */
19 #define         POPBUFSIZE      512     /* per RFC 937 */
20 #define         MSGBUFSIZE      2048    /* size of message read buffer */
21 #define         HOSTLEN         128     /* max hostname length */
22 #define         USERNAMELEN     32      /* max user-length */
23 #define         PASSWORDLEN     MAX_PASSWORD_LENGTH
24 #define         FOLDERLEN       256     /* max folder name length */
25 #define         DIGESTLEN       33      /* length of MD5 digest */
26 #define         MDALEN          256     /* length of delivery agent command */
27 #define         IDLEN           128     /* length of UIDL message ID */
28
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
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 */
46
47 #define         SIZETICKER      1024    /* print 1 dot per this many bytes */
48 #define         MDA_MAXARGS     32      /* max arguments per MDA call */
49
50 struct idlist
51 {
52     char *id;
53     union
54     {
55         int num;
56         char *id2;
57     } val;
58     struct idlist *next;
59 };
60
61 struct query
62 {
63     /* per-host data */
64     char servername [HOSTLEN+1];
65     struct idlist *localnames;
66     int protocol;
67     int port;
68     int authenticate;
69     int timeout;
70     int skip;
71
72     /* per-user data */
73     char remotename [USERNAMELEN+1];
74     char password [PASSWORDLEN+1];
75     char mailbox [FOLDERLEN];
76     char smtphost[HOSTLEN+1];
77     char mda [MDALEN+1];
78
79     /* per-user MDA arguments */
80     int mda_argcount;
81     char *mda_argv[MDA_MAXARGS];
82
83     /* per-user control flags */
84     int keep;
85     int fetchall;
86     int flush;
87     int norewrite;
88     int limit;
89
90     /* unseen, previous state of mailbox (initially from .fetchids) */
91     struct idlist *oldsaved, *newsaved;
92
93     /* internal use */
94     int active;
95     struct query *next; /* next host in chain */
96     unsigned int uid;           /* UID of user to deliver to */
97     char digest [DIGESTLEN];
98 #ifdef HAVE_GETHOSTBYNAME
99     char *canonical_name;       /* DNS canonical name of server host */
100 #endif /* HAVE_GETHOSTBYNAME */
101 };
102
103 struct method
104 {
105     char *name;                 /* protocol name */
106     int port;                   /* service port */
107     int tagged;                 /* if true, generate & expect command tags */
108     int delimited;              /* if true, accept "." message delimiter */
109     int (*parse_response)();    /* response_parsing function */
110     int (*getauth)();           /* authorization fetcher */
111     int (*getrange)();          /* get message range to fetch */
112     int (*getsizes)();          /* get sizes of messages */
113     int (*is_old)();            /* check for old message */
114     int (*fetch)();             /* fetch a given message */
115     int (*trail)();             /* eat trailer of a message */
116     int (*delete)();            /* delete method */
117     char *expunge_cmd;          /* expunge command */
118     char *exit_cmd;             /* exit command */
119 };
120
121 #define TAGLEN  6
122 extern char tag[TAGLEN];
123
124 /* list of hosts assembled from run control file and command line */
125 extern struct query cmd_opts, *querylist;
126
127 /* controls the detail level of status/progress messages written to stderr */
128 extern int outlevel;            /* see the O_.* constants above */
129 extern int yydebug;             /* enable parse debugging */
130
131 /* daemon mode control */
132 extern int poll_interval;       /* poll interval in seconds */
133 extern char *logfile;           /* log file for daemon mode */
134 extern int quitmode;            /* if --quit was set */
135 extern int check_only;          /* if --check was set */
136
137 /* miscellaneous global controls */
138 extern char *rcfile;            /* path name of rc file */
139 extern char *idfile;            /* path name of UID file */
140 extern int linelimit;           /* limit # lines retrieved per site */
141 extern int versioninfo;         /* emit only version info */
142 extern char *dfltuser;          /* invoking user */
143
144 #ifdef HAVE_PROTOTYPES
145
146 /* prototypes for globally callable functions */
147 #if defined(HAVE_STDARG_H)
148 void gen_send (int socket, char *, ... );
149 int gen_transact (int socket, char *, ... );
150 #else
151 void gen_send ();
152 int gen_transact ();
153 #endif
154
155 void *xmalloc(int);
156 char *xstrdup(char *);
157
158 int do_protocol(struct query *, const struct method *);
159 int doPOP2 (struct query *); 
160 int doPOP3 (struct query *);
161 int doIMAP (struct query *);
162
163 void initialize_saved_lists(struct query *, char *);
164 void save_uid(struct idlist **, int, char *);
165 void free_uid_list(struct idlist **);
166 void save_id_pair(struct idlist **, char *, char *);
167 void free_idpair_list(struct idlist **);
168 int delete_uid(struct idlist **, int);
169 int uid_in_list(struct idlist **, char *);
170 char *uid_find(struct idlist **, int);
171 char *idpair_find(struct idlist **, char *);
172 void append_uid_list(struct idlist **, struct idlist **);
173 void update_uid_lists(struct query *);
174 void write_saved_lists(struct query *, char *);
175
176 struct query *hostalloc(struct query *); 
177 int parsecmdline (int, char **, struct query *);
178 void optmerge(struct query *, struct query *);
179 char *MD5Digest (char *);
180 int openmailpipe (char **);
181 int closemailpipe(int);
182 int daemonize(const char *, void (*)(int));
183
184 int prc_parse_file(const char *);
185 int prc_filecheck(const char *);
186 void prc_register();
187 void prc_reset();
188
189 char *getpassword(char *);
190
191 void escapes(const char *, char *);
192
193 void yyerror(const char *);
194 int yylex();
195
196 #else
197
198 struct query *hostinit(); 
199 char *MD5Digest ();
200 void optmerge();
201
202 #endif
203
204 #define FALSE   0
205 #define TRUE    1