From: Stephan Bosch Date: Tue, 8 Oct 2019 16:56:57 +0000 (+0200) Subject: plugins: fts-solr: Move solr_lookup_xml_end() from solr-connection.c to solr-response.c. X-Git-Tag: 2.3.10~157 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b066e5be22a48d4abd01f4a3d0b500a30288facc;p=thirdparty%2Fdovecot%2Fcore.git plugins: fts-solr: Move solr_lookup_xml_end() from solr-connection.c to solr-response.c. --- diff --git a/src/plugins/fts-solr/solr-connection.c b/src/plugins/fts-solr/solr-connection.c index f6d0639f16..375d034ce5 100644 --- a/src/plugins/fts-solr/solr-connection.c +++ b/src/plugins/fts-solr/solr-connection.c @@ -126,39 +126,6 @@ void solr_connection_deinit(struct solr_connection **_conn) i_free(conn); } -static void solr_lookup_xml_end(void *context, const char *name ATTR_UNUSED) -{ - struct solr_lookup_xml_context *ctx = context; - int ret; - - if (ctx->content_state == SOLR_XML_CONTENT_STATE_ERROR) - return; - - i_assert(ctx->depth >= (int)ctx->state); - - if (ctx->state == SOLR_XML_RESPONSE_STATE_CONTENT && - ctx->content_state == SOLR_XML_CONTENT_STATE_MAILBOX && - ctx->mailbox == NULL) { - /* mailbox is namespace prefix */ - ctx->mailbox = i_strdup(""); - } - - if (ctx->depth == (int)ctx->state) { - ret = 0; - if (ctx->state == SOLR_XML_RESPONSE_STATE_DOC) { - T_BEGIN { - ret = solr_lookup_add_doc(ctx); - } T_END; - } - ctx->state--; - if (ret < 0) - ctx->content_state = SOLR_XML_CONTENT_STATE_ERROR; - else - ctx->content_state = SOLR_XML_CONTENT_STATE_NONE; - } - ctx->depth--; -} - static int uint32_parse(const char *str, int len, uint32_t *value_r) { uint32_t value = 0; diff --git a/src/plugins/fts-solr/solr-response.c b/src/plugins/fts-solr/solr-response.c index baec9f3963..2a5c4847f9 100644 --- a/src/plugins/fts-solr/solr-response.c +++ b/src/plugins/fts-solr/solr-response.c @@ -185,3 +185,36 @@ static int solr_lookup_add_doc(struct solr_lookup_xml_context *ctx) } return 0; } + +static void solr_lookup_xml_end(void *context, const char *name ATTR_UNUSED) +{ + struct solr_lookup_xml_context *ctx = context; + int ret; + + if (ctx->content_state == SOLR_XML_CONTENT_STATE_ERROR) + return; + + i_assert(ctx->depth >= (int)ctx->state); + + if (ctx->state == SOLR_XML_RESPONSE_STATE_CONTENT && + ctx->content_state == SOLR_XML_CONTENT_STATE_MAILBOX && + ctx->mailbox == NULL) { + /* mailbox is namespace prefix */ + ctx->mailbox = i_strdup(""); + } + + if (ctx->depth == (int)ctx->state) { + ret = 0; + if (ctx->state == SOLR_XML_RESPONSE_STATE_DOC) { + T_BEGIN { + ret = solr_lookup_add_doc(ctx); + } T_END; + } + ctx->state--; + if (ret < 0) + ctx->content_state = SOLR_XML_CONTENT_STATE_ERROR; + else + ctx->content_state = SOLR_XML_CONTENT_STATE_NONE; + } + ctx->depth--; +}