8 * If the MONO_ENV_OPTIONS environment variable is set, it uses this as a
9 * source of command line arguments that are passed to Mono before the
10 * command line arguments specified in the command line.
13 mono_main_with_options (int argc
, char *argv
[])
15 const char *env_options
= getenv ("MONO_ENV_OPTIONS");
16 if (env_options
!= NULL
){
17 GPtrArray
*array
= g_ptr_array_new ();
18 GString
*buffer
= g_string_new ("");
22 for (p
= env_options
; *p
; p
++){
25 if (buffer
->len
!= 0){
26 g_ptr_array_add (array
, g_strdup (buffer
->str
));
27 g_string_truncate (buffer
, 0);
32 g_string_append_c (buffer
, p
[1]);
37 g_string_append_c (buffer
, *p
);
42 g_ptr_array_add (array
, g_strdup (buffer
->str
));
43 g_string_free (buffer
, TRUE
);
46 int new_argc
= array
->len
+ argc
;
47 char **new_argv
= g_new (char *, new_argc
+ 1);
50 new_argv
[0] = argv
[0];
52 /* First the environment variable settings, to allow the command line options to override */
53 for (i
= 0; i
< array
->len
; i
++)
54 new_argv
[i
+1] = g_ptr_array_index (array
, i
);
56 for (j
= 1; j
< argc
; j
++)
57 new_argv
[i
++] = argv
[j
];
63 g_ptr_array_free (array
, TRUE
);
66 return mono_main (argc
, argv
);
79 argvw
= CommandLineToArgvW (GetCommandLine (), &argc
);
80 argv
= g_new0 (gchar
*, argc
+ 1);
81 for (i
= 0; i
< argc
; i
++)
82 argv
[i
] = g_utf16_to_utf8 (argvw
[i
], -1, NULL
, NULL
, NULL
);
87 return mono_main_with_options (argc
, argv
);
93 main (int argc
, char* argv
[])
95 mono_build_date
= build_date
;
97 return mono_main_with_options (argc
, argv
);