c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#ifndef DICT_CLIENT_H
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#define DICT_CLIENT_H
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
419cf63077e755935ce105747d6ebc67b7d38a7fTimo Sirainen#include "dict.h"
419cf63077e755935ce105747d6ebc67b7d38a7fTimo Sirainen
842b049f6e2f8f88f7b69a182f5ad8e58f76f1dfTimo Sirainen#define DEFAULT_DICT_SERVER_SOCKET_FNAME "dict"
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainen#define DICT_CLIENT_PROTOCOL_MAJOR_VERSION 2
217683437468663839ec9bb6c7d2892b98fae4f9Timo Sirainen#define DICT_CLIENT_PROTOCOL_MINOR_VERSION 2
217683437468663839ec9bb6c7d2892b98fae4f9Timo Sirainen
217683437468663839ec9bb6c7d2892b98fae4f9Timo Sirainen#define DICT_CLIENT_PROTOCOL_VERSION_MIN_MULTI_OK 2
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen#define DICT_CLIENT_MAX_LINE_LENGTH (64*1024)
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
c02488b7f2d1eac2b4a8db0b6644bb00de32422eTimo Sirainenenum dict_protocol_cmd {
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainen /* <major-version> <minor-version> <value type> <user> <dict name> */
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen DICT_PROTOCOL_CMD_HELLO = 'H',
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen DICT_PROTOCOL_CMD_LOOKUP = 'L', /* <key> */
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainen DICT_PROTOCOL_CMD_ITERATE = 'I', /* <flags> <path> */
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen DICT_PROTOCOL_CMD_BEGIN = 'B', /* <id> */
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen DICT_PROTOCOL_CMD_COMMIT = 'C', /* <id> */
03b10bd68ecd2307c7f505ddbdeee2d40a5d1441Timo Sirainen DICT_PROTOCOL_CMD_COMMIT_ASYNC = 'D', /* <id> */
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen DICT_PROTOCOL_CMD_ROLLBACK = 'R', /* <id> */
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen DICT_PROTOCOL_CMD_SET = 'S', /* <id> <key> <value> */
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainen DICT_PROTOCOL_CMD_UNSET = 'U', /* <id> <key> */
345fceae2f430dcad449f2a09598ba1a225116ddTimo Sirainen DICT_PROTOCOL_CMD_ATOMIC_INC = 'A', /* <id> <key> <diff> */
345fceae2f430dcad449f2a09598ba1a225116ddTimo Sirainen DICT_PROTOCOL_CMD_TIMESTAMP = 'T', /* <id> <secs> <nsecs> */
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen};
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
c02488b7f2d1eac2b4a8db0b6644bb00de32422eTimo Sirainenenum dict_protocol_reply {
fc494f157828dee9bb9885dd3630e9b7b45cdb25Timo Sirainen DICT_PROTOCOL_REPLY_ERROR = -1,
fc494f157828dee9bb9885dd3630e9b7b45cdb25Timo Sirainen
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen DICT_PROTOCOL_REPLY_OK = 'O', /* <value> */
217683437468663839ec9bb6c7d2892b98fae4f9Timo Sirainen DICT_PROTOCOL_REPLY_MULTI_OK = 'M', /* protocol v2.2+ */
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen DICT_PROTOCOL_REPLY_NOTFOUND = 'N',
3954326e793bdef1e94e0ad781ed6cc7e48beebbTimo Sirainen DICT_PROTOCOL_REPLY_FAIL = 'F',
c5d27aee77dad4b10d6dd915b9cb4c8757c0e988Timo Sirainen DICT_PROTOCOL_REPLY_WRITE_UNCERTAIN = 'W',
fc494f157828dee9bb9885dd3630e9b7b45cdb25Timo Sirainen DICT_PROTOCOL_REPLY_ASYNC_COMMIT = 'A',
fc494f157828dee9bb9885dd3630e9b7b45cdb25Timo Sirainen DICT_PROTOCOL_REPLY_ITER_FINISHED = '\0',
44c54229a117b8dab05eaff9c54ba61fbae9a39fTimo Sirainen DICT_PROTOCOL_REPLY_ASYNC_ID = '*',
44c54229a117b8dab05eaff9c54ba61fbae9a39fTimo Sirainen DICT_PROTOCOL_REPLY_ASYNC_REPLY = '+',
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen};
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen
ff52f5c52ee6a4c8a9c79964d32b5d0ff0ae92e6Timo Sirainen#endif