Merge pull request #93 from konrad-kruczynski/dispatcher_timer_fix
[mono.git] / scripts / launch.c
1 #define PROFILE_BASE_DIR "/mono/lib/mono/4.0"
2 #define MONO_BINARY "/mono/bin/mono"
3 #include <stdio.h>
4 #include <string.h>
5 #include <unistd.h>
6 #include <malloc.h>
7
8 int
9 main (int argc, char *argv [])
10 {
11         char **nargv = (char **) malloc (sizeof (char *) * (argc + 1));
12         char *last = strrchr (argv [0], '/');
13         char *command;
14         int i, len;
15
16         if (last == NULL){
17                 fprintf (stderr, "Do not know how to invoke the program given [%s]\n", argv [0]);
18                 return 1;
19         }
20         len = strlen (last) + strlen (PROFILE_BASE_DIR) + 1;
21         command = malloc (len);
22         if (command == NULL){
23                 fprintf (stderr, "Error allocating memory");
24                 return 1;
25         }
26         strcpy (command, PROFILE_BASE_DIR);
27         strcat (command, last);
28         nargv [0] = command;
29         nargv [1] = command;
30         
31         for (i = 1; i < argc; i++)
32                 nargv [1+i] = argv [i];
33         
34         execvp (MONO_BINARY, nargv);
35 }