12 * Reads size bytes into the destination buffer from filename.
15 void slurp(char *filename, char *destination, int size) {
18 if ((fd = open(filename, O_RDONLY)) == -1)
19 die("Could not open \"%s\"\n", filename);
21 (void)read(fd, destination, size);
26 * Skip the given character for exactly 'amount' times, returns
27 * a pointer to the first non-'character' character in 'input'.
30 char *skip_character(char *input, char character, int amount) {
32 size_t len = strlen(input);
35 for (walk = input; ((size_t)(walk - input) < len) && (blanks < amount); walk++)
36 if (*walk == character)
39 return (walk == input ? walk : walk-1);
43 * Write errormessage to statusbar and exit
46 void die(const char *fmt, ...) {
50 (void)vsnprintf(buffer, sizeof(buffer), fmt, ap);
53 if (wmii_path != NULL)
54 write_error_to_statusbar(buffer);
56 fprintf(stderr, "%s", buffer);
61 * This function just concats two strings in place, it should only be used
62 * for concatting order to the name of a file or concatting color codes.
63 * Otherwise, the buffer size would have to be increased.
66 char *order_to_str(int number, char *name) {
68 (void)snprintf(buf, sizeof(buf), "%d%s", number, name);