]> 4ch.mooo.com Git - 16.git/blobdiff - 16/portable.h
added regestry dump function and added it to ps.exe for testing reason
[16.git] / 16 / portable.h
diff --git a/16/portable.h b/16/portable.h
new file mode 100755 (executable)
index 0000000..5acb46d
--- /dev/null
@@ -0,0 +1,166 @@
+/*============================================================================\r
+\r
+    portable.h   v1.00      Written by Scott Robert Ladd.\r
+\r
+    _MSC_VER        Microsoft C 6.0 and later\r
+    _QC             Microsoft Quick C 2.51 and later\r
+    __TURBOC__      Borland Turbo C, Turbo C++, and Borland C++\r
+    __BORLANDC__    Borland C++\r
+    __ZTC__         Zortech C++ and Symantec C++\r
+    __SC__          Symantec C++\r
+    __WATCOM__      WATCOM C\r
+    __POWERC        Mix Power C\r
+\r
+    Revised:\r
+    09/14/93  Fred Cole  Moved MK_FP() macro to end of file to avoid\r
+                         redefinition error when dos.h gets included\r
+                         at the in/outport definitions for __TURBOC__\r
+    09/15/93  Thad Smith Add conditional code for TC 2.01\r
+                         Fix findfirst/findnext support for ZTC 3.0\r
+    10/15/93  Bob Stout  Revise find first/next support\r
+    04/03/94  Bob Stout  Add Power C support, FAR\r
+============================================================================*/\r
+\r
+\r
+/* prevent multiple inclusions of this header file */\r
+\r
+#if !defined(PORTABLE_H)\r
+#define PORTABLE_H\r
+\r
+/*\r
+**  Correct far pointer syntax\r
+*/\r
+\r
+#if defined(__POWERC) || (defined(__TURBOC__) && !defined(__BORLANDC__))\r
+ #define FAR far\r
+#else\r
+ #define FAR _far\r
+#endif\r
+\r
+/*----------------------------------------------------------------------------\r
+    Directory search macros and data structures\r
+\r
+    DOSFileData         MS-DOS file data structure\r
+    FIND_FIRST          MS-DOS function 0x4E -- find first file matchine spec\r
+    FIND_NEXT           MS-DOS function 0x4F -- find subsequent files\r
+----------------------------------------------------------------------------*/\r
+\r
+/* make sure the structure is packed on byte boundary */\r
+\r
+#if defined(_MSC_VER) || defined(_QC) || defined(__WATCOM__)\r
+    #pragma pack(1)\r
+#elif defined(__ZTC__)\r
+    #pragma ZTC align 1\r
+#elif defined(__TURBOC__) && (__TURBOC__ > 0x202)\r
+    #pragma option -a-\r
+#endif\r
+\r
+/* use this structure in place of compiler-defined file structure */\r
+\r
+typedef struct {\r
+      char        reserved[21];\r
+      char        attrib;\r
+      unsigned    time;\r
+      unsigned    date;\r
+      long        size;\r
+      char        name[13];\r
+      } DOSFileData;\r
+\r
+/* set structure alignment to default */\r
+\r
+#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__)\r
+ #pragma pack()\r
+#elif defined (__ZTC__)\r
+ #pragma ZTC align\r
+#elif defined(__TURBOC__) && (__TURBOC__ > 0x202)\r
+ #pragma option -a.\r
+#endif\r
+\r
+/* include proper header files and create macros */\r
+\r
+#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC)\r
+ #include "direct.h"\r
+ #define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\\r
+       (struct find_t *)buf)\r
+ #define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf)\r
+#elif defined (__TURBOC__)\r
+ #include "dir.h"\r
+ #define FIND_FIRST(spec,attr,buf) findfirst(spec,(struct ffblk *)buf,attr)\r
+ #define FIND_NEXT(buf) findnext((struct ffblk *)buf)\r
+#elif defined (__ZTC__)\r
+ #include "dos.h"\r
+ #define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\\r
+       (struct find_t *)buf)\r
+ #define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf)\r
+#endif\r
+\r
+/*----------------------------------------------------------------------------\r
+    I/O Port Macros\r
+\r
+    IN_PORT     read byte from I/O port\r
+    IN_PORTW    read word from I/O port\r
+    OUT_PORT    write byte to I/O port\r
+    OUT_PORTW   write word to I/O port\r
+----------------------------------------------------------------------------*/\r
+\r
+#if defined(__TURBOC__)\r
+ #include "dos.h"\r
+ #define IN_PORT(port)           inportb(port)\r
+ #define IN_PORTW(port)          inport(port)\r
+ #define OUT_PORT(port, val)     outportb(port, val)\r
+ #define OUT_PORTW(port, val)    outport(port, val)\r
+#else\r
+ #include "conio.h"\r
+\r
+ #define IN_PORT(port)           inp(port)\r
+ #define IN_PORTW(port)          inpw(port)\r
+ #define OUT_PORT(port, val)     outp(port, val)\r
+ #define OUT_PORTW(port, val)    outpw(port, val)\r
+\r
+/*----------------------------------------------------------------------------\r
+    Borland pseudo register macros\r
+\r
+    These macros replace references to Borland's pseudo register\r
+    variables and geninterrup() funciton with traditional struct\r
+    REGS/int86 references.\r
+----------------------------------------------------------------------------*/\r
+\r
+#if !defined(__TURBOC__)\r
+ #include "dos.h"\r
+\r
+ extern union REGS CPURegs;\r
+\r
+ #define _AX CPURegs.x.ax\r
+ #define _BX CPURegs.x.bx\r
+ #define _CX CPURegs.x.cx\r
+ #define _DX CPURegs.x.dx\r
+\r
+ #define _AH CPURegs.h.ah\r
+ #define _AL CPURegs.h.al\r
+ #define _BH CPURegs.h.bh\r
+ #define _BL CPURegs.h.bl\r
+ #define _CH CPURegs.h.ch\r
+ #define _CL CPURegs.h.cl\r
+ #define _DH CPURegs.h.dh\r
+ #define _DL CPURegs.h.dl\r
+\r
+ #define geninterrupt(n) int86(n,&CPURegs,&CPURegs);\r
+ #define O_DENYALL   0x10\r
+ #define O_DENYWRITE 0x20\r
+ #define O_DENYREAD  0x30\r
+ #define O_DENYNONE  0x40\r
+#endif\r
+\r
+#endif\r
+\r
+/*----------------------------------------------------------------------------\r
+    Pointer-related macros\r
+\r
+    MK_FP   creates a far pointer from segment and offset values\r
+----------------------------------------------------------------------------*/\r
+\r
+#if !defined(MK_FP)\r
+    #define MK_FP(seg,off) ((void FAR *)(((long)(seg) << 16)|(unsigned)(off)))\r
+#endif\r
+\r
+#endif\r