solr-connection.c revision 48566ca412a7cf3b42512fd0ec112744778e5da0
/* Copyright (c) 2006-2008 Dovecot authors, see the included COPYING file */
/* curl: 7.16.0 curl_multi_timeout */
#include "lib.h"
#include "str.h"
#include "strescape.h"
#include "solr-connection.h"
#include <expat.h>
enum solr_xml_response_state {
};
enum solr_xml_content_state {
};
struct solr_lookup_xml_context {
enum solr_xml_response_state state;
int depth;
};
struct solr_connection_post {
struct solr_connection *conn;
const unsigned char *data;
unsigned int failed:1;
};
struct solr_connection {
char curl_errorbuf[CURL_ERROR_SIZE];
char *url;
unsigned int debug:1;
unsigned int posting:1;
unsigned int xml_failed:1;
};
static void
{
const char *const *tmp;
return;
} else {
}
}
i_fatal("fts_solr: url setting missing");
}
static size_t
{
/* @UNSAFE */
return size;
}
{
int line;
if (conn->xml_failed)
return -1;
return 0;
if (err != XML_ERROR_FINISHED) {
i_error("fts_solr: Invalid XML input at line %d: %s",
return -1;
}
return 0;
}
static size_t
{
return size;
}
{
struct solr_connection *conn;
"fts_solr: Failed to allocate curl");
}
/* set global curl options */
"Transfer-Encoding: chunked");
"Expect:");
"fts_solr: Failed to allocate XML parser");
}
return conn;
}
{
}
const char *str)
{
char *encoded;
}
static const char *attrs_get_name(const char **attrs)
{
return attrs[1];
}
return "";
}
static void
{
const char *name_attr;
/* skipping over unwanted elements */
return;
}
/* response -> result -> doc */
break;
break;
break;
else
break;
break;
break;
}
}
{
}
}
{
int i;
switch (ctx->content_state) {
break;
break;
}
if (i != len) {
i_error("fts_solr: received invalid uid");
break;
}
break;
/* FIXME */
break;
}
}
{
if (ret != 0) {
i_error("fts_solr: HTTP GET failed: %s",
return -1;
}
}
struct solr_connection_post *
{
struct solr_connection_post *post;
i_error("fts_solr: curl_multi_add_handle() failed: %s",
} else {
conn->headers_post);
}
return post;
}
{
struct timeval timeout_tv;
long timeout;
return;
for (;;) {
if (merr == CURLM_CALL_MULTI_PERFORM)
continue;
i_error("fts_solr: curl_multi_perform() failed: %s",
break;
}
/* everything sent successfully */
return;
}
/* everything wasn't sent - wait. just use select,
since libcurl interface is easiest with it. */
i_error("fts_solr: curl_multi_fdset() failed: %s",
break;
}
i_error("fts_solr: curl_multi_timeout() failed: %s",
break;
}
if (timeout < 0) {
timeout_tv.tv_usec = 0;
} else {
}
if (ret < 0) {
i_error("fts_solr: select() failed: %m");
break;
}
}
}
{
long httpret;
ret = -1;
}
return ret;
}
{
struct solr_connection_post *post;
return solr_connection_end(post);
}