Pass argc and argv to modules

This lets modules parse options from the command line.
diff --git a/src/compositor.c b/src/compositor.c
index fb5cb2c..9198b3b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3211,11 +3211,13 @@
 }
 
 static int
-load_modules(struct weston_compositor *ec, const char *modules)
+load_modules(struct weston_compositor *ec, const char *modules,
+	     int *argc, char *argv[], const char *config_file)
 {
 	const char *p, *end;
 	char buffer[256];
-	int (*module_init)(struct weston_compositor *ec);
+	int (*module_init)(struct weston_compositor *ec,
+			   int *argc, char *argv[], const char *config_file);
 
 	if (modules == NULL)
 		return 0;
@@ -3226,7 +3228,7 @@
 		snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
 		module_init = load_module(buffer, "module_init");
 		if (module_init)
-			module_init(ec);
+			module_init(ec, argc, argv, config_file);
 		p = end;
 		while (*p == ',')
 			p++;
@@ -3429,14 +3431,6 @@
 	sigaction(SIGSEGV, &segv_action, NULL);
 	segv_compositor = ec;
 
-
-	for (i = 1; i < argc; i++)
-		weston_log("fatal: unhandled option: %s\n", argv[i]);
-	if (argc > 1) {
-		ret = EXIT_FAILURE;
-		goto out;
-	}
-
 	free(config_file);
 
 	ec->option_idle_time = idle_time;
@@ -3444,11 +3438,18 @@
 
 	setenv("WAYLAND_DISPLAY", socket_name, 1);
 
-	if (load_modules(ec, modules) < 0)
+	if (load_modules(ec, modules, &argc, argv, config_file) < 0)
 		goto out;
-	if (load_modules(ec, option_modules) < 0)
+	if (load_modules(ec, option_modules, &argc, argv, config_file) < 0)
 		goto out;
 
+	for (i = 1; i < argc; i++)
+		weston_log("fatal: unhandled option: %s\n", argv[i]);
+	if (argc > 1) {
+		ret = EXIT_FAILURE;
+		goto out;
+	}
+
 	if (wl_display_add_socket(display, socket_name)) {
 		weston_log("fatal: failed to add socket: %m\n");
 		ret = EXIT_FAILURE;
diff --git a/src/compositor.h b/src/compositor.h
index 11afbb9..a45fdf6 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -843,7 +843,8 @@
 	     const char *config_file);
 
 int
-module_init(struct weston_compositor *compositor);
+module_init(struct weston_compositor *compositor,
+	    int *argc, char *argv[], const char *config_file);
 
 void
 weston_transformed_coord(int width, int height,
diff --git a/src/shell.c b/src/shell.c
index af802a5..a4511fd 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -345,9 +345,8 @@
 }
 
 static void
-shell_configuration(struct desktop_shell *shell)
+shell_configuration(struct desktop_shell *shell, const char *config_file)
 {
-	char *config_file;
 	char *path = NULL;
 	int duration = 60;
 	unsigned int num_workspaces = DEFAULT_NUM_WORKSPACES;
@@ -371,9 +370,7 @@
 		{ "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL },
 	};
 
-	config_file = config_file_path("weston.ini");
 	parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);
-	free(config_file);
 
 	shell->screensaver.path = path;
 	shell->screensaver.duration = duration;
@@ -3957,7 +3954,8 @@
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *ec)
+module_init(struct weston_compositor *ec,
+	    int *argc, char *argv[], const char *config_file)
 {
 	struct weston_seat *seat;
 	struct desktop_shell *shell;
@@ -4002,7 +4000,7 @@
 	wl_array_init(&shell->workspaces.array);
 	wl_list_init(&shell->workspaces.client_list);
 
-	shell_configuration(shell);
+	shell_configuration(shell, config_file);
 
 	for (i = 0; i < shell->workspaces.num; i++) {
 		pws = wl_array_add(&shell->workspaces.array, sizeof *pws);
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index 9e88e27..57226e8 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -531,7 +531,8 @@
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *compositor)
+module_init(struct weston_compositor *compositor,
+	    int *argc, char *argv[], const char *config_file)
 {
 	struct tablet_shell *shell;
 	struct wl_event_loop *loop;
diff --git a/src/xwayland/launcher.c b/src/xwayland/launcher.c
index ddd9640..e50177e 100644
--- a/src/xwayland/launcher.c
+++ b/src/xwayland/launcher.c
@@ -315,7 +315,9 @@
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *compositor)
+module_init(struct weston_compositor *compositor,
+	    int *argc, char *argv[], const char *config_file)
+
 {
 	struct wl_display *display = compositor->wl_display;
 	struct weston_xserver *wxs;
diff --git a/tests/surface-global-test.c b/tests/surface-global-test.c
index 5908f60..5bafa08 100644
--- a/tests/surface-global-test.c
+++ b/tests/surface-global-test.c
@@ -67,7 +67,8 @@
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *compositor)
+module_init(struct weston_compositor *compositor,
+	    int *argc, char *argv[], const char *config_file)
 {
 	struct wl_event_loop *loop;
 
diff --git a/tests/surface-test.c b/tests/surface-test.c
index b41c63f..8157e33 100644
--- a/tests/surface-test.c
+++ b/tests/surface-test.c
@@ -50,7 +50,8 @@
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *compositor)
+module_init(struct weston_compositor *compositor,
+	    int *argc, char *argv[], const char *config_file)
 {
 	struct wl_event_loop *loop;
 
diff --git a/tests/weston-test.c b/tests/weston-test.c
index a9def4b..83a7124 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -224,7 +224,8 @@
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *ec)
+module_init(struct weston_compositor *ec,
+	    int *argc, char *argv[], const char *config_file)
 {
 	struct weston_test *test;
 	struct wl_event_loop *loop;