text_buffer bug fixes & Sort option

This commit is contained in:
2020-03-20 20:54:22 -04:00
parent 6e5772f13b
commit 0505303503
14 changed files with 160 additions and 65 deletions

View File

@@ -116,7 +116,7 @@ void *create_bulk_buffer(int max, int *count, size_t *buf_len) {
return buf;
}
void *print_errors(response_t *r) {
void print_errors(response_t *r) {
char * tmp = malloc(r->size + 1);
memcpy(tmp, r->body, r->size);
*(tmp + r->size) = '\0';

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
static const char *const Version = "1.3.3";
static const char *const Version = "1.3.4";
static const char *const usage[] = {
"sist2 scan [OPTION]... PATH",
"sist2 index [OPTION]... INDEX",

View File

@@ -114,7 +114,7 @@ static void grow_buffer_small(dyn_buffer_t *buf) {
}
__always_inline
static void dyn_buffer_write(dyn_buffer_t *buf, void *data, size_t size) {
static void dyn_buffer_write(dyn_buffer_t *buf, const void *data, size_t size) {
grow_buffer(buf, size);
memcpy(buf->buf + buf->cur, data, size);
@@ -251,8 +251,17 @@ static int text_buffer_append_string(text_buffer_t *buf, const char *str, size_t
return 0;
}
if (len <= 4) {
for (int i = 0; i < len; i++) {
if (((utf8_int32_t)0xffffff80 & str[i]) == 0) {
dyn_buffer_write_char(&buf->dyn_buffer, str[i]);
}
}
return 0;
}
utf8_int32_t c;
char tmp[4];
char tmp[16];
do {
ptr = utf8codepoint(ptr, &c);

View File

@@ -244,6 +244,16 @@ int search(UNUSED(void *p), onion_request *req, onion_response *res) {
onion_response_write(res, r->body, r->size);
} else {
sist_log("serve.c", SIST_WARNING, "ElasticSearch error during query");
if (r->size != 0) {
char * tmp = malloc(r->size + 1);
memcpy(tmp, r->body, r->size);
*(tmp + r->size) = '\0';
cJSON *json = cJSON_Parse(tmp);
char *json_str = cJSON_Print(json);
sist_log("serve.c", SIST_WARNING, json_str);
free(json_str);
free(tmp);
}
onion_response_set_code(res, HTTP_INTERNAL_ERROR);
}

File diff suppressed because one or more lines are too long