mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Use xs_between() where applicable.
This commit is contained in:
parent
b856664663
commit
88fc843d3e
4 changed files with 8 additions and 8 deletions
|
@ -3324,11 +3324,11 @@ int mastoapi_patch_handler(const xs_dict *req, const char *q_path,
|
|||
persist_image("avatar", v, payload, &snac);
|
||||
}
|
||||
else
|
||||
if (xs_starts_and_ends("fields_attributes", k, "[name]")) {
|
||||
if (xs_between("fields_attributes", k, "[name]")) {
|
||||
field_name = strcmp(v, "") != 0 ? v : NULL;
|
||||
}
|
||||
else
|
||||
if (xs_starts_and_ends("fields_attributes", k, "[value]")) {
|
||||
if (xs_between("fields_attributes", k, "[value]")) {
|
||||
if (field_name != NULL) {
|
||||
new_fields = xs_dict_set(new_fields, field_name, v);
|
||||
snac.config = xs_dict_set(snac.config, "metadata", new_fields);
|
||||
|
|
8
xs.h
8
xs.h
|
@ -80,9 +80,9 @@ xs_str *xs_replace_in(xs_str *str, const char *sfrom, const char *sto, int times
|
|||
#define xs_replace_n(str, sfrom, sto, times) xs_replace_in(xs_dup(str), sfrom, sto, times)
|
||||
xs_str *xs_fmt(const char *fmt, ...);
|
||||
int xs_str_in(const char *haystack, const char *needle);
|
||||
int xs_starts_and_ends(const char *prefix, const char *str, const char *suffix);
|
||||
#define xs_startswith(str, prefix) xs_starts_and_ends(prefix, str, NULL)
|
||||
#define xs_endswith(str, suffix) xs_starts_and_ends(NULL, str, suffix)
|
||||
int xs_between(const char *prefix, const char *str, const char *suffix);
|
||||
#define xs_startswith(str, prefix) xs_between(prefix, str, NULL)
|
||||
#define xs_endswith(str, suffix) xs_between(NULL, str, suffix)
|
||||
xs_str *xs_crop_i(xs_str *str, int start, int end);
|
||||
xs_str *xs_lstrip_chars_i(xs_str *str, const char *chars);
|
||||
xs_str *xs_rstrip_chars_i(xs_str *str, const char *chars);
|
||||
|
@ -586,7 +586,7 @@ int xs_str_in(const char *haystack, const char *needle)
|
|||
}
|
||||
|
||||
|
||||
int xs_starts_and_ends(const char *prefix, const char *str, const char *suffix)
|
||||
int xs_between(const char *prefix, const char *str, const char *suffix)
|
||||
/* returns true if str starts with prefix and ends with suffix */
|
||||
{
|
||||
int sz = strlen(str);
|
||||
|
|
2
xs_url.h
2
xs_url.h
|
@ -109,7 +109,7 @@ xs_dict *xs_multipart_form_data(const char *payload, int p_size, const char *hea
|
|||
boundary = xs_dup(xs_list_get(l1, 1));
|
||||
|
||||
/* Tokodon sends the boundary header with double quotes surrounded */
|
||||
if (xs_starts_and_ends("\"", boundary, "\"") != 0)
|
||||
if (xs_between("\"", boundary, "\"") != 0)
|
||||
boundary = xs_strip_chars_i(boundary, "\"");
|
||||
|
||||
boundary = xs_fmt("--%s", boundary);
|
||||
|
|
|
@ -1 +1 @@
|
|||
/* fb6646ef1b1d5f24768bc829680eb70272755584 2024-08-05T05:32:08+02:00 */
|
||||
/* 3536c4e2ab0849eccf81c50741028453e9ad7f3a 2024-08-05T18:37:46+02:00 */
|
||||
|
|
Loading…
Reference in a new issue