diff options
author | Jonathan Clairembault <jonathan@clairembault.fr> | 2012-11-23 00:06:28 +0100 |
---|---|---|
committer | Jonathan Clairembault <jonathan@clairembault.fr> | 2012-11-23 00:06:28 +0100 |
commit | 939fa7408fa68af8568fd07de64a1606af0a0c06 (patch) | |
tree | 86dda7e86cadc1831dd5d69277ec926eb3d43f6b /lib | |
parent | a5f8c733d478a57ad03c0b0efe7fa995e4c364a2 (diff) | |
download | toybox-939fa7408fa68af8568fd07de64a1606af0a0c06.tar.gz |
Add expand command as described in POSIX-2008.
Erratum: Do not handle backspace.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 11 | ||||
-rw-r--r-- | lib/lib.h | 11 |
2 files changed, 21 insertions, 1 deletions
@@ -1182,6 +1182,17 @@ char* make_human_readable(unsigned long long size, unsigned long unit) return NULL; //not reached } +// strtoul with exit on error +unsigned long xstrtoul(const char *nptr, char **endptr, int base) +{ + unsigned long l; + errno = 0; + l = strtoul(nptr, endptr, base); + if (errno) + perror_exit("xstrtoul"); + return l; +} + /* * used to get the interger value. */ @@ -29,6 +29,11 @@ struct arg_list { char *arg; }; +struct offset_list { + struct offset_list *next; + off_t off; +}; + struct double_list { struct double_list *next, *prev; char *data; @@ -145,7 +150,7 @@ void crc_init(unsigned int *crc_table, int little_endian); void terminal_size(unsigned *x, unsigned *y); int yesno(char *prompt, int def); void for_each_pid_with_name_in(char **names, void (*callback)(pid_t pid)); - +unsigned long xstrtoul(const char *nptr, char **endptr, int base); // getmountlist.c struct mtab_list { @@ -176,5 +181,9 @@ int update_password(char *filename, char* username, char* encrypted); // du helper functions char* make_human_readable(unsigned long long size, unsigned long unit); +// useful tools +#define min(a,b) (a)<(b) ? (a) : (b) +#define max(a,b) (a)>(b) ? (a) : (b) + // cut helper functions unsigned long get_int_value(const char *numstr, unsigned lowrange, unsigned highrange); |