parse-util: Introduce new parse_range function

This function will be useful for CPUAffinity settings that involve
ranges of CPUs.

Make it generic and include test coverage to prevent regressions.
This commit is contained in:
Filipe Brandenburger
2015-10-12 23:55:31 -07:00
parent 4fc66acb93
commit 28cb17ef02
3 changed files with 220 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ int parse_pid(const char *s, pid_t* ret_pid);
int parse_mode(const char *s, mode_t *ret);
int parse_size(const char *t, uint64_t base, uint64_t *size);
int parse_range(const char *t, unsigned *lower, unsigned *upper);
#define FORMAT_BYTES_MAX 8
char *format_bytes(char *buf, size_t l, uint64_t t);