home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / showtype.zip / apptype.c next >
C/C++ Source or Header  |  1993-06-11  |  2KB  |  85 lines

  1. /* apptype.c */
  2.  
  3. /* Written by Eberhard Mattes and put into the public domain */
  4.  
  5. #define INCL_DOSSESMGR
  6. #define INCL_DOSERRORS
  7. #include <os2.h>
  8. #if defined (MSC)
  9. #include "fapptyp.h"
  10. typedef USHORT APPTYPE;
  11. #define DosQueryAppType(filename, type)    DosQAppType(filename, type)
  12. #else
  13. typedef ULONG APPTYPE;
  14. #endif
  15.  
  16. #include <stdio.h>
  17.  
  18. int main (int argc, char *argv[])
  19. {
  20.     int result, i;
  21.    APPTYPE rc, type;
  22.  
  23. #ifdef __EMX__
  24.   _wildcard (&argc, &argv);
  25. #endif
  26.   result = 0;
  27.   if (argc < 2)
  28.     {
  29.       puts ("Usage: apptype <program>...");
  30.       return (1);
  31.     }
  32.   for (i = 1; i < argc; ++i)
  33.     {
  34.       rc = DosQueryAppType (argv[i], &type);
  35.       if (rc == ERROR_INVALID_EXE_SIGNATURE)
  36.         fprintf (stderr, "%s: not an executable file\n", argv[i]);
  37.       else if (rc == ERROR_FILE_NOT_FOUND)
  38.         fprintf (stderr, "%s: not found\n", argv[i]);
  39.       else if (rc == ERROR_ACCESS_DENIED)
  40.         fprintf (stderr, "%s: access denied\n", argv[i]);
  41.       else if (rc != 0)
  42.         fprintf (stderr, "%s: error code = %lu\n", argv[i], rc);
  43.       else
  44.         {
  45.           printf ("%s:", argv[i]);
  46.           if (type & FAPPTYP_32BIT)
  47.             printf (" 32-bit");
  48.           if (type & FAPPTYP_PHYSDRV)
  49.             printf (" physical device driver");
  50.           else if (type & FAPPTYP_VIRTDRV)
  51.             printf (" virtual device driver");
  52.           else if (type & FAPPTYP_DLL)
  53.             {
  54.               if (type & FAPPTYP_PROTDLL)
  55.                 printf (" protected");
  56.               printf (" DLL");
  57.             }
  58.           else if (type & (FAPPTYP_WINDOWSREAL|FAPPTYP_WINDOWSPROT))
  59.             printf ("Windows executable");
  60.           else if (type & FAPPTYP_DOS)
  61.             printf (" DOS executable");
  62.           else if (type & FAPPTYP_BOUND)
  63.             printf (" bound executable");
  64.           else if ((type & 7) == FAPPTYP_WINDOWAPI)
  65.             printf (" PM executable");
  66.           else
  67.             printf (" OS/2 executable");
  68.         }
  69.       switch(type & (FAPPTYP_NOTWINDOWCOMPAT |
  70.                FAPPTYP_WINDOWCOMPAT | FAPPTYP_WINDOWAPI)) {
  71.       case FAPPTYP_NOTWINDOWCOMPAT:
  72.         printf(" [NOTWINDOWCOMPAT]");
  73.         break;
  74.       case FAPPTYP_WINDOWCOMPAT:
  75.         printf(" [WINDOWCOMPAT]");
  76.         break;
  77.       case FAPPTYP_WINDOWAPI:
  78.          printf(" [WINDOWAPI]");
  79.          break;
  80.       }
  81.       putchar ('\n');
  82.     }
  83.   return (0);
  84. }
  85.