home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / PAX20.ZIP / PORT.H < prev    next >
C/C++ Source or Header  |  1990-11-12  |  4KB  |  125 lines

  1. /* $Source: /u/mark/src/pax/RCS/port.h,v $
  2.  *
  3.  * $Revision: 2.0.0.4 $
  4.  *
  5.  * port.h - defnitions for portability library
  6.  *
  7.  * DESCRIPTION
  8.  *
  9.  *    Header for maintaing portablilty across operating system and
  10.  *    version boundries.  For the most part, this file contains
  11.  *    definitions which map functions which have the same functionality
  12.  *    but different names on different systems, to have the same name.
  13.  *
  14.  * AUTHORS
  15.  *
  16.  *    Mark H. Colburn, Open Systems Architects, Inc. (mark@minnetech.mn.org)
  17.  *    John Gilmore (gnu@hoptoad)
  18.  *
  19.  * COPYRIGHT
  20.  *
  21.  *    Copyright (c) 1989 Mark H. Colburn.  All rights reserved.
  22.  *
  23.  *    Redistribution and use in source and binary forms are permitted
  24.  *    provided that the above copyright notice and this paragraph are
  25.  *    duplicated in all such forms and that any documentation,
  26.  *    advertising materials, and other materials related to such
  27.  *    distribution and use acknowledge that the software was developed
  28.  *    by Mark H. Colburn.
  29.  *
  30.  *    THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  31.  *    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  32.  *    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  33.  */
  34.  
  35. #ifndef _PAX_PORT_H
  36. #define _PAX_PORT_H
  37.  
  38. /*
  39.  * Everybody does wait() differently.  There seem to be no definitions for
  40.  * this in V7 (e.g. you are supposed to shift and mask things out using
  41.  * constant shifts and masks.)  In order to provide the functionality, here
  42.  * are some non standard but portable macros.  Don't change to a "union wait"
  43.  * based approach -- the ordering of the elements of the struct depends on the
  44.  * byte-sex of the machine.
  45.  */
  46.  
  47. #define    TERM_SIGNAL(status)    ((status) & 0x7F)
  48. #define TERM_VALUE(status)    ((status) >> 8)
  49.  
  50. #ifdef MSDOS
  51.  
  52. #include <io.h>
  53. #define    major(x)    (0)
  54. #define    minor(x)    (0)
  55. #define    makedev(x,y)    (0)
  56.  
  57. struct passwd {
  58.     char           *pw_name;
  59.     char           *pw_passwd;
  60.     int            pw_uid;
  61.     int            pw_gid;
  62.     int            pw_quota;
  63.     char           *pw_comment;
  64.     char           *pw_gecos;
  65.     char           *pw_dir;
  66.     char           *pw_shell;
  67. };
  68.  
  69. struct group {
  70.     char           *gr_name;
  71.     char           *gr_passwd;
  72.     int            gr_gid;
  73.     char          **gr_mem;
  74. };
  75.  
  76. #endif /* MSDOS */
  77.  
  78.  
  79. #ifdef MSDOS
  80.  
  81. #if defined(DIO)
  82.  
  83. #define OPEN2(p,f) \
  84.     ( (dio_open_check(p) < 0) ? dio_open2(p,f) : open(p,f) )
  85. #define OPEN3(p,f,m) \
  86.     ( (dio_open_check(p) < 0) ? dio_open3(p,f,m) : open(p,f,m) )
  87. #define CLOSE(h) \
  88.     ( (h < 0) ? dio_close(h) : close(h) )
  89. #define READ(h,b,c) \
  90.     ( (h < 0) ? dio_read(h,b,c) : read(h,b,c) )
  91. #define WRITE(h,b,c) \
  92.     ( (h < 0) ? dio_write(h,b,c) : write(h,b,c) )
  93. #define LSEEK(h,o,r) \
  94.     ( (h < 0) ? dio_lseek(h,o,r) : lseek(h,o,r) )
  95.  
  96. #elif defined(DISKACC)
  97.  
  98. #define _DSKBIAS                128
  99.  
  100. #define dskdev(path)            ((path[1] == ':' && path[2] == 0))
  101. #define isdsk(fd)               ((fd) >= _DSKBIAS)
  102.  
  103. #define OPEN2(path,oflag)       (dskdev(path) ? dsk_open(path, oflag, 0) + _DSKBIAS : open(path, oflag))
  104. #define OPEN3(path,oflag,mode)  (dskdev(path) ? dsk_open(path, oflag, mode) + _DSKBIAS : open(path, oflag, mode))
  105. #define READ(fd, buf, n)        (isdsk(fd) ? dsk_read(fd - _DSKBIAS, buf, n) : read(fd, buf, n))
  106. #define WRITE(fd, buf, n)       (isdsk(fd) ? dsk_write(fd - _DSKBIAS, buf, n) : write(fd, buf, n))
  107. #define LSEEK(fd, off, wh)      (isdsk(fd) ? dsk_lseek(fd - _DSKBIAS, off, wh) : lseek(fd, off, wh))
  108. #define CLOSE(fd)               (isdsk(fd) ? dsk_close(fd - _DSKBIAS) : close(fd))
  109.  
  110. #else
  111.  
  112. #define OPEN2(p,f) open(p,f)
  113. #define OPEN3(p,f,m) open(p,f,m)
  114. #define CLOSE(h) close(h)
  115. #define READ(h,b,c) read(h,b,c)
  116. #define WRITE(h,b,c) write(h,b,c)
  117. #define LSEEK(h,o,r) lseek(h,o,r)
  118.  
  119. #endif
  120.  
  121. #endif /* MSDOS */
  122. #endif /* _PAX_PORT_H */
  123.  
  124.  
  125.