1 // vim:ts=4:sw=4:expandtab
15 * Reads size bytes into the destination buffer from filename.
18 bool slurp(const char *filename, char *destination, int size) {
21 if ((fd = open(filename, O_RDONLY)) == -1)
24 /* We need one byte for the trailing 0 byte */
25 int n = read(fd, destination, size - 1);
27 destination[n] = '\0';
34 * Skip the given character for exactly 'amount' times, returns
35 * a pointer to the first non-'character' character in 'input'.
38 char *skip_character(char *input, char character, int amount) {
40 size_t len = strlen(input);
43 for (walk = input; ((size_t)(walk - input) < len) && (blanks < amount); walk++)
44 if (*walk == character)
47 return (walk == input ? walk : walk - 1);
51 * Write errormessage to statusbar and exit
54 void die(const char *fmt, ...) {
57 (void)vfprintf(stderr, fmt, ap);