chiark / gitweb /
util: unify line caching and column caching
[elogind.git] / src / shared / util.h
index e23d706ebd501b0292782866aa6c495c44b09718..affb66998c1977c78b53bd8b142f2c2cf1b0bcc2 100644 (file)
@@ -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,20 @@ 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);
 }
 
-static inline void *memdup_multiply(const void *p, size_t a, size_t b) {
-        if (_unlikely_(a > ((size_t) -1) / b))
+_malloc_ static inline void *memdup_multiply(const void *p, size_t a, size_t 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);