summaryrefslogtreecommitdiff
path: root/ext/posix/POSIX.xs
blob: 7981f8818bd6fa6da44dba47dfa54696983be4f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <sys/utsname.h>

#define HAS_UNAME

#ifndef HAS_GETPGRP
#define getpgrp(a,b) not_here("getpgrp")
#endif
#ifndef HAS_NICE
#define nice(a) not_here("nice")
#endif
#ifndef HAS_READLINK
#define readlink(a,b,c) not_here("readlink")
#endif
#ifndef HAS_SETPGID
#define setpgid(a,b) not_here("setpgid")
#endif
#ifndef HAS_SETPGRP
#define setpgrp(a,b) not_here("setpgrp")
#endif
#ifndef HAS_SETSID
#define setsid() not_here("setsid")
#endif
#ifndef HAS_SYMLINK
#define symlink(a,b) not_here("symlink")
#endif
#ifndef HAS_TCGETPGRP
#define tcgetpgrp(a) not_here("tcgetpgrp")
#endif
#ifndef HAS_TCSETPGRP
#define tcsetpgrp(a,b) not_here("tcsetpgrp")
#endif
#ifndef HAS_TIMES
#define times(a) not_here("times")
#endif
#ifndef HAS_UNAME
#define uname(a) not_here("uname")
#endif
#ifndef HAS_WAITPID
#define waitpid(a,b,c) not_here("waitpid")
#endif

static int
not_here(s)
char *s;
{
    croak("POSIX::%s not implemented on this architecture", s);
    return -1;
}

MODULE = POSIX	PACKAGE = POSIX

void
_exit(status)
	int		status

int
chdir(path)
	char *		path

int
chmod(path, mode)
	char *		path
	mode_t		mode

int
close(fd)
	int		fd

int
dup(fd)
	int		fd

int
dup2(fd1, fd2)
	int		fd1
	int		fd2

FILE *
fdopen(fd, type)
	int		fd
	char *		type

int
fstat(fd, buf)
	int		fd
	struct stat *	buf = (struct stat*)sv_grow(ST(2),sizeof(struct stat));
	CLEANUP:
	SvCUR(ST(2)) = sizeof(struct stat);

int
getpgrp(pid)
	int		pid

int
link()

int
lseek()

int
lstat()

int
mkdir()

int
nice(incr)
	int		incr

int
open()

int
pipe()

int
read()

int
readlink(path, buf, bufsiz)
	char *		path
	char *		buf = sv_grow(ST(2), SvIV(ST(3)));
	int		bufsiz

int
rename()

int
rmdir()

int
setgid()

int
setpgid(pid, pgid)
	pid_t		pid
	pid_t		pgid

int
setpgrp(pid, pgrp)
	int		pid
	int		pgrp

pid_t
setsid()

int
setuid()

int
stat()

int
symlink()

int
system()

pid_t
tcgetpgrp(fd)
	int		fd

int
tcsetpgrp(fd, pgrp_id)
	int		fd
	pid_t		pgrp_id

int
times(tms)
	struct tms *	tms = (struct tms*)sv_grow(ST(1), sizeof(struct tms));
	CLEANUP:
	SvCUR(ST(1)) = sizeof(struct tms);

int
umask()

int
uname()
	CODE:
	dSP;
	struct utsname utsname;
	sp--;
	if (uname(&utsname) >= 0) {
	    EXTEND(sp, 5);
	    PUSHs(sv_2mortal(newSVpv(utsname.sysname, 0)));
	    PUSHs(sv_2mortal(newSVpv(utsname.nodename, 0)));
	    PUSHs(sv_2mortal(newSVpv(utsname.release, 0)));
	    PUSHs(sv_2mortal(newSVpv(utsname.version, 0)));
	    PUSHs(sv_2mortal(newSVpv(utsname.machine, 0)));
	}
	return sp - stack_base;

int
unlink()

int
utime()

int
wait()

int
waitpid(pid, statusp, options)
	int		pid
	int		&statusp
	int		options
	OUTPUT:
	statusp

int
write()