From d86f6ee27f63b120fce952e0905a8c627861ba81 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 25 Sep 2022 22:57:18 +0200 Subject: [PATCH] Backported from xs. --- activitypub.c | 2 +- webfinger.c | 2 +- xs.h | 24 ++++++++++++------------ xs_json.h | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/activitypub.c b/activitypub.c index 39fcdfe..8a02d7e 100644 --- a/activitypub.c +++ b/activitypub.c @@ -256,7 +256,7 @@ void process_message(snac *snac, char *msg, char *req) char *object, *utype; object = xs_dict_get(msg, "object"); - if (object != NULL && xs_type(object) == XSTYPE_SOD) + if (object != NULL && xs_type(object) == XSTYPE_DICT) utype = xs_dict_get(object, "type"); else utype = "(null)"; diff --git a/webfinger.c b/webfinger.c index e9f0893..6476bba 100644 --- a/webfinger.c +++ b/webfinger.c @@ -82,7 +82,7 @@ int webfinger_request(char *qs, char **actor, char **user) char *v; while (xs_list_iter(&list, &v)) { - if (xs_type(v) == XSTYPE_SOD) { + if (xs_type(v) == XSTYPE_DICT) { char *type = xs_dict_get(v, "type"); if (type && strcmp(type, "application/activity+json") == 0) { diff --git a/xs.h b/xs.h index 3562070..8205b98 100644 --- a/xs.h +++ b/xs.h @@ -17,10 +17,10 @@ typedef enum { XSTYPE_NULL = 0x18, XSTYPE_TRUE = 0x06, XSTYPE_FALSE = 0x15, - XSTYPE_SOL = 0x11, + XSTYPE_LIST = 0x11, XSTYPE_LITEM = 0x1f, XSTYPE_EOL = 0x12, - XSTYPE_SOD = 0x13, + XSTYPE_DICT = 0x13, XSTYPE_DITEM = 0x1e, XSTYPE_EOD = 0x14, XSTYPE_NUMBER = 0x17, @@ -103,9 +103,9 @@ xstype xs_type(const char *data) case XSTYPE_NULL: case XSTYPE_TRUE: case XSTYPE_FALSE: - case XSTYPE_SOL: + case XSTYPE_LIST: case XSTYPE_EOL: - case XSTYPE_SOD: + case XSTYPE_DICT: case XSTYPE_EOD: case XSTYPE_LITEM: case XSTYPE_DITEM: @@ -136,19 +136,19 @@ int xs_size(const char *data) len = strlen(data) + 1; break; - case XSTYPE_SOL: + case XSTYPE_LIST: /* look for a balanced EOL */ do { - c += data[len] == XSTYPE_SOL ? 1 : data[len] == XSTYPE_EOL ? -1 : 0; + c += data[len] == XSTYPE_LIST ? 1 : data[len] == XSTYPE_EOL ? -1 : 0; len++; } while (c); break; - case XSTYPE_SOD: + case XSTYPE_DICT: /* look for a balanced EOD */ do { - c += data[len] == XSTYPE_SOD ? 1 : data[len] == XSTYPE_EOD ? -1 : 0; + c += data[len] == XSTYPE_DICT ? 1 : data[len] == XSTYPE_EOD ? -1 : 0; len++; } while (c); @@ -397,7 +397,7 @@ d_char *xs_list_new(void) d_char *list; list = malloc(_xs_blk_size(2)); - list[0] = XSTYPE_SOL; + list[0] = XSTYPE_LIST; list[1] = XSTYPE_EOL; return list; @@ -429,7 +429,7 @@ int xs_list_iter(char **list, char **value) p = *list; /* skip a possible start of the list */ - if (*p == XSTYPE_SOL) + if (*p == XSTYPE_LIST) p++; /* an element? */ @@ -572,7 +572,7 @@ d_char *xs_dict_new(void) d_char *dict; dict = malloc(_xs_blk_size(2)); - dict[0] = XSTYPE_SOD; + dict[0] = XSTYPE_DICT; dict[1] = XSTYPE_EOD; return dict; @@ -606,7 +606,7 @@ int xs_dict_iter(char **dict, char **key, char **value) p = *dict; /* skip a possible start of the list */ - if (*p == XSTYPE_SOD) + if (*p == XSTYPE_DICT) p++; /* an element? */ diff --git a/xs_json.h b/xs_json.h index 8aa3f16..4915a62 100644 --- a/xs_json.h +++ b/xs_json.h @@ -111,7 +111,7 @@ d_char *_xs_json_dumps(d_char *s, char *data, int level, int indent) } break; - case XSTYPE_SOL: + case XSTYPE_LIST: s = xs_str_cat(s, "["); while (xs_list_iter(&data, &v)) { @@ -129,7 +129,7 @@ d_char *_xs_json_dumps(d_char *s, char *data, int level, int indent) break; - case XSTYPE_SOD: + case XSTYPE_DICT: s = xs_str_cat(s, "{"); while (xs_dict_iter(&data, &k, &v)) { @@ -171,7 +171,7 @@ d_char *xs_json_dumps_pp(char *data, int indent) xstype t = xs_type(data); d_char *s = NULL; - if (t == XSTYPE_SOL || t == XSTYPE_SOD) { + if (t == XSTYPE_LIST || t == XSTYPE_DICT) { s = xs_str_new(NULL); s = _xs_json_dumps(s, data, 0, indent); }