]> Pileus Git - ~andy/fetchmail/blob - fetchmail.h
70f97fc1db97db44547ce3d40344da5e4cf0876e
[~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         IDLEN           128     /* length of UIDL message ID */
31
32 /* exit code values */
33 #define         PS_SUCCESS      0       /* successful receipt of messages */
34 #define         PS_NOMAIL       1       /* no mail available */
35 #define         PS_SOCKET       2       /* socket I/O woes */
36 #define         PS_AUTHFAIL     3       /* user authorization failed */
37 #define         PS_PROTOCOL     4       /* protocol violation */
38 #define         PS_SYNTAX       5       /* command-line syntax error */
39 #define         PS_IOERR        6       /* bad permissions on rc file */
40 #define         PS_ERROR        7       /* protocol error */
41 #define         PS_EXCLUDE      8       /* exclusion error */
42 #define         PS_SMTP         9       /* SMTP error */
43 #define         PS_UNDEFINED    10      /* something I hadn't thought of */
44
45 /* output noise level */
46 #define         O_SILENT        0       /* mute, max squelch, etc. */
47 #define         O_NORMAL        1       /* user-friendly */
48 #define         O_VERBOSE       2       /* excessive */
49
50 #define         SIZETICKER      1024    /* print 1 dot per this many bytes */
51
52 struct hostrec
53 {
54     /* per-host data */
55     char servername [HOSTLEN+1];
56     char localname [USERNAMELEN+1];
57     char remotename [USERNAMELEN+1];
58     char password [PASSWORDLEN+1];
59     char remotefolder [FOLDERLEN];
60     char smtphost[HOSTLEN+1];
61     int protocol;
62     int port;
63
64     /* control flags */
65     int keep;
66     int fetchall;
67     int flush;
68     int norewrite;
69     int skip;
70
71     /* internal use */
72     struct hostrec *next;       /* next host in chain */
73     char digest [DIGESTLEN];
74 };
75
76 struct method
77 {
78     char *name;                 /* protocol name */
79     int port;                   /* service port */
80     int tagged;                 /* if true, generate & expect command tags */
81     int delimited;              /* if true, accept "." message delimiter */
82     int (*parse_response)();    /* response_parsing function */
83     int (*getauth)();           /* authorization fetcher */
84     int (*getrange)();          /* get message range to fetch */
85     int (*is_old)();            /* check for old message */
86     int (*fetch)();             /* fetch a given message */
87     int (*trail)();             /* eat trailer of a message */
88     int (*delete)();            /* delete method */
89     char *expunge_cmd;          /* expunge command */
90     char *exit_cmd;             /* exit command */
91 };
92
93 #define TAGLEN  6
94 extern char tag[TAGLEN];
95
96 /* controls the detail level of status/progress messages written to stderr */
97 extern int outlevel;            /* see the O_.* constants above */
98 extern int yydebug;             /* enable parse debugging */
99
100 /* daemon mode control */
101 extern int poll_interval;       /* poll interval in seconds */
102 extern char *logfile;           /* log file for daemon mode */
103 extern int quitmode;            /* if --quit was set */
104
105 /* miscellaneous global controls */
106 extern char *rcfile;            /* path name of rc file */
107 extern int linelimit;           /* limit # lines retrieved per site */
108 extern int versioninfo;         /* emit only version info */
109
110 #ifdef HAVE_PROTOTYPES
111
112 /* prototypes for globally callable functions */
113 void gen_send ();
114 int gen_transact ();
115
116 int doPOP2 (struct hostrec *); 
117 int doPOP3 (struct hostrec *);
118 int doIMAP (struct hostrec *);
119
120 int parsecmdline (int, char **, struct hostrec *);
121 int setdefaults (struct hostrec *);
122 char *getnextserver (int argc, char **, int *);
123 char *MD5Digest (char *);
124 void append_server_names(int *, char **, int);
125 int daemonize(const char *, void (*)(int));
126
127 #else
128
129 char *getnextserver();
130 char *MD5Digest ();
131 void append_server_names ();
132 int daemonize ();
133
134 #endif
135