just for a start i hacked this together (doesn't do the conversion when trying to load the .pd-files though!)
mfg.asd.r IOhannes
--- s_loader.c.org 2005-11-16 19:45:32.550161296 +0100 +++ s_loader.c 2005-11-16 19:41:13.935476704 +0100 @@ -46,10 +46,45 @@
void class_set_extern_dir(t_symbol *s);
+/* replace everything but [a-zA-Z0-9_] by "0x%x" */ +static char*alternative_classname(char*classname) +{ + char *altname=(char*)getbytes(sizeof(char)*MAXPDSTRING); + int count=0; + int i=0; + for(i=0; i<MAXPDSTRING; i++) + altname[i]=0; + i=0; + while(*classname) + { + char c=*classname; + if((c>=48 && c<=57)|| /* [0-9] */ + (c>=65 && c<=90)|| /* [A-Z] */ + (c>=97 && c<=122)||/* [a-z] */ + (c==95)) /* [_] */ + { + altname[i]=c; + i++; + } + else /* a "bad" character */ + { + sprintf(altname+i, "0x%02x", c); + i+=4; + count++; + } + classname++; + } + if(count>0)return altname; + /* seems like the given classname is fine as can be */ + freebytes(altname, sizeof(char)*MAXPDSTRING); + return 0; +} + int sys_load_lib(char *dirname, char *classname) { char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING], - classname2[MAXPDSTRING], *nameptr, *lastdot; + classname2[MAXPDSTRING], *nameptr, *lastdot, + altsymname[MAXPDSTRING], *altname=0; void *dlobj; t_xxx makeout = NULL; int fd; @@ -59,6 +94,7 @@ #if 0 fprintf(stderr, "lib %s %s\n", dirname, classname); #endif + altname=alternative_classname(classname); /* try looking in the path for (classname).(sys_dllextent) ... */ if ((fd = open_via_path(dirname, classname, sys_dllextent, dirbuf, &nameptr, MAXPDSTRING, 1)) < 0) @@ -72,6 +108,25 @@ if ((fd = open_via_path(dirname, classname2, sys_dllextent, dirbuf, &nameptr, MAXPDSTRING, 1)) < 0) { + /* next try (alternative_classname).(sys_dllextent) */ + if(altname) + { + if ((fd = open_via_path(dirname, altname, sys_dllextent, + dirbuf, &nameptr, MAXPDSTRING, 1)) < 0) + + /* next try (alternative_classname)/(alternative_classname).(sys_dllextent) ... */ + strncpy(classname2, altname, MAXPDSTRING); + filename[MAXPDSTRING-2] = 0; + strcat(classname2, "/"); + strncat(classname2, altname, MAXPDSTRING-strlen(classname2)); + filename[MAXPDSTRING-1] = 0; + if ((fd = open_via_path(dirname, classname2, sys_dllextent, + dirbuf, &nameptr, MAXPDSTRING, 1)) < 0) + { + return 0; + } + } + else return (0); } } @@ -93,9 +148,20 @@ #ifdef MACOSX strcpy(symname, "_"); strcat(symname, nameptr); + if(altname) + { + strcpy(altsymname, "_setup_"); + strcat(symname, altname); + } #else strcpy(symname, nameptr); + if(altname) + { + strcpy(altsymname, "setup_"); + strcat(altsymname, altname); + } #endif + /* if the last character is a tilde, replace with "_tilde" */ if (symname[strlen(symname) - 1] == '~') strcpy(symname + (strlen(symname) - 1), "_tilde"); @@ -110,6 +176,7 @@ return (0); } makeout = (t_xxx)dlsym(dlobj, symname); + if(!makeout)makeout = (t_xxx)dlsym(dlobj, altsymname); #endif #ifdef MSW sys_bashfilename(filename, filename); @@ -121,6 +188,7 @@ return (0); } makeout = (t_xxx)GetProcAddress(ntdll, symname); + if(!makeout)makeout = (t_xxx)GetProcAddress(ntdll, altsymname); #endif #ifdef MACOSX { @@ -147,6 +215,8 @@ } s = NSLookupSymbolInModule(ret, symname);
+ if(!s)s=NSLookupSymbolInModule(ret, altsymname); + if (s) makeout = (t_xxx)NSAddressOfSymbol( s); else makeout = 0; @@ -156,6 +226,8 @@ if (!makeout) { post("load_object: Symbol "%s" not found", symname); + if(altname) + post("load_object: Symbol "%s" not found", altsymname); class_set_extern_dir(&s_); return 0; }