chiark / gitweb /
catalog: open up catalog internals
[elogind.git] / src / shared / util.h
index 8ac4bbc2499f0cc4ccec3233a4b0aa1d805a9ef3..aefde5f85a23ffc25e4f3ca974b19892a2b678ff 100644 (file)
@@ -36,6 +36,7 @@
 #include <dirent.h>
 #include <sys/resource.h>
 #include <stddef.h>
+#include <systemd/sd-journal.h>
 
 #include "macro.h"
 #include "time-util.h"
@@ -328,6 +329,7 @@ ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
 bool is_device_path(const char *path);
 
 int dir_is_empty(const char *path);
+char* dirname_malloc(const char *path);
 
 void rename_process(const char name[8]);
 
@@ -428,9 +430,11 @@ int socket_from_display(const char *display, char **path);
 int get_user_creds(const char **username, uid_t *uid, gid_t *gid, const char **home, const char **shell);
 int get_group_creds(const char **groupname, gid_t *gid);
 
+int in_gid(gid_t gid);
 int in_group(const char *name);
 
 char* uid_to_name(uid_t uid);
+char* gid_to_name(gid_t gid);
 
 int glob_exists(const char *path);
 
@@ -516,7 +520,6 @@ bool in_initrd(void);
 
 void warn_melody(void);
 
-int get_shell(char **ret);
 int get_home_dir(char **ret);
 
 static inline void freep(void *p) {
@@ -531,6 +534,10 @@ static inline void umaskp(mode_t *u) {
         umask(*u);
 }
 
+static inline void journal_closep(sd_journal **j) {
+        sd_journal_close(*j);
+}
+
 _malloc_  static inline void *malloc_multiply(size_t a, size_t b) {
         if (_unlikely_(b == 0 || a > ((size_t) -1) / b))
                 return NULL;
@@ -574,7 +581,7 @@ 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);
-int create_tmp_dir(char template[], mode_t mask, bool need_sticky, char** dir_name);
+int create_tmp_dir(char template[], char** dir_name);
 
 #define FOREACH_LINE(line, f, on_error)                         \
         for (;;)                                                \
@@ -600,3 +607,7 @@ static inline void *mempset(void *s, int c, size_t n) {
         memset(s, c, n);
         return (char*)s + n;
 }
+
+char *hexmem(const void *p, size_t l);
+char *strextend(char **x, ...);
+char *strrep(const char *s, unsigned n);