rxunixsys.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 2009-2021 Rexx Language Association. All rights reserved. */
4 /* */
5 /* This program and the accompanying materials are made available under */
6 /* the terms of the Common Public License v1.0 which accompanies this */
7 /* distribution. A copy is also available at the following address: */
8 /* https://www.oorexx.org/license.html */
9 /* */
10 /* Redistribution and use in source and binary forms, with or */
11 /* without modification, are permitted provided that the following */
12 /* conditions are met: */
13 /* */
14 /* Redistributions of source code must retain the above copyright */
15 /* notice, this list of conditions and the following disclaimer. */
16 /* Redistributions in binary form must reproduce the above copyright */
17 /* notice, this list of conditions and the following disclaimer in */
18 /* the documentation and/or other materials provided with the distribution. */
19 /* */
20 /* Neither the name of Rexx Language Association nor the names */
21 /* of its contributors may be used to endorse or promote products */
22 /* derived from this software without specific prior written permission. */
23 /* */
24 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
25 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
26 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
27 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
28 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
29 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
30 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
31 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
32 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
33 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
34 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
35 /* */
36 /*----------------------------------------------------------------------------*/
37 
38 
39 #ifndef ORXUNIXAPI_H
40 #define ORXUNIXAPI_H
41 
42 #ifdef HAVE_CONFIG_H
43 # include "config.h"
44 #endif
45 
46 #include <oorexxapi.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <stdio.h>
50 #include <sys/types.h>
51 #include <sys/stat.h>
52 #include <sys/utsname.h>
53 #include <signal.h>
54 #include <unistd.h>
55 #include <pwd.h>
56 #include <grp.h>
57 #include <time.h>
58 #include <netdb.h>
59 #include <arpa/inet.h>
60 #ifdef HAVE_WORDEXP_H
61 #include <wordexp.h>
62 #endif
63 #ifdef HAVE_ALLOCA
64 #include <alloca.h>
65 #endif
66 #include <pthread.h>
67 #include <errno.h>
68 #include <dirent.h>
69 
70 #ifdef HAVE_SYS_XATTR_H
71 #define HAVE_XATTR 1
72 #include <sys/xattr.h>
73 #endif
74 
75 /*----------------------------------------------------------------------------*/
76 /* Definitions */
77 /*----------------------------------------------------------------------------*/
78 
79 #if defined(__APPLE__)
80 # define stat64 stat
81 
82 // on DARWIN the xattr functions have additional arguments
83 // ssize_t getxattr(const char *path, const char *name, void *value, size_t size, u_int32_t position, int options);
84 // int setxattr(const char *path, const char *name, const void *value, size_t size, u_int32_t position, int options);
85 // int removexattr(const char *path, const char *name, int options);
86 // ssize_t listxattr(const char *path, char *namebuff, size_t size, int options);
87 #define GetXattr(path, name, value, size) getxattr(path, name, value, size, 0, 0)
88 #define SetXattr(path, name, value, size, options) setxattr(path, name, value, size, 0, options)
89 #define RemoveXattr(path, name) removexattr(path, name, 0)
90 #define ListXattr(path, namebuff, size) listxattr(path, namebuff, size, 0)
91 #else
92 #define GetXattr getxattr
93 #define SetXattr setxattr
94 #define RemoveXattr removexattr
95 #define ListXattr listxattr
96 #endif
97 
98 #if defined(OPSYS_NETBSD) || defined(OPSYS_FREEBSD) || defined(OPSYS_OPENBSD)
99 #define stat64 stat
100 #endif
101 
102 #if !defined(HOST_NAME_MAX) && defined(_POSIX_HOST_NAME_MAX)
103 # define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
104 #endif
105 
106 /*----------------------------------------------------------------------------*/
107 /* Global variables */
108 /*----------------------------------------------------------------------------*/
109 
110 
111 #endif /* ORXUNIXAPI_H */
112