home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / ENUMP2.ZIP / TEST.C < prev   
C/C++ Source or Header  |  1988-05-30  |  1KB  |  51 lines

  1. /* test.c -- tester for enumproc.c */
  2. /* enumerates exported procs from OS/2 or Windows DLL file */
  3. /* Andrew Schulman 28-May-1988 */
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include "doscalls.h"
  8.  
  9. char *enumproc(char *dll, char *buf, unsigned *ord);
  10.  
  11. main(int argc, char *argv[])
  12. {
  13.     char buf[256];  /* must be large enough to accept proc name */
  14.     char filename[128];
  15.     unsigned ord;
  16.     
  17.     if (argc < 2)
  18.     {
  19.         printf("ENUMPROC <module name>\n");
  20.         return 1;
  21.     }
  22.     
  23.     strcpy(filename, argv[1]);
  24.  
  25.     /* if they didn't pass in full filename, try to get it for them */
  26.     if (! strchr(filename, '.'))
  27.     {
  28.         unsigned handle;
  29.         if (DOSGETMODHANDLE(argv[1], &handle))
  30.             { printf("Can't locate %s\n", argv[1]); return 1; }
  31.         else
  32.         {
  33.             if (DOSGETMODNAME(handle, sizeof(filename), filename))
  34.                 { printf("Can't locate %s\n", argv[1]); return 1; }
  35.             else
  36.                 puts(filename);
  37.         }
  38.     }
  39.     
  40.     if (enumproc(filename, buf, &ord))
  41.     {
  42.         /* first entry is just module name, ordinal number zero */
  43.         printf("Module: %s\n", buf);
  44.         while (enumproc(0, buf, &ord))
  45.             printf("%s (#%u)\n", buf, ord);
  46.     }
  47.     
  48.     return 0;
  49. }
  50.  
  51.