X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=util.h;h=af39accc946c47c079ace7164f9e65c38d7f86db;hp=9f9bca86f2c44df00401069854b362e5408d0a67;hb=dda5a135b8311ed3be5d930a4f6f560d638813f4;hpb=5af98f828476716954f327c479c4cf6321ae3fe4 diff --git a/util.h b/util.h index 9f9bca86f..af39accc9 100644 --- a/util.h +++ b/util.h @@ -163,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);