chiark / gitweb /
binfmt,tmpfiles,modules-load,sysctl: rework the various early-boot services that...
[elogind.git] / src / shared / util.h
index 18494f14f2ff31a6ead6507733fd10a1996a22fc..cd13457528c14d2727483b1497e673adc404c9db 100644 (file)
@@ -567,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