Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2011-05-17 17:29:47 +0400
committerMiguel de Icaza <miguel@gnome.org>2011-05-17 17:30:11 +0400
commit45e21ca8bef8a6b73e8ebfe3f70a7b7849806a5c (patch)
treea4a66671e6241e18a89050433e9ee4754b6d4ea9 /scripts/launch.c
parent9997aa97dda1931e62fa098adfe1171c5239c125 (diff)
Add C launcher for Mono-shipped binaries
Diffstat (limited to 'scripts/launch.c')
-rw-r--r--scripts/launch.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/launch.c b/scripts/launch.c
new file mode 100644
index 00000000000..856f12335b3
--- /dev/null
+++ b/scripts/launch.c
@@ -0,0 +1,35 @@
+#define PROFILE_BASE_DIR "/mono/lib/mono/4.0"
+#define MONO_BINARY "/mono/bin/mono"
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <malloc.h>
+
+int
+main (int argc, char *argv [])
+{
+ char **nargv = (char **) malloc (sizeof (char *) * (argc + 1));
+ char *last = strrchr (argv [0], '/');
+ char *command;
+ int i, len;
+
+ if (last == NULL){
+ fprintf (stderr, "Do not know how to invoke the program given [%s]\n", argv [0]);
+ return 1;
+ }
+ len = strlen (last) + strlen (PROFILE_BASE_DIR) + 1;
+ command = malloc (len);
+ if (command == NULL){
+ fprintf (stderr, "Error allocating memory");
+ return 1;
+ }
+ strcpy (command, PROFILE_BASE_DIR);
+ strcat (command, last);
+ nargv [0] = command;
+ nargv [1] = command;
+
+ for (i = 1; i < argc; i++)
+ nargv [1+i] = argv [i];
+
+ execvp (MONO_BINARY, nargv);
+}