port.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* $Source: /u/mark/src/pax/RCS/port.h,v $
  2. *
  3. * $Revision: 1.2 $
  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, NAPS International (mark@jhereg.mn.org)
  17. * John Gilmore (gnu@hoptoad)
  18. *
  19. * Sponsored by The USENIX Association for public distribution.
  20. *
  21. * Copyright (c) 1989 Mark H. Colburn.
  22. * All rights reserved.
  23. *
  24. * Redistribution and use in source and binary forms are permitted
  25. * provided that the above copyright notice and this paragraph are
  26. * duplicated in all such forms and that any documentation,
  27. * advertising materials, and other materials related to such
  28. * distribution and use acknowledge that the software was developed
  29. * by Mark H. Colburn and sponsored by The USENIX Association.
  30. *
  31. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  32. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  33. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  34. */
  35. #ifndef _PAX_PORT_H
  36. #define _PAX_PORT_H
  37. /*
  38. * Everybody does wait() differently. There seem to be no definitions for
  39. * this in V7 (e.g. you are supposed to shift and mask things out using
  40. * constant shifts and masks.) In order to provide the functionality, here
  41. * are some non standard but portable macros. Don't change to a "union wait"
  42. * based approach -- the ordering of the elements of the struct depends on the
  43. * byte-sex of the machine.
  44. */
  45. #define TERM_SIGNAL(status) ((status) & 0x7F)
  46. #define TERM_COREDUMP(status) (((status) & 0x80) != 0)
  47. #define TERM_VALUE(status) ((status) >> 8)
  48. /*
  49. * String library emulation definitions for the different variants of UNIX
  50. */
  51. #if defined(USG)
  52. # include <string.h>
  53. #ifndef _POSIX_SOURCE
  54. # include <memory.h>
  55. #endif
  56. #else /* USG */
  57. /*
  58. * The following functions are defined here since func.h has no idea which
  59. * of the functions will actually be used.
  60. */
  61. # ifdef __STDC__
  62. extern char *rindex(char *, char);
  63. extern char *index(char *, char);
  64. extern char *bcopy(char *, char *, unsigned int);
  65. extern char *bzero(char *, unsigned int);
  66. extern char *strcat(char *, char *);
  67. extern char *strcpy(char *, char *);
  68. # else /* !__STDC__ */
  69. extern char *rindex();
  70. extern char *index();
  71. extern char *bcopy();
  72. extern char *bzero();
  73. extern char *strcat();
  74. extern char *strcpy();
  75. # endif /* __STDC__ */
  76. /*
  77. * Map ANSI C compatible functions to V7 functions
  78. */
  79. # define memcpy(a,b,n) bcopy((b),(a),(n))
  80. # define memset(a,b,n) bzero((a),(n))
  81. # define strrchr(s,c) rindex(s,c)
  82. # define strchr(s,c) index(s,c)
  83. #endif /* USG */
  84. #endif /* _PAX_PORT_H */