13 * Reads size bytes into the destination buffer from filename.
16 void slurp(char *filename, char *destination, int size) {
19 if ((fd = open(filename, O_RDONLY)) == -1)
20 die("Could not open \"%s\"\n", filename);
22 (void)read(fd, destination, size);
27 * Skip the given character for exactly 'amount' times, returns
28 * a pointer to the first non-'character' character in 'input'.
31 char *skip_character(char *input, char character, int amount) {
33 size_t len = strlen(input);
36 for (walk = input; ((size_t)(walk - input) < len) && (blanks < amount); walk++)
37 if (*walk == character)
40 return (walk == input ? walk : walk-1);
44 * Write errormessage to statusbar and exit
47 void die(const char *fmt, ...) {
51 (void)vsnprintf(buffer, sizeof(buffer), fmt, ap);
54 if (wmii_path != NULL)
55 write_error_to_statusbar(buffer);
57 fprintf(stderr, "%s", buffer);
62 * This function just concats two strings in place, it should only be used
63 * for concatting order to the name of a file or concatting color codes.
64 * Otherwise, the buffer size would have to be increased.
67 char *order_to_str(int number, char *name) {
69 (void)snprintf(buf, sizeof(buf), "%d%s", number, name);