client.c revision 04d0cb8d447c468c6128f03c90a5f4b43c644d42
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "network.h"
#include "istream.h"
#include "ostream.h"
#include "commands.h"
#include "namespace.h"
#include <stdlib.h>
/* If we can't send a buffer in a minute, disconnect the client */
/* If we don't soon receive expected data from client while processing
a command, disconnect the client */
/* Disconnect client when it sends too many bad commands in a row */
#define CLIENT_MAX_BAD_COMMANDS 20
extern struct mail_storage_callbacks mail_storage_callbacks;
static void client_output_timeout(void *context)
{
}
static void client_input_timeout(void *context)
{
"Disconnected for inactivity while waiting for command data.");
}
{
/* set timeout for reading expected data (eg. APPEND). This is
different from the actual idle time. */
/* set timeout for sending data */
while (namespaces != NULL) {
}
if (hook_client_created != NULL)
return client;
}
{
/* quit the program */
}
{
}
{
}
{
return;
}
{
return;
tag = "*";
}
{
int fatal;
if (fatal) {
return;
}
}
else {
}
"Too many invalid IMAP commands.");
}
}
{
int ret;
/* all parameters read successfully */
return TRUE;
} else if (ret == -2) {
/* need more data */
return FALSE;
} else {
/* error, or missing arguments */
"Missing arguments");
return FALSE;
}
}
{
const char *str;
unsigned int i;
return FALSE;
for (i = 0; i < count; i++) {
break;
}
break;
}
}
return i == count;
}
{
}
/* Skip incoming data until newline is found,
returns TRUE if newline was found. */
{
const unsigned char *data;
for (i = 0; i < data_size; i++) {
if (data[i] == '\n') {
i++;
break;
}
}
return !client->input_skip_line;
}
{
/* command is being executed - continue it */
/* command execution was finished */
client->bad_counter = 0;
return TRUE;
}
return FALSE;
}
if (client->input_skip_line) {
/* we're just waiting for new line.. */
if (!client_skip_line(client))
return FALSE;
/* got the newline */
/* pass through to parse next command */
}
return FALSE; /* need more data */
}
return FALSE; /* need more data */
}
/* command not given - cmd_func is already NULL. */
} else {
/* find the command function */
}
/* unknown command */
} else {
/* command execution was finished */
client->bad_counter = 0;
} else {
/* unfinished */
return FALSE;
}
}
return TRUE;
}
void _client_input(void *context)
{
case -1:
/* disconnected */
return;
case -2:
/* parameter word is longer than max. input buffer size.
this is most likely an error, so skip the new data
until newline is found. */
break;
}
while (client_handle_input(client))
;
}
{
return;
"* BYE Disconnected for inactivity.");
}
}
void clients_init(void)
{
}
void clients_deinit(void)
{
}
}