unistd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_COMPAT_UNISTD_H
10 #define SQUID_COMPAT_UNISTD_H
11 
12 #if HAVE_PATHS_H
13 #include <paths.h>
14 #endif
15 #if HAVE_UNISTD_H
16 #include <unistd.h>
17 #endif
18 
20 int xclose(int fd);
21 
23 int xgethostname(char *name, size_t nameLength);
24 
26 int xopen(const char *filename, int oflag, int pmode = 0);
27 
29 int xread(int fd, void * buf, size_t bufSize);
30 
32 int xwrite(int fd, const void * buf, size_t bufSize);
33 
34 #if _SQUID_WINDOWS_ || _SQUID_MINGW_
35 
36 #if !defined(_PATH_DEVNULL)
37 #define _PATH_DEVNULL "NUL"
38 #endif
39 
40 #else /* _SQUID_WINDOWS_ || _SQUID_MINGW_ */
41 
42 inline int
43 xclose(int fd)
44 {
45  return close(fd);
46 }
47 
48 inline int
49 xgethostname(char *name, size_t nameLength)
50 {
51  return gethostname(name, nameLength);
52 }
53 
54 inline int
55 xopen(const char *filename, int oflag, int pmode)
56 {
57  return open(filename, oflag, pmode);
58 }
59 
60 inline int
61 xread(int fd, void * buf, size_t bufSize)
62 {
63  return read(fd, buf, bufSize);
64 }
65 
66 inline int
67 xwrite(int fd, const void * buf, size_t bufSize)
68 {
69  return write(fd, buf, bufSize);
70 }
71 
72 #endif /* _SQUID_WINDOWS_ || _SQUID_MINGW_ */
73 #endif /* SQUID_COMPAT_UNISTD_H */
int xwrite(int fd, const void *buf, size_t bufSize)
POSIX write(2) equivalent.
Definition: unistd.h:67
int xread(int fd, void *buf, size_t bufSize)
POSIX read(2) equivalent.
Definition: unistd.h:61
int xopen(const char *filename, int oflag, int pmode=0)
POSIX open(2) equivalent.
Definition: unistd.h:55
int xclose(int fd)
POSIX close(2) equivalent.
Definition: unistd.h:43
int xgethostname(char *name, size_t nameLength)
POSIX gethostname(2) equivalent.
Definition: unistd.h:49

 

Introduction

Documentation

Support

Miscellaneous