#define QUOTES "\"\'"
#define COMMENTS "#;\n"
-#define FORMAT_TIMESTAMP_MAX 64
+#define FORMAT_TIMESTAMP_MAX (5+11+9+4+1)
#define FORMAT_TIMESTAMP_PRETTY_MAX 256
#define FORMAT_TIMESPAN_MAX 64
#define FORMAT_BYTES_MAX 8
return !p || !p[0];
}
-bool 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);
+char *endswith(const char *s, const char *postfix);
+char *startswith(const char *s, const char *prefix);
+char *startswith_no_case(const char *s, const char *prefix);
bool first_word(const char *s, const char *word);
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);
int getenv_for_pid(pid_t pid, const char *field, char **_value);
int can_sleep(const char *type);
+int can_sleep_disk(const char *type);
bool is_valid_documentation_url(const char *url);
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);
+
+void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
+ int (*compar) (const void *, const void *, void *),
+ void *arg);