1 /* $Id: Client.h,v 1.42 2005/05/08 21:31:22 bluehal Exp $ */
2 /* Author : Scott Holden ( scotth@thezone.net )
3 Modified : Yong-iL Joh ( tolkien@mizi.com )
4 Modified : Jorge GarcĂa ( Jorge.Garcia@uv.es )
6 * Email Checker Pop3/Imap4/Gicu/mbox/maildir/finger
8 * Last Updated : $Date: 2005/05/08 21:31:22 $
29 typedef unsigned int off_t
;
37 typedef struct _mbox_t
*Pop3
;
38 typedef struct _mbox_t
{
39 char label
[BUF_SMALL
]; /* Printed at left; max 5 chars */
40 char path
[BUF_BIG
]; /* Path to mailbox */
41 char notify
[BUF_BIG
]; /* Program to notify mail arrivation */
42 char action
[BUF_BIG
]; /* Action to execute on mouse click, reduces to
43 * what happens on button1. this is executed after
44 * either actionnew or actionnonew (if they are
45 * defined in the config file) */
46 char actionnew
[BUF_BIG
]; /* Action to execute on mouse click when new mail */
47 char actionnonew
[BUF_BIG
]; /* Action to execute on mouse click when no new mail */
48 char actiondc
[BUF_BIG
]; /* Action to execute when icq is disconnected */
49 char button2
[BUF_BIG
]; /* What to run on button2. (middle) */
50 char fetchcmd
[BUF_BIG
]; /* Action for mail fetching for pop3/imap, reduces to what happens on button3 */
52 int TotalMsgs
; /* Total messages in mailbox */
53 int UnreadMsgs
; /* New (unread) messages in mailbox */
56 char TextStatus
[10]; /* if set to a string, toupper() and blit
57 * that string. instead of a message count */
58 int blink_stat
; /* blink digits flag-counter */
59 int debug
; /* debugging status */
61 struct msglst
*headerCache
;
76 unsigned int dircache_flush
:1; /* hack to flush directory caches */
79 char password
[BUF_SMALL
];
80 char userName
[BUF_BIG
];
81 char serverName
[BUF_BIG
];
85 unsigned int dossl
:1; /* use tls. */
86 /* prompt the user if we can't login / password is empty */
87 unsigned int interactive_password
:1;
88 /* using the msglst feature, fetch the headers
89 to have them on hand */
90 unsigned int wantCacheHeaders
:1;
91 unsigned char password_len
; /* memfrob may shorten passwords */
95 int (*checkMail
) ( /*@notnull@ */ Pop3
);
97 /* collect the headers to show in a pop up */
98 struct msglst
*(*getHeaders
) ( /*@notnull@ */ Pop3
);
99 /* allow the client to free the headers, or keep them cached */
100 void (*releaseHeaders
) ( /*@notnull@ */ Pop3
, struct msglst
* ml
);
103 time_t prevfetch_time
;
104 int loopinterval
; /* loop interval for this mailbox */
106 /* command to execute to get a password, if needed */
110 /* creation calls must have this prototype */
111 int pop3Create( /*@notnull@ */ Pop3 pc
, const char *str
);
112 int imap4Create( /*@notnull@ */ Pop3 pc
, const char *str
);
113 int shellCreate( /*@notnull@ */ Pop3 pc
, const char *str
);
114 int mboxCreate( /*@notnull@ */ Pop3 pc
, const char *str
);
115 int maildirCreate( /*@notnull@ */ Pop3 pc
, const char *str
);
117 int sock_connect(const char *hostname
, uint16_t port
);
118 FILE *openMailbox(Pop3 pc
, const char *mbox_filename
);
120 /* backtickExpand returns null on failure */
122 char *backtickExpand(Pop3 pc
, const char *path
);
123 int fileHasChanged(const char *mbox_filename
, time_t * atime
,
124 time_t * mtime
, off_t
* size
);
125 int grabCommandOutput(Pop3 pc
, const char *command
,
126 /*@out@ */ char **output
,
127 /*@out@ *//*@null@ */ char **details
);
128 int exists(const char *filename
); /* test -f */
130 /* _NONE is for silent operation. _ERROR is for things that should
131 be printed assuming that the user might possibly see them. _INFO is
132 for reasonably useless but possibly interesting messages. _ALL is
133 for everything. Restated, _ERROR will always be printed, _INFO only
134 if debugging messages were requested. */
136 #define DEBUG_ERROR 1
139 /* inspired by ksymoops-2.3.4/ksymoops.h */
140 #define DM(mbox, msglevel, X...) \
142 if (mbox == NULL || (mbox)->debug >= msglevel) { \
143 printf("wmbiff/%s ", (mbox != NULL) ? (mbox)->label : "NULL"); \
145 (void)fflush(NULL); \
149 extern int debug_default
;
150 #define DMA(msglevel, X...) \
152 if (debug_default >= msglevel) { \
153 printf("wmbiff: " X); \
154 (void)fflush(NULL); \
158 /* technique used in apache to allow GCC's attribute tags,
159 without requiring gcc as the compiler */
160 #if !defined(__GNUC__) || __GNUC__ < 2 || \
161 (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
162 #ifndef __attribute__
163 #define __attribute__(__x)
166 #endif /* client.h */
170 #define TRUE (!FALSE)
174 /* lclint doesn't do typeof */
175 #define min(x,y) ((x > y) ? x : y)
176 #define max(x,y) ((x > y) ? x : y)
178 /* from linux/kernel.h */
179 #define min(x,y) ({ \
180 const typeof(x) _xi = (x); \
181 const typeof(y) _yi = (y); \
182 (void) (&_xi == &_yi); \
183 _xi < _yi ? _xi : _yi; })
184 #define max(x,y) ({ \
185 const typeof(x) _xa = (x); \
186 const typeof(y) _ya = (y); \
187 (void) (&_xa == &_ya); \
188 _xa > _ya ? _xa : _ya; })