X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=a9c39b867ea1a05b58af339641973113f59b2630;hb=a9e12476ed32256690eb801099c41526834b6390;hp=2e49cfde2efda507b6546929387e129b3b15b409;hpb=040f18ea8a682dc80c9f3940cf234ccd1135e115;p=elogind.git diff --git a/src/shared/util.h b/src/shared/util.h index 2e49cfde2..a9c39b867 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -141,7 +141,7 @@ static inline bool isempty(const char *p) { return !p || !p[0]; } -bool endswith(const char *s, const char *postfix); +char *endswith(const char *s, const char *postfix); bool startswith(const char *s, const char *prefix); bool startswith_no_case(const char *s, const char *prefix); @@ -384,10 +384,11 @@ int status_welcome(void); int fd_columns(int fd); unsigned columns(void); -unsigned columns_uncached(void); - int fd_lines(int fd); unsigned lines(void); +void columns_lines_cache_reset(int _unused_ signum); + +bool on_tty(void); int running_in_chroot(void); @@ -545,15 +546,24 @@ void closedirp(DIR **d); void umaskp(mode_t *u); _malloc_ static inline void *malloc_multiply(size_t a, size_t b) { - if (_unlikely_(a > ((size_t) -1) / b)) + if (_unlikely_(b == 0 || a > ((size_t) -1) / b)) return NULL; return malloc(a * b); } _malloc_ static inline void *memdup_multiply(const void *p, size_t a, size_t b) { - if (_unlikely_(a > ((size_t) -1) / b)) + if (_unlikely_(b == 0 || a > ((size_t) -1) / b)) return NULL; return memdup(p, a * b); } + +bool filename_is_safe(const char *p); +bool string_is_safe(const char *p); + +int parse_timestamp(const char *t, usec_t *usec); + +void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg);