aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-11 17:54:38 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-11 17:54:38 +0200
commit0c4b727961ed144c69268a5a325d2472652f3f0d (patch)
treec891a606844cbc648f3d1a7cfa78e4175f32e083 /common.c
parente57939e705a3d39a427f0dd713b719a4bde9dafc (diff)
downloadxK-0c4b727961ed144c69268a5a325d2472652f3f0d.tar.gz
xK-0c4b727961ed144c69268a5a325d2472652f3f0d.tar.xz
xK-0c4b727961ed144c69268a5a325d2472652f3f0d.zip
Bump liberty
Diffstat (limited to 'common.c')
-rw-r--r--common.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/common.c b/common.c
index 8f35896..423bb7e 100644
--- a/common.c
+++ b/common.c
@@ -49,38 +49,6 @@
// --- To be moved to liberty --------------------------------------------------
-#define LIST_INSERT_WITH_TAIL(head, tail, link, following) \
- BLOCK_START \
- if (following) \
- LIST_APPEND_WITH_TAIL ((head), (following)->prev, (link)); \
- else \
- LIST_APPEND_WITH_TAIL ((head), (tail), (link)); \
- (link)->next = (following); \
- BLOCK_END
-
-#define TRIVIAL_STRXFRM(name, fn) \
- static size_t \
- name (char *dest, const char *src, size_t n) \
- { \
- size_t len = strlen (src); \
- while (n-- && (*dest++ = (fn) (*src++))) \
- ; \
- return len; \
- }
-
-static void
-transform_str (char *s, int (*tolower) (int c))
-{
- for (; *s; s++)
- *s = tolower (*s);
-}
-
-static char *
-str_cut_until (const char *s, const char *alphabet)
-{
- return xstrndup (s, strcspn (s, alphabet));
-}
-
static void
split_str (const char *s, char delimiter, struct str_vector *out)
{
@@ -102,71 +70,6 @@ str_vector_find (const struct str_vector *v, const char *s)
return -1;
}
-static int
-strncasecmp_ascii (const char *a, const char *b, size_t n)
-{
- int x;
- while (n-- && (*a || *b))
- if ((x = tolower_ascii (*(const unsigned char *) a++)
- - tolower_ascii (*(const unsigned char *) b++)))
- return x;
- return 0;
-}
-
-static int
-irc_tolower_strict (int c)
-{
- if (c == '[') return '{';
- if (c == ']') return '}';
- if (c == '\\') return '|';
- return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c;
-}
-
-TRIVIAL_STRXFRM (irc_strxfrm_strict, irc_tolower_strict)
-
-static char *
-resolve_relative_runtime_filename (const char *filename)
-{
- struct str path;
- str_init (&path);
-
- const char *runtime_dir = getenv ("XDG_RUNTIME_DIR");
- if (runtime_dir && *runtime_dir == '/')
- str_append (&path, runtime_dir);
- else
- get_xdg_home_dir (&path, "XDG_DATA_HOME", ".local/share");
- str_append_printf (&path, "/%s/%s", PROGRAM_NAME, filename);
-
- // Try to create the file's ancestors
- const char *last_slash = strrchr (path.str, '/');
- if (last_slash && last_slash != path.str)
- {
- char *copy = xstrndup (path.str, last_slash - path.str);
- (void) mkdir_with_parents (copy, NULL);
- free (copy);
- }
- return str_steal (&path);
-}
-
-static char *
-resolve_filename (const char *filename, char *(*relative_cb) (const char *))
-{
- // Absolute path is absolute
- if (*filename == '/')
- return xstrdup (filename);
-
- // We don't want to use wordexp() for this as it may execute /bin/sh
- if (*filename == '~')
- {
- // Paths to home directories ought to be absolute
- char *expanded = try_expand_tilde (filename + 1);
- if (expanded)
- return expanded;
- print_debug ("failed to expand the home directory in `%s'", filename);
- }
- return relative_cb (filename);
-}
-
// --- Logging -----------------------------------------------------------------
static void