1 /* XCHAT 2.0 PLUGIN: Mail checker */
10 #include "xchat-plugin.h"
13 static xchat_plugin
*ph
; /* plugin handle */
16 mail_items(char *file
)
22 fp
= fopen(file
, "r");
27 while(fgets(buf
, sizeof buf
, fp
))
29 if(!strncmp(buf
, "From ", 5))
38 xchat_mail_check (void)
40 static int last_size
= -1;
46 maildir
= getenv("MAIL");
49 snprintf (buf
, sizeof(buf
), "/var/spool/mail/%s", getenv("USER"));
53 if(stat(maildir
, &st
) < 0)
67 "-\0033-\0039-\017\tYou have new mail (%d messages, %d bytes total).",
68 mail_items(maildir
), size
);
74 static int timeout_cb(void *userdata
)
81 int xchat_plugin_init(xchat_plugin
*plugin_handle
,
82 char **plugin_name
, char **plugin_desc
, char **plugin_version
,
87 *plugin_name
= "MailCheck";
88 *plugin_desc
= "Checks your mailbox every 30 seconds";
89 *plugin_version
= "0.1";
91 xchat_hook_timer(ph
, 30000, timeout_cb
, 0);