snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit a38c7aeadcc69b3405d40b008a0b87f7c5d023dc
parent e46559c022c6b28302ab7e1df4778ee46457cfa4
Author: default <nobody@localhost>
Date:   Tue, 17 Jan 2023 09:50:16 +0100

Updated year in copyright notices.

Diffstat:
MLICENSE | 2+-
Mactivitypub.c | 2+-
Mdata.c | 2+-
Mformat.c | 2+-
Mhtml.c | 2+-
Mhttp.c | 2+-
Mhttpd.c | 2+-
Mmain.c | 4++--
Msnac.c | 2+-
Msnac.h | 2+-
Mupgrade.c | 2+-
Mutils.c | 2+-
Mwebfinger.c | 2+-
Mxs.h | 45+++++++++++++++++++++++++++------------------
Mxs_curl.h | 2+-
Mxs_encdec.h | 2+-
Mxs_glob.h | 2+-
Mxs_httpd.h | 2+-
Mxs_io.h | 2+-
Mxs_json.h | 2+-
Mxs_mime.h | 4+++-
Mxs_openssl.h | 2+-
Mxs_regex.h | 2+-
Mxs_set.h | 2+-
Mxs_socket.h | 2+-
Mxs_time.h | 2+-
Mxs_version.h | 2+-
27 files changed, 56 insertions(+), 45 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 grunfink (Fediverse: @grunfink@comam.es) +Copyright (c) 2022 - 2023 grunfink (Fediverse: @grunfink@comam.es) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/activitypub.c b/activitypub.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_encdec.h" diff --git a/data.c b/data.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/format.c b/format.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_regex.h" diff --git a/html.c b/html.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/http.c b/http.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/httpd.c b/httpd.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/main.c b/main.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_io.h" @@ -11,7 +11,7 @@ int usage(void) { printf("snac " VERSION " - A simple, minimalistic ActivityPub instance\n"); - printf("Copyright (c) 2022 grunfink - MIT license\n"); + printf("Copyright (c) 2022 - 2023 grunfink / MIT license\n"); printf("\n"); printf("Commands:\n"); printf("\n"); diff --git a/snac.c b/snac.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #define XS_IMPLEMENTATION diff --git a/snac.h b/snac.h @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #define VERSION "2.19-dev" diff --git a/upgrade.c b/upgrade.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/utils.c b/utils.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/webfinger.c b/webfinger.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" #include "xs_encdec.h" diff --git a/xs.h b/xs.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_H @@ -53,7 +53,9 @@ d_char *xs_insert_m(d_char *data, int offset, const char *mem, int size); #define xs_insert(data, offset, data2) xs_insert_m(data, offset, data2, xs_size(data2)) #define xs_append_m(data, mem, size) xs_insert_m(data, xs_size(data) - 1, mem, size) d_char *xs_str_new(const char *str); -#define xs_str_cat(str1, str2) xs_insert(str1, xs_size(str1) - 1, str2) +d_char *xs_str_wrap_i(const char *prefix, d_char *str, const char *suffix); +#define xs_str_prepend_i(str, prefix) xs_str_wrap_i(prefix, str, NULL) +#define xs_str_cat(str, suffix) xs_str_wrap_i(NULL, str, suffix) d_char *xs_replace_i(d_char *str, const char *sfrom, const char *sto); #define xs_replace(str, sfrom, sto) xs_replace_i(xs_dup(str), sfrom, sto) d_char *xs_fmt(const char *fmt, ...); @@ -64,7 +66,6 @@ d_char *xs_crop_i(d_char *str, int start, int end); d_char *xs_strip_chars_i(d_char *str, const char *chars); #define xs_strip_i(str) xs_strip_chars_i(str, " \r\n\t\v\f") d_char *xs_tolower_i(d_char *str); -d_char *xs_str_prepend_i(d_char *str, const char *prefix); d_char *xs_list_new(void); d_char *xs_list_append_m(d_char *list, const char *mem, int dsz); #define xs_list_append(list, data) xs_list_append_m(list, data, xs_size(data)) @@ -364,6 +365,19 @@ d_char *xs_str_new(const char *str) } +d_char *xs_str_wrap_i(const char *prefix, d_char *str, const char *suffix) +/* wraps str with prefix and suffix */ +{ + if (prefix) + str = xs_insert_m(str, 0, prefix, strlen(prefix)); + + if (suffix) + str = xs_insert_m(str, xs_size(str) - 1, suffix, xs_size(suffix)); + + return str; +} + + d_char *xs_replace_i(d_char *str, const char *sfrom, const char *sto) /* replaces inline all sfrom with sto */ { @@ -490,18 +504,6 @@ d_char *xs_tolower_i(d_char *str) } -d_char *xs_str_prepend_i(d_char *str, const char *prefix) -/* prepends prefix into string */ -{ - int sz = strlen(prefix); - - str = xs_expand(str, 0, sz); - memcpy(str, prefix, sz); - - return str; -} - - /** lists **/ d_char *xs_list_new(void) @@ -666,9 +668,16 @@ d_char *xs_list_set(d_char *list, int num, const char *data) d_char *xs_list_pop(d_char *list, char **data) /* pops the last element from the list */ { - if ((*data = xs_list_get(list, -1)) != NULL) { - *data = xs_dup(*data); - list = xs_list_del(list, -1); + char *p = list, *v = NULL; + + /* iterate to the end */ + while (xs_list_iter(&p, &v)); + + if (v != NULL) { + *data = xs_dup(v); + + /* collapse from the address of the element */ + list = xs_collapse(list, v - 1 - list, xs_size(v - 1)); } return list; diff --git a/xs_curl.h b/xs_curl.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_CURL_H diff --git a/xs_encdec.h b/xs_encdec.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_ENCDEC_H diff --git a/xs_glob.h b/xs_glob.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_GLOB_H diff --git a/xs_httpd.h b/xs_httpd.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_HTTPD_H diff --git a/xs_io.h b/xs_io.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_IO_H diff --git a/xs_json.h b/xs_json.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_JSON_H diff --git a/xs_mime.h b/xs_mime.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_MIME @@ -23,6 +23,8 @@ struct _mime_info { { "text/html", ".html" }, { "text/plain", ".txt" }, { "text/xml", ".xml" }, + { "text/markdown", ".md" }, + { "text/gemini", ".gmi" }, { NULL, NULL } }; diff --git a/xs_openssl.h b/xs_openssl.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_OPENSSL_H diff --git a/xs_regex.h b/xs_regex.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_REGEX_H diff --git a/xs_set.h b/xs_set.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_SET_H diff --git a/xs_socket.h b/xs_socket.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_SOCKET_H diff --git a/xs_time.h b/xs_time.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 grunfink - MIT license */ +/* copyright (c) 2022 - 2023 grunfink / MIT license */ #ifndef _XS_TIME_H diff --git a/xs_version.h b/xs_version.h @@ -1 +1 @@ -/* 41985e780c622a078118ea7c7143dc304758d958 */ +/* 366ce5817597e9f4d735bced6b8c40ecc897608e */