Move code within common.c

This commit is contained in:
Přemysl Eric Janouch 2015-05-08 23:29:09 +02:00
parent 29db258102
commit 1b2fabe4cc
1 changed files with 23 additions and 23 deletions

View File

@ -47,6 +47,29 @@
#define LOG_LIBC_FAILURE(name) \ #define LOG_LIBC_FAILURE(name) \
print_debug ("%s: %s: %s", __func__, (name), strerror (errno)) print_debug ("%s: %s: %s", __func__, (name), strerror (errno))
// --- To be moved to liberty --------------------------------------------------
static void
split_str (const char *s, char delimiter, struct str_vector *out)
{
const char *begin = s, *end;
while ((end = strchr (begin, delimiter)))
{
str_vector_add_owned (out, xstrndup (begin, end - begin));
begin = ++end;
}
str_vector_add (out, begin);
}
static ssize_t
str_vector_find (const struct str_vector *v, const char *s)
{
for (size_t i = 0; i < v->len; i++)
if (!strcmp (v->vector[i], s))
return i;
return -1;
}
// --- Logging ----------------------------------------------------------------- // --- Logging -----------------------------------------------------------------
static void static void
@ -473,29 +496,6 @@ fail:
return result; return result;
} }
// --- To be moved to liberty --------------------------------------------------
static void
split_str (const char *s, char delimiter, struct str_vector *out)
{
const char *begin = s, *end;
while ((end = strchr (begin, delimiter)))
{
str_vector_add_owned (out, xstrndup (begin, end - begin));
begin = ++end;
}
str_vector_add (out, begin);
}
static ssize_t
str_vector_find (const struct str_vector *v, const char *s)
{
for (size_t i = 0; i < v->len; i++)
if (!strcmp (v->vector[i], s))
return i;
return -1;
}
// --- CTCP decoding ----------------------------------------------------------- // --- CTCP decoding -----------------------------------------------------------
#define CTCP_M_QUOTE '\020' #define CTCP_M_QUOTE '\020'