X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=util.h;h=af39accc946c47c079ace7164f9e65c38d7f86db;hb=d3725859f3d80972d7da3a73b92e58a06ac7d69a;hp=49abce1dbbbdeb5b5df5635f991ea48b03f41c5a;hpb=f62c0e4f30a96bcb0cfeae607d729a6658bfae83;p=elogind.git diff --git a/util.h b/util.h index 49abce1db..af39accc9 100644 --- a/util.h +++ b/util.h @@ -136,6 +136,8 @@ char hexchar(int x); int unhexchar(char c); char octchar(int x); int unoctchar(char c); +char decchar(int x); +int undecchar(char c); char *cescape(const char *s); char *cunescape(const char *s); @@ -161,15 +163,26 @@ bool ignore_file(const char *filename); } \ type name##_from_string(const char *s) { \ type i; \ + unsigned u; \ assert(s); \ for (i = 0; i < (type)ELEMENTSOF(name##_table); i++) \ if (streq(name##_table[i], s)) \ return i; \ + if (safe_atou(s, &u) >= 0 && \ + u < ELEMENTSOF(name##_table)) \ + return (type) u; \ return (type) -1; \ } \ struct __useless_struct_to_allow_trailing_semicolon__ +int fd_nonblock(int fd, bool nonblock); +int fd_cloexec(int fd, bool cloexec); + +int close_all_fds(const int except[], unsigned n_except); + +extern char * __progname; + const char *ioprio_class_to_string(int i); int ioprio_class_from_string(const char *s);