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