Hi, Just a minor improvement to be able to provide with a list of function names to generate. New -S: Search only prototype names found in 'symfile'. Similiar to -s/-e (Start/End prototype search after symbol 'num'}. Commit requested if approved as I have no CVS commit access. I am missing some general utility library such as GLib, Qt, NSPR or APR to provide general datastructures such as hashes etc. Maybe it is provided by W32? Therefore /* FIXME: Replace with some hash such as GHashTable */. Jan Kratochvil
Index: main.c =================================================================== RCS file: /home/wine/wine/tools/winedump/main.c,v retrieving revision 1.9 diff -u -r1.9 main.c --- main.c 26 Aug 2002 21:47:41 -0000 1.9 +++ main.c 15 Sep 2002 22:28:47 -0000 @@ -124,6 +124,30 @@ } +static void do_symfile (const char *arg) +{ + FILE *f; + char symstring[256]; /* keep count with "%<width>s" below */ + search_symbol *symbolp,**symbolptail = &globals.search_symbol; + + if (!(f = fopen(arg, "rt"))) + fatal ("Cannot open <symfile>"); + while (1 == fscanf(f, "%255s", symstring)) /* keep count with [<width>] above */ + { + symstring[sizeof(symstring)-1] = '\0'; + if (!(symbolp = malloc(sizeof(*symbolp) + strlen(symstring)))) + fatal ("Out of memory"); + strcpy(symbolp->symbolname, symstring); + symbolp->found = 0; + symbolp->next = NULL; + *symbolptail = symbolp; + symbolptail = &symbolp->next; + } + if (fclose(f)) + fatal ("Cannot close <symfile>"); +} + + static void do_verbose (void) { globals.do_verbose = 1; @@ -173,6 +197,7 @@ {"-C", SPEC, 0, do_cdecl, "-C Assume __cdecl calls (default: __stdcall)"}, {"-s", SPEC, 1, do_start, "-s num Start prototype search after symbol 'num'"}, {"-e", SPEC, 1, do_end, "-e num End prototype search after symbol 'num'"}, + {"-S", SPEC, 1, do_symfile, "-S symfile Search only prototype names found in 'symfile'"}, {"-q", SPEC, 0, do_quiet, "-q Don't show progress (quiet)."}, {"-v", SPEC, 0, do_verbose, "-v Show lots of detail while working (verbose)."}, {"dump", DUMP, 0, do_dump, "dump <mod> Dumps the content of the module (dll, exe...) named <mod>"}, @@ -290,6 +315,54 @@ OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( strdup (OUTPUT_DLL_NAME)) : ""; } +/* Marks the symbol as 'found'! */ +/* return: perform-search */ +static int symbol_searched(int count, const char *symbolname) +{ + search_symbol *search_symbol; + + if (!(count >= globals.start_ordinal + && (!globals.end_ordinal || count <= globals.end_ordinal))) + return 0; + if (!globals.search_symbol) + return 1; + for (search_symbol = globals.search_symbol; + search_symbol; + search_symbol = search_symbol->next) + { + if (!strcmp(symbolname, search_symbol->symbolname)) + { + search_symbol->found = 1; + return 1; + } + } + return 0; +} + +/* return: some symbols weren't found */ +static int symbol_finish(void) +{ + const search_symbol *search_symbol; + int started = 0; + + for (search_symbol = globals.search_symbol; + search_symbol; + search_symbol = search_symbol->next) + { + if (search_symbol->found) + continue; + if (!started) + { + /* stderr? not a practice here */ + puts("These requested <symfile> symbols weren't found:"); + started = 1; + } + printf("\t%s\n",search_symbol->symbolname); + return 1; + } + return started; +} + /******************************************************************* * main */ @@ -344,8 +417,7 @@ printf ("Export %3d - '%s' ...%c", count, symbol.symbol, VERBOSE ? '\n' : ' '); - if (globals.do_code && count >= globals.start_ordinal - && (!globals.end_ordinal || count <= globals.end_ordinal)) + if (globals.do_code && symbol_searched(count, symbol.symbol)) { /* Attempt to get information about the symbol */ int result = symbol_demangle (&symbol); @@ -375,6 +447,8 @@ if (VERBOSE) puts ("Finished, Cleaning up..."); + if (symbol_finish()) + return 1; break; case NONE: do_usage(); Index: winedump.h =================================================================== RCS file: /home/wine/wine/tools/winedump/winedump.h,v retrieving revision 1.5 diff -u -r1.5 winedump.h --- winedump.h 31 May 2002 23:41:00 -0000 1.5 +++ winedump.h 15 Sep 2002 22:28:48 -0000 @@ -91,6 +91,14 @@ char *arg_name [MAX_FUNCTION_ARGS]; } parsed_symbol; +/* FIXME: Replace with some hash such as GHashTable */ +typedef struct __search_symbol +{ + struct __search_symbol *next; + int found; + char symbolname[1]; /* static string, be ANSI C compliant by [1] */ +} search_symbol; + /* All globals */ typedef struct __globals { @@ -117,6 +125,7 @@ /* Option arguments: spec mode */ int start_ordinal; /* -s */ int end_ordinal; /* -e */ + search_symbol *search_symbol; /* -S */ const char *directory; /* -I */ const char *forward_dll; /* -f */ const char *dll_name; /* -o */