summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2022-12-14 04:55:47 +0100
committerGravatar default2022-12-14 04:55:47 +0100
commit645e7ec43e24600c8a3ecab3e43b07a6dbc91eb4 (patch)
treec964f5950b6519d37d932fb059972c1b5fd56ee0
parentUpdated TODO. (diff)
downloadsnac2-645e7ec43e24600c8a3ecab3e43b07a6dbc91eb4.tar.gz
snac2-645e7ec43e24600c8a3ecab3e43b07a6dbc91eb4.tar.xz
snac2-645e7ec43e24600c8a3ecab3e43b07a6dbc91eb4.zip
Some code reordering to placate scan-build's wrath.
-rw-r--r--activitypub.c20
-rw-r--r--format.c3
-rw-r--r--snac.c16
3 files changed, 25 insertions, 14 deletions
diff --git a/activitypub.c b/activitypub.c
index 88febbf..e003cfc 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -264,7 +264,9 @@ void process_tags(const char *content, d_char **n_content, d_char **tag)
264 char *p, *v; 264 char *p, *v;
265 int n = 0; 265 int n = 0;
266 266
267 p = split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)"); 267 split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)");
268
269 p = split;
268 while (xs_list_iter(&p, &v)) { 270 while (xs_list_iter(&p, &v)) {
269 if ((n & 0x1)) { 271 if ((n & 0x1)) {
270 if (*v == '@') { 272 if (*v == '@') {
@@ -320,18 +322,24 @@ d_char *msg_base(snac *snac, char *type, char *id, char *actor, char *date, char
320 xs *published = NULL; 322 xs *published = NULL;
321 323
322 /* generated values */ 324 /* generated values */
323 if (date && strcmp(date, "@now") == 0) 325 if (date && strcmp(date, "@now") == 0) {
324 date = published = xs_str_utctime(0, "%Y-%m-%dT%H:%M:%SZ"); 326 published = xs_str_utctime(0, "%Y-%m-%dT%H:%M:%SZ");
327 date = published;
328 }
325 329
326 if (id != NULL) { 330 if (id != NULL) {
327 if (strcmp(id, "@dummy") == 0) { 331 if (strcmp(id, "@dummy") == 0) {
328 xs *ntid = tid(0); 332 xs *ntid = tid(0);
329 id = did = xs_fmt("%s/d/%s/%s", snac->actor, ntid, type); 333 did = xs_fmt("%s/d/%s/%s", snac->actor, ntid, type);
334
335 id = did;
330 } 336 }
331 else 337 else
332 if (strcmp(id, "@object") == 0) { 338 if (strcmp(id, "@object") == 0) {
333 if (object != NULL) 339 if (object != NULL) {
334 id = did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type); 340 did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type);
341 id = did;
342 }
335 else 343 else
336 id = NULL; 344 id = NULL;
337 } 345 }
diff --git a/format.c b/format.c
index d149def..7ded83c 100644
--- a/format.c
+++ b/format.c
@@ -98,8 +98,9 @@ d_char *not_really_markdown(const char *content)
98 char *p, *v; 98 char *p, *v;
99 99
100 /* work by lines */ 100 /* work by lines */
101 p = list = xs_split(content, "\n"); 101 list = xs_split(content, "\n");
102 102
103 p = list;
103 while (xs_list_iter(&p, &v)) { 104 while (xs_list_iter(&p, &v)) {
104 xs *ss = NULL; 105 xs *ss = NULL;
105 106
diff --git a/snac.c b/snac.c
index 903713b..2a54447 100644
--- a/snac.c
+++ b/snac.c
@@ -74,17 +74,17 @@ int validate_uid(const char *uid)
74void srv_debug(int level, d_char *str) 74void srv_debug(int level, d_char *str)
75/* logs a debug message */ 75/* logs a debug message */
76{ 76{
77 xs *msg = str; 77 if (xs_str_in(str, srv_basedir) != -1) {
78
79 if (xs_str_in(msg, srv_basedir) != -1) {
80 /* replace basedir with ~ */ 78 /* replace basedir with ~ */
81 msg = xs_replace_i(msg, srv_basedir, "~"); 79 str = xs_replace_i(str, srv_basedir, "~");
82 } 80 }
83 81
84 if (dbglevel >= level) { 82 if (dbglevel >= level) {
85 xs *tm = xs_str_localtime(0, "%H:%M:%S"); 83 xs *tm = xs_str_localtime(0, "%H:%M:%S");
86 fprintf(stderr, "%s %s\n", tm, msg); 84 fprintf(stderr, "%s %s\n", tm, str);
87 } 85 }
86
87 xs_free(str);
88} 88}
89 89
90 90
@@ -110,8 +110,10 @@ d_char *hash_password(const char *uid, const char *passwd, const char *nonce)
110 xs *combi; 110 xs *combi;
111 xs *hash; 111 xs *hash;
112 112
113 if (nonce == NULL) 113 if (nonce == NULL) {
114 nonce = d_nonce = xs_fmt("%08x", random()); 114 d_nonce = xs_fmt("%08x", random());
115 nonce = d_nonce;
116 }
115 117
116 combi = xs_fmt("%s:%s:%s", nonce, uid, passwd); 118 combi = xs_fmt("%s:%s:%s", nonce, uid, passwd);
117 hash = xs_sha1_hex(combi, strlen(combi)); 119 hash = xs_sha1_hex(combi, strlen(combi));