mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
Some code reordering to placate scan-build's wrath.
This commit is contained in:
parent
f5086fecd7
commit
645e7ec43e
3 changed files with 25 additions and 14 deletions
|
@ -264,7 +264,9 @@ void process_tags(const char *content, d_char **n_content, d_char **tag)
|
|||
char *p, *v;
|
||||
int n = 0;
|
||||
|
||||
p = split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)");
|
||||
split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)");
|
||||
|
||||
p = split;
|
||||
while (xs_list_iter(&p, &v)) {
|
||||
if ((n & 0x1)) {
|
||||
if (*v == '@') {
|
||||
|
@ -320,18 +322,24 @@ d_char *msg_base(snac *snac, char *type, char *id, char *actor, char *date, char
|
|||
xs *published = NULL;
|
||||
|
||||
/* generated values */
|
||||
if (date && strcmp(date, "@now") == 0)
|
||||
date = published = xs_str_utctime(0, "%Y-%m-%dT%H:%M:%SZ");
|
||||
if (date && strcmp(date, "@now") == 0) {
|
||||
published = xs_str_utctime(0, "%Y-%m-%dT%H:%M:%SZ");
|
||||
date = published;
|
||||
}
|
||||
|
||||
if (id != NULL) {
|
||||
if (strcmp(id, "@dummy") == 0) {
|
||||
xs *ntid = tid(0);
|
||||
id = did = xs_fmt("%s/d/%s/%s", snac->actor, ntid, type);
|
||||
did = xs_fmt("%s/d/%s/%s", snac->actor, ntid, type);
|
||||
|
||||
id = did;
|
||||
}
|
||||
else
|
||||
if (strcmp(id, "@object") == 0) {
|
||||
if (object != NULL)
|
||||
id = did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type);
|
||||
if (object != NULL) {
|
||||
did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type);
|
||||
id = did;
|
||||
}
|
||||
else
|
||||
id = NULL;
|
||||
}
|
||||
|
|
3
format.c
3
format.c
|
@ -98,8 +98,9 @@ d_char *not_really_markdown(const char *content)
|
|||
char *p, *v;
|
||||
|
||||
/* work by lines */
|
||||
p = list = xs_split(content, "\n");
|
||||
list = xs_split(content, "\n");
|
||||
|
||||
p = list;
|
||||
while (xs_list_iter(&p, &v)) {
|
||||
xs *ss = NULL;
|
||||
|
||||
|
|
16
snac.c
16
snac.c
|
@ -74,17 +74,17 @@ int validate_uid(const char *uid)
|
|||
void srv_debug(int level, d_char *str)
|
||||
/* logs a debug message */
|
||||
{
|
||||
xs *msg = str;
|
||||
|
||||
if (xs_str_in(msg, srv_basedir) != -1) {
|
||||
if (xs_str_in(str, srv_basedir) != -1) {
|
||||
/* replace basedir with ~ */
|
||||
msg = xs_replace_i(msg, srv_basedir, "~");
|
||||
str = xs_replace_i(str, srv_basedir, "~");
|
||||
}
|
||||
|
||||
if (dbglevel >= level) {
|
||||
xs *tm = xs_str_localtime(0, "%H:%M:%S");
|
||||
fprintf(stderr, "%s %s\n", tm, msg);
|
||||
fprintf(stderr, "%s %s\n", tm, str);
|
||||
}
|
||||
|
||||
xs_free(str);
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,8 +110,10 @@ d_char *hash_password(const char *uid, const char *passwd, const char *nonce)
|
|||
xs *combi;
|
||||
xs *hash;
|
||||
|
||||
if (nonce == NULL)
|
||||
nonce = d_nonce = xs_fmt("%08x", random());
|
||||
if (nonce == NULL) {
|
||||
d_nonce = xs_fmt("%08x", random());
|
||||
nonce = d_nonce;
|
||||
}
|
||||
|
||||
combi = xs_fmt("%s:%s:%s", nonce, uid, passwd);
|
||||
hash = xs_sha1_hex(combi, strlen(combi));
|
||||
|
|
Loading…
Reference in a new issue