dict-commands.c revision 373b27178af59c8579967c126e7c2c002974d095
/* Copyright (c) 2005-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "ostream.h"
#include "str.h"
#include "strescape.h"
#include "dict-client.h"
#include "dict-settings.h"
#include "dict-connection.h"
#include "dict-commands.h"
#define DICT_OUTPUT_OPTIMAL_SIZE 1024
struct dict_cmd_func {
enum dict_protocol_cmd cmd;
};
struct dict_connection_cmd {
const struct dict_cmd_func *cmd;
struct dict_connection *conn;
char *reply;
struct dict_iterate_context *iter;
enum dict_iterate_flags iter_flags;
unsigned int trans_id;
};
{
}
{
struct dict_connection_cmd *const *cmds;
unsigned int i, count;
for (i = 0; i < count; i++) {
return;
}
}
i_unreached();
}
{
cmd = *first_cmdp;
/* command not finished yet */
break;
}
}
}
static void
{
} else {
}
}
{
/* <key> */
return 1;
}
{
str_truncate(str, 0);
/* continue later when there's more space
in output buffer */
return 0;
}
/* flushed everything, continue */
}
}
/* wait for the next iteration callback */
return 0;
}
str_truncate(str, 0);
return 1;
}
static void cmd_iterate_callback(void *context)
{
}
{
const char *const *args;
unsigned int flags;
i_error("dict client: ITERATE: broken input");
return -1;
}
/* <flags> <path> */
return 1;
}
static struct dict_connection_transaction *
unsigned int id)
{
struct dict_connection_transaction *transaction;
return NULL;
return transaction;
}
return NULL;
}
static void
unsigned int id)
{
const struct dict_connection_transaction *transactions;
unsigned int i, count;
for (i = 0; i < count; i++) {
return;
}
}
i_unreached();
}
{
struct dict_connection_transaction *trans;
unsigned int id;
return -1;
}
return -1;
}
/* <id> */
return 0;
}
static int
const char *line,
struct dict_connection_transaction **trans_r)
{
unsigned int id;
return -1;
}
return -1;
}
return 0;
}
static void
{
char chr;
switch (ret) {
case 1:
break;
case 0:
break;
default:
break;
}
if (async) {
} else {
}
}
{
}
{
}
static int
{
struct dict_connection_transaction *trans;
return -1;
return 1;
}
static int
{
struct dict_connection_transaction *trans;
return -1;
return 1;
}
{
struct dict_connection_transaction *trans;
return -1;
return 0;
}
{
struct dict_connection_transaction *trans;
const char *const *args;
/* <id> <key> <value> */
i_error("dict client: SET: broken input");
return -1;
}
return -1;
return 0;
}
{
struct dict_connection_transaction *trans;
const char *const *args;
/* <id> <key> */
i_error("dict client: UNSET: broken input");
return -1;
}
return -1;
return 0;
}
{
struct dict_connection_transaction *trans;
const char *const *args;
long long diff;
/* <id> <key> <diff> */
i_error("dict client: ATOMIC_INC: broken input");
return -1;
}
return -1;
return 0;
}
static const struct dict_cmd_func cmds[] = {
{ DICT_PROTOCOL_CMD_SET, cmd_set },
{ 0, NULL }
};
{
unsigned int i;
return &cmds[i];
}
return NULL;
}
{
const struct dict_cmd_func *cmd_func;
struct dict_connection_cmd *cmd;
int ret;
return -1;
}
return ret;
}
return 0;
}
{
struct dict_connection_cmd *const *first_cmdp;
if (*first_cmdp == cmd)
(void)cmd_iterate_flush(cmd);
}
{
/* only iterators may be returning a lot of data */
cmd = *first_cmdp;
break;
if (cmd_iterate_flush(cmd) == 0) {
/* unfinished */
break;
}
/* cmd should be freed now */
}
}