home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / snados.h < prev    next >
Text File  |  1998-04-25  |  5KB  |  176 lines

  1. /****************************** Module Header ******************************\
  2. *
  3. * Module Name: SNADOS.H
  4. *
  5. * Description: Microsoft SNA Server MSDOS specific 3270 Emulator Interface
  6. *              definitions.
  7. *
  8. * Copyright (c) 1994, Microsoft Corporation.  All rights reserved.
  9. *
  10. \***************************************************************************/
  11.  
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15.  
  16. /* Common definitions */
  17.  
  18. #define PASCAL    pascal
  19. #define FAR        far
  20. #define NEAR    near
  21. #define VOID    void
  22.  
  23. #define APIENTRY far pascal
  24. #ifndef WINAPI
  25. #define WINAPI APIENTRY
  26. #endif
  27.  
  28. #define CHAR    char        /* ch  */
  29. #define SHORT    short        /* s   */
  30. #define LONG    long        /* l   */
  31. #define INT        int            /* i   */
  32.  
  33. typedef unsigned char UCHAR;    /* uch */
  34. typedef unsigned short USHORT;    /* us  */
  35. typedef unsigned long ULONG;    /* ul  */
  36. typedef unsigned int  UINT;        /* ui  */
  37. typedef unsigned char BYTE;        /* b   */
  38.  
  39. typedef unsigned short SHANDLE;
  40.  
  41.  
  42. /* define NULL pointer value */
  43. /* Echo the format of the ifdefs that stdio.h uses */
  44.  
  45. #if (_MSC_VER >= 600)
  46. #define NULL    ((void *)0)
  47. #else
  48. #if (defined(M_I86L) || defined(M_I86CM) || defined(M_I86LM) || defined(M_I86HM))
  49. #define  NULL     0L
  50. #else
  51. #define  NULL     0
  52. #endif
  53. #endif
  54.  
  55. typedef SHANDLE HFILE;        /* hf */
  56. typedef HFILE far *PHFILE;
  57.  
  58. typedef unsigned char far  *PSZ;
  59. typedef unsigned char near *NPSZ;
  60. typedef char far *LPSTR;
  61.  
  62. typedef unsigned char far  *PCH;
  63. typedef unsigned char near *NPCH;
  64.  
  65. typedef int   (pascal far  *PFN)();
  66. typedef int   (pascal near *NPFN)();
  67. typedef PFN far *PPFN;
  68.  
  69. typedef BYTE   FAR  *PBYTE;
  70. typedef BYTE   near *NPBYTE;
  71.  
  72. typedef CHAR   FAR *PCHAR;
  73. typedef SHORT  FAR *PSHORT;
  74. typedef LONG   FAR *PLONG;
  75. typedef INT    FAR *PINT;
  76.  
  77. typedef UCHAR  FAR *PUCHAR;
  78. typedef USHORT FAR *PUSHORT;
  79. typedef ULONG  FAR *PULONG;
  80. typedef UINT   FAR *PUINT;
  81. typedef VOID   FAR *PVOID;
  82.  
  83. typedef unsigned short BOOL;    /* f   */
  84. typedef BOOL FAR *PBOOL;
  85.  
  86. #ifndef TRUE
  87. #define TRUE    1
  88. #endif
  89.  
  90. #ifndef FALSE
  91. #define FALSE   0
  92. #endif
  93.  
  94. typedef unsigned short SEL;        /* sel */
  95. typedef SEL FAR *PSEL;
  96.  
  97. /*** Useful Helper Macros */
  98.  
  99. /* Create untyped far pointer from selector and offset */
  100. #define MAKEP(sel, off)     ((PVOID)MAKEULONG(off, sel))
  101.  
  102. /* Extract selector or offset from far pointer */
  103. #define SELECTOROF(p)        (((PUSHORT)&(p))[1])
  104. #define OFFSETOF(p)        (((PUSHORT)&(p))[0])
  105.  
  106.  
  107. /* Cast any variable to an instance of the specified type. */
  108. #define MAKETYPE(v, type)    (*((type far *)&v))
  109.  
  110. /* Calculate the byte offset of a field in a structure of type type. */
  111. #define FIELDOFFSET(type, field)    ((SHORT)&(((type *)0)->field))
  112.  
  113. /* Combine l & h to form a 32 bit quantity. */
  114. #define MAKEULONG(l, h) ((ULONG)(((USHORT)(l)) | ((ULONG)((USHORT)(h))) << 16))
  115. #define MAKELONG(l, h)    ((LONG)MAKEULONG(l, h))
  116.  
  117. /* Combine l & h to form a 16 bit quantity. */
  118. #define MAKEUSHORT(l, h) (((USHORT)(l)) | ((USHORT)(h)) << 8)
  119. #define MAKESHORT(l, h)  ((SHORT)MAKEUSHORT(l, h))
  120.  
  121. /* Extract high and low order parts of 16 and 32 bit quantity */
  122. #define LOBYTE(w)    LOUCHAR(w)
  123. #define HIBYTE(w)    HIUCHAR(w)
  124. #define LOUCHAR(w)    ((UCHAR)(USHORT)(w))
  125. #define HIUCHAR(w)    ((UCHAR)(((USHORT)(w) >> 8) & 0xff))
  126. #define LOUSHORT(l)    ((USHORT)(ULONG)(l))
  127. #define HIUSHORT(l)    ((USHORT)(((ULONG)(l) >> 16) & 0xffff))
  128.  
  129. #define SWAPUSHORT(x) (x=(((x<<8)&0xFF00)|((x>>8)&0x00FF)))
  130.  
  131. /*** Common DOS types */
  132.  
  133. typedef USHORT      HMODULE;    /* hmod */
  134. typedef HMODULE FAR *PHMODULE;
  135.  
  136. typedef USHORT      PID;        /* pid    */
  137. typedef PID FAR *PPID;
  138.  
  139. typedef USHORT      TID;        /* tid    */
  140. typedef TID FAR *PTID;
  141.  
  142. typedef VOID FAR *HSEM;         /* hsem */
  143. typedef HSEM FAR *PHSEM;
  144.  
  145. /**** DOS FMI Error codes */
  146.  
  147. #define ERROR_SEM_TIMEOUT  0xfffc /* Time out happened from the     */
  148.                                   /* semaphore api functions.       */
  149. #define ERROR_SEM_OWNED    0xfffd /* Semaphore is already owned     */
  150.  
  151. /**** DOS FMI Semaphore functions */
  152.  
  153. extern USHORT  APIENTRY CMDSemClear(HSEM);
  154. extern USHORT  APIENTRY CMDSemRequest(HSEM, USHORT);
  155. extern USHORT  APIENTRY CMDSemSet(HSEM);
  156. extern USHORT  APIENTRY CMDSemWait(HSEM, USHORT);
  157.  
  158. /*** DOS FMI TSR functions */
  159.  
  160. extern USHORT  APIENTRY CMDGoTSR(ULONG, UCHAR FAR *, UCHAR FAR *);
  161.  
  162. extern USHORT  APIENTRY CMDStartFG(void);
  163. extern USHORT  APIENTRY CMDStopFG(USHORT);
  164.  
  165. /*** DOS FMI Task switching functions */
  166. extern USHORT  APIENTRY RegisterSwitchProc(ULONG);
  167.  
  168. /*** Other DOS FMI functions */
  169. extern USHORT APIENTRY SNAGetVersion(VOID);
  170.  
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174.  
  175.  
  176.