chiark / gitweb /
fileio: in envfiles, do not skip lines following empty lines
[elogind.git] / src / shared / util.h
index 38851237ab15957762723d7023fb2bf12e6359bf..ad9753655a9300524911b9710db53e68d0498551 100644 (file)
@@ -52,7 +52,7 @@ union dirent_storage {
 #define WHITESPACE " \t\n\r"
 #define NEWLINE "\n\r"
 #define QUOTES "\"\'"
-#define COMMENTS "#;\n"
+#define COMMENTS "#;"
 
 #define FORMAT_BYTES_MAX 8
 
@@ -618,6 +618,8 @@ char *strextend(char **x, ...);
 char *strrep(const char *s, unsigned n);
 
 void* greedy_realloc(void **p, size_t *allocated, size_t need);
+#define GREEDY_REALLOC(array, allocated, need) \
+        greedy_realloc((void**) &(array), &(allocated), (sizeof *array) * (need))
 
 static inline void _reset_errno_(int *saved_errno) {
         errno = *saved_errno;
@@ -647,4 +649,11 @@ static inline bool logind_running(void) {
         return access("/run/systemd/seats/", F_OK) >= 0;
 }
 
+static inline unsigned decimal_str_max(unsigned x) {
+        unsigned ans = 1;
+        while (x /= 10)
+                ans ++;
+        return ans;
+}
+
 int unlink_noerrno(const char *path);