chiark / gitweb /
util: unify reading of /proc/cmdline
[elogind.git] / src / shared / util.h
index 63cb4ac636967adc8bb8101c725ae4c597a9f60b..8b4c15512a4cc24e1a9cdfe63b21d28efff4c6bd 100644 (file)
@@ -572,6 +572,10 @@ static inline void umaskp(mode_t *u) {
         umask(*u);
 }
 
+static inline void close_pipep(int (*p)[2]) {
+        close_pipe(*p);
+}
+
 DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, fclose);
 DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, pclose);
 DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir);
@@ -585,6 +589,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent);
 #define _cleanup_pclose_ _cleanup_(pclosep)
 #define _cleanup_closedir_ _cleanup_(closedirp)
 #define _cleanup_endmntent_ _cleanup_(endmntentp)
+#define _cleanup_close_pipe_ _cleanup_(close_pipep)
 
 _malloc_  _alloc_(1, 2) static inline void *malloc_multiply(size_t a, size_t b) {
         if (_unlikely_(b == 0 || a > ((size_t) -1) / b))
@@ -765,6 +770,8 @@ void parse_user_at_host(char *arg, char **user, char **host);
 
 int split_pair(const char *s, const char *sep, char **l, char **r);
 
+int shall_restore_state(void);
+
 /**
  * Normal qsort requires base to be nonnull. Here were require
  * that only if nmemb > 0.
@@ -776,3 +783,5 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size,
                 qsort(base, nmemb, size, compar);
         }
 }
+
+int proc_cmdline(char **ret);