config-parser: Honor XDG_CONFIG_DIRS

This set of changes adds support for searching for a given config file
in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in
$XDG_CONFIG_HOME or ~/.config.  This allows packages to install custom
config files in /etc/xdg/weston, for example, thus allowing them to
avoid dealing with home directories.

To avoid a TOCTOU race the config file is actually open()ed during the
search.  Its file descriptor is returned and stored in the compositor
for later use when performing subsequent config file parses.

Signed-off-by: Ossama Othman <ossama.othman@intel.com>
diff --git a/src/compositor.h b/src/compositor.h
index 99468a1..318fc0d 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -545,6 +545,8 @@
 	struct xkb_rule_names xkb_names;
 	struct xkb_context *xkb_context;
 	struct weston_xkb_info xkb_info;
+
+	int config_fd;
 };
 
 struct weston_buffer_reference {
@@ -987,7 +989,7 @@
 
 int
 weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,
-		       int *argc, char *argv[], const char *config_file);
+		       int *argc, char *argv[], int config_fd);
 void
 weston_compositor_shutdown(struct weston_compositor *ec);
 void
@@ -1125,11 +1127,11 @@
 
 struct weston_compositor *
 backend_init(struct wl_display *display, int *argc, char *argv[],
-	     const char *config_file);
+	     int config_fd);
 
 int
 module_init(struct weston_compositor *compositor,
-	    int *argc, char *argv[], const char *config_file);
+	    int *argc, char *argv[]);
 
 void
 weston_transformed_coord(int width, int height,