Renamed xs_splitn() to xs_split_n().

This commit is contained in:
default 2022-09-19 23:08:59 +02:00
parent dd1a5ff147
commit e5167b7b49
4 changed files with 8 additions and 8 deletions

2
snac.c
View File

@ -113,7 +113,7 @@ int check_password(char *uid, char *passwd, char *hash)
/* checks a password */
{
int ret = 0;
xs *spl = xs_splitn(hash, ":", 1);
xs *spl = xs_split_n(hash, ":", 1);
if (xs_list_len(spl) == 2) {
xs *n_hash = hash_password(uid, passwd, xs_list_get(spl, 0));

6
xs.h
View File

@ -65,8 +65,8 @@ int xs_list_len(char *list);
char *xs_list_get(char *list, int num);
int xs_list_in(char *list, char *val);
d_char *xs_join(char *list, const char *sep);
d_char *xs_splitn(const char *str, const char *sep, int times);
#define xs_split(str, sep) xs_splitn(str, sep, 0xfffffff)
d_char *xs_split_n(const char *str, const char *sep, int times);
#define xs_split(str, sep) xs_split_n(str, sep, 0xfffffff)
d_char *xs_dict_new(void);
d_char *xs_dict_append_m(d_char *dict, const char *key, const char *mem, int dsz);
#define xs_dict_append(dict, key, data) xs_dict_append_m(dict, key, data, xs_size(data))
@ -527,7 +527,7 @@ d_char *xs_join(char *list, const char *sep)
}
d_char *xs_splitn(const char *str, const char *sep, int times)
d_char *xs_split_n(const char *str, const char *sep, int times)
/* splits a string into a list upto n times */
{
int sz = strlen(sep);

View File

@ -25,7 +25,7 @@ static size_t _header_callback(char *buffer, size_t size,
/* only the HTTP/x 200 line and the last one doesn't have ': ' */
if (xs_str_in(l, ": ") != -1) {
xs *knv = xs_splitn(l, ": ", 1);
xs *knv = xs_split_n(l, ": ", 1);
headers = xs_dict_append(headers, xs_list_get(knv, 0), xs_list_get(knv, 1));
}

View File

@ -57,7 +57,7 @@ d_char *xs_url_vars(char *str)
l = args;
while (xs_list_iter(&l, &v)) {
xs *kv = xs_splitn(v, "=", 2);
xs *kv = xs_split_n(v, "=", 2);
if (xs_list_len(kv) == 2)
vars = xs_dict_append(vars,
@ -98,7 +98,7 @@ d_char *xs_httpd_request(FILE *f)
{
/* split the path with its optional variables */
xs *udp = xs_url_dec(xs_list_get(l2, 1));
xs *pnv = xs_splitn(udp, "?", 1);
xs *pnv = xs_split_n(udp, "?", 1);
/* store the path */
headers = xs_dict_append(headers, "path", xs_list_get(pnv, 0));
@ -118,7 +118,7 @@ d_char *xs_httpd_request(FILE *f)
break;
/* split header and content */
p = xs_splitn(l, ": ", 1);
p = xs_split_n(l, ": ", 1);
if (xs_list_len(p) == 2)
headers = xs_dict_append(headers,