chiark / gitweb /
always use the same code for creating temporary files
[elogind.git] / src / shared / util.h
index ebc765da35668e4759093d4dbfcbb700183b4819..117855de819933fc173e6e9d9e7073ea00bb8501 100644 (file)
@@ -272,6 +272,7 @@ int make_stdio(int fd);
 int make_null_stdio(void);
 int make_console_stdio(void);
 
+int dev_urandom(void *p, size_t n);
 void random_bytes(void *p, size_t n);
 
 static inline uint64_t random_u64(void) {
@@ -295,7 +296,8 @@ static inline uint32_t random_u32(void) {
         }                                                               \
         scope type name##_from_string(const char *s) {                  \
                 type i;                                                 \
-                assert(s);                                              \
+                if (!s)                                                 \
+                        return (type) -1;                               \
                 for (i = 0; i < (type)ELEMENTSOF(name##_table); i++)    \
                         if (name##_table[i] &&                          \
                             streq(name##_table[i], s))                  \
@@ -848,3 +850,8 @@ bool pid_valid(pid_t pid);
 
 int getpeercred(int fd, struct ucred *ucred);
 int getpeersec(int fd, char **ret);
+
+int writev_safe(int fd, const struct iovec *w, int j);
+
+int mkostemp_safe(char *pattern, int flags);
+int open_tmpfile(const char *path, int flags);