X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=util.h;h=af39accc946c47c079ace7164f9e65c38d7f86db;hb=ac8cfcf56c5d7b3eaeec64e94f6c4659e82a2b10;hp=a1e79d47b1d491060e7a420b6e4dd62e63cc9815;hpb=a0d40ac588701010ea6a9366f6a874e83844858e;p=elogind.git diff --git a/util.h b/util.h index a1e79d47b..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__ @@ -177,6 +181,8 @@ 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);