X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=47497b578c36001b5314b6c07d25947a0587b528;hb=ac7019f33f1618f5b69ed44a8623e2596f1e3856;hp=f1bcb8a1017a596de38c620f8dc305a462e5d11d;hpb=5f23d5b149513d98bb90df8cb912b6f567bed89f;p=elogind.git diff --git a/src/shared/util.h b/src/shared/util.h index f1bcb8a10..47497b578 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -39,6 +39,7 @@ #include "macro.h" typedef uint64_t usec_t; +typedef uint64_t nsec_t; typedef struct dual_timestamp { usec_t realtime; @@ -53,11 +54,17 @@ typedef struct dual_timestamp { #define NSEC_PER_USEC 1000ULL #define USEC_PER_MINUTE (60ULL*USEC_PER_SEC) +#define NSEC_PER_MINUTE (60ULL*NSEC_PER_SEC) #define USEC_PER_HOUR (60ULL*USEC_PER_MINUTE) +#define NSEC_PER_HOUR (60ULL*NSEC_PER_MINUTE) #define USEC_PER_DAY (24ULL*USEC_PER_HOUR) +#define NSEC_PER_DAY (24ULL*NSEC_PER_HOUR) #define USEC_PER_WEEK (7ULL*USEC_PER_DAY) +#define NSEC_PER_WEEK (7ULL*NSEC_PER_DAY) #define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC) +#define NSEC_PER_MONTH (2629800ULL*NSEC_PER_SEC) #define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC) +#define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC) /* What is interpreted as whitespace? */ #define WHITESPACE " \t\n\r" @@ -103,7 +110,7 @@ bool streq_ptr(const char *a, const char *b); #define newa(t, n) ((t*) alloca(sizeof(t)*(n))) -#define newdup(t, p, n) ((t*) memdup(p, sizeof(t)*(n)) +#define newdup(t, p, n) ((t*) memdup(p, sizeof(t)*(n))) #define malloc0(n) (calloc((n), 1)) @@ -139,6 +146,7 @@ void close_many(const int fds[], unsigned n_fd); int parse_boolean(const char *v); int parse_usec(const char *t, usec_t *usec); +int parse_nsec(const char *t, nsec_t *nsec); int parse_bytes(const char *t, off_t *bytes); int parse_pid(const char *s, pid_t* ret_pid); int parse_uid(const char *s, uid_t* ret_uid); @@ -313,7 +321,7 @@ int reset_terminal_fd(int fd, bool switch_to_text); int reset_terminal(const char *name); int open_terminal(const char *name, int mode); -int acquire_terminal(const char *name, bool fail, bool force, bool ignore_tiocstty_eperm); +int acquire_terminal(const char *name, bool fail, bool force, bool ignore_tiocstty_eperm, usec_t timeout); int release_terminal(void); int flush_fd(int fd); @@ -337,6 +345,7 @@ void rename_process(const char name[8]); void sigset_add_many(sigset_t *ss, ...); char* gethostname_malloc(void); +bool hostname_is_set(void); char* getlogname_malloc(void); int getttyname_malloc(int fd, char **r); @@ -348,6 +357,7 @@ int get_ctty(pid_t, dev_t *_devnr, char **r); int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid); +int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev); int rm_rf(const char *path, bool only_dirs, bool delete_root, bool honour_sticky); int pipe_eof(int fd); @@ -508,4 +518,10 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value); int can_sleep(const char *type); +bool is_valid_documentation_url(const char *url); + +bool in_initrd(void); + +void warn_melody(void); + #endif