5 #include "buildver-sgen.h"
12 * If the MONO_ENV_OPTIONS environment variable is set, it uses this as a
13 * source of command line arguments that are passed to Mono before the
14 * command line arguments specified in the command line.
17 mono_main_with_options (int argc, char *argv [])
19 const char *env_options = getenv ("MONO_ENV_OPTIONS");
20 if (env_options != NULL){
21 GPtrArray *array = g_ptr_array_new ();
22 GString *buffer = g_string_new ("");
25 gboolean in_quotes = FALSE;
26 char quote_char = '\0';
28 for (p = env_options; *p; p++){
32 if (buffer->len != 0){
33 g_ptr_array_add (array, g_strdup (buffer->str));
34 g_string_truncate (buffer, 0);
37 g_string_append_c (buffer, *p);
42 g_string_append_c (buffer, p [1]);
52 g_string_append_c (buffer, *p);
59 g_string_append_c (buffer, *p);
64 fprintf (stderr, "Unmatched quotes in value of MONO_ENV_OPTIONS: [%s]\n", env_options);
69 g_ptr_array_add (array, g_strdup (buffer->str));
70 g_string_free (buffer, TRUE);
73 int new_argc = array->len + argc;
74 char **new_argv = g_new (char *, new_argc + 1);
77 new_argv [0] = argv [0];
79 /* First the environment variable settings, to allow the command line options to override */
80 for (i = 0; i < array->len; i++)
81 new_argv [i+1] = g_ptr_array_index (array, i);
83 for (j = 1; j < argc; j++)
84 new_argv [i++] = argv [j];
90 g_ptr_array_free (array, TRUE);
93 return mono_main (argc, argv);
106 argvw = CommandLineToArgvW (GetCommandLine (), &argc);
107 argv = g_new0 (gchar*, argc + 1);
108 for (i = 0; i < argc; i++)
109 argv [i] = g_utf16_to_utf8 (argvw [i], -1, NULL, NULL, NULL);
114 return mono_main_with_options (argc, argv);
120 main (int argc, char* argv[])
122 mono_build_date = build_date;
124 return mono_main_with_options (argc, argv);