Squid Web Cache master
Loading...
Searching...
No Matches
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
20int xclose(int fd);
21
23int xgethostname(char *name, size_t nameLength);
24
26int xopen(const char *filename, int oflag, int pmode = 0);
27
29int xread(int fd, void * buf, size_t bufSize);
30
32int 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
42inline int
43xclose(int fd)
44{
45 return close(fd);
46}
47
48inline int
49xgethostname(char *name, size_t nameLength)
50{
51 return gethostname(name, nameLength);
52}
53
54inline int
55xopen(const char *filename, int oflag, int pmode)
56{
57 return open(filename, oflag, pmode);
58}
59
60inline int
61xread(int fd, void * buf, size_t bufSize)
62{
63 return read(fd, buf, bufSize);
64}
65
66inline int
67xwrite(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 xread(int fd, void *buf, size_t bufSize)
POSIX read(2) equivalent.
Definition unistd.h:61
int xwrite(int fd, const void *buf, size_t bufSize)
POSIX write(2) equivalent.
Definition unistd.h:67
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
int xopen(const char *filename, int oflag, int pmode=0)
POSIX open(2) equivalent.
Definition unistd.h:55