chiark / gitweb /
Prep v221: Update and clean up build system to sync with upstream
[elogind.git] / src / basic / util.c
similarity index 99%
rename from src/shared/util.c
rename to src/basic/util.c
index 950519ed06ddfe96578ff98454c52580c24cbe73..3945abdbef17c212206d4f7b6f8c5b8b41bcb6ad 100644 (file)
@@ -789,6 +789,8 @@ char *strstrip(char *s) {
         return s;
 }
 
+/// UNNEEDED by elogind
+#if 0
 char *delete_chars(char *s, const char *bad) {
         char *f, *t;
 
@@ -805,6 +807,7 @@ char *delete_chars(char *s, const char *bad) {
 
         return s;
 }
+#endif // 0
 
 char *file_in_same_dir(const char *path, const char *filename) {
         char *e, *ret;
@@ -1923,6 +1926,8 @@ int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid) {
         assert(fd >= 0);
 
@@ -1940,6 +1945,7 @@ int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid) {
 
         return 0;
 }
+#endif // 0
 
 cpu_set_t* cpu_set_malloc(unsigned *ncpus) {
         cpu_set_t *r;
@@ -2144,6 +2150,8 @@ int touch(const char *path) {
         return touch_file(path, false, USEC_INFINITY, UID_INVALID, GID_INVALID, 0);
 }
 
+/// UNNEEDED by elogind
+#if 0
 static char *unquote(const char *s, const char* quotes) {
         size_t l;
         assert(s);
@@ -2163,6 +2171,7 @@ static char *unquote(const char *s, const char* quotes) {
 
         return strdup(s);
 }
+#endif // 0
 
 noreturn void freeze(void) {
 
@@ -2198,6 +2207,8 @@ int null_or_empty_path(const char *fn) {
         return null_or_empty(&st);
 }
 
+/// UNNEEDED by elogind
+#if 0
 int null_or_empty_fd(int fd) {
         struct stat st;
 
@@ -2208,6 +2219,7 @@ int null_or_empty_fd(int fd) {
 
         return null_or_empty(&st);
 }
+#endif // 0
 
 DIR *xopendirat(int fd, const char *name, int flags) {
         int nfd;
@@ -2228,6 +2240,8 @@ DIR *xopendirat(int fd, const char *name, int flags) {
         return d;
 }
 
+/// UNNEEDED by elogind
+#if 0
 static char *tag_to_udev_node(const char *tagvalue, const char *by) {
         _cleanup_free_ char *t = NULL, *u = NULL;
         size_t enc_len;
@@ -2264,6 +2278,7 @@ char *fstab_node_to_udev_node(const char *p) {
 
         return strdup(p);
 }
+#endif // 0
 
 bool dirent_is_file(const struct dirent *de) {
         assert(de);
@@ -2293,6 +2308,8 @@ bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
         return endswith(de->d_name, suffix);
 }
 
+/// UNNEEDED by elogind
+#if 0
 static int do_execute(char **directories, usec_t timeout, char *argv[]) {
         _cleanup_hashmap_free_free_ Hashmap *pids = NULL;
         _cleanup_set_free_free_ Set *seen = NULL;
@@ -2432,6 +2449,7 @@ void execute_directories(const char* const* directories, usec_t timeout, char *a
 
         wait_for_terminate_and_warn(name, executor_pid, true);
 }
+#endif // 0
 
 bool nulstr_contains(const char*nulstr, const char *needle) {
         const char *i;
@@ -2446,9 +2464,12 @@ bool nulstr_contains(const char*nulstr, const char *needle) {
         return false;
 }
 
+/// UNNEEDED by elogind
+#if 0
 bool plymouth_running(void) {
         return access("/run/plymouth/pid", F_OK) >= 0;
 }
+#endif // 0
 
 char* strshorten(char *s, size_t l) {
         assert(s);
@@ -2566,6 +2587,8 @@ int symlink_atomic(const char *from, const char *to) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int symlink_idempotent(const char *from, const char *to) {
         _cleanup_free_ char *p = NULL;
         int r;
@@ -2629,6 +2652,7 @@ int mkfifo_atomic(const char *path, mode_t mode) {
 
         return 0;
 }
+#endif // 0
 
 bool display_is_local(const char *display) {
         assert(display);
@@ -2829,6 +2853,8 @@ int in_gid(gid_t gid) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int in_group(const char *name) {
         int r;
         gid_t gid;
@@ -2839,6 +2865,7 @@ int in_group(const char *name) {
 
         return in_gid(gid);
 }
+#endif // 0
 
 int glob_exists(const char *path) {
         _cleanup_globfree_ glob_t g = {};
@@ -2859,6 +2886,8 @@ int glob_exists(const char *path) {
                 return errno ? -errno : -EIO;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int glob_extend(char ***strv, const char *path) {
         _cleanup_globfree_ glob_t g = {};
         int k;
@@ -2882,6 +2911,7 @@ int glob_extend(char ***strv, const char *path) {
 
         return k;
 }
+#endif // 0
 
 int dirent_ensure_type(DIR *d, struct dirent *de) {
         struct stat st;
@@ -3196,6 +3226,8 @@ bool kexec_loaded(void) {
        return loaded;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int prot_from_flags(int flags) {
 
         switch (flags & O_ACCMODE) {
@@ -3213,7 +3245,7 @@ int prot_from_flags(int flags) {
                 return -EINVAL;
         }
 }
-
+#endif // 0
 char *format_bytes(char *buf, size_t l, off_t t) {
         unsigned i;
 
@@ -3427,6 +3459,8 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 bool http_etag_is_valid(const char *etag) {
         if (isempty(etag))
                 return false;
@@ -3439,6 +3473,7 @@ bool http_etag_is_valid(const char *etag) {
 
         return true;
 }
+#endif // 0
 
 bool http_url_is_valid(const char *url) {
         const char *p;
@@ -3678,6 +3713,8 @@ bool path_is_safe(const char *p) {
         return true;
 }
 
+/// UNNEEDED by elogind
+#if 0
 /* hey glibc, APIs with callbacks without a user pointer are so useless */
 void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
                  int (*compar) (const void *, const void *, void *), void *arg) {
@@ -3705,6 +3742,7 @@ void init_gettext(void) {
         setlocale(LC_ALL, "");
         textdomain(GETTEXT_PACKAGE);
 }
+#endif // 0
 
 bool is_locale_utf8(void) {
         const char *set;
@@ -4047,6 +4085,8 @@ int search_and_fopen(const char *path, const char *mode, const char *root, const
         return search_and_fopen_internal(path, mode, root, copy, _f);
 }
 
+/// UNNEEDED by elogind
+#if 0
 int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f) {
         _cleanup_strv_free_ char **s = NULL;
 
@@ -4068,6 +4108,7 @@ int search_and_fopen_nulstr(const char *path, const char *mode, const char *root
 
         return search_and_fopen_internal(path, mode, root, s, _f);
 }
+#endif // 0
 
 char *strextend(char **x, ...) {
         va_list ap;
@@ -4226,6 +4267,8 @@ bool id128_is_valid(const char *s) {
         return true;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int split_pair(const char *s, const char *sep, char **l, char **r) {
         char *x, *a, *b;
 
@@ -4269,6 +4312,7 @@ int shall_restore_state(void) {
 
         return parse_boolean(value) != 0;
 }
+#endif // 0
 
 int proc_cmdline(char **ret) {
         assert(ret);
@@ -4318,6 +4362,8 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int get_proc_cmdline_key(const char *key, char **value) {
         _cleanup_free_ char *line = NULL, *ret = NULL;
         bool found = false;
@@ -4370,6 +4416,7 @@ int get_proc_cmdline_key(const char *key, char **value) {
         return found;
 
 }
+#endif // 0
 
 int container_get_leader(const char *machine, pid_t *pid) {
         _cleanup_free_ char *s = NULL, *class = NULL;
@@ -4611,6 +4658,8 @@ int fd_warn_permissions(const char *path, int fd) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 unsigned long personality_from_string(const char *p) {
 
         /* Parse a personality specifier. We introduce our own
@@ -4636,6 +4685,7 @@ unsigned long personality_from_string(const char *p) {
 
         return PERSONALITY_INVALID;
 }
+#endif // 0
 
 const char* personality_to_string(unsigned long p) {
 
@@ -4668,6 +4718,8 @@ uint64_t physical_memory(void) {
         return (uint64_t) mem * (uint64_t) page_size();
 }
 
+/// UNNEEDED by elogind
+#if 0
 void hexdump(FILE *f, const void *p, size_t s) {
         const uint8_t *b = p;
         unsigned n = 0;
@@ -4710,6 +4762,7 @@ void hexdump(FILE *f, const void *p, size_t s) {
                 s -= 16;
         }
 }
+#endif // 0
 
 int update_reboot_param_file(const char *param) {
         int r = 0;
@@ -5043,6 +5096,8 @@ int tempfn_random(const char *p, const char *extra, char **ret) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int tempfn_random_child(const char *p, const char *extra, char **ret) {
         char *t, *x;
         uint64_t u;
@@ -5117,6 +5172,7 @@ int take_password_lock(const char *root) {
 
         return fd;
 }
+#endif // 0
 
 int is_symlink(const char *path) {
         struct stat info;
@@ -5141,6 +5197,8 @@ int is_dir(const char* path, bool follow) {
         return !!S_ISDIR(st.st_mode);
 }
 
+/// UNNEEDED by elogind
+#if 0
 int is_device_node(const char *path) {
         struct stat info;
 
@@ -5149,6 +5207,7 @@ int is_device_node(const char *path) {
 
         return !!(S_ISBLK(info.st_mode) || S_ISCHR(info.st_mode));
 }
+#endif // 0
 
 int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
         _cleanup_free_ char *s = NULL;
@@ -5350,6 +5409,8 @@ int unquote_first_word_and_warn(
         return r;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int unquote_many_words(const char **p, UnquoteFlags flags, ...) {
         va_list ap;
         char **l;
@@ -5405,6 +5466,7 @@ int unquote_many_words(const char **p, UnquoteFlags flags, ...) {
 
         return c;
 }
+#endif // 0
 
 int free_and_strdup(char **p, const char *s) {
         char *t;
@@ -5457,6 +5519,8 @@ int ptsname_malloc(int fd, char **ret) {
         }
 }
 
+/// UNNEEDED by elogind
+#if 0
 int openpt_in_namespace(pid_t pid, int flags) {
         _cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
         _cleanup_close_pair_ int pair[2] = { -1, -1 };
@@ -5542,6 +5606,7 @@ int openpt_in_namespace(pid_t pid, int flags) {
 
         return -EIO;
 }
+#endif // 0
 
 ssize_t fgetxattrat_fake(int dirfd, const char *filename, const char *attribute, void *value, size_t size, int flags) {
         _cleanup_close_ int fd = -1;
@@ -5605,6 +5670,8 @@ int fd_getcrtime_at(int dirfd, const char *name, usec_t *usec, int flags) {
         return parse_crtime(le, usec);
 }
 
+/// UNNEEDED by elogind
+#if 0
 int path_getcrtime(const char *p, usec_t *usec) {
         le64_t le;
         ssize_t n;
@@ -5620,6 +5687,7 @@ int path_getcrtime(const char *p, usec_t *usec) {
 
         return parse_crtime(le, usec);
 }
+#endif // 0
 
 int fd_setcrtime(int fd, usec_t usec) {
         le64_t le;
@@ -5780,6 +5848,8 @@ int read_attr_path(const char *p, unsigned *ret) {
         return read_attr_fd(fd, ret);
 }
 
+/// UNNEEDED by elogind
+#if 0
 static size_t nul_length(const uint8_t *p, size_t sz) {
         size_t n = 0;
 
@@ -5841,6 +5911,7 @@ ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length) {
 
         return q - (const uint8_t*) p;
 }
+#endif // 0
 
 void sigkill_wait(pid_t *pid) {
         if (!pid)
@@ -5852,6 +5923,8 @@ void sigkill_wait(pid_t *pid) {
                 (void) wait_for_terminate(*pid, NULL);
 }
 
+/// UNNEEDED by elogind
+#if 0
 int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
         int a = 0, b = 0, c = 0;
         int k;
@@ -5893,6 +5966,7 @@ int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
         *p += k;
         return 1;
 }
+#endif // 0
 
 ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
         size_t i;