X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=util.h;h=af39accc946c47c079ace7164f9e65c38d7f86db;hb=c16c534dcb35f88439e31d0f21a415bf43fb40f7;hp=772d7ae9ffb82a40d44f0c6296012a9fd3693bc2;hpb=3a0ecb08f4b3bfa84ff3d04bc7816730df35139e;p=elogind.git diff --git a/util.h b/util.h index 772d7ae9f..af39accc9 100644 --- a/util.h +++ b/util.h @@ -163,10 +163,14 @@ 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__ @@ -175,6 +179,10 @@ bool ignore_file(const char *filename); 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);