home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / bpos13.zip / os2def.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-24  |  16KB  |  472 lines

  1. {***************************************************************************\
  2. *
  3. * Module Name: OS2DEF.H
  4. *
  5. * OS/2 Common Definitions file
  6. *
  7. * Copyright (c) International Business Machines Corporation 1981, 1988, 1989
  8. * Copyright (c) Microsoft Corporation 1981, 1988, 1989
  9. *
  10. \**************************************************************************}
  11.  
  12. {| Version:   1.02
  13.  | Original translation: Peter Singer (PSi)
  14.  | Contributing:
  15.  |   Peter Singer (PSi)
  16.  |   Peter Sawatzki (ps)
  17.  |
  18.  | change history:
  19.  | Date:    Ver: Author:
  20.  | 11/08/93 1.00 PSi    original translation by PSi
  21.  | 11/10/93 1.01 ps     added Inline macros
  22.  | 11/11/93 1.02 ps     correct some bugs
  23. }
  24. {$Define USE13}
  25. { Comments:
  26.   search for '***MC' for unresolved macros
  27.   search for '***TC' for unresolved types and constants
  28.   search for '-UNSURE-' for possibly incorrect translations
  29.   search for '-CANT-' for types that can't be translated correctly
  30. }
  31. Unit Os2Def;
  32. Interface
  33. type
  34.      SHANDLE    = word;
  35.      LHANDLE    = pointer;
  36.      Long       = LongInt;                {-ps-}
  37.  
  38. {***TC #define EXPENTRY pascal far _loadds
  39. ***TC #define APIENTRY pascal far}
  40.  
  41.      UCHAR      = Byte;
  42.      USHORT     = Word;
  43.      SHORT      = Integer;
  44.      UINT       = Word;
  45.      ULONG      = Longint;
  46.      BOOL       = {$IfDef Use13} WordBool {$Else} LongInt {$EndIf}; {-ps-}
  47.  
  48. { define NULL pointer value }
  49. { Echo the format of the ifdefs that stdio.h uses }
  50.  
  51. CONST NULL      = 0;
  52.  
  53.  
  54. type PSZ        = pChar;                       {-ps-}
  55.      NPSZ       = PSZ;      {-CANT-}           {-ps-}
  56.      PCH        = Pointer;
  57.      NPCH       = Pointer;  {-CANT-}
  58.  
  59. {typedef int   (pascal far  *PFN)();
  60.  typedef int   (pascal near *NPFN)();}
  61.   pFn = Function: Integer;                     {-ps-}
  62.   npFn = Function: Integer;  {-CANT-}          {-ps-}
  63.  
  64.      PBYTE      = ^Byte;                       {-ps-}
  65.      NPBYTE     = ^Byte;     {-CANT-}          {-ps-}
  66. {    PCHAR      = Pointer;}                    {-ps-}
  67.      PSHORT     = ^Integer;                    {-ps-}
  68.      PLONG      = ^Longint;                    {-ps-}
  69.      PINT       = ^Integer;                    {-ps-}
  70.      PUCHAR     = PChar;                       {-ps-}
  71.      PUSHORT    = PSHORT;                      {-ps-}
  72.      PULONG     = PLONG;                       {-ps-}
  73.      PUINT      = ^Word;
  74.      PVOID      = Pointer;
  75.      PBOOL      = ^Boolean;                    {-ps-}
  76.  
  77. CONST
  78.      FALSE      = BOOL(0);
  79.      TRUE       = BOOL(1);
  80.  
  81. Type
  82.     SEL         = Word;
  83.     PSEl        = Pointer;
  84.  
  85. Const
  86.   PopAx = $58;
  87.   PopDx = $5A;
  88.   PopBx = $5B;
  89. {** Useful Helper Macros }
  90.  
  91. { Create untyped far pointer from selector and offset }
  92. {#define MAKEP(sel, off)     ((PVOID)MAKEULONG(off, sel))}
  93. Function MakeP(Sel,Off: Word): Pointer;        {-ps-}
  94.   Inline(PopAx/PopDx);                         {-ps-}
  95.  
  96. { Extract selector or offset from far pointer }
  97. {#define SELECTOROF(p)       (((PUSHORT)&(p))[1])}
  98. {#define OFFSETOF(p)         (((PUSHORT)&(p))[0])}
  99. Function SelectorOf(p: Pointer): Word;         {-ps-}
  100.   Inline(PopDx/PopAx);                         {-ps-}
  101.  
  102. Function OffsetOf(p: Pointer): Word;           {-ps-}
  103.   Inline(PopAx/PopDx);                         {-ps-}
  104.  
  105. { Cast any variable to an instance of the specified type. }
  106. {***MC #define MAKETYPE(v, type)   (*((type far *)&v))}
  107.  
  108. { Calculate the byte offset of a field in a structure of type type. }
  109. {#define FIELDOFFSET(type, field)    ((SHORT)&(((type *)0)->field))}
  110. {instead of the type of the structure, we pass the structure itself -PS}
  111. Function FieldOffset (Var Structure; Var Field): Word;            {-ps-}
  112.   Inline(PopBx/PopDx/PopAx/PopDx/ $29/$D8 {Sub Ax,Bx});           {-ps-}
  113.  
  114. { Combine l & h to form a 32 bit quantity. }
  115. {#define MAKEULONG(l, h)  ((ULONG)(((USHORT)(l)) | ((ULONG)((USHORT)(h))) << 16))}
  116. {#define MAKELONG(l, h)   ((LONG)MAKEULONG(l, h))}
  117. Function MakeLong(L, H: Word): Long;           {-ps-}
  118.   Inline(PopDx/PopAx);                         {-ps-}
  119.  
  120. Function MakeULong(L, H: Word): ULong;         {-ps-}
  121.   Inline(PopDx/PopAx);                         {-ps-}
  122.  
  123. { Combine l & h to form a 16 bit quantity. }
  124. {#define MAKEUSHORT(l, h) (((USHORT)(l)) | ((USHORT)(h)) << 8)}
  125. {#define MAKESHORT(l, h)  ((SHORT)MAKEUSHORT(l, h))}
  126. Function MakeShort (l,h: Byte): Short;                        {-ps-}
  127.   Inline(PopBx/PopAx/ $88/$DC {Mov Ah,Bl});                   {-ps-}
  128.  
  129. Function MakeUShort (l,h: Byte): UShort;                      {-ps-}
  130.   Inline(PopBx/PopAx/ $88/$DC {Mov Ah,Bl});                   {-ps-}
  131.  
  132. { Extract high and low order parts of 16 and 32 bit quantity }
  133. {#define LOBYTE(w)       LOUCHAR(w)                           }
  134. {#define HIBYTE(w)       HIUCHAR(w)                           }
  135. {#define LOUCHAR(w)      ((UCHAR)(w))                         }
  136. {#define HIUCHAR(w)      ((UCHAR)(((USHORT)(w) >> 8) & 0xff)) }
  137. {#define LOUSHORT(l)     ((USHORT)(l))                        }
  138. {#define HIUSHORT(l)     ((USHORT)(((ULONG)(l) >> 16) & 0xffff))}
  139. Function LoByte(w: Word): Byte;                                    {-ps-}
  140.   Inline(PopAx / $32/$E4 {Xor Ah,Ah});                             {-ps-}
  141. Function LoUByte(w: Word): UChar;                                  {-ps-}
  142.   Inline(PopAx / $32/$E4 {Xor Ah,Ah});                             {-ps-}
  143.  
  144. Function HiByte(w: Word): Byte;                                    {-ps-}
  145.   Inline(PopAx / $8A/$C4 {Mov Al,Ah} / $32/$E4 {Xor Ah,Ah});       {-ps-}
  146. Function HiUChar(w: Word): UChar;                                  {-ps-}
  147.   Inline(PopAx / $8A/$C4 {Mov Al,Ah} / $32/$E4 {Xor Ah,Ah});       {-ps-}
  148.  
  149. Function LoUShort(l: Long): UShort;                                {-ps-}
  150.   Inline(PopAx/PopDx);                                             {-ps-}
  151. Function HiUShort(l: Long): UShort;                                {-ps-}
  152.   Inline(PopDx/PopAx);                                             {-ps-}
  153.  
  154. {** Common Error definitions ***}
  155.  
  156. type
  157.      ERRORID    = Longint;   { ULONG ERRORID}
  158.      PERRORID   = Pointer;
  159.  
  160. { Combine severity and error code to produce ERRORID }
  161. {#define MAKEERRORID(sev, error) (ERRORID)(MAKEULONG((error), (sev)))}
  162. Function MakeErrorId(sev, error: UShort): ERRORID;          {-ps-}
  163.   Inline(PopDx/PopAx);                                      {-ps-}
  164. { Extract error number from an errorid }
  165. {#define ERRORIDERROR(errid)            (LOUSHORT(errid))}
  166. Function ErrorIdError(errid: ERRORID): UShort;              {-ps-}
  167.   Inline(PopAx/PopDx);                                      {-ps-}
  168. { Extract severity from an errorid }
  169. {#define ERRORIDSEV(errid)              (HIUSHORT(errid))}
  170. Function ErrorIdSev(errid: ERRORID): UShort;                {-ps-}
  171.   Inline(PopDx/PopAx);                                      {-ps-}
  172.  
  173. { Severity codes }
  174. CONST
  175.       SEVERITY_NOERROR         = $0000;
  176.       SEVERITY_WARNING         = $0004;
  177.       SEVERITY_ERROR           = $0008;
  178.       SEVERITY_SEVERE          = $000C;
  179.       SEVERITY_UNRECOVERABLE   = $0010;
  180.  
  181. { Base component error values }
  182.  
  183.       WINERR_BASE              = $1000;  { Window Manager                  }
  184.       GPIERR_BASE              = $2000;  { Graphics Presentation Interface }
  185.       DEVERR_BASE              = $3000;  { Device Manager                  }
  186.       SPLERR_BASE              = $4000;  { Spooler                         }
  187.  
  188. {** Common types used across components }
  189.  
  190. {** Common DOS types }
  191.  
  192. Type
  193.     HMODULE             = {$IfDef Use13} Word {$Else} LongInt {$EndIf};
  194.     PHMODULE            = ^HMODULE;
  195.     PID                 = {$IfDef Use13} Word {$Else} LongInt {$EndIf};
  196.     PPID                = ^PID;
  197.     TID                 = {$IfDef Use13} Word {$Else} LongInt {$EndIf};
  198.     PTID                = ^TID;
  199.     HSEM                = Pointer;                     { hsem }
  200.     PHSEM               = ^HSEM;
  201.  
  202. {** Common SUP types }
  203.  
  204.     HAB                 = LHANDLE;      { hab  }
  205.     PHAB                = ^HAB;
  206.  
  207. {** Common GPI/DEV types }
  208.  
  209.     HPS                 = LHANDLE;      { hps  }
  210.     PHPS                = ^HPS;
  211.  
  212.     HDC                 = LHANDLE;      { hdc  }
  213.     PHDC                = ^HDC;
  214.  
  215.     HRGN                = LHANDLE;      { hrgn  }
  216.     PHRGN               = ^HRGN;
  217.  
  218.     HBITMAP             = LHANDLE;      { hbm  }
  219.     PHBITMAP            = ^HBITMAP;
  220.  
  221.     HMF                 = LHANDLE;      { hmf  }
  222.     PHMF                = ^HMF;
  223.  
  224.  
  225.     COLOR               = LONG;     { clr  }
  226.     PCOLOR              = ^COLOR;
  227.  
  228.     POINTL   = record               { ptl  }
  229.        x,
  230.        y  : LONG;
  231.     end;
  232.     PPOINTL             = ^POINTL;
  233.     NPPOINTL            = ^POINTL;  {-CANT-}
  234.  
  235.     POINTS   = record               { pts  }
  236.        x,
  237.        y  : Integer;
  238.     end;
  239.     PPOINTS             = ^POINTS;
  240.  
  241.     RECTL    = record              { rcl }
  242.        xLeft,
  243.        yBottom,
  244.        xRight,
  245.        yTop  : LONG;
  246.     end;
  247.     PRECTL              = ^RECTL;
  248.     NPRECTL             = ^RECTL;   {-CANT-}
  249.  
  250.     STR8                = Array[0..7] Of Char;         {-ps-}
  251.     PSTR8               = ^STR8;
  252.  
  253. {** common DEV/SPL types }
  254.  
  255. { structure for Device Driver data }
  256.  
  257.     DRIVDATA   = record           { driv }
  258.        cb,
  259.        lVersion       : LONG;
  260.        szDeviceName   : Array[0..31] Of Char;           {-ps-}
  261.        abGeneralData  : Array[0..0] Of Char;            {-ps-}
  262.     end;
  263.     PDRIVDATA           = ^DRIVDATA;
  264.  
  265. { array indices for array parameter for DevOpenDC, SplQmOpen or SplQpOpen }
  266.  
  267. CONST
  268.       ADDRESS        = 0;
  269.       DRIVER_NAME    = 1;
  270.       DRIVER_DATA    = 2;
  271.       DATA_TYPE      = 3;
  272.       COMMENT        = 4;
  273.       PROC_NAME      = 5;
  274.       PROC_PARAMS    = 6;
  275.       SPL_PARAMS     = 7;
  276.       NETWORK_PARAMS = 8;
  277.  
  278. { structure definition as an alternative of the array parameter }
  279. TYPE
  280.     DEVOPENSTRUC = record            { dop }
  281.       pszLogAddress,
  282.       pszDriverName   : PSZ;
  283.       pdriv           : PDRIVDATA;
  284.       pszDataType,
  285.       pszComment,
  286.       pszQueueProcName,
  287.       pszQueueProcParams,
  288.       pszSpoolerParams,
  289.       pszNetworkParams  : PSZ;
  290.     end;
  291.     PDEVOPENSTRUC      = ^DEVOPENSTRUC;
  292.  
  293. {** common AVIO/GPI types }
  294.  
  295. { values of fsSelection field of FATTRS structure }
  296. CONST
  297.       FATTR_SEL_ITALIC         = $0001;
  298.       FATTR_SEL_UNDERSCORE     = $0002;
  299.       FATTR_SEL_OUTLINE        = $0008;          { Hollow Outline Font }
  300.       FATTR_SEL_STRIKEOUT      = $0010;
  301.       FATTR_SEL_BOLD           = $0020;
  302.  
  303. { values of fsType field of FATTRS structure }
  304.       FATTR_TYPE_KERNING       = $0004;
  305.       FATTR_TYPE_MBCS          = $0008;
  306.       FATTR_TYPE_DBCS          = $0010;
  307.       FATTR_TYPE_ANTIALIASED   = $0020;
  308.  
  309. { values of fsFontUse field of FATTRS structure }
  310.       FATTR_FONTUSE_NOMIX       = $0002;
  311.       FATTR_FONTUSE_OUTLINE     = $0004;
  312.       FATTR_FONTUSE_TRANSFORMABLE = $0008;
  313.  
  314.  
  315. { size for fields in the font structures }
  316.  
  317.       FACESIZE = 32;
  318.  
  319. { font struct for Vio/GpiCreateLogFont }
  320. TYPE
  321.     FATTRS   = record            { fat }
  322.       usRecordLength,
  323.       fsSelection    : USHORT;
  324.       lMatch         : LONG;
  325.       szFacename     : Array[0..FACESIZE-1] Of Char;      {-ps-}
  326.       idRegistry,
  327.       usCodePage     : USHORT;
  328.       lMaxBaselineExt,
  329.       lAveCharWidth  : LONG;
  330.       fsType,
  331.       fsFontUse      : USHORT
  332.     end;
  333.     PFATTRS    = ^FATTRS;
  334.  
  335. { values of fsType field of FONTMETRICS structure }
  336. CONST
  337.       FM_TYPE_FIXED            = $0001;
  338.       FM_TYPE_LICENSED         = $0002;
  339.       FM_TYPE_KERNING          = $0004;
  340.       FM_TYPE_DBCS             = $0010;
  341.       FM_TYPE_MBCS             = $0018;
  342.       FM_TYPE_64K              = $8000;
  343.  
  344. { values of fsDefn field of FONTMETRICS structure }
  345.       FM_DEFN_OUTLINE          = $0001;
  346.       FM_DEFN_GENERIC          = $8000;
  347.  
  348. { values of fsSelection field of FONTMETRICS structure }
  349.       FM_SEL_ITALIC            = $0001;
  350.       FM_SEL_UNDERSCORE        = $0002;
  351.       FM_SEL_NEGATIVE          = $0004;
  352.       FM_SEL_OUTLINE           = $0008;          { Hollow Outline Font }
  353.       FM_SEL_STRIKEOUT         = $0010;
  354.       FM_SEL_BOLD              = $0020;
  355.  
  356. { values of fsCapabilities field of FONTMETRICS structure }
  357.  
  358.       FM_CAP_NOMIX             = $0001;
  359.  
  360. { font metrics returned by GpiQueryFonts and others }
  361. Type
  362. {$IfNDef Use13}
  363.   _PANOSE = Record                                   {-ps-/2.1}
  364.     bFamilyType,                                     {-ps-/2.1}
  365.     bSerifStyle,                                     {-ps-/2.1}
  366.     bWeight,                                         {-ps-/2.1}
  367.     bProportion,                                     {-ps-/2.1}
  368.     bContrast,                                       {-ps-/2.1}
  369.     bStrokeVariation,                                {-ps-/2.1}
  370.     bArmStyle,                                       {-ps-/2.1}
  371.     bLetterform,                                     {-ps-/2.1}
  372.     bMidline,                                        {-ps-/2.1}
  373.     bXHeight,                                        {-ps-/2.1}
  374.     fbPassedISO,                                     {-ps-/2.1}
  375.     fbFailedISO: Byte                                {-ps-/2.1}
  376.   End;                                               {-ps-/2.1}
  377. {$EndIf}
  378.  
  379.      FONTMETRICS   =   Record       { fm }
  380.        szFamilyname,
  381.        szFacename       : Array[0..FACESIZE-1] Of Char;
  382.        idRegistry,
  383.        usCodePage        : USHORT;
  384.        lEmHeight,
  385.        lXHeight,
  386.        lMaxAscender,
  387.        lMaxDescender,
  388.        lLowerCaseAscent,
  389.        lLowerCaseDescent,
  390.        lInternalLeading,
  391.        lExternalLeading,
  392.        lAveCharWidth,
  393.        lMaxCharInc,
  394.        lEmInc,
  395.        lMaxBaselineExt   : LONG;
  396.        sCharSlope,
  397.        sInlineDir,
  398.        sCharRot          : SHORT;
  399.        usWeightClass,
  400.        usWidthClass      : USHORT;
  401.        sXDeviceRes,
  402.        sYDeviceRes,
  403.        sFirstChar,
  404.        sLastChar,
  405.        sDefaultChar,
  406.        sBreakChar,
  407.        sNominalPointSize,
  408.        sMinimumPointSize,
  409.        sMaximumPointSize        : SHORT;
  410.        fsType,
  411.        fsDefn,
  412.        fsSelection,
  413.        fsCapabilities           : USHORT;
  414.        lSubscriptXSize,
  415.        lSubscriptYSize,
  416.        lSubscriptXOffset,
  417.        lSubscriptYOffset,
  418.        lSuperscriptXSize,
  419.        lSuperscriptYSize,
  420.        lSuperscriptXOffset,
  421.        lSuperscriptYOffset,
  422.        lUnderscoreSize,
  423.        lUnderscorePosition,
  424.        lStrikeoutSize,
  425.        lStrikeoutPosition       : LONG;
  426.        sKerningPairs,
  427.        sFamilyClass             : SHORT;
  428.        lMatch                   : LONG;
  429. {$IfNDef Use13}
  430.        FamilyNameAtom,                        {-ps-/2.1}
  431.        FaceNameAtom: LONG;                    {-ps-/2.1}
  432.        panose: _PANOSE                        {-ps-/2.1}
  433. {$EndIf}
  434.      end;
  435.      PFONTMETRICS  = ^FONTMETRICS;
  436.  
  437. {** Common WIN types }
  438.  
  439.     HWND       = LHANDLE;       { hwnd }
  440.     PHWND      = ^HWND;
  441.  
  442.     WRECT  = Record             { wrc }
  443.       xLeft,
  444.       dummy1,
  445.       yBottom,
  446.       dummy2,
  447.       xRight,
  448.       dummy3,
  449.       yTop,
  450.       dummy4  : SHORT;
  451.     end;
  452.     PWRECT      = ^WRECT;
  453.     NPWRECT     = ^WRECT;           {-CANT-}
  454.  
  455.     WPOINT   = record    { wpt }
  456.       x,
  457.       dummy1,
  458.       y,
  459.       dummy2  : SHORT;
  460.     end;
  461.     PWPOINT     = ^WPOINT;
  462.     NPWPOINT    = ^WPOINT;          {-CANT-}
  463.  
  464.   Procedure UnKnown (aFunc, aMod: pChar); {called for unkown functions}
  465. Implementation
  466.   Procedure UnKnown (aFunc, aMod: pChar);
  467.   Begin
  468.     WriteLn('### unknown function in Module ',aMod,': ',aFunc);
  469.     Halt(255)
  470.   End;
  471. End.
  472.