[Pkg-mono-svn-commits] rev 168 - mono/trunk/debian
Eduard Bloch
blade@quantz.debian.org
Mon, 09 Feb 2004 14:08:11 +0100
Author: blade
Date: 2004-02-09 14:08:10 +0100 (Mon, 09 Feb 2004)
New Revision: 168
Modified:
mono/trunk/debian/changelog
mono/trunk/debian/cli-wrapper.c
Log:
"Improved" cli-wrapper
Modified: mono/trunk/debian/changelog
===================================================================
--- mono/trunk/debian/changelog 2004-02-08 23:23:41 UTC (rev 167)
+++ mono/trunk/debian/changelog 2004-02-09 13:08:10 UTC (rev 168)
@@ -1,3 +1,10 @@
+mono (0.30-0pre1v1) unstable; urgency=low
+
+ * NOT RELEASED YET
+ * catch-them-all cli-wrapper rewrite
+
+ -- Eduard Bloch <blade@debian.org> Mon, 9 Feb 2004 00:23:40 +0100
+
mono (0.29.99.20040114-3) unstable; urgency=low
* bugfix release, hopefully the last of 0.29* series
Modified: mono/trunk/debian/cli-wrapper.c
===================================================================
--- mono/trunk/debian/cli-wrapper.c 2004-02-08 23:23:41 UTC (rev 167)
+++ mono/trunk/debian/cli-wrapper.c 2004-02-09 13:08:10 UTC (rev 168)
@@ -1,15 +1,54 @@
#include <stdio.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+extern int errno;
extern char **environ;
+#define cmd args[1]
+#define NAME_ISREG(name) \
+ ((! stat(name,&si)) && \
+ S_ISREG((&si)->st_mode))
+#define runit if(NAME_ISREG(cmd)) return execve("/usr/bin/cli",args,environ);
+#define trypath(dir) sprintf(cmd, "%s/%s.exe", dir, exName); runit; sprintf(cmd, "%s/%s/%s.exe", dir, exName, exName); runit;
+#define runthem(paths) { char **tmp=paths; while(*tmp) { trypath(*tmp); tmp++; } }
+
int main(int argc, char **argv){
- char *tmp;
+ char *exName;
char *args[argc+2];
+ struct stat si;
+ char *paths[] = {
+ "/usr/bin",
+ "/usr/share/dotnet/exe",
+ "/usr/share/dotnet/bin",
+ "/usr/share/dotnet",
+ "/usr/lib/dotnet/exe",
+ "/usr/lib/dotnet/bin",
+ "/usr/lib/dotnet",
+ NULL
+ };
+ const char *path;
+
memcpy(args+sizeof(char), argv, sizeof(char *) * argc);
args[argc+1]=NULL;
args[0]=argv[0];
- tmp = strrchr(argv[0], '/');
- if(!tmp) tmp=argv[0]; else tmp++;
- args[1] = (char *) calloc( 15+strlen(tmp), sizeof(char));
- sprintf(args[1], "/usr/bin/%s.exe", tmp);
- return execve("/usr/bin/cli",args,environ);
+ exName = strrchr(argv[0], '/');
+ if(!exName) exName=argv[0]; else exName++;
+ cmd = (char *) calloc( 215+strlen(exName), sizeof(char));
+ /* Done. exName has the binary name, look for it and write result to cmd */
+
+ path = getenv ("MONO_PATH");
+ if (path)
+ runthem(g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 1000));
+
+ runthem(paths);
+
+ /* should never be reached */
+ errno = ENOENT;
+ return(-1);
}