summaryrefslogtreecommitdiff
path: root/webfinger.c
diff options
context:
space:
mode:
authorGravatar default2024-05-21 14:12:15 +0200
committerGravatar default2024-05-21 14:12:15 +0200
commit4777fc86cb962917a8f34afb3bfa40f26290815d (patch)
tree268c078531a018f07c1b6d029f14f87134805f7b /webfinger.c
parentVersion 2.53 RELEASED. (diff)
downloadpenes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.tar.gz
penes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.tar.xz
penes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.zip
Added const everywhere.
Diffstat (limited to 'webfinger.c')
-rw-r--r--webfinger.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/webfinger.c b/webfinger.c
index 7255ae2..a12134d 100644
--- a/webfinger.c
+++ b/webfinger.c
@@ -16,7 +16,7 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
16 int p_size = 0; 16 int p_size = 0;
17 xs *headers = xs_dict_new(); 17 xs *headers = xs_dict_new();
18 xs *l = NULL; 18 xs *l = NULL;
19 xs_str *host = NULL; 19 const char *host = NULL;
20 xs *resource = NULL; 20 xs *resource = NULL;
21 21
22 if (xs_startswith(qs, "https:/") || xs_startswith(qs, "http:/")) { 22 if (xs_startswith(qs, "https:/") || xs_startswith(qs, "http:/")) {
@@ -87,19 +87,20 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
87 87
88 if (obj) { 88 if (obj) {
89 if (user != NULL) { 89 if (user != NULL) {
90 char *subject = xs_dict_get(obj, "subject"); 90 const char *subject = xs_dict_get(obj, "subject");
91 91
92 if (subject) 92 if (subject)
93 *user = xs_replace_n(subject, "acct:", "", 1); 93 *user = xs_replace_n(subject, "acct:", "", 1);
94 } 94 }
95 95
96 if (actor != NULL) { 96 if (actor != NULL) {
97 char *list = xs_dict_get(obj, "links"); 97 const xs_list *list = xs_dict_get(obj, "links");
98 int c = 0;
98 char *v; 99 char *v;
99 100
100 while (xs_list_iter(&list, &v)) { 101 while (xs_list_next(list, &v, &c)) {
101 if (xs_type(v) == XSTYPE_DICT) { 102 if (xs_type(v) == XSTYPE_DICT) {
102 char *type = xs_dict_get(v, "type"); 103 const char *type = xs_dict_get(v, "type");
103 104
104 if (type && (strcmp(type, "application/activity+json") == 0 || 105 if (type && (strcmp(type, "application/activity+json") == 0 ||
105 strcmp(type, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") == 0)) { 106 strcmp(type, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") == 0)) {
@@ -133,8 +134,8 @@ int webfinger_get_handler(xs_dict *req, char *q_path,
133 if (strcmp(q_path, "/.well-known/webfinger") != 0) 134 if (strcmp(q_path, "/.well-known/webfinger") != 0)
134 return 0; 135 return 0;
135 136
136 char *q_vars = xs_dict_get(req, "q_vars"); 137 const char *q_vars = xs_dict_get(req, "q_vars");
137 char *resource = xs_dict_get(q_vars, "resource"); 138 const char *resource = xs_dict_get(q_vars, "resource");
138 139
139 if (resource == NULL) 140 if (resource == NULL)
140 return 400; 141 return 400;
@@ -145,7 +146,7 @@ int webfinger_get_handler(xs_dict *req, char *q_path,
145 if (xs_startswith(resource, "https:/") || xs_startswith(resource, "http:/")) { 146 if (xs_startswith(resource, "https:/") || xs_startswith(resource, "http:/")) {
146 /* actor search: find a user with this actor */ 147 /* actor search: find a user with this actor */
147 xs *l = xs_split(resource, "/"); 148 xs *l = xs_split(resource, "/");
148 char *uid = xs_list_get(l, -1); 149 const char *uid = xs_list_get(l, -1);
149 150
150 if (uid) 151 if (uid)
151 found = user_open(&snac, uid); 152 found = user_open(&snac, uid);
@@ -163,8 +164,8 @@ int webfinger_get_handler(xs_dict *req, char *q_path,
163 l = xs_split_n(an, "@", 1); 164 l = xs_split_n(an, "@", 1);
164 165
165 if (xs_list_len(l) == 2) { 166 if (xs_list_len(l) == 2) {
166 char *uid = xs_list_get(l, 0); 167 const char *uid = xs_list_get(l, 0);
167 char *host = xs_list_get(l, 1); 168 const char *host = xs_list_get(l, 1);
168 169
169 if (strcmp(host, xs_dict_get(srv_config, "host")) == 0) 170 if (strcmp(host, xs_dict_get(srv_config, "host")) == 0)
170 found = user_open(&snac, uid); 171 found = user_open(&snac, uid);
@@ -194,7 +195,7 @@ int webfinger_get_handler(xs_dict *req, char *q_path,
194 195
195 links = xs_list_append(links, prof); 196 links = xs_list_append(links, prof);
196 197
197 char *avatar = xs_dict_get(snac.config, "avatar"); 198 const char *avatar = xs_dict_get(snac.config, "avatar");
198 if (!xs_is_null(avatar) && *avatar) { 199 if (!xs_is_null(avatar) && *avatar) {
199 xs *d = xs_dict_new(); 200 xs *d = xs_dict_new();
200 201