diff options
Diffstat (limited to 'src/libudev/util.c')
-rw-r--r-- | src/libudev/util.c | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/src/libudev/util.c b/src/libudev/util.c index dc1641c3bc..e447f89647 100644 --- a/src/libudev/util.c +++ b/src/libudev/util.c @@ -438,68 +438,6 @@ char *strappend(const char *s, const char *suffix) { return strnappend(s, suffix, suffix ? strlen(suffix) : 0); } -int readlink_malloc(const char *p, char **r) { - size_t l = 100; - - assert(p); - assert(r); - - for (;;) { - char *c; - ssize_t n; - - if (!(c = new(char, l))) - return -ENOMEM; - - if ((n = readlink(p, c, l-1)) < 0) { - int ret = -errno; - free(c); - return ret; - } - - if ((size_t) n < l-1) { - c[n] = 0; - *r = c; - return 0; - } - - free(c); - l *= 2; - } -} - -char hexchar(int x) { - static const char table[16] = "0123456789abcdef"; - - return table[x & 15]; -} - -int unhexchar(char c) { - - if (c >= '0' && c <= '9') - return c - '0'; - - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - - return -1; -} - -char octchar(int x) { - return '0' + (x & 7); -} - -int unoctchar(char c) { - - if (c >= '0' && c <= '7') - return c - '0'; - - return -1; -} - _pure_ static bool ignore_file_allow_backup(const char *filename) { assert(filename); @@ -525,73 +463,6 @@ bool ignore_file(const char *filename) { return ignore_file_allow_backup(filename); } -_pure_ static bool fd_in_set(int fd, const int fdset[], unsigned n_fdset) { - unsigned i; - - assert(n_fdset == 0 || fdset); - - for (i = 0; i < n_fdset; i++) - if (fdset[i] == fd) - return true; - - return false; -} - -char *format_timespan(char *buf, size_t l, usec_t t) { - static const struct { - const char *suffix; - usec_t usec; - } table[] = { - { "w", USEC_PER_WEEK }, - { "d", USEC_PER_DAY }, - { "h", USEC_PER_HOUR }, - { "min", USEC_PER_MINUTE }, - { "s", USEC_PER_SEC }, - { "ms", USEC_PER_MSEC }, - { "us", 1 }, - }; - - unsigned i; - char *p = buf; - - assert(buf); - assert(l > 0); - - if (t == (usec_t) -1) - return NULL; - - if (t == 0) { - snprintf(p, l, "0"); - p[l-1] = 0; - return p; - } - - /* The result of this function can be parsed with parse_usec */ - - for (i = 0; i < ELEMENTSOF(table); i++) { - int k; - size_t n; - - if (t < table[i].usec) - continue; - - if (l <= 1) - break; - - k = snprintf(p, l, "%s%llu%s", p > buf ? " " : "", (unsigned long long) (t / table[i].usec), table[i].suffix); - n = MIN((size_t) k, l); - - l -= n; - p += n; - - t %= table[i].usec; - } - - *p = 0; - - return buf; -} - int open_terminal(const char *name, int mode) { int fd, r; unsigned c = 0; |