-/*
- * This function exists primarily for resolving ~ in pathnames. However, you
- * can also specify ~/Movies/ *, which will only return the first match!
- *
- */
-char *glob_path(const char *path) {
- static glob_t globbuf;
- if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
- die("glob() failed");
- char *result = strdup(globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path);
- globfree(&globbuf);
- return result;
-}
-
-/*
- * Loads configuration from configfile
- *
- */
-static void get_next_config_entry(FILE *handle, char **dest_name, char **dest_value, char *whole_buffer, int whole_buffer_size) {
- char *ret;
- if ((ret = fgets(whole_buffer, whole_buffer_size, handle)) == whole_buffer) {
- char *c = whole_buffer;
- /* Skip whitespaces in the beginning */
- while (isspace((int)*c) && *c != '\0')
- c++;
- *dest_name = c;
- while (!isspace((int)*c))
- c++;
- /* Terminate string as soon as whitespaces begin or it's terminated anyway */
- *(c++) = '\0';
-
- /* Same for the value: strip whitespaces */
- while (isspace((int)*c) && *c != '\0')
- c++;
- *dest_value = c;
- /* Whitespace is allowed, newline/carriage return is not */
- while ((*c != '\n') && (*c != '\r') && (*c != '\0'))
- c++;
- *c = 0;
- } else if (ret != NULL)
- die("Could not read line in configuration file");
-}
-