#include <dirent.h>
#include <sys/resource.h>
#include <stddef.h>
+#include <systemd/sd-journal.h>
#include "macro.h"
#include "time-util.h"
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]);
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);
void warn_melody(void);
-int get_shell(char **ret);
int get_home_dir(char **ret);
static inline void freep(void *p) {
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;
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[], char** dir_name);
#define FOREACH_LINE(line, f, on_error) \
for (;;) \
#define FOREACH_DIRENT(de, d, on_error) \
for (errno = 0, de = readdir(d);; errno = 0, de = readdir(d)) \
if (!de) { \
- if (errno != 0) { \
+ if (errno > 0) { \
on_error; \
} \
break; \
memset(s, c, n);
return (char*)s + n;
}
+
+char *hexmem(const void *p, size_t l);
+void *unhexmem(const char *p, size_t l);
+
+char *strextend(char **x, ...);
+char *strrep(const char *s, unsigned n);
+
+void* greedy_realloc(void **p, size_t *allocated, size_t need);