Hello community, here is the log from the commit of package imapfilter checked in at Wed Aug 2 12:47:25 CEST 2006. -------- --- imapfilter/imapfilter.changes 2006-07-19 09:21:20.000000000 +0200 +++ imapfilter/imapfilter.changes 2006-08-02 09:59:11.000000000 +0200 @@ -1,0 +2,17 @@ +Wed Aug 2 09:47:06 CEST 2006 - mskibbe@suse.de + +- fixed some compiler warnings +- add RPM_OPT_FLAGS to make +- update to version 1.2.2 which + o Bug fix; a mix up of connections could happen in certain + circumstances, when a hostname and/or username was a prefix of + another hostname and/or username respectively, or when the same + hostname and username was used to connect to a different port. + o Bug fix; the list()/lsub() functions parsed mailboxes/folders + whose names contained spaces incorrectly. + o The list() function now does not return the folder itself, when + listing mailboxes inside a specific folder. + o It is now possible to define new user keywords for messages + inside a mailbox, apart from the standard system flags. + +------------------------------------------------------------------- Old: ---- imapfilter-1.2.1.tar.bz2 New: ---- imapfilter-1.2.2-warnings.patch imapfilter-1.2.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ imapfilter.spec ++++++ --- /var/tmp/diff_new_pack.Si1sTY/_old 2006-08-02 12:41:23.000000000 +0200 +++ /var/tmp/diff_new_pack.Si1sTY/_new 2006-08-02 12:41:23.000000000 +0200 @@ -1,5 +1,5 @@ # -# spec file for package imapfilter (Version 1.2.1) +# spec file for package imapfilter (Version 1.2.2) # # Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine @@ -14,14 +14,15 @@ BuildRequires: lua-devel openssl-devel Requires: lua Summary: a mail filtering utility -Version: 1.2.1 +Version: 1.2.2 Release: 1 License: X11/MIT Group: Productivity/Networking/Email/Utilities Source: %{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build URL: http://imapfilter.hellug.gr -Patch: %{name}-%{version}-makeinstall.patch +Patch: %{name}-1.2.1-makeinstall.patch +Patch1: %{name}-%{version}-warnings.patch %description IMAPFilter is a mail filtering utility. It connects to remote mail @@ -43,10 +44,11 @@ %prep %setup %patch +%patch1 %build ./configure -d /usr -b %{_bindir} -m %{_mandir} -r %{buildroot} -make +make MYCFLAGS="$RPM_OPT_FLAGS" %install %makeinstall @@ -64,6 +66,20 @@ %{_mandir}/man5/imapfilter_config.5.gz %changelog -n imapfilter +* Wed Aug 02 2006 - mskibbe@suse.de +- fixed some compiler warnings +- add RPM_OPT_FLAGS to make +- update to version 1.2.2 which + o Bug fix; a mix up of connections could happen in certain + circumstances, when a hostname and/or username was a prefix of + another hostname and/or username respectively, or when the same + hostname and username was used to connect to a different port. + o Bug fix; the list()/lsub() functions parsed mailboxes/folders + whose names contained spaces incorrectly. + o The list() function now does not return the folder itself, when + listing mailboxes inside a specific folder. + o It is now possible to define new user keywords for messages + inside a mailbox, apart from the standard system flags. * Mon Jul 17 2006 - mskibbe@suse.de - create package - add fix to build in BUILDROOT ++++++ imapfilter-1.2.2-warnings.patch ++++++ --- cert.c +++ cert.c @@ -163,11 +163,13 @@ FILE *fd; char b, c, buf[64]; char *certf; + char *rt; do { printf("(R)eject, accept (t)emporarily or " "accept (p)ermanently? "); - fgets(buf, sizeof(buf), stdin); + rt = fgets(buf, sizeof(buf), stdin); + free (rt); c = tolower((int)(*buf)); } while (c != 'r' && c != 't' && c != 'p'); @@ -210,11 +212,13 @@ mismatch_cert(void) { char c, buf[64]; + char *rt; do { printf("ATTENTION: SSL/TLS certificate fingerprint mismatch.\n" "Proceed with the connection (y/n)? "); - fgets(buf, sizeof(buf), stdin); + rt = fgets(buf, sizeof(buf), stdin); + free(rt); c = tolower((int)(*buf)); } while (c != 'y' && c != 'n'); --- system.c +++ system.c @@ -211,8 +211,10 @@ luaL_checktype(lua, 1, LUA_TUSERDATA); luaL_checktype(lua, 2, LUA_TSTRING); - fwrite(lua_tostring(lua, 2), sizeof(char), strlen(lua_tostring(lua, + size_t rt; + rt = fwrite(lua_tostring(lua, 2), sizeof(char), strlen(lua_tostring(lua, 2)), *(FILE **) (lua_touserdata(lua, 1))); + free(&rt); lua_pop(lua, 2); @@ -283,8 +285,10 @@ close(STDOUT_FILENO); close(STDERR_FILENO); if (open("/dev/null", O_RDWR) != -1) { - dup(STDIN_FILENO); - dup(STDIN_FILENO); + int rt = 0; + rt = dup(STDIN_FILENO); + rt = dup(STDIN_FILENO); + free(&rt); } return 0; ++++++ imapfilter-1.2.1.tar.bz2 -> imapfilter-1.2.2.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/NEWS new/imapfilter-1.2.2/NEWS --- old/imapfilter-1.2.1/NEWS 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/NEWS 2006-08-01 14:11:20.000000000 +0200 @@ -1,3 +1,17 @@ +Version 1.2.2 - 1 August 2006 +----------------------------- +- Bug fix; a mix up of connections could happen in certain circumstances, when + a hostname and/or username was a prefix of another hostname and/or username + respectively, or when the same hostname and username was used to connect to + a different port. +- Bug fix; the list()/lsub() functions parsed mailboxes/folders whose names + contained spaces incorrectly. +- The list() function now does not return the folder itself, when listing + mailboxes inside a specific folder. +- It is now possible to define new user keywords for messages inside a mailbox, + apart from the standard system flags. + + Version 1.2.1 - 9 March 2006 ---------------------------- - Buf fix; program fault when using the fetch*() family of functions. diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/README new/imapfilter-1.2.2/README --- old/imapfilter-1.2.1/README 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/README 2006-08-01 14:11:20.000000000 +0200 @@ -1,4 +1,4 @@ -IMAPFilter Version 1.2.1 +IMAPFilter Version 1.2.2 ======================== Requirements diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/core.c new/imapfilter-1.2.2/core.c --- old/imapfilter-1.2.1/core.c 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/core.c 2006-08-01 14:11:20.000000000 +0200 @@ -13,6 +13,7 @@ static int ifcore_status(lua_State *lua); static int ifcore_select(lua_State *lua); static int ifcore_close(lua_State *lua); +static int ifcore_expunge(lua_State *lua); static int ifcore_search(lua_State *lua); static int ifcore_list(lua_State *lua); static int ifcore_lsub(lua_State *lua); @@ -33,6 +34,7 @@ { "status", ifcore_status }, { "select", ifcore_select }, { "close", ifcore_close }, + { "expunge", ifcore_expunge }, { "list", ifcore_list }, { "lsub", ifcore_lsub }, { "search", ifcore_search }, @@ -56,13 +58,16 @@ }; +#define DISCOVER_PORT(P, S) ((P) ? (P) : (!(S) ? "143" : "993")) + + /* * Core function to reset any inactivity autologout timer on the server. */ static int ifcore_noop(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; if (lua_gettop(lua) != 1) @@ -74,8 +79,9 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); - r = request_noop(s, u); + r = request_noop(s, p, u); lua_pop(lua, 1); @@ -91,7 +97,7 @@ static int ifcore_login(lua_State *lua) { - const char *s, *u, *p; + const char *s, *u, *w, *p; int r; if (lua_gettop(lua) != 1) @@ -103,11 +109,11 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); - if (!(p = get_table_string("password"))) + if (!(w = get_table_string("password"))) luaL_error(lua, "no password specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); - r = request_login(s, u, p, get_table_string("port"), - get_table_string("ssl")); + r = request_login(s, p, get_table_string("ssl"), u, w); lua_pop(lua, 1); @@ -124,7 +130,7 @@ static int ifcore_logout(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; if (lua_gettop(lua) != 1) @@ -136,8 +142,9 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); - r = request_logout(s, u); + r = request_logout(s, p, u); lua_pop(lua, 1); @@ -153,7 +160,7 @@ static int ifcore_status(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; unsigned int exists, recent, unseen; @@ -170,9 +177,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_status(s, u, lua_tostring(lua, 2), &exists, &recent, + r = request_status(s, p, u, lua_tostring(lua, 2), &exists, &recent, &unseen); lua_pop(lua, 2); @@ -192,7 +200,7 @@ static int ifcore_select(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; if (lua_gettop(lua) != 2) @@ -206,9 +214,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_select(s, u, lua_tostring(lua, 2)); + r = request_select(s, p, u, lua_tostring(lua, 2)); lua_pop(lua, 2); @@ -224,7 +233,37 @@ static int ifcore_close(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; + int r; + + if (lua_gettop(lua) != 1) + luaL_error(lua, "wrong number of arguments"); + + luaL_checktype(lua, 1, LUA_TTABLE); + + if (!(s = get_table_string("server"))) + luaL_error(lua, "no mail server specified"); + if (!(u = get_table_string("username"))) + luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); + + r = request_close(s, p, u); + + lua_pop(lua, 1); + + lua_pushboolean(lua, (r == STATUS_RESPONSE_OK)); + + return 1; +} + + +/* + * Core function to expunge a mailbox. + */ +static int +ifcore_expunge(lua_State *lua) +{ + const char *s, *u, *p; int r; if (lua_gettop(lua) != 1) @@ -236,8 +275,9 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); - r = request_close(s, u); + r = request_expunge(s, p, u); lua_pop(lua, 1); @@ -253,7 +293,7 @@ static int ifcore_list(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; char *mboxs, *folders; @@ -271,9 +311,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_list(s, u, lua_tostring(lua, 2), lua_tostring(lua, 3), + r = request_list(s, p, u, lua_tostring(lua, 2), lua_tostring(lua, 3), &mboxs, &folders); lua_pop(lua, 3); @@ -299,7 +340,7 @@ static int ifcore_lsub(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; char *mboxs, *folders; @@ -317,9 +358,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_lsub(s, u, lua_tostring(lua, 2), lua_tostring(lua, 3), + r = request_lsub(s, p, u, lua_tostring(lua, 2), lua_tostring(lua, 3), &mboxs, &folders); lua_pop(lua, 3); @@ -344,7 +386,7 @@ static int ifcore_search(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; char *mesgs; @@ -361,9 +403,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_search(s, u, lua_tostring(lua, 2), &mesgs); + r = request_search(s, p, u, lua_tostring(lua, 2), &mesgs); lua_pop(lua, 2); @@ -386,7 +429,7 @@ static int ifcore_fetchfast(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; char *flags, *date, *size; @@ -403,9 +446,11 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_fetchfast(s, u, lua_tostring(lua, 2), &flags, &date, &size); + r = request_fetchfast(s, p, u, lua_tostring(lua, 2), &flags, &date, + &size); lua_pop(lua, 2); @@ -432,7 +477,7 @@ static int ifcore_fetchheader(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; char *header; size_t len; @@ -451,9 +496,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_fetchheader(s, u, lua_tostring(lua, 2), &header, &len); + r = request_fetchheader(s, p, u, lua_tostring(lua, 2), &header, &len); lua_pop(lua, 2); @@ -474,7 +520,7 @@ static int ifcore_fetchtext(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; char *text; size_t len; @@ -493,9 +539,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_fetchtext(s, u, lua_tostring(lua, 2), &text, &len); + r = request_fetchtext(s, p, u, lua_tostring(lua, 2), &text, &len); lua_pop(lua, 2); @@ -516,7 +563,7 @@ static int ifcore_fetchfields(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; char *fields; size_t len; @@ -536,9 +583,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_fetchfields(s, u, lua_tostring(lua, 2), + r = request_fetchfields(s, p, u, lua_tostring(lua, 2), lua_tostring(lua, 3), &fields, &len); lua_pop(lua, 3); @@ -560,7 +608,7 @@ static int ifcore_store(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; if (lua_gettop(lua) != 4) @@ -576,9 +624,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_store(s, u, lua_tostring(lua, 2), lua_tostring(lua, 3), + r = request_store(s, p, u, lua_tostring(lua, 2), lua_tostring(lua, 3), lua_tostring(lua, 4)); lua_pop(lua, 4); @@ -595,7 +644,7 @@ static int ifcore_copy(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; if (lua_gettop(lua) != 3) @@ -610,9 +659,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_copy(s, u, lua_tostring(lua, 2), lua_tostring(lua, 3)); + r = request_copy(s, p, u, lua_tostring(lua, 2), lua_tostring(lua, 3)); lua_pop(lua, 3); @@ -628,7 +678,7 @@ static int ifcore_append(lua_State *lua) { - const char *s, *u; + const char *s, *u, *p; int r; switch (lua_gettop(lua)) { @@ -653,9 +703,10 @@ luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); + p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); lua_pop(lua, 1); - r = request_append(s, u, lua_tostring(lua, 2), lua_tostring(lua, 3), + r = request_append(s, p, u, lua_tostring(lua, 2), lua_tostring(lua, 3), lua_strlen(lua, 3), lua_tostring(lua, 4), lua_tostring(lua, 5)); lua_pop(lua, lua_gettop(lua)); diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/imapfilter.h new/imapfilter-1.2.2/imapfilter.h --- old/imapfilter-1.2.1/imapfilter.h 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/imapfilter.h 2006-08-01 14:11:20.000000000 +0200 @@ -168,34 +168,38 @@ const char *reverse_namespace(const char *mbox, char *prefix, char delim); /* request.c */ -int request_noop(const char *server, const char *user); -int request_login(const char *server, const char *user, const char *pass, - const char *port, const char *ssl); -int request_logout(const char *server, const char *user); -int request_status(const char *server, const char *user, const char *mbox, - unsigned int *exist, unsigned int *recent, unsigned int *unseen); -int request_select(const char *server, const char *user, const char *mbox); -int request_close(const char *server, const char *user); -int request_list(const char *server, const char *user, const char *refer, - const char *name, char **mboxs, char **folders); -int request_lsub(const char *server, const char *user, const char *refer, - const char *name, char **mboxs, char **folders); -int request_search(const char *server, const char *user, const char *criteria, - char **mesgs); -int request_fetchfast(const char *server, const char *user, const char *mesg, - char **flags, char **date, char **size); -int request_fetchheader(const char *server, const char *user, const char *mesg, - char **header, size_t *len); -int request_fetchtext(const char *server, const char *user, const char *mesg, - char **text, size_t *len); -int request_fetchfields(const char *server, const char *user, - const char *mesg, const char *headerfields, char **fields, size_t *len); -int request_store(const char *server, const char *user, const char *mesg, - const char *mode, const char *flags); -int request_copy(const char *server, const char *user, const char *mesg, +int request_noop(const char *server, const char *port, const char *user); +int request_login(const char *server, const char *port, const char *ssl, + const char *user, const char *pass); +int request_logout(const char *server, const char *port, const char *user); +int request_status(const char *server, const char *port, const char *user, + const char *mbox, unsigned int *exist, unsigned int *recent, + unsigned int *unseen); +int request_select(const char *server, const char *port, const char *user, const char *mbox); -int request_append(const char *server, const char *user, const char *mbox, - const char *mesg, size_t mesglen, const char *flags, const char *date); +int request_close(const char *server, const char *port, const char *user); +int request_expunge(const char *server, const char *port, const char *user); +int request_list(const char *server, const char *port, const char *user, + const char *refer, const char *name, char **mboxs, char **folders); +int request_lsub(const char *server, const char *port, const char *user, + const char *refer, const char *name, char **mboxs, char **folders); +int request_search(const char *server, const char *port, const char *user, + const char *criteria, char **mesgs); +int request_fetchfast(const char *server, const char *port, const char *user, + const char *mesg, char **flags, char **date, char **size); +int request_fetchheader(const char *server, const char *port, const char *user, + const char *mesg, char **header, size_t *len); +int request_fetchtext(const char *server, const char *port, const char *user, + const char *mesg, char **text, size_t *len); +int request_fetchfields(const char *server, const char *port, const char *user, + const char *mesg, const char *headerfields, char **fields, size_t *len); +int request_store(const char *server, const char *port, const char *user, + const char *mesg, const char *mode, const char *flags); +int request_copy(const char *server, const char *port, const char *user, + const char *mesg, const char *mbox); +int request_append(const char *server, const char *port, const char *user, + const char *mbox, const char *mesg, size_t mesglen, const char *flags, + const char *date); /* response.c */ int response_generic(session *ssn, int tag); diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/imapfilter_config.5 new/imapfilter-1.2.2/imapfilter_config.5 --- old/imapfilter-1.2.1/imapfilter_config.5 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/imapfilter_config.5 2006-08-01 14:11:20.000000000 +0200 @@ -1,4 +1,4 @@ -.Dd Feb 16, 2006 +.Dd Jul 30, 2006 .Dt IMAPFILTER_CONFIG 5 .Os .Sh NAME @@ -337,9 +337,10 @@ .El .Pp Searching criteria based on a message's text, where the -.Aq string -and +.Aq string , .Aq field-name +and +.Aq flag refer to a sequence of characters enclosed in double quotes: .Bl -tag -offset indent -width Ds .It bcc Aq string @@ -361,6 +362,8 @@ specified string in the text of the header (what comes after the colon). If the string to search for is zero-length, this matches all messages that have a header line with the specified field-name regardless of the contents. +.It keyword Aq flag +Messages with the specified keyword flag set. .It subject Aq string Messages that contain the specified string in the envelope structure's .Dq Subject @@ -603,7 +606,7 @@ .Vt table containing .Vt strings , -that can be one of: +that can be one of the standard system flags: .Dq answered , .Dq deleted , .Dq draft , @@ -615,6 +618,27 @@ results = match(myaccount, 'INBOX', myfilter) flag(myaccount, 'INBOX', 'add', { 'seen' }, results) .Ed +.Pp +If the server supports it, new user keywords may be defined in the +.Fa mailbox , +by enabling the +.Dq keywords +option element in the +.Fa flags +.Vt table . +In this case, the +.Vt strings +inside the +.Vt table +can be anything, while the aforementioned standard system flags must be +prefixed with +.Dq \e\e . +Examples: +.Bd -literal -offset indend +results = match(myaccount, 'INBOX', myfilter) +flag(myaccount, 'INBOX', 'add', + { keywords = true, 'myflag', '\e\eseen' }, results) +.Ed .It Fn fetchheader account mailbox messages The .Fn fetchheader diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/interface.lua new/imapfilter-1.2.2/interface.lua --- old/imapfilter-1.2.1/interface.lua 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/interface.lua 2006-08-01 14:27:40.000000000 +0200 @@ -165,7 +165,20 @@ local f = '' if (table.getn(flags) ~= 0) then - f = '\\' .. table.concat(flags, ' \\') + if (flags.keywords ~= true) then + for k, v in ipairs(flags) do + if (string.lower(v) == 'answered' or + string.lower(v) == 'deleted' or + string.lower(v) == 'draft' or + string.lower(v) == 'flagged' or + string.lower(v) == 'seen') then + f = f .. '\\' .. v .. ' ' + end + end + f = string.gsub(f, '(.+) ', '%1') + else + f = table.concat(flags, ' ') + end end local m = range_sequence(messages) @@ -260,16 +273,13 @@ for i in pairs(fast) do for k, v in ipairs(fast[i]['flags']) do - if (string.lower(v) == 'recent') then + if (string.lower(v) == '\\recent') then table.remove(fast[i]['flags'], k) end end - local f = '' - if (table.getn(fast[i]['flags']) ~= 0) then - f = '\\' .. table.concat(fast[i]['flags'], ' \\') - end - r = ifcore.append(dstaccount, dstmbox, msgs[i], f, fast[i]['date']) + r = ifcore.append(dstaccount, dstmbox, msgs[i], + table.concat(fast[i]['flags'], ' '), fast[i]['date']) end end @@ -524,7 +534,7 @@ local _, flags, date, size = ifcore.fetchfast(account, tostring(v)) if (flags ~= nil and date ~= nil and size ~= nil ) then local f = {} - for s in string.gfind(flags, '%w+') do + for s in string.gfind(flags, '%S+') do table.insert(f, s) end results[tonumber(v)] = {} @@ -571,13 +581,15 @@ local _, mboxs, folders = ifcore.list(account, '', name .. '%') local m = {} - for s in string.gfind(mboxs, '[%w%p]+') do + for s in string.gfind(mboxs, '%C+') do table.insert(m, s) end local f = {} - for s in string.gfind(folders, '[%w%p]+') do - table.insert(f, s) + for s in string.gfind(folders, '%C+') do + if s ~= name and s ~= name .. '/' then + table.insert(f, s) + end end return m, f @@ -613,13 +625,15 @@ local _, mboxs, folders = ifcore.lsub(account, '', name .. '%') local m = {} - for s in string.gfind(mboxs, '[%w%p]+') do + for s in string.gfind(mboxs, '%C+') do table.insert(m, s) end local f = {} - for s in string.gfind(folders, '[%w%p]+') do - table.insert(f, s) + for s in string.gfind(folders, '%C+') do + if s ~= name and s ~= name .. '/' then + table.insert(f, s) + end end return m, f diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/request.c new/imapfilter-1.2.2/request.c --- old/imapfilter-1.2.1/request.c 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/request.c 2006-08-01 14:11:20.000000000 +0200 @@ -17,12 +17,12 @@ * Reset any inactivity autologout timer on the server. */ int -request_noop(const char *server, const char *user) +request_noop(const char *server, const char *port, const char *user) { int r; session *s; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; if ((r = response_generic(s, imap_noop(s))) == -1) @@ -42,26 +42,26 @@ * the namespace of the mailboxes. */ int -request_login(const char *server, const char *user, const char *pass, - const char *port, const char *ssl) +request_login(const char *server, const char *port, const char *ssl, + const char *user, const char *pass) { int r, rg; session *s; - if ((s = session_find(server, user))) + if ((s = session_find(server, port, user))) return STATUS_RESPONSE_OK; s = session_new(); s->server = xstrdup(server); + s->port = xstrdup(port); s->username = xstrdup(user); if (ssl && strncasecmp(ssl, "tls1", 4) && strncasecmp(ssl, "ssl3", 4) && strncasecmp(ssl, "ssl2", 4)) ssl = NULL; - if (open_connection(s, server, (port ? port : (!ssl ? "143" : "993")), - ssl) == -1) + if (open_connection(s, server, port, ssl) == -1) goto fail; if ((rg = response_greeting(s)) == -1) @@ -129,12 +129,12 @@ * Logout from the IMAP server and disconnect from the server. */ int -request_logout(const char *server, const char *user) +request_logout(const char *server, const char *port, const char *user) { int r; session *s; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; r = response_generic(s, imap_logout(s)); @@ -150,14 +150,15 @@ * Get mailbox's status. */ int -request_status(const char *server, const char *user, const char *mbox, - unsigned int *exists, unsigned int *recent, unsigned int *unseen) +request_status(const char *server, const char *port, const char *user, + const char *mbox, unsigned int *exists, unsigned int *recent, + unsigned int *unseen) { int t, r; session *s; const char *m; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; m = apply_namespace(mbox, s->ns.prefix, s->ns.delim); @@ -187,13 +188,14 @@ * Open mailbox in read-write mode. */ int -request_select(const char *server, const char *user, const char *mbox) +request_select(const char *server, const char *port, const char *user, + const char *mbox) { int r; session *s; const char *m; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; m = apply_namespace(mbox, s->ns.prefix, s->ns.delim); @@ -214,12 +216,12 @@ * Close examined/selected mailbox. */ int -request_close(const char *server, const char *user) +request_close(const char *server, const char *port, const char *user) { int r; session *s; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; if ((r = response_generic(s, imap_close(s))) == -1) @@ -235,17 +237,41 @@ /* + * Remove all messages marked for deletion from selected mailbox. + */ +int +request_expunge(const char *server, const char *port, const char *user) +{ + int r; + session *s; + + if (!(s = session_find(server, port, user))) + return -1; + + if ((r = response_generic(s, imap_expunge(s))) == -1) + goto fail; + + return r; +fail: + close_connection(s); + session_destroy(s); + + return -1; +} + + +/* * List available mailboxes. */ int -request_list(const char *server, const char *user, const char *refer, - const char *name, char **mboxs, char **folders) +request_list(const char *server, const char *port, const char *user, + const char *refer, const char *name, char **mboxs, char **folders) { int t, r; session *s; const char *n; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; n = apply_namespace(name, s->ns.prefix, s->ns.delim); @@ -267,14 +293,14 @@ * List subscribed mailboxes. */ int -request_lsub(const char *server, const char *user, const char *refer, - const char *name, char **mboxs, char **folders) +request_lsub(const char *server, const char *port, const char *user, + const char *refer, const char *name, char **mboxs, char **folders) { int t, r; session *s; const char *n; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; n = apply_namespace(name, s->ns.prefix, s->ns.delim); @@ -296,13 +322,13 @@ * Search selected mailbox according to the supplied search criteria. */ int -request_search(const char *server, const char *user, const char *criteria, - char **mesgs) +request_search(const char *server, const char *port, const char *user, + const char *criteria, char **mesgs) { int t, r; session *s; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; t = imap_search(s, get_option_boolean("uid"), @@ -323,13 +349,13 @@ * Fetch the FLAGS, INTERNALDATE and RFC822.SIZE of the messages. */ int -request_fetchfast(const char *server, const char *user, const char *mesg, - char **flags, char **date, char **size) +request_fetchfast(const char *server, const char *port, const char *user, + const char *mesg, char **flags, char **date, char **size) { int t, r; session *s; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; t = imap_fetch(s, get_option_boolean("uid"), mesg, "FAST"); @@ -349,13 +375,13 @@ * Fetch the header, ie. BODY[HEADER], of the messages. */ int -request_fetchheader(const char *server, const char *user, const char *mesg, - char **header, size_t *len) +request_fetchheader(const char *server, const char *port, const char *user, + const char *mesg, char **header, size_t *len) { int t, r; session *s; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; t = imap_fetch(s, get_option_boolean("uid"), mesg, "BODY.PEEK[HEADER]"); @@ -375,13 +401,13 @@ * Fetch the text, ie. BODY[TEXT], of the messages. */ int -request_fetchtext(const char *server, const char *user, const char *mesg, - char **text, size_t *len) +request_fetchtext(const char *server, const char *port, const char *user, + const char *mesg, char **text, size_t *len) { int t, r; session *s; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; t = imap_fetch(s, get_option_boolean("uid"), mesg, "BODY.PEEK[TEXT]"); @@ -402,8 +428,8 @@ * messages. */ int -request_fetchfields(const char *server, const char *user, const char *mesg, - const char *headerfields, char **fields, size_t *len) +request_fetchfields(const char *server, const char *port, const char *user, + const char *mesg, const char *headerfields, char **fields, size_t *len) { int t, r, n; session *s; @@ -413,7 +439,7 @@ f = (char *)xmalloc(n * sizeof(char)); snprintf(f, n, "%s%s%s", "BODY.PEEK[HEADER.FIELDS (", headerfields, ")]"); - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; t = imap_fetch(s, get_option_boolean("uid"), mesg, f); @@ -435,13 +461,13 @@ * Add, remove or replace the specified flags of the messages. */ int -request_store(const char *server, const char *user, const char *mesg, - const char *mode, const char *flags) +request_store(const char *server, const char *port, const char *user, + const char *mesg, const char *mode, const char *flags) { int t, r; session *s; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; t = imap_store(s, get_option_boolean("uid"), mesg, mode, flags); @@ -465,14 +491,14 @@ * Copy the specified messages to another mailbox. */ int -request_copy(const char *server, const char *user, const char *mesg, - const char *mbox) +request_copy(const char *server, const char *port, const char *user, + const char *mesg, const char *mbox) { int t, r; session *s; const char *m; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; m = apply_namespace(mbox, s->ns.prefix, s->ns.delim); @@ -503,14 +529,15 @@ * Append supplied message to the specified mailbox. */ int -request_append(const char *server, const char *user, const char *mbox, - const char *mesg, size_t mesglen, const char *flags, const char *date) +request_append(const char *server, const char *port, const char *user, + const char *mbox, const char *mesg, size_t mesglen, const char *flags, + const char *date) { int t, r; session *s; const char *m; - if (!(s = session_find(server, user))) + if (!(s = session_find(server, port, user))) return -1; m = apply_namespace(mbox, s->ns.prefix, s->ns.delim); diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/session.c new/imapfilter-1.2.2/session.c --- old/imapfilter-1.2.1/session.c 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/session.c 2006-08-01 14:11:20.000000000 +0200 @@ -35,6 +35,7 @@ { ssn->server = NULL; + ssn->port = NULL; ssn->username = NULL; ssn->socket = -1; #ifndef NO_SSLTLS @@ -69,6 +70,8 @@ if (ssn->server) xfree(ssn->server); + if (ssn->port) + xfree(ssn->port); if (ssn->username) xfree(ssn->username); if (ssn->ns.prefix) @@ -81,15 +84,16 @@ * Based on the specified socket, find an active IMAP session. */ session * -session_find(const char *serv, const char *user) +session_find(const char *serv, const char *port, const char *user) { list *l; session *s; for (l = sessions; l; l = l->next) { s = l->data; - if (!strncmp(s->server, serv, strlen(serv)) && - !strncmp(s->username, user, strlen(user))) + if (!strcmp(s->server, serv) && + !strcmp(s->port, port) && + !strcmp(s->username, user)) return s; } diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/session.h new/imapfilter-1.2.2/session.h --- old/imapfilter-1.2.1/session.h 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/session.h 2006-08-01 14:11:20.000000000 +0200 @@ -10,6 +10,7 @@ /* IMAP session. */ typedef struct session { char *server; /* Server hostname. */ + char *port; /* Server port. */ char *username; /* User name. */ int socket; /* Socket. */ #ifndef NO_SSLTLS @@ -30,7 +31,7 @@ void session_init(session *ssn); void session_destroy(session *ssn); void session_free(session *ssn); -session *session_find(const char *server, const char *user); +session *session_find(const char *server, const char *port, const char *user); #endif /* SESSION_H */ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/socket.c new/imapfilter-1.2.2/socket.c --- old/imapfilter-1.2.1/socket.c 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/socket.c 2006-08-01 14:11:20.000000000 +0200 @@ -65,7 +65,8 @@ res = res->ai_next; } - freeaddrinfo(ressave); + if (ressave) + freeaddrinfo(ressave); if (sockfd == -1) { error("error while initiating connection to %s at port %s\n", diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/imapfilter-1.2.1/version.h new/imapfilter-1.2.2/version.h --- old/imapfilter-1.2.1/version.h 2006-03-09 23:57:39.000000000 +0100 +++ new/imapfilter-1.2.2/version.h 2006-08-01 14:11:20.000000000 +0200 @@ -3,7 +3,7 @@ /* Program's version number. */ -#define IMAPFILTER_VERSION "1.2.1" +#define IMAPFILTER_VERSION "1.2.2" /* Program's copyright. */ #define IMAPFILTER_COPYRIGHT "Copyright (c) 2001-2006 Lefteris Chatzibarbas" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun...