X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Futil.h;h=0b397ac0d4deb40631d9917af032be3a8e666596;hp=a77a952ed6d053436421b14b644f8f9a450604c7;hb=d3782d60cd47f57f48a9229bdd3badbd2f4bae44;hpb=e99e38bbdcca3fe5956823bdb3d38544ccf93221 diff --git a/src/util.h b/src/util.h index a77a952ed..0b397ac0d 100644 --- a/src/util.h +++ b/src/util.h @@ -28,9 +28,15 @@ #include #include #include +#include typedef uint64_t usec_t; +typedef struct timestamp { + usec_t realtime; + usec_t monotonic; +} timestamp; + #define MSEC_PER_SEC 1000ULL #define USEC_PER_SEC 1000000ULL #define USEC_PER_MSEC 1000ULL @@ -48,9 +54,12 @@ typedef uint64_t usec_t; #define NEWLINE "\n\r" #define FORMAT_TIMESTAMP_MAX 64 +#define FORMAT_TIMESPAN_MAX 64 usec_t now(clockid_t clock); +timestamp* timestamp_get(timestamp *ts); + usec_t timespec_load(const struct timespec *ts); struct timespec *timespec_store(struct timespec *ts, usec_t u); @@ -130,6 +139,7 @@ int read_one_line_file(const char *fn, char **line); char *strappend(const char *s, const char *suffix); int readlink_malloc(const char *p, char **r); +int readlink_and_make_absolute(const char *p, char **r); char *file_name_from_path(const char *p); bool is_path(const char *p); @@ -137,7 +147,9 @@ bool is_path(const char *p); bool path_is_absolute(const char *p); char *path_make_absolute(const char *p, const char *prefix); char *path_make_absolute_cwd(const char *p); + char **strv_path_make_absolute_cwd(char **l); +char **strv_path_canonicalize(char **l); int reset_all_signal_handlers(void); @@ -178,11 +190,14 @@ bool ignore_file(const char *filename); bool chars_intersect(const char *a, const char *b); char *format_timestamp(char *buf, size_t l, usec_t t); +char *format_timespan(char *buf, size_t l, usec_t t); int make_stdio(int fd); bool is_clean_exit(int code, int status); +unsigned long long random_ull(void); + #define DEFINE_STRING_TABLE_LOOKUP(name,type) \ const char *name##_to_string(type i) { \ if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \ @@ -218,12 +233,14 @@ int ask(char *ret, const char *replies, const char *text, ...); int reset_terminal(int fd); int open_terminal(const char *name, int mode); -int acquire_terminal(const char *name, bool fail, bool force); +int acquire_terminal(const char *name, bool fail, bool force, bool ignore_tiocstty_eperm); int release_terminal(void); int flush_fd(int fd); -int ignore_signal(int sig); +int ignore_signals(int sig, ...); +int default_signals(int sig, ...); +int sigaction_many(const struct sigaction *sa, ...); int close_pipe(int p[]); @@ -233,6 +250,8 @@ int path_is_mount_point(const char *path); bool is_device_path(const char *path); +int dir_is_empty(const char *path); + extern char * __progname; const char *ioprio_class_to_string(int i);