From 461ded42ac222d6f5cecb2514ca702c87ca94a31 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 22 Mar 1999 14:54:05 +0000 Subject: [PATCH] Added -dll option for winelib programs. (Note: will not print warnings on failure currently). --- if1632/builtin.c | 34 +++++++++++++++++++-------- include/module.h | 3 ++- misc/main.c | 5 ++++ miscemu/main.c | 4 ++-- relay32/builtin32.c | 56 +++++++++++++++++++++++++++++++++++---------- 5 files changed, 78 insertions(+), 24 deletions(-) diff --git a/if1632/builtin.c b/if1632/builtin.c index 2004114a9f..d5c6444a60 100644 --- a/if1632/builtin.c +++ b/if1632/builtin.c @@ -351,15 +351,20 @@ void BUILTIN_DefaultIntHandler( CONTEXT *context ) * * Set runtime DLL usage flags */ -BOOL BUILTIN_ParseDLLOptions( const char *str ) +BOOL BUILTIN_ParseDLLOptions( char *str ) { BUILTIN16_DLL *dll; - const char *p; + char *p,*last; + + last = str; while (*str) { - while (*str && isspace(*str)) str++; - if (!*str) return TRUE; + while (*str && (*str==',' || isspace(*str))) str++; + if (!*str) { + *last = '\0'; /* cut off garbage at end at */ + return TRUE; + } if ((*str != '+') && (*str != '-')) return FALSE; str++; if (!(p = strchr( str, ',' ))) p = str + strlen(str); @@ -380,11 +385,22 @@ BOOL BUILTIN_ParseDLLOptions( const char *str ) break; } } - if (!dll->descr) - if (!BUILTIN32_EnableDLL( str, (int)(p - str), (str[-1] == '+') )) - return FALSE; - str = p; - while (*str && (isspace(*str) || (*str == ','))) str++; + if (!dll->descr) { + /* not found, but could get handled by BUILTIN32_, so move last */ + last = p; + str = p; + } else { + /* handled. cut out the "[+-]DLL," string, so it isn't handled + * by BUILTIN32 + */ + if (*p) { + memcpy(last,p,strlen(p)+1); + str = last; + } else { + *last = '\0'; + break; + } + } } return TRUE; } diff --git a/include/module.h b/include/module.h index cbed021902..9a81bd7f59 100644 --- a/include/module.h +++ b/include/module.h @@ -199,11 +199,12 @@ HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD s extern BOOL BUILTIN_Init(void); extern HMODULE16 BUILTIN_LoadModule( LPCSTR name, BOOL force ); extern LPCSTR BUILTIN_GetEntryPoint16( WORD cs, WORD ip, WORD *pOrd ); -extern BOOL BUILTIN_ParseDLLOptions( const char *str ); +extern BOOL BUILTIN_ParseDLLOptions( char *str ); extern void BUILTIN_PrintDLLs(void); /* relay32/builtin.c */ extern HMODULE BUILTIN32_LoadImage( LPCSTR name, OFSTRUCT *ofs, BOOL force ); +extern BOOL BUILTIN32_ParseDLLOptions( char *str ); /* if1632/builtin.c */ extern HMODULE16 (*fnBUILTIN_LoadModule)(LPCSTR name, BOOL force); diff --git a/misc/main.c b/misc/main.c index 46353d0e76..a09b751a9c 100644 --- a/misc/main.c +++ b/misc/main.c @@ -34,6 +34,7 @@ #include "debug.h" #include "debugdefs.h" #include "xmalloc.h" +#include "module.h" #include "version.h" #include "winnls.h" #include "console.h" @@ -816,6 +817,10 @@ BOOL MAIN_WineInit( int *argc, char *argv[] ) #endif /* !defined(X_DISPLAY_MISSING) */ MONITOR_Initialize(&MONITOR_PrimaryMonitor); + if (Options.dllFlags) + BUILTIN32_ParseDLLOptions( Options.dllFlags ); + /* if (__winelib && errors ) print_error_message_like_misc_main(); */ + atexit(called_at_exit); return TRUE; } diff --git a/miscemu/main.c b/miscemu/main.c index 1819592ea7..d26b7ac4b3 100644 --- a/miscemu/main.c +++ b/miscemu/main.c @@ -140,8 +140,8 @@ int main( int argc, char *argv[] ) /* Handle -dll option (hack) */ if (Options.dllFlags) { - if (!BUILTIN_ParseDLLOptions( Options.dllFlags )) - { + /* If there are options left, or if the parser had errors, report it */ + if (!BUILTIN_ParseDLLOptions( Options.dllFlags )||Options.dllFlags[0]) { MSG("%s: Syntax: -dll +xxx,... or -dll -xxx,...\n", argv[0] ); BUILTIN_PrintDLLs(); diff --git a/relay32/builtin32.c b/relay32/builtin32.c index f274285426..23af85c53a 100644 --- a/relay32/builtin32.c +++ b/relay32/builtin32.c @@ -435,29 +435,61 @@ void BUILTIN32_Unimplemented( const BUILTIN32_DESCRIPTOR *descr, int ordinal ) ExitProcess(1); } - /*********************************************************************** - * BUILTIN32_EnableDLL + * BUILTIN32_ParseDLLOptions * - * Enable or disable a built-in DLL. + * Set runtime DLL usage flags */ -int BUILTIN32_EnableDLL( const char *name, int len, int enable ) +BOOL BUILTIN32_ParseDLLOptions( char *str ) { - int i; BUILTIN32_DLL *dll; + char *p,*last; - for (i = 0, dll = BuiltinDLLs; dll->descr; dll++) + last = str; + while (*str) { - if (!lstrncmpiA( name, dll->descr->name, len )) - { - dll->used = enable; - return TRUE; - } + while (*str && (*str==',' || isspace(*str))) str++; + if (!*str) { + *last = '\0'; /* cut off garbage at end at */ + return TRUE; + } + if ((*str != '+') && (*str != '-')) return FALSE; + str++; + if (!(p = strchr( str, ',' ))) p = str + strlen(str); + while ((p > str) && isspace(p[-1])) p--; + if (p == str) return FALSE; + for (dll = BuiltinDLLs; dll->descr; dll++) + { + if (!lstrncmpiA( dll->descr->name, str, (int)(p-str) )) + { + if (dll->descr->name[p-str]) /* partial match - skip */ + continue; + dll->used = (str[-1]!='-'); + break; + } + } + if (!dll->descr) { + /* not found, but could get handled by BUILTIN_, so move last */ + last = p; + str = p; + } else { + /* handled. cut out the "[+-]DLL," string, so it isn't handled + * by BUILTIN + */ + if (*p) { + memcpy(last,p,strlen(p)+1); + str = last; + } else { + *last = '\0'; + break; + } + } } - return FALSE; + return TRUE; } + /*********************************************************************** * BUILTIN32_PrintDLLs * -- 2.32.0.93.g670b81a890