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 $
30 typedef unsigned int off_t
;
39 typedef struct Pop3_
{
40 char label
[BUF_SMALL
]; /* Printed at left; max 5 chars */
41 char path
[BUF_BIG
]; /* Path to mailbox */
42 char notify
[BUF_BIG
]; /* Program to notify mail arrivation */
43 char action
[BUF_BIG
]; /* Action to execute on mouse click, reduces to
44 * what happens on button1. this is executed after
45 * either actionnew or actionnonew (if they are
46 * defined in the config file) */
47 char actionnew
[BUF_BIG
]; /* Action to execute on mouse click when new mail */
48 char actionnonew
[BUF_BIG
]; /* Action to execute on mouse click when no new mail */
49 char actiondc
[BUF_BIG
]; /* Action to execute when icq is disconnected */
50 char button2
[BUF_BIG
]; /* What to run on button2. (middle) */
51 char fetchcmd
[BUF_BIG
]; /* Action for mail fetching for pop3/imap, reduces to what happens on button3 */
53 int TotalMsgs
; /* Total messages in mailbox */
54 int UnreadMsgs
; /* New (unread) messages in mailbox */
57 char TextStatus
[10]; /* if set to a string, toupper() and blit
58 * that string. instead of a message count */
59 int blink_stat
; /* blink digits flag-counter */
60 int debug
; /* debugging status */
62 struct msglst
*headerCache
;
77 unsigned int dircache_flush
:1; /* hack to flush directory caches */
80 char password
[BUF_SMALL
];
81 char userName
[BUF_BIG
];
82 char serverName
[BUF_BIG
];
86 unsigned int dossl
:1; /* use tls. */
87 /* prompt the user if we can't login / password is empty */
88 unsigned int interactive_password
:1;
89 /* using the msglst feature, fetch the headers
90 to have them on hand */
91 unsigned int wantCacheHeaders
:1;
92 size_t password_len
; /* memfrob may shorten passwords */
96 int (*checkMail
) ( /*@notnull@ */ struct Pop3_
*);
98 /* collect the headers to show in a pop up */
99 struct msglst
*(*getHeaders
) ( /*@notnull@ */ struct Pop3_
*);
100 /* allow the client to free the headers, or keep them cached */
101 void (*releaseHeaders
) ( /*@notnull@ */ struct Pop3_
*, struct msglst
* ml
);
104 time_t prevfetch_time
;
105 int loopinterval
; /* loop interval for this mailbox */
107 /* command to execute to get a password, if needed */
111 /* creation calls must have this prototype */
112 int pop3Create( /*@notnull@ */ Pop3
*pc
, const char *str
);
113 int imap4Create( /*@notnull@ */ Pop3
*pc
, const char *str
);
114 int shellCreate( /*@notnull@ */ Pop3
*pc
, const char *str
);
115 int mboxCreate( /*@notnull@ */ Pop3
*pc
, const char *str
);
116 int maildirCreate( /*@notnull@ */ Pop3
*pc
, const char *str
);
118 int sock_connect(const char *hostname
, uint16_t port
);
119 FILE *openMailbox(Pop3
*pc
, const char *mbox_filename
);
121 /* backtickExpand returns null on failure */
123 char *backtickExpand(Pop3
*pc
, const char *path
);
124 int fileHasChanged(const char *mbox_filename
, time_t * atime
,
125 time_t * mtime
, off_t
* size
);
126 int grabCommandOutput(Pop3
*pc
, const char *command
,
127 /*@out@ */ char **output
,
128 /*@out@ *//*@null@ */ char **details
);
129 int exists(const char *filename
); /* test -f */
131 /* _NONE is for silent operation. _ERROR is for things that should
132 be printed assuming that the user might possibly see them. _INFO is
133 for reasonably useless but possibly interesting messages. _ALL is
134 for everything. Restated, _ERROR will always be printed, _INFO only
135 if debugging messages were requested. */
137 #define DEBUG_ERROR 1
140 /* inspired by ksymoops-2.3.4/ksymoops.h */
141 #define DM(mbox, msglevel, X...) \
143 if (mbox == NULL || (mbox)->debug >= msglevel) { \
144 printf("wmbiff/%s ", (mbox != NULL) ? (mbox)->label : "NULL"); \
146 (void)fflush(NULL); \
150 extern int debug_default
;
151 #define DMA(msglevel, X...) \
153 if (debug_default >= msglevel) { \
154 printf("wmbiff: " X); \
155 (void)fflush(NULL); \
159 /* technique used in apache to allow GCC's attribute tags,
160 without requiring gcc as the compiler */
161 #if !defined(__GNUC__) || __GNUC__ < 2 || \
162 (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
163 #ifndef __attribute__
164 #define __attribute__(__x)
167 #endif /* client.h */
171 #define TRUE (!FALSE)
175 /* lclint doesn't do typeof */
176 #define min(x,y) ((x > y) ? x : y)
177 #define max(x,y) ((x > y) ? x : y)
179 /* from linux/kernel.h */
180 #define min(x,y) ({ \
181 const typeof(x) _xi = (x); \
182 const typeof(y) _yi = (y); \
183 (void) (&_xi == &_yi); \
184 _xi < _yi ? _xi : _yi; })
185 #define max(x,y) ({ \
186 const typeof(x) _xa = (x); \
187 const typeof(y) _ya = (y); \
188 (void) (&_xa == &_ya); \
189 _xa > _ya ? _xa : _ya; })