chiark / gitweb /
binfmt,tmpfiles,modules-load,sysctl: rework the various early-boot services that...
[elogind.git] / src / shared / util.h
index 223617c3ff6284f17fc329ce1134cce98c402ff8..cd13457528c14d2727483b1497e673adc404c9db 100644 (file)
@@ -544,6 +544,7 @@ _malloc_ static inline void *memdup_multiply(const void *p, size_t a, size_t b)
 bool filename_is_safe(const char *p);
 bool path_is_safe(const char *p);
 bool string_is_safe(const char *p);
+bool string_has_cc(const char *p);
 
 void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
                  int (*compar) (const void *, const void *, void *),
@@ -566,3 +567,15 @@ char *strreplace(const char *text, const char *old_string, const char *new_strin
 char *strip_tab_ansi(char **p, size_t *l);
 
 int on_ac_power(void);
+
+int search_and_fopen(const char *path, const char *mode, const char **search, FILE **_f);
+int search_and_fopen_nulstr(const char *path, const char *mode, const char *search, FILE **_f);
+
+#define FOREACH_LINE(f, line, on_error)                         \
+        for (char line[LINE_MAX]; !feof(f); )                   \
+                if (!fgets(line, sizeof(line), f)) {            \
+                        if (ferror(f)) {                        \
+                                on_error;                       \
+                        }                                       \
+                        break;                                  \
+                } else