client.c revision fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "buffer.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 10 minutes, 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 int client_output(void *context);
{
struct mailbox_sync_context *ctx;
struct mailbox_sync_rec sync_rec;
;
}
{
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++) {
break;
}
break;
}
client->total_size = 0;
break;
}
}
if (mailbox_search_deinit(ctx) < 0) {
break;
}
if (!failed) {
return TRUE;
}
/* well, sync and try again */
}
if (i == 2)
return FALSE;
}
{
enum mailbox_open_flags flags;
int syntax_error;
/* always use nonblocking I/O */
flags = 0;
if (no_flag_updates)
if ((uidl_keymask & UIDL_MD5) != 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) {
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 int client_output(void *context)
{
int ret;
return 1;
}
/* enable input again */
}
}
{
return;
} else {
"-ERR Disconnected for inactivity.");
}
}
}
void clients_init(void)
{
}
void clients_deinit(void)
{
}
}