1003.xs

filter: Statementstmt 33.7% 60 / 178 Branchbran 8.2% 12 / 146 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 22.2% 72 / 324 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/POSIX/1003/Proc.pm ↑ Summary symbols.PL »
1 #define PERL_EXT_POSIX_1003
2  
3 #include "EXTERN.h"
4  
5 /* We need our hands on the pure config, because CORE/perl.h makes
6 some "smart" changes :(
7  
8 For now, we believe CORE/config.h for the following variables:
9 I_UNISTD
10 I_FCNTL
11 I_POLL
12 I_SYS_POLL
13 I_SYS_RESOURCE
14 I_ULIMIT
15  
16 HAS_FCNTL
17 HAS_SETEUID
18 HAS_SETREUID
19 HAS_SETREGID
20 HAS_SETRESGID
21 HAS_SETRESUID
22 HAS_GETGROUPS
23 HAS_SETGROUPS
24 HAS_POLL
25 HAS_STRERROR
26 */
27  
28 #ifdef PERL_MICRO
29 # include "uconfig.h"
30 #elif USE_CROSS_COMPILE
31 # include "xconfig.h"
32 #else
33 # include "config.h"
34 #endif
35  
36 /* Get Perl's smartness
37
38 We like only to provide setre[ug]id when it is pure, not a rewrite
39 to getres[ug]id. There are too many system dependencies/bug etc
40 in these library functions to cover it up.
41 */
42  
43 #ifdef HAS_SETREUID
44 #define _HAS_SETREUID
45 #endif
46  
47 #ifdef HAS_SETREGID
48 #define _HAS_SETREGID
49 #endif
50  
51 #include "perl.h"
52  
53 #ifdef _HAS_SETREUID
54 #undef _HAS_SETREUID
55 #undef HAS_SETREUID
56 #endif
57  
58 #ifdef _HAS_SETREGID
59 #undef _HAS_SETREGID
60 #undef HAS_SETREGID
61 #endif
62  
63 /* Now some Perl-guts
64 */
65  
66 #include "XSUB.h"
67  
68 /* My own extensions
69 Overrule via files in the "system" sub-directory of this distribution.
70 */
71  
72 #ifndef HAS_CONFSTR
73 #define HAS_CONFSTR
74 #endif
75  
76 #ifndef HAS_ULIMIT
77 #define HAS_ULIMIT
78 #endif
79  
80 #ifndef HAS_RLIMIT
81 #define HAS_RLIMIT
82 #endif
83  
84 #ifndef HAS_MKNOD
85 #define HAS_MKNOD
86 #endif
87  
88 #ifndef HAS_STRSIGNAL
89 #define HAS_STRSIGNAL
90 #endif
91  
92 #ifndef HAS_SETUID
93 #define HAS_SETUID
94 #endif
95  
96 #ifndef CACHE_UID
97 #if PERL_VERSION < 15 || PERL_VERSION == 15 && PERL_SUBVERSION < 8
98 #define CACHE_UID
99 #endif
100 #endif
101  
102 #ifdef HAS_FCNTL
103 # ifndef HAS_FCNTL_OWN_EX
104 # define HAS_FCNTL_OWN_EX
105 # endif
106 #endif
107  
108 #ifndef HAS_FLOCK
109 #define HAS_FLOCK
110 #endif
111  
112 #ifndef HAS_LOCKF
113 #define HAS_LOCKF
114 #endif
115  
116 #ifndef HAS_FTRUNCATE
117 #define HAS_FTRUNCATE
118 #endif
119  
120 /*
121 * work-arounds for various operating systems
122 */
123  
124 #include "system.c"
125  
126 #ifdef I_UNISTD
127 #include <unistd.h>
128 #endif
129  
130 #ifdef I_FCNTL
131 #include <fcntl.h>
132 #endif
133  
134 #ifdef HAS_ULIMIT
135 # ifdef I_ULIMIT
136 # define I_ULIMIT
137 # endif
138 # include <ulimit.h>
139 #endif
140  
141 #ifdef I_SYS_RESOURCE
142 #include <sys/resource.h>
143 #endif
144  
145 #ifdef I_POLL
146 #include <poll.h>
147 #else
148 #ifdef I_SYS_POLL
149 #include <sys/poll.h>
150 #endif
151 #endif
152  
153 HV * sc_table = NULL;
154 HV *
155 1 fill_sysconf()
156 1 ▶{ if(sc_table) return sc_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(sc_table) return sc_table; 0 1 1
157  
158 1 sc_table = newHV();
159 #include "sysconf.c"
160 1 return sc_table;
161 }
162  
163 HV * cs_table = NULL;
164 HV *
165 1 fill_confstr()
166 1 ▶{ if(cs_table) return cs_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(cs_table) return cs_table; 0 1 1
167  
168 1 cs_table = newHV();
169 #include "confstr.c"
170 1 return cs_table;
171 }
172  
173 HV * pc_table = NULL;
174 HV *
175 1 fill_pathconf()
176 1 ▶{ if(pc_table) return pc_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(pc_table) return pc_table; 0 1 1
177  
178 1 pc_table = newHV();
179 #include "pathconf.c"
180 1 return pc_table;
181 }
182  
183 HV * sig_table = NULL;
184 HV *
185 1 fill_signals()
186 1 ▶{ if(sig_table) return sig_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(sig_table) return sig_table; 0 1 1
187  
188 1 sig_table = newHV();
189 #include "signals.c"
190 1 return sig_table;
191 }
192  
193 HV * pr_table = NULL;
194 HV *
195 1 fill_properties()
196 1 ▶{ if(pr_table) return pr_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(pr_table) return pr_table; 0 1 1
197  
198 1 pr_table = newHV();
199 #include "properties.c"
200 1 return pr_table;
201 }
202  
203 HV * fdio_table = NULL;
204 HV *
205 1 fill_fdio()
206 1 ▶{ if(fdio_table) return fdio_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(fdio_table) return fdio_table; 0 1 1
207  
208 1 fdio_table = newHV();
209 #include "fdio.c"
210 1 return fdio_table;
211 }
212  
213 HV * fcntl_table = NULL;
214 HV *
215 1 fill_fcntl()
216 1 ▶{ if(fcntl_table) return fcntl_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(fcntl_table) return fcntl_table; 0 1 1
217  
218 1 fcntl_table = newHV();
219 #include "fcntl.c"
220 1 return fcntl_table;
221 }
222  
223 HV * fsys_table = NULL;
224 HV *
225 1 fill_fsys()
226 1 ▶{ if(fsys_table) return fsys_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(fsys_table) return fsys_table; 0 1 1
227  
228 1 fsys_table = newHV();
229 #include "fsys.c"
230 1 return fsys_table;
231 }
232  
233 HV * ul_table = NULL;
234 HV *
235 1 fill_ulimit()
236 1 ▶{ if(ul_table) return ul_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(ul_table) return ul_table; 0 1 1
237  
238 1 ul_table = newHV();
239 #include "ulimit.c"
240 1 return ul_table;
241 }
242  
243 HV * rl_table = NULL;
244 HV *
245 1 fill_rlimit()
246 1 ▶{ if(rl_table) return rl_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(rl_table) return rl_table; 0 1 1
247  
248 1 rl_table = newHV();
249 #include "rlimit.c"
250 1 return rl_table;
251 }
252  
253 HV * poll_table = NULL;
254 HV *
255 1 fill_poll()
256 1 ▶{ if(poll_table) return poll_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(poll_table) return poll_table; 0 1 1
257  
258 1 poll_table = newHV();
259 #include "poll.c"
260 1 return poll_table;
261 }
262  
263 HV * errno_table = NULL;
264 HV *
265 1 fill_errno()
266 1 ▶{ if(errno_table) return errno_table;
Branch: 1 branch
BranchTrueFalseTotal
{ if(errno_table) return errno_table; 0 1 1
267  
268 1 errno_table = newHV();
269 #include "errno.c"
270 1 return errno_table;
271 }
272  
273 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Sysconf
274  
275 HV *
276 sysconf_table()
277 PROTOTYPE:
278 CODE:
279 1 RETVAL = fill_sysconf();
280 OUTPUT:
281 RETVAL
282  
283 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Signals
284  
285 HV *
286 signals_table()
287 PROTOTYPE:
288 CODE:
289 1 RETVAL = fill_signals();
290 OUTPUT:
291 RETVAL
292  
293 SV *
294 _strsignal(signr)
295 int signr;
296 PROTOTYPE: $
297 PREINIT:
298 char * buf;
299 CODE:
300 #ifdef HAS_STRSIGNAL
301 0 buf = strsignal(signr);
302 0 ▶ RETVAL = buf==NULL ? &PL_sv_undef : newSVpv(buf, 0);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = buf==NULL ? &PL_sv_undef : newSVpv(buf, 0); 0 0 0
303 #else
304 errno = ENOSYS;
305 RETVAL = &PL_sv_undef;
306 #endif
307 OUTPUT:
308 RETVAL
309  
310 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Confstr
311  
312 HV *
313 confstr_table()
314 PROTOTYPE:
315 CODE:
316 1 RETVAL = fill_confstr();
317 OUTPUT:
318 RETVAL
319  
320 SV *
321 _confstr(name)
322 int name;
323 PROTOTYPE: $
324 PREINIT:
325 char buf[4096];
326 STRLEN len;
327 CODE:
328 #ifdef HAS_CONFSTR
329 0 len = confstr(name, buf, sizeof(buf));
330 0 ▶ RETVAL = len==0 ? &PL_sv_undef : newSVpv(buf, len-1);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = len==0 ? &PL_sv_undef : newSVpv(buf, len-1); 0 0 0
331 #else
332 errno = ENOSYS;
333 RETVAL = &PL_sv_undef;
334 #endif
335 OUTPUT:
336 RETVAL
337  
338 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Pathconf
339  
340 HV *
341 pathconf_table()
342 PROTOTYPE:
343 CODE:
344 1 RETVAL = fill_pathconf();
345 OUTPUT:
346 RETVAL
347  
348 MODULE = POSIX::1003 PACKAGE = POSIX::1003::FdIO
349  
350 HV *
351 fdio_table()
352 PROTOTYPE:
353 CODE:
354 1 RETVAL = fill_fdio();
355 OUTPUT:
356 RETVAL
357  
358 SV *
359 truncfd(fd, l = 0)
360 int fd;
361 off_t l;
362 PROTOTYPE: $;$
363 PREINIT:
364 long result;
365 CODE:
366 #ifdef HAS_FTRUNCATE
367 0 result = ftruncate(fd, l);
368 0 ▶ RETVAL = result==-1 ? &PL_sv_undef : newSViv(result);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = result==-1 ? &PL_sv_undef : newSViv(result); 0 0 0
369 #else
370 errno = ENOSYS;
371 RETVAL = &PL_sv_undef;
372 #endif
373 OUTPUT:
374 RETVAL
375  
376 MODULE = POSIX::1003 PACKAGE = POSIX::1003::FS
377  
378 HV *
379 fsys_table()
380 PROTOTYPE:
381 CODE:
382 1 RETVAL = fill_fsys();
383 OUTPUT:
384 RETVAL
385  
386 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Properties
387  
388 HV *
389 property_table()
390 PROTOTYPE:
391 CODE:
392 1 RETVAL = fill_properties();
393 OUTPUT:
394 RETVAL
395  
396 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Limit
397  
398 HV *
399 ulimit_table()
400 PROTOTYPE:
401 CODE:
402 1 RETVAL = fill_ulimit();
403 OUTPUT:
404 RETVAL
405  
406 HV *
407 rlimit_table()
408 PROTOTYPE:
409 CODE:
410 1 RETVAL = fill_rlimit();
411 OUTPUT:
412 RETVAL
413  
414 SV *
415 _ulimit(cmd, value)
416 int cmd;
417 long value;
418 PROTOTYPE: $$
419 PREINIT:
420 long result;
421 CODE:
422 #ifdef HAS_ULIMIT
423 0 result = ulimit(cmd, value);
424 0 ▶ RETVAL = result==-1 ? &PL_sv_undef : newSViv(result);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = result==-1 ? &PL_sv_undef : newSViv(result); 0 0 0
425 #else
426 errno = ENOSYS;
427 RETVAL = &PL_sv_undef;
428 #endif
429 OUTPUT:
430 RETVAL
431  
432 #ifdef HAS_RLIMIT
433 #ifdef HAS_RLIMIT_64
434  
435 void
436 _getrlimit(resource)
437 int resource;
438 PROTOTYPE: $
439 PREINIT:
440 struct rlimit64 rlim;
441 int result;
442 PPCODE:
443 /* on linux, rlim64_t is a __UQUAD_TYPE */
444 0 result = getrlimit64(resource, &rlim);
445 0 PUSHs(sv_2mortal(newSVuv(rlim.rlim_cur)));
446 0 PUSHs(sv_2mortal(newSVuv(rlim.rlim_max)));
447 0 ▶ PUSHs(result==-1 ? &PL_sv_no : &PL_sv_yes);
Branch: 1 branch
BranchTrueFalseTotal
PUSHs(result==-1 ? &PL_sv_no : &PL_sv_yes); 0 0 0
448  
449 SV *
450 _setrlimit(resource, cur, max)
451 int resource;
452 unsigned long cur;
453 unsigned long max;
454 PROTOTYPE: $$$
455 PREINIT:
456 struct rlimit64 rlim;
457 int result;
458 CODE:
459 0 rlim.rlim_cur = cur;
460 0 rlim.rlim_max = max;
461 0 result = setrlimit64(resource, &rlim);
462 0 ▶ RETVAL = result==-1 ? &PL_sv_no : &PL_sv_yes;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = result==-1 ? &PL_sv_no : &PL_sv_yes; 0 0 0
463 OUTPUT:
464 RETVAL
465  
466 #else /* HAS_RLIMIT_64 */
467  
468  
469 void
470 _getrlimit(resource)
471 int resource;
472 PROTOTYPE: $
473 PREINIT:
474 struct rlimit rlim;
475 int result;
476 PPCODE:
477 /* on linux, rlim64_t is a __ULONGWORD_TYPE */
478 result = getrlimit(resource, &rlim);
479 PUSHs(sv_2mortal(newSVuv(rlim.rlim_cur)));
480 PUSHs(sv_2mortal(newSVuv(rlim.rlim_max)));
481 PUSHs(result==-1 ? &PL_sv_no : &PL_sv_yes);
482  
483 SV *
484 _setrlimit(resource, cur, max)
485 int resource;
486 unsigned long cur;
487 unsigned long max;
488 PROTOTYPE: $$$
489 PREINIT:
490 struct rlimit rlim;
491 int result;
492 CODE:
493 rlim.rlim_cur = cur;
494 rlim.rlim_max = max;
495 result = setrlimit(resource, &rlim);
496 RETVAL = result==-1 ? &PL_sv_no : &PL_sv_yes;
497 OUTPUT:
498 RETVAL
499  
500 #endif /* HAS_RLIMIT_64 */
501 #else /* HAS_RLIMIT */
502  
503 void
504 _getrlimit(resource)
505 int resource;
506 PROTOTYPE: $
507 PPCODE:
508 PUSHs(&PL_sv_undef);
509 PUSHs(&PL_sv_undef);
510 PUSHs(&PL_sv_no);
511  
512 SV *
513 _setrlimit(resource, cur, max)
514 int resource;
515 unsigned long cur;
516 unsigned long max;
517 PROTOTYPE: $$$
518 CODE:
519 RETVAL = &PL_sv_no;
520 OUTPUT:
521 RETVAL
522  
523 #endif /* HAS_RLIMIT */
524  
525  
526 MODULE = POSIX::1003 PACKAGE = POSIX::1003::FS
527  
528 #ifdef HAS_SYSMKDEV
529 #include <sys/mkdev.h>
530 #endif
531  
532 dev_t
533 makedev(dev_t major, dev_t minor)
534 PROTOTYPE: $$
535  
536 dev_t
537 major(dev_t dev)
538 PROTOTYPE: $
539  
540 dev_t
541 minor(dev_t dev)
542 PROTOTYPE: $
543  
544 int
545 mknod(filename, mode, dev)
546 char * filename
547 mode_t mode
548 dev_t dev
549 CODE:
550 #ifdef HAS_MKNOD
551 0 RETVAL = mknod(filename, mode, dev);
552 #else
553 errno = ENOSYS;
554 RETVAL = &PL_sv_undef;
555 #endif
556 OUTPUT:
557 RETVAL
558  
559  
560 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Events
561  
562 HV *
563 poll_table()
564 PROTOTYPE:
565 CODE:
566 1 RETVAL = fill_poll();
567 OUTPUT:
568 RETVAL
569  
570  
571 HV *
572 _poll(handles, timeout)
573 HV * handles;
574 int timeout;
575 PREINIT:
576 struct pollfd * fds;
577 HV * ret;
578 char * key;
579 char key_str[8];
580 int rc;
581 HE * entry;
582 I32 len;
583 int j;
584 PPCODE:
585 #ifdef HAS_POLL
586 0 const int nfd = hv_iterinit(handles);
587 0 Newx(fds, nfd, struct pollfd);
588 0 ▶ for(j=0; j < nfd; j++)
Branch: 1 branch
BranchTrueFalseTotal
for(j=0; j < nfd; j++) 0 0 0
589 0 { entry = hv_iternext(handles);
590 0 key = hv_iterkey(entry, &len);
591 0 key[len] = 0;
592 0 fds[j].fd = atoi(key_str);
593 0 fds[j].events = SvUV(hv_iterval(handles, entry));
594 0 fds[j].revents = 0; // returned events
595 }
596 0 rc = poll(fds, nfd, timeout);
597 0 ▶ if(rc==-1)
Branch: 1 branch
BranchTrueFalseTotal
if(rc==-1) 0 0 0
598 0 ▶ { XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
{ XPUSHs(&PL_sv_undef); 0 0 0
599 }
600 else
601 0 { ret = newHV();
602 0 ▶ if(rc > 0)
Branch: 1 branch
BranchTrueFalseTotal
if(rc > 0) 0 0 0
603 0 ▶ { for(j=0; j < nfd; j++)
Branch: 1 branch
BranchTrueFalseTotal
{ for(j=0; j < nfd; j++) 0 0 0
604 0 ▶ { if(fds[j].revents)
Branch: 1 branch
BranchTrueFalseTotal
{ if(fds[j].revents) 0 0 0
605 0 { sprintf((char *)key_str, "%d", fds[j].fd);
606 0 (void)hv_store(ret, key_str, strlen(key_str), newSVuv(fds[j].revents), 0);
607 }
608 }
609 }
610 0 ▶ XPUSHs((SV*)ret);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs((SV*)ret); 0 0 0
611 }
612 0 XSRETURN(1);
613 #else
614 errno = ENOSYS;
615 XPUSHs(&PL_sv_undef);
616 #endif
617  
618 MODULE = POSIX::1003 PACKAGE = POSIX::1003::User
619  
620 void
621 setuid(uid)
622 uid_t uid
623 PROTOTYPE: $
624 INIT:
625 int result;
626 PPCODE:
627 #ifdef HAS_SETUID
628 0 result = setuid(uid);
629 #ifdef CACHE_UID
630 PL_uid = getuid();
631 PL_euid = geteuid();
632 #endif
633 #else
634 errno = ENOSYS;
635 result = -1;
636 #endif
637 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
638  
639 uid_t
640 getuid()
641 PROTOTYPE:
642 INIT:
643 int result;
644 PPCODE:
645 #ifdef HAS_SETUID
646 0 result = getuid();
647 #else
648 errno = ENOSYS;
649 result = -1;
650 #endif
651 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
652  
653 int
654 setgid(gid)
655 gid_t gid
656 PROTOTYPE: $
657 INIT:
658 int result;
659 PPCODE:
660 #ifdef HAS_SETUID
661 0 result = setgid(gid);
662 #else
663 errno = ENOSYS;
664 result = -1;
665 #endif
666 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
667  
668 gid_t
669 getgid()
670 PROTOTYPE:
671 INIT:
672 int result;
673 PPCODE:
674 #ifdef HAS_SETUID
675 0 result = getgid();
676 #ifdef CACHE_UID
677 PL_gid = getgid();
678 PL_egid = getegid();
679 #endif
680 #else
681 errno = ENOSYS;
682 result = -1;
683 #endif
684 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
685  
686  
687 int
688 seteuid(euid)
689 uid_t euid
690 PROTOTYPE: $
691 INIT:
692 int result;
693 PPCODE:
694 #ifdef HAS_SETEUID
695 0 result = seteuid(euid);
696 #ifdef CACHE_UID
697 PL_euid = geteuid();
698 #endif
699 #else
700 errno = ENOSYS;
701 result = -1;
702 #endif
703 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
704  
705 uid_t
706 geteuid()
707 PROTOTYPE:
708 INIT:
709 int result;
710 PPCODE:
711 #ifdef HAS_SETEUID
712 0 result = geteuid();
713 #ifdef CACHE_UID
714 PL_egid = getegid();
715 #endif
716 #else
717 errno = ENOSYS;
718 result = -1;
719 #endif
720 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
721  
722  
723 int
724 setegid(egid)
725 gid_t egid
726 PROTOTYPE: $
727 INIT:
728 int result;
729 PPCODE:
730 #ifdef HAS_SETEUID
731 0 result = setegid(egid);
732 #else
733 errno = ENOSYS;
734 result = -1;
735 #endif
736 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
737  
738 gid_t
739 getegid()
740 PROTOTYPE:
741 INIT:
742 int result;
743 PPCODE:
744 #ifdef HAS_SETEUID
745 0 result = getegid();
746 #else
747 errno = ENOSYS;
748 result = -1;
749 #endif
750 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
751  
752  
753 int
754 setreuid(ruid, euid)
755 uid_t ruid
756 uid_t euid
757 PROTOTYPE: $$
758 INIT:
759 int result;
760 PPCODE:
761 #ifdef HAS_SETREUID
762 result = setreuid(ruid, euid);
763 #ifdef CACHE_UID
764 PL_uid = getuid();
765 PL_euid = geteuid();
766 #endif
767 #else
768 0 errno = ENOSYS;
769 0 result = -1;
770 #endif
771 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
772  
773 int
774 setregid(rgid, egid)
775 gid_t rgid
776 gid_t egid
777 PROTOTYPE: $$
778 INIT:
779 int result;
780 PPCODE:
781 #ifdef HAS_SETREGID
782 result = setregid(rgid, egid);
783 #ifdef CACHE_UID
784 PL_gid = getgid();
785 PL_egid = getegid();
786 #endif
787 #else
788 0 errno = ENOSYS;
789 0 result = -1;
790 #endif
791 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
792  
793  
794 int
795 setresuid(ruid, euid, suid)
796 uid_t ruid
797 uid_t euid
798 uid_t suid
799 PROTOTYPE: $$$
800 INIT:
801 int result;
802 PPCODE:
803 #ifdef HAS_SETRESUID
804 0 result = setresuid(ruid, euid, suid);
805 #ifdef CACHE_UID
806 PL_uid = getuid();
807 PL_euid = geteuid();
808 #endif
809 #else
810 errno = ENOSYS;
811 result = -1;
812 #endif
813 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
814  
815 void
816 getresuid()
817 PROTOTYPE:
818 INIT:
819 uid_t ruid;
820 uid_t euid;
821 uid_t suid;
822 int result;
823 PPCODE:
824 #ifdef HAS_SETRESUID
825 0 result = getresuid(&ruid, &euid, &suid);
826 0 ▶ if(result==0) {
Branch: 1 branch
BranchTrueFalseTotal
if(result==0) { 0 0 0
827 0 ▶ XPUSHs(sv_2mortal(newSVuv(ruid)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(ruid))); 0 0 0
828 0 ▶ XPUSHs(sv_2mortal(newSVuv(euid)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(euid))); 0 0 0
829 0 ▶ XPUSHs(sv_2mortal(newSVuv(suid)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(suid))); 0 0 0
830 }
831 #else
832 errno = ENOSYS;
833 #endif
834  
835  
836 int
837 setresgid(rgid, egid, sgid)
838 gid_t rgid
839 gid_t egid
840 gid_t sgid
841 PROTOTYPE: $$$
842 INIT:
843 int result;
844 PPCODE:
845 #ifdef HAS_SETRESGID
846 0 result = setresgid(rgid, egid, sgid);
847 #ifdef CACHE_UID
848 PL_gid = getgid();
849 PL_egid = getegid();
850 #endif
851 #else
852 errno = ENOSYS;
853 result = -1;
854 #endif
855 0 ▶ XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result))); 0 0 0
856  
857 void
858 getresgid()
859 PROTOTYPE:
860 INIT:
861 gid_t rgid;
862 gid_t egid;
863 gid_t sgid;
864 int result;
865 PPCODE:
866 #ifdef HAS_SETRESUID
867 0 result = getresgid(&rgid, &egid, &sgid);
868 0 ▶ if(result==0) {
Branch: 1 branch
BranchTrueFalseTotal
if(result==0) { 0 0 0
869 0 ▶ XPUSHs(sv_2mortal(newSVuv(rgid)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(rgid))); 0 0 0
870 0 ▶ XPUSHs(sv_2mortal(newSVuv(egid)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(egid))); 0 0 0
871 0 ▶ XPUSHs(sv_2mortal(newSVuv(sgid)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(sgid))); 0 0 0
872 }
873 #else
874 errno = ENOSYS;
875 #endif
876  
877 void
878 getgroups()
879 PROTOTYPE:
880 INIT:
881 gid_t grouplist[NGROUPS_MAX+1];
882 int nr_groups;
883 PPCODE:
884 #ifdef HAS_GETGROUPS
885 0 nr_groups = getgroups(NGROUPS_MAX+1, grouplist);
886 0 ▶ if(nr_groups >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(nr_groups >= 0) { 0 0 0
887 int nr;
888 0 ▶ for(nr = 0; nr < nr_groups; nr++)
Branch: 1 branch
BranchTrueFalseTotal
for(nr = 0; nr < nr_groups; nr++) 0 0 0
889 0 ▶ XPUSHs(sv_2mortal(newSVuv(grouplist[nr])));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(grouplist[nr]))); 0 0 0
890 }
891 #else
892 errno = ENOSYS;
893 #endif
894  
895 void
896 setgroups(...)
897 PROTOTYPE: @
898 INIT:
899 int index;
900 gid_t groups[NGROUPS_MAX];
901 int result;
902 CODE:
903 #ifdef HAS_SETGROUPS
904 0 ▶ for(index = 0; index < items && index < NGROUPS_MAX; index++)
Branch: 2 branches
BranchTrueFalseTotal
for(index = 0; index < items && index < NGROUPS_MAX; index++) 0 0 0
for(index = 0; index < items && index < NGROUPS_MAX; index++) 0 0 0
905 0 { groups[index] = (gid_t)SvUV(ST(index));
906 }
907 0 result = setgroups(index, groups);
908 0 ▶ XPUSHs(result==-1 ? &PL_sv_no : &PL_sv_yes);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(result==-1 ? &PL_sv_no : &PL_sv_yes); 0 0 0
XPUSHs(result==-1 ? &PL_sv_no : &PL_sv_yes); 0 0 0
909 #else
910 errno = ENOSYS;
911 #endif
912  
913  
914 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Errno
915  
916 HV *
917 errno_table()
918 PROTOTYPE:
919 CODE:
920 1 RETVAL = fill_errno();
921 OUTPUT:
922 RETVAL
923  
924 SV *
925 _strerror(int errnr)
926 PROTOTYPE: $
927 INIT:
928 char * buf;
929 CODE:
930 #ifdef HAS_STRERROR
931 buf = strerror(errnr);
932 RETVAL = buf==NULL ? &PL_sv_undef : newSVpv(buf, 0);
933 #else
934 0 errno = ENOSYS;
935 0 RETVAL = &PL_sv_undef;
936 #endif
937 OUTPUT:
938 RETVAL
939  
940  
941 MODULE = POSIX::1003 PACKAGE = POSIX::1003::Fcntl
942  
943 HV *
944 fcntl_table()
945 PROTOTYPE:
946 CODE:
947 1 RETVAL = fill_fcntl();
948 OUTPUT:
949 RETVAL
950  
951 SV *
952 _fcntl(fd, function, value)
953 int fd
954 SV * function
955 int value
956 PROTOTYPE: $$$
957 INIT:
958 int ret;
959 CODE:
960 #ifdef HAS_FCNTL
961 0 ▶ if(SvOK(function))
Branch: 1 branch
BranchTrueFalseTotal
if(SvOK(function)) 0 0 0
962 0 { ret = fcntl(fd, SvIV(function), value);
963 0 ▶ RETVAL = ret==-1 ? &PL_sv_undef : newSVuv(ret);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ret==-1 ? &PL_sv_undef : newSVuv(ret); 0 0 0
964 }
965 else
966 { /* catch-all for all unsupported functions */
967 0 errno = ENOSYS;
968 0 RETVAL = &PL_sv_undef;
969 }
970 #else
971 errno = ENOSYS;
972 RETVAL = &PL_sv_undef;
973 #endif
974 OUTPUT:
975 RETVAL
976  
977 SV *
978 _lock(fd, function, param)
979 int fd
980 int function
981 SV * param
982 PROTOTYPE: $$$
983 INIT:
984 struct flock locker;
985 SV **type, **whence, **start, **len;
986 HV *fl, *fs;
987 CODE:
988 #ifdef HAS_FCNTL
989 0 fs = (HV *)SvRV(param);
990 0 type = hv_fetch(fs, "type", 4, 0);
991 0 whence = hv_fetch(fs, "whence", 6, 0);
992 0 start = hv_fetch(fs, "start", 5, 0);
993 0 len = hv_fetch(fs, "len", 3, 0);
994  
995 0 locker.l_type = SvIV(*type );
996 0 locker.l_whence = SvIV(*whence);
997 0 locker.l_start = SvIV(*start );
998 0 locker.l_len = SvIV(*len );
999 0 locker.l_pid = 0;
1000  
1001 0 ▶ if(fcntl(fd, function, &locker)==-1)
Branch: 1 branch
BranchTrueFalseTotal
if(fcntl(fd, function, &locker)==-1) 0 0 0
1002 0 XSRETURN_UNDEF;
1003  
1004 0 fl = newHV();
1005 0 (void)hv_store(fl, "type", 4, newSViv(locker.l_type ), 0);
1006 0 (void)hv_store(fl, "whence", 6, newSViv(locker.l_whence), 0);
1007 0 (void)hv_store(fl, "start", 5, newSViv(locker.l_start ), 0);
1008 0 (void)hv_store(fl, "len", 3, newSViv(locker.l_len ), 0);
1009  
1010 0 ▶ if(function==F_GETLK)
Branch: 1 branch
BranchTrueFalseTotal
if(function==F_GETLK) 0 0 0
1011 0 (void)hv_store(fl, "pid",3, newSViv(locker.l_pid ), 0);
1012  
1013 0 RETVAL = newRV_noinc((SV *)fl);
1014 #else
1015 errno = ENOSYS;
1016 RETVAL = &PL_sv_undef;
1017 #endif
1018 OUTPUT:
1019 RETVAL
1020  
1021 void
1022 _own_ex(function, fd, pid, type)
1023 int function
1024 int fd
1025 pid_t pid
1026 int type
1027 PROTOTYPE: $$$$
1028 INIT:
1029 PPCODE:
1030 #ifdef HAS_FCNTL_OWN_EX
1031 { struct f_owner_ex ex;
1032 0 ex.type = type;
1033 0 ex.pid = pid;
1034  
1035 0 ▶ if(fcntl(fd, function, &ex)==-1)
Branch: 1 branch
BranchTrueFalseTotal
if(fcntl(fd, function, &ex)==-1) 0 0 0
1036 0 return;
1037  
1038 0 ▶ XPUSHs(sv_2mortal(newSVuv(ex.type)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(ex.type))); 0 0 0
1039 0 ▶ XPUSHs(sv_2mortal(newSVuv(ex.pid)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVuv(ex.pid))); 0 0 0
1040 }
1041 #else
1042 errno = ENOSYS;
1043 #endif
1044  
1045 SV *
1046 _flock(fd, function)
1047 int fd
1048 int function
1049 PROTOTYPE: $$
1050 INIT:
1051 int ret;
1052 CODE:
1053 #ifdef HAS_FLOCK
1054 0 ret = flock(fd, function);
1055 0 ▶ RETVAL = ret==-1 ? &PL_sv_undef : newSVuv(ret);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ret==-1 ? &PL_sv_undef : newSVuv(ret); 0 0 0
1056 #else
1057 errno = ENOSYS;
1058 RETVAL = &PL_sv_undef;
1059 #endif
1060 OUTPUT:
1061 RETVAL
1062  
1063 SV *
1064 _lockf(fd, function, len)
1065 int fd
1066 int function
1067 off_t len
1068 PROTOTYPE: $$$
1069 INIT:
1070 int ret;
1071 CODE:
1072 #ifdef HAS_LOCKF
1073 0 ret = lockf(fd, function, len);
1074 0 ▶ RETVAL = ret==-1 ? &PL_sv_undef : newSVuv(ret);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ret==-1 ? &PL_sv_undef : newSVuv(ret); 0 0 0
1075 #else
1076 errno = ENOSYS;
1077 RETVAL = &PL_sv_undef;
1078 #endif
1079 OUTPUT:
1080 RETVAL
« blib/lib/POSIX/1003/Proc.pm ↑ Summary symbols.PL »