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