client.c revision e5ee67f18b03015c88b579c8c1f17ebe6ce19b76
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "network.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "mail-storage.h"
#include "commands.h"
#include "mail-search.h"
#include <stdlib.h>
/* max. length of input command line (spec says 512) */
#define MAX_INBUF_SIZE 2048
/* Stop reading input when output buffer has this many bytes. Once the buffer
size has dropped to half of it, start reading input again. */
#define OUTBUF_THROTTLE_SIZE 4096
/* If we can't send anything for a minute, disconnect the client */
/* Disconnect client when it sends too many bad commands in a row */
#define CLIENT_MAX_BAD_COMMANDS 20
/* Disconnect client after idling this many seconds */
extern struct mail_storage_callbacks mail_storage_callbacks;
static void client_input(void *context);
static void client_output(void *context);
{
struct mailbox_sync_context *ctx;
struct mailbox_sync_rec sync_rec;
struct mailbox_status status;
;
}
{
struct mail_search_arg search_arg;
struct mailbox_transaction_context *t;
struct mail_search_context *ctx;
struct mailbox_status status;
int i, failed;
for (i = 0; i < 2; i++) {
return FALSE;
}
&status) < 0) {
return FALSE;
}
client->total_size = 0;
client->deleted_size = 0;
if (client->messages_count == 0)
return TRUE;
return FALSE;
}
const struct mail_full_flags *flags;
break;
}
}
if (mailbox_search_deinit(ctx) < 0) {
return FALSE;
}
if (!failed) {
mailbox_transaction_commit(t, 0);
return TRUE;
}
/* well, sync and try again */
}
return FALSE;
}
{
enum mailbox_open_flags flags;
int syntax_error;
/* always use nonblocking I/O */
flags = 0;
i_error("Couldn't open INBOX: %s",
return NULL;
}
if (!init_mailbox(client)) {
return NULL;
}
if (hook_client_created != NULL)
return client;
}
{
/* deinitialize command */
}
/* quit the program */
}
{
}
{
return -1;
t_push();
if (ret < 0)
else {
ret = 1;
} else {
ret = 0;
/* no more input until client has read
our output */
}
}
}
t_pop();
return (int)ret;
}
{
const char *error;
int syntax;
"state, please relogin.");
return;
}
"BUG: Unknown error");
}
static void client_input(void *context)
{
/* we're still processing a command. wait until it's
finished. */
return;
}
case -1:
/* disconnected */
return;
case -2:
/* line too long, kill it */
return;
}
args = "";
else
*args++ = '\0';
client->bad_counter = 0;
break;
}
}
}
}
static void client_output(void *context)
{
int ret;
return;
}
/* enable input again */
}
}
{
return;
} else {
"-ERR Disconnected for inactivity.");
}
}
}
void clients_init(void)
{
}
void clients_deinit(void)
{
}
}