DCL 3.7.4
Loading...
Searching...
No Matches
_unistd.cpp
Go to the documentation of this file.
1
2#include <dcl/Config.h>
3
4#ifndef __WINNT__
5
6#include <errno.h> // errno
7#if defined(_AIX) || defined(__sun__)
8 #include <alloca.h>
9#endif
10#include <stdlib.h> // alloca
11#include <limits.h> // PATH_MAX
12#include <dcl/_unistd.h>
13#include <dcl/Object.h> // __T(str)
14#include <dcl/String.h>
15
16#include "__strumbs.h"
17
18#if __DCL_HAVE_THIS_FILE__
19#undef __THIS_FILE__
20static const char_t __UNUSED__ __THIS_FILE__[] = __T("dcl/_unistd.cpp");
21#endif
22
23__DCL_BEGIN_NAMESPACE
24
25int __access(const String& _path, int _type)
26{
27 STRTOMBS_ER(_path, path);
28 return access(path, _type);
29}
30
31int __chown(const String& _path, uid_t _owner, gid_t _group)
32{
33 STRTOMBS_ER(_path, path);
34 return chown(path, _owner, _group);
35}
36
37int __lchown(const String& _path, uid_t _owner, gid_t _group)
38{
39 STRTOMBS_ER(_path, path);
40 return lchown(path, _owner, _group);
41}
42
43int __chdir(const String& _path)
44{
45 STRTOMBS_ER(_path, path);
46 return chdir(path);
47}
48
49int __getcwd(String& _r)
50{
51 char buf[PATH_MAX + 1];
52 char* s = getcwd(buf, sizeof(buf));
53 if (s) {
54 MBSTOSTR_ER(s, (size_t)-1, _r);
55 return 0;
56 }
57 return -1;
58}
59
60int __ttyname(int fd, String& _r)
61{
62 char buf[PATH_MAX + 1];
63 int n = ttyname_r(fd, buf, sizeof(buf));
64 if (n == 0)
65 MBSTOSTR_ER(buf, (size_t)-1, _r);
66 return n;
67}
68
69int __link(const String& _from, const String& _to)
70{
71 STRTOMBS_ER(_from, from);
72 STRTOMBS_ER(_to, to);
73 return link(from, to);
74}
75
76int __symlink(const String& _from, const String& _to)
77{
78 STRTOMBS_ER(_from, from);
79 STRTOMBS_ER(_to, to);
80 return symlink(from, to);
81}
82
83ssize_t __readlink(const String& _path, String& _r)
84{
85 STRTOMBS_ER(_path, path);
86 char buf[PATH_MAX + 1];
87 ssize_t n = readlink(path, buf, sizeof(buf));
88 if (n != -1) {
89 MBSTOSTR_ER(buf, n, _r);
90 return _r.length();
91 }
92 return n;
93}
94
95int __unlink(const String& _path)
96{
97 STRTOMBS_ER(_path, path);
98 return unlink(path);
99}
100
101int __rmdir(const String& _path)
102{
103 STRTOMBS_ER(_path, path);
104 return rmdir(path);
105}
106
107int __getlogin(String& _r)
108{
109 char buf[PATH_MAX + 1];
110 int n = getlogin_r(buf, sizeof(buf));
111 if (n == 0)
112 MBSTOSTR_ER(buf, (size_t)-1, _r);
113 return n;
114}
115
116int __gethostname(String& _r)
117{
118 char buf[PATH_MAX + 1];
119 int n = gethostname(buf, sizeof(buf));
120 if (n == 0)
121 MBSTOSTR_ER(buf, (size_t)-1, _r);
122 return n;
123}
124#if !(defined(_AIX) || defined(__sun))
125int __getdomainname(String _r)
126{
127 char buf[PATH_MAX + 1];
128 int n = getdomainname(buf, sizeof(buf));
129 if (n == 0)
130 MBSTOSTR_ER(buf, (size_t)-1, _r);
131 return n;
132}
133#endif
134int __truncate(const String& _path, off_t _len)
135{
136 STRTOMBS_ER(_path, path);
137 return truncate(path, _len);
138}
139
140__DCL_END_NAMESPACE
141
142#endif // __WINNT__
#define STRTOMBS_ER(str, mbs)
Definition __strumbs.h:33
#define MBSTOSTR_ER(mbs, nmbs, str)
Definition __strumbs.h:19
#define __THIS_FILE__
Definition _trace.h:14
int __symlink(const String &_from, const String &_to)
Definition _unistd.cpp:76
int __lchown(const String &_path, uid_t _owner, gid_t _group)
Definition _unistd.cpp:37
int __getlogin(String &_r)
Definition _unistd.cpp:107
int __chdir(const String &_path)
Definition _unistd.cpp:43
int __link(const String &_from, const String &_to)
Definition _unistd.cpp:69
int __gethostname(String &_r)
Definition _unistd.cpp:116
int __unlink(const String &_path)
Definition _unistd.cpp:95
int __getdomainname(String _r)
Definition _unistd.cpp:125
int __getcwd(String &_r)
Definition _unistd.cpp:49
int __rmdir(const String &_path)
Definition _unistd.cpp:101
ssize_t __readlink(const String &_path, String &_r)
Definition _unistd.cpp:83
int __truncate(const String &_path, off_t _len)
Definition _unistd.cpp:134
int __chown(const String &_path, uid_t _owner, gid_t _group)
Definition _unistd.cpp:31
__DCL_BEGIN_NAMESPACE int __access(const String &_path, int _type)
Definition _unistd.cpp:25
int __ttyname(int fd, String &_r)
Definition _unistd.cpp:60
#define __UNUSED__
Definition Config.h:341
wchar_t char_t
Definition Config.h:247
#define __T(str)
Definition Object.h:60