cmd-sort.c revision c4b376dd6e0c423006d7ac83a39253bcaf8e7c47
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "buffer.h"
#include "commands.h"
#include "imap-search.h"
#include "imap-sort.h"
struct sort_name {
enum mail_sort_type type;
const char *name;
};
static struct sort_name sort_names[] = {
{ MAIL_SORT_ARRIVAL, "arrival" },
{ MAIL_SORT_CC, "cc" },
{ MAIL_SORT_DATE, "date" },
{ MAIL_SORT_FROM, "from" },
{ MAIL_SORT_SIZE, "size" },
{ MAIL_SORT_SUBJECT, "subject" },
{ MAIL_SORT_TO, "to" },
{ MAIL_SORT_END, NULL }
};
static int
{
enum mail_sort_type mask = 0;
unsigned int i, pos;
bool reverse;
/* empyty list */
return -1;
}
args++) {
continue;
}
break;
}
return -1;
}
continue;
/* @UNSAFE: mask check should prevent us from ever
overflowing */
(reverse ? MAIL_SORT_FLAG_REVERSE : 0);
}
"Invalid sort list argument.");
return -1;
}
return 0;
}
{
struct mail_search_args *sargs;
int args_count;
const char *charset;
int ret;
if (args_count == -2)
return FALSE;
if (args_count < 3) {
"Missing or invalid arguments.");
return TRUE;
}
if (!client_verify_open_mailbox(cmd))
return TRUE;
/* sort program */
return TRUE;
}
return TRUE;
args++;
/* charset */
"Invalid charset argument.");
return TRUE;
}
args++;
if (ret <= 0)
return ret < 0;
if (ret < 0) {
return TRUE;
}
0, "OK Sort completed.");
}