chiark / gitweb /
util: remove unused FOREACH_WORD_SEPARATOR_QUOTED
[elogind.git] / src / shared / util.h
index 3e89aaf17fe2a1e9640a355c4a7c084a921c9436..87ad317319315b07052f98bd3c0c719e7d3deca2 100644 (file)
@@ -69,7 +69,7 @@
 
 #if SIZEOF_TIME_T == 8
 #  define PRI_TIME PRIu64
-#elif SIZEOF_GID_T == 4
+#elif SIZEOF_TIME_T == 4
 #  define PRI_TIME PRIu32
 #else
 #  error Unknown time_t size
@@ -128,6 +128,8 @@ bool streq_ptr(const char *a, const char *b) _pure_;
 
 #define newa(t, n) ((t*) alloca(sizeof(t)*(n)))
 
+#define newa0(t, n) ((t*) alloca0(sizeof(t)*(n)))
+
 #define newdup(t, p, n) ((t*) memdup_multiply(p, sizeof(t), (n)))
 
 #define malloc0(n) (calloc((n), 1))
@@ -246,9 +248,6 @@ const char* split(const char **state, size_t *l, const char *separator, bool quo
 #define FOREACH_WORD_QUOTED(word, length, s, state)                     \
         _FOREACH_WORD(word, length, s, WHITESPACE, true, state)
 
-#define FOREACH_WORD_SEPARATOR_QUOTED(word, length, s, separator, state)       \
-        _FOREACH_WORD(word, length, s, separator, true, state)
-
 #define _FOREACH_WORD(word, length, s, separator, quoted, state)        \
         for ((state) = (s), (word) = split(&(state), &(length), (separator), (quoted)); (word); (word) = split(&(state), &(length), (separator), (quoted)))
 
@@ -845,29 +844,19 @@ int unlink_noerrno(const char *path);
                 (void *) memset(_new_, 0, _len_);       \
         })
 
-#define strappenda(a, b)                                \
-        ({                                              \
-                const char *_a_ = (a), *_b_ = (b);      \
-                char *_c_;                              \
-                size_t _x_, _y_;                        \
-                _x_ = strlen(_a_);                      \
-                _y_ = strlen(_b_);                      \
-                _c_ = alloca(_x_ + _y_ + 1);            \
-                strcpy(stpcpy(_c_, _a_), _b_);          \
-                _c_;                                    \
-        })
-
-#define strappenda3(a, b, c)                                    \
-        ({                                                      \
-                const char *_a_ = (a), *_b_ = (b), *_c_ = (c);  \
-                char *_d_;                                      \
-                size_t _x_, _y_, _z_;                           \
-                _x_ = strlen(_a_);                              \
-                _y_ = strlen(_b_);                              \
-                _z_ = strlen(_c_);                              \
-                _d_ = alloca(_x_ + _y_ + _z_ + 1);              \
-                strcpy(stpcpy(stpcpy(_d_, _a_), _b_), _c_);     \
-                _d_;                                            \
+#define strappenda(a, ...)                                       \
+        ({                                                       \
+                int _len = strlen(a);                            \
+                unsigned _i;                                     \
+                char *_d_, *_p_;                                 \
+                const char *_appendees_[] = { __VA_ARGS__ };     \
+                for (_i = 0; _i < ELEMENTSOF(_appendees_); _i++) \
+                        _len += strlen(_appendees_[_i]);         \
+                _d_ = alloca(_len + 1);                          \
+                _p_ = stpcpy(_d_, a);                            \
+                for (_i = 0; _i < ELEMENTSOF(_appendees_); _i++) \
+                        _p_ = stpcpy(_p_, _appendees_[_i]);      \
+                _d_;                                             \
         })
 
 #define procfs_file_alloca(pid, field)                                  \
@@ -976,3 +965,8 @@ char *tempfn_random(const char *p);
 bool is_localhost(const char *hostname);
 
 int take_password_lock(const char *root);
+
+int is_symlink(const char *path);
+
+int unquote_first_word(const char **p, char **ret);
+int unquote_many_words(const char **p, ...) _sentinel_;