(unsigned int)ioloop_timeval.tv_usec);
}
+static void
+cmd_lookup_write_reply(struct dict_connection_cmd *cmd,
+ const char *const *values, string_t *str)
+{
+ string_t *tmp;
+
+ i_assert(values[0] != NULL);
+
+ if (cmd->conn->minor_version < DICT_CLIENT_PROTOCOL_VERSION_MIN_MULTI_OK ||
+ values[1] == NULL) {
+ str_append_c(str, DICT_PROTOCOL_REPLY_OK);
+ str_append_tabescaped(str, values[0]);
+ return;
+ }
+ /* the results get double-tabescaped so they end up becoming a single
+ parameter */
+ tmp = t_str_new(128);
+ for (unsigned int i = 0; values[i] != NULL; i++) {
+ str_append_c(tmp, '\t');
+ str_append_tabescaped(tmp, values[i]);
+ }
+ str_append_c(str, DICT_PROTOCOL_REPLY_MULTI_OK);
+ str_append_tabescaped(str, str_c(tmp) + 1);
+}
+
static void
cmd_lookup_callback(const struct dict_lookup_result *result, void *context)
{
string_t *str = t_str_new(128);
if (result->ret > 0) {
- str_append_c(str, DICT_PROTOCOL_REPLY_OK);
- str_append_tabescaped(str, result->value);
+ cmd_lookup_write_reply(cmd, result->values, str);
} else if (result->ret == 0) {
str_append_c(str, DICT_PROTOCOL_REPLY_NOTFOUND);
} else {
#define DEFAULT_DICT_SERVER_SOCKET_FNAME "dict"
#define DICT_CLIENT_PROTOCOL_MAJOR_VERSION 2
-#define DICT_CLIENT_PROTOCOL_MINOR_VERSION 1
+#define DICT_CLIENT_PROTOCOL_MINOR_VERSION 2
+
+#define DICT_CLIENT_PROTOCOL_VERSION_MIN_MULTI_OK 2
#define DICT_CLIENT_MAX_LINE_LENGTH (64*1024)
DICT_PROTOCOL_REPLY_ERROR = -1,
DICT_PROTOCOL_REPLY_OK = 'O', /* <value> */
+ DICT_PROTOCOL_REPLY_MULTI_OK = 'M', /* protocol v2.2+ */
DICT_PROTOCOL_REPLY_NOTFOUND = 'N',
DICT_PROTOCOL_REPLY_FAIL = 'F',
DICT_PROTOCOL_REPLY_WRITE_UNCERTAIN = 'W',