+2008-02-13 Martin Mares <mj@ucw.cz>
+
+ * Added support for gzipped mailboxes, based on a patch by
+ Michal Vaner.
+
+ * Released as 1.2.
+
2008-01-16 Martin Mares <mj@ucw.cz>
* Non-ASCII characters are displayed properly in UTF-8 locale.
parts do not look printable. This mode is now enabled by default,
tweak the Makefile if you do not have libncursesw.
+ * Released as 1.1.
+
2007-06-25 Martin Mares <mj@ucw.cz>
* Non-ASCII characters encoded as per RFC 2047 are now deciphered
#include <unistd.h>
#include <pwd.h>
#include <time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#ifdef CONFIG_WIDE_CURSES
#include <ncursesw/ncurses.h>
{
char buf[1024], sender[1024], subject[1024];
int c;
+ int compressed = 0;
const char from[] = "\nFrom ";
if (!st->st_size)
b->total = b->new = b->flagged = -1;
return;
}
+
+ char signature[2];
+ c = read(mb_fd, signature, 2);
+ lseek(mb_fd, 0, SEEK_SET);
+
+ if (c == 2 && !memcmp(signature, "\037\213", 2)) //gzip
+ {
+ debug("[decompressing] ");
+ int fds[2];
+ if (pipe(fds))
+ die("pipe failed: %m");
+ int pid = fork();
+ if (pid < 0)
+ die("fork failed: %m");
+ if (!pid)
+ {
+ if (dup2(mb_fd, 0) < 0 || dup2(fds[1], 1) < 0)
+ die("dup2 failed: %m");
+ close(fds[0]);
+ close(fds[1]);
+ close(mb_fd);
+ execlp("gzip", "gzip", "-cd", NULL);
+ die("Cannot execute gzip: %m");
+ }
+ close(fds[1]);
+ close(mb_fd);
+ mb_fd = fds[0];
+ compressed = 1;
+ }
mb_reset(0);
int incremental = 0;
- if (b->last_size && b->last_pos && st->st_size > b->last_size && !b->force_refresh)
+ if (b->last_size && b->last_pos && st->st_size > b->last_size && !b->force_refresh && !compressed)
{
mb_seek(b->last_pos);
if (mb_check(from, 6))
done:
close(mb_fd);
+ if (compressed)
+ {
+ int status;
+ if (wait(&status) < 0 || !WIFEXITED(status) || WEXITSTATUS(status))
+ b->total = b->new = b->flagged = -1;
+ }
}
static void