1N/A#define PERL_EXT_POSIX
1N/A
1N/A#ifdef NETWARE
1N/A #define _POSIX_
1N/A /*
1N/A * Ideally this should be somewhere down in the includes
1N/A * but putting it in other places is giving compiler errors.
1N/A * Also here I am unable to check for HAS_UNAME since it wouldn't have
1N/A * yet come into the file at this stage - sgp 18th Oct 2000
1N/A */
1N/A #include <sys/utsname.h>
1N/A#endif /* NETWARE */
1N/A
1N/A#define PERL_NO_GET_CONTEXT
1N/A
1N/A#include "EXTERN.h"
1N/A#define PERLIO_NOT_STDIO 1
1N/A#include "perl.h"
1N/A#include "XSUB.h"
1N/A#if defined(PERL_IMPLICIT_SYS)
1N/A# undef signal
1N/A# undef open
1N/A# undef setmode
1N/A# define open PerlLIO_open3
1N/A#endif
1N/A#include <ctype.h>
1N/A#ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
1N/A#include <dirent.h>
1N/A#endif
1N/A#include <errno.h>
1N/A#ifdef I_FLOAT
1N/A#include <float.h>
1N/A#endif
1N/A#ifdef I_LIMITS
1N/A#include <limits.h>
1N/A#endif
1N/A#include <locale.h>
1N/A#include <math.h>
1N/A#ifdef I_PWD
1N/A#include <pwd.h>
1N/A#endif
1N/A#include <setjmp.h>
1N/A#include <signal.h>
1N/A#include <stdarg.h>
1N/A
1N/A#ifdef I_STDDEF
1N/A#include <stddef.h>
1N/A#endif
1N/A
1N/A#ifdef I_UNISTD
1N/A#include <unistd.h>
1N/A#endif
1N/A
1N/A/* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
1N/A metaconfig for future extension writers. We don't use them in POSIX.
1N/A (This is really sneaky :-) --AD
1N/A*/
1N/A#if defined(I_TERMIOS)
1N/A#include <termios.h>
1N/A#endif
1N/A#ifdef I_STDLIB
1N/A#include <stdlib.h>
1N/A#endif
1N/A#ifndef __ultrix__
1N/A#include <string.h>
1N/A#endif
1N/A#include <sys/stat.h>
1N/A#include <sys/types.h>
1N/A#include <time.h>
1N/A#ifdef I_UNISTD
1N/A#include <unistd.h>
1N/A#endif
1N/A#ifdef MACOS_TRADITIONAL
1N/A#undef fdopen
1N/A#endif
1N/A#include <fcntl.h>
1N/A
1N/A#ifdef HAS_TZNAME
1N/A# if !defined(WIN32) && !defined(__CYGWIN__) && !defined(NETWARE) && !defined(__UWIN__)
1N/Aextern char *tzname[];
1N/A# endif
1N/A#else
1N/A#if !defined(WIN32) && !defined(__UWIN__) || (defined(__MINGW32__) && !defined(tzname))
1N/Achar *tzname[] = { "" , "" };
1N/A#endif
1N/A#endif
1N/A
1N/A#if defined(__VMS) && !defined(__POSIX_SOURCE)
1N/A# include <libdef.h> /* LIB$_INVARG constant */
1N/A# include <lib$routines.h> /* prototype for lib$ediv() */
1N/A# include <starlet.h> /* prototype for sys$gettim() */
1N/A# if DECC_VERSION < 50000000
1N/A# define pid_t int /* old versions of DECC miss this in types.h */
1N/A# endif
1N/A
1N/A# undef mkfifo
1N/A# define mkfifo(a,b) (not_here("mkfifo"),-1)
1N/A# define tzset() not_here("tzset")
1N/A
1N/A#if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
1N/A# define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
1N/A# include <utsname.h>
1N/A# endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
1N/A
1N/A /* The POSIX notion of ttyname() is better served by getname() under VMS */
1N/A static char ttnambuf[64];
1N/A# define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
1N/A
1N/A /* The non-POSIX CRTL times() has void return type, so we just get the
1N/A current time directly */
1N/A clock_t vms_times(struct tms *bufptr) {
1N/A dTHX;
1N/A clock_t retval;
1N/A /* Get wall time and convert to 10 ms intervals to
1N/A * produce the return value that the POSIX standard expects */
1N/A# if defined(__DECC) && defined (__ALPHA)
1N/A# include <ints.h>
1N/A uint64 vmstime;
1N/A _ckvmssts(sys$gettim(&vmstime));
1N/A vmstime /= 100000;
1N/A retval = vmstime & 0x7fffffff;
1N/A# else
1N/A /* (Older hw or ccs don't have an atomic 64-bit type, so we
1N/A * juggle 32-bit ints (and a float) to produce a time_t result
1N/A * with minimal loss of information.) */
1N/A long int vmstime[2],remainder,divisor = 100000;
1N/A _ckvmssts(sys$gettim((unsigned long int *)vmstime));
1N/A vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
1N/A _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
1N/A# endif
1N/A /* Fill in the struct tms using the CRTL routine . . .*/
1N/A times((tbuffer_t *)bufptr);
1N/A return (clock_t) retval;
1N/A }
1N/A# define times(t) vms_times(t)
1N/A#else
1N/A#if defined (__CYGWIN__)
1N/A# define tzname _tzname
1N/A#endif
1N/A#if defined (WIN32) || defined (NETWARE)
1N/A# undef mkfifo
1N/A# define mkfifo(a,b) not_here("mkfifo")
1N/A# define ttyname(a) (char*)not_here("ttyname")
1N/A# define sigset_t long
1N/A# define pid_t long
1N/A# ifdef __BORLANDC__
1N/A# define tzname _tzname
1N/A# endif
1N/A# ifdef _MSC_VER
1N/A# define mode_t short
1N/A# endif
1N/A# ifdef __MINGW32__
1N/A# define mode_t short
1N/A# ifndef tzset
1N/A# define tzset() not_here("tzset")
1N/A# endif
1N/A# ifndef _POSIX_OPEN_MAX
1N/A# define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
1N/A# endif
1N/A# endif
1N/A# define sigaction(a,b,c) not_here("sigaction")
1N/A# define sigpending(a) not_here("sigpending")
1N/A# define sigprocmask(a,b,c) not_here("sigprocmask")
1N/A# define sigsuspend(a) not_here("sigsuspend")
1N/A# define sigemptyset(a) not_here("sigemptyset")
1N/A# define sigaddset(a,b) not_here("sigaddset")
1N/A# define sigdelset(a,b) not_here("sigdelset")
1N/A# define sigfillset(a) not_here("sigfillset")
1N/A# define sigismember(a,b) not_here("sigismember")
1N/A#ifndef NETWARE
1N/A# undef setuid
1N/A# undef setgid
1N/A# define setuid(a) not_here("setuid")
1N/A# define setgid(a) not_here("setgid")
1N/A#endif /* NETWARE */
1N/A#else
1N/A
1N/A# ifndef HAS_MKFIFO
1N/A# if defined(OS2) || defined(MACOS_TRADITIONAL)
1N/A# define mkfifo(a,b) not_here("mkfifo")
1N/A# else /* !( defined OS2 ) */
1N/A# ifndef mkfifo
1N/A# define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
1N/A# endif
1N/A# endif
1N/A# endif /* !HAS_MKFIFO */
1N/A
1N/A# ifdef MACOS_TRADITIONAL
1N/A# define ttyname(a) (char*)not_here("ttyname")
1N/A# define tzset() not_here("tzset")
1N/A# else
1N/A# include <grp.h>
1N/A# include <sys/times.h>
1N/A# ifdef HAS_UNAME
1N/A# include <sys/utsname.h>
1N/A# endif
1N/A# include <sys/wait.h>
1N/A# endif
1N/A# ifdef I_UTIME
1N/A# include <utime.h>
1N/A# endif
1N/A#endif /* WIN32 || NETWARE */
1N/A#endif /* __VMS */
1N/A
1N/Atypedef int SysRet;
1N/Atypedef long SysRetLong;
1N/Atypedef sigset_t* POSIX__SigSet;
1N/Atypedef HV* POSIX__SigAction;
1N/A#ifdef I_TERMIOS
1N/Atypedef struct termios* POSIX__Termios;
1N/A#else /* Define termios types to int, and call not_here for the functions.*/
1N/A#define POSIX__Termios int
1N/A#define speed_t int
1N/A#define tcflag_t int
1N/A#define cc_t int
1N/A#define cfgetispeed(x) not_here("cfgetispeed")
1N/A#define cfgetospeed(x) not_here("cfgetospeed")
1N/A#define tcdrain(x) not_here("tcdrain")
1N/A#define tcflush(x,y) not_here("tcflush")
1N/A#define tcsendbreak(x,y) not_here("tcsendbreak")
1N/A#define cfsetispeed(x,y) not_here("cfsetispeed")
1N/A#define cfsetospeed(x,y) not_here("cfsetospeed")
1N/A#define ctermid(x) (char *) not_here("ctermid")
1N/A#define tcflow(x,y) not_here("tcflow")
1N/A#define tcgetattr(x,y) not_here("tcgetattr")
1N/A#define tcsetattr(x,y,z) not_here("tcsetattr")
1N/A#endif
1N/A
1N/A/* Possibly needed prototypes */
1N/Achar *cuserid (char *);
1N/A#ifndef WIN32
1N/Adouble strtod (const char *, char **);
1N/Along strtol (const char *, char **, int);
1N/Aunsigned long strtoul (const char *, char **, int);
1N/A#endif
1N/A
1N/A#ifndef HAS_CUSERID
1N/A#define cuserid(a) (char *) not_here("cuserid")
1N/A#endif
1N/A#ifndef HAS_DIFFTIME
1N/A#ifndef difftime
1N/A#define difftime(a,b) not_here("difftime")
1N/A#endif
1N/A#endif
1N/A#ifndef HAS_FPATHCONF
1N/A#define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
1N/A#endif
1N/A#ifndef HAS_MKTIME
1N/A#define mktime(a) not_here("mktime")
1N/A#endif
1N/A#ifndef HAS_NICE
1N/A#define nice(a) not_here("nice")
1N/A#endif
1N/A#ifndef HAS_PATHCONF
1N/A#define pathconf(f,n) (SysRetLong) not_here("pathconf")
1N/A#endif
1N/A#ifndef HAS_SYSCONF
1N/A#define sysconf(n) (SysRetLong) not_here("sysconf")
1N/A#endif
1N/A#ifndef HAS_READLINK
1N/A#define readlink(a,b,c) not_here("readlink")
1N/A#endif
1N/A#ifndef HAS_SETPGID
1N/A#define setpgid(a,b) not_here("setpgid")
1N/A#endif
1N/A#ifndef HAS_SETSID
1N/A#define setsid() not_here("setsid")
1N/A#endif
1N/A#ifndef HAS_STRCOLL
1N/A#define strcoll(s1,s2) not_here("strcoll")
1N/A#endif
1N/A#ifndef HAS_STRTOD
1N/A#define strtod(s1,s2) not_here("strtod")
1N/A#endif
1N/A#ifndef HAS_STRTOL
1N/A#define strtol(s1,s2,b) not_here("strtol")
1N/A#endif
1N/A#ifndef HAS_STRTOUL
1N/A#define strtoul(s1,s2,b) not_here("strtoul")
1N/A#endif
1N/A#ifndef HAS_STRXFRM
1N/A#define strxfrm(s1,s2,n) not_here("strxfrm")
1N/A#endif
1N/A#ifndef HAS_TCGETPGRP
1N/A#define tcgetpgrp(a) not_here("tcgetpgrp")
1N/A#endif
1N/A#ifndef HAS_TCSETPGRP
1N/A#define tcsetpgrp(a,b) not_here("tcsetpgrp")
1N/A#endif
1N/A#ifndef HAS_TIMES
1N/A#ifndef NETWARE
1N/A#define times(a) not_here("times")
1N/A#endif /* NETWARE */
1N/A#endif
1N/A#ifndef HAS_UNAME
1N/A#define uname(a) not_here("uname")
1N/A#endif
1N/A#ifndef HAS_WAITPID
1N/A#define waitpid(a,b,c) not_here("waitpid")
1N/A#endif
1N/A
1N/A#ifndef HAS_MBLEN
1N/A#ifndef mblen
1N/A#define mblen(a,b) not_here("mblen")
1N/A#endif
1N/A#endif
1N/A#ifndef HAS_MBSTOWCS
1N/A#define mbstowcs(s, pwcs, n) not_here("mbstowcs")
1N/A#endif
1N/A#ifndef HAS_MBTOWC
1N/A#define mbtowc(pwc, s, n) not_here("mbtowc")
1N/A#endif
1N/A#ifndef HAS_WCSTOMBS
1N/A#define wcstombs(s, pwcs, n) not_here("wcstombs")
1N/A#endif
1N/A#ifndef HAS_WCTOMB
1N/A#define wctomb(s, wchar) not_here("wcstombs")
1N/A#endif
1N/A#if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
1N/A/* If we don't have these functions, then we wouldn't have gotten a typedef
1N/A for wchar_t, the wide character type. Defining wchar_t allows the
1N/A functions referencing it to compile. Its actual type is then meaningless,
1N/A since without the above functions, all sections using it end up calling
1N/A not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
1N/A#ifndef wchar_t
1N/A#define wchar_t char
1N/A#endif
1N/A#endif
1N/A
1N/A#ifndef HAS_LOCALECONV
1N/A#define localeconv() not_here("localeconv")
1N/A#endif
1N/A
1N/A#ifdef HAS_LONG_DOUBLE
1N/A# if LONG_DOUBLESIZE > NVSIZE
1N/A# undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
1N/A# endif
1N/A#endif
1N/A
1N/A#ifndef HAS_LONG_DOUBLE
1N/A#ifdef LDBL_MAX
1N/A#undef LDBL_MAX
1N/A#endif
1N/A#ifdef LDBL_MIN
1N/A#undef LDBL_MIN
1N/A#endif
1N/A#ifdef LDBL_EPSILON
1N/A#undef LDBL_EPSILON
1N/A#endif
1N/A#endif
1N/A
1N/A/* Background: in most systems the low byte of the wait status
1N/A * is the signal (the lowest 7 bits) and the coredump flag is
1N/A * the eight bit, and the second lowest byte is the exit status.
1N/A * BeOS bucks the trend and has the bytes in different order.
1N/A * See beos/beos.c for how the reality is bent even in BeOS
1N/A * to follow the traditional. However, to make the POSIX
1N/A * wait W*() macros to work in BeOS, we need to unbend the
1N/A * reality back in place. --jhi */
1N/A#ifdef __BEOS__
1N/A# define WMUNGE(x) (((x) & 0xFF00) >> 8 | ((x) & 0x00FF) << 8)
1N/A#else
1N/A# define WMUNGE(x) (x)
1N/A#endif
1N/A
1N/Astatic int
1N/Anot_here(char *s)
1N/A{
1N/A croak("POSIX::%s not implemented on this architecture", s);
1N/A return -1;
1N/A}
1N/A
1N/A#include "const-c.inc"
1N/A
1N/A/* These were implemented in the old "constant" subroutine. They are actually
1N/A macros that take an integer argument and return an integer result. */
1N/Astatic int
1N/Aint_macro_int (const char *name, STRLEN len, IV *arg_result) {
1N/A /* Initially switch on the length of the name. */
1N/A /* This code has been edited from a "constant" function generated by:
1N/A
1N/Ause ExtUtils::Constant qw (constant_types C_constant XS_constant);
1N/A
1N/Amy $types = {map {($_, 1)} qw(IV)};
1N/Amy @names = (qw(S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG WEXITSTATUS WIFEXITED
1N/A WIFSIGNALED WIFSTOPPED WSTOPSIG WTERMSIG));
1N/A
1N/Aprint constant_types(); # macro defs
1N/Aforeach (C_constant ("POSIX", 'int_macro_int', 'IV', $types, undef, 5, @names) ) {
1N/A print $_, "\n"; # C constant subs
1N/A}
1N/Aprint "#### XS Section:\n";
1N/Aprint XS_constant ("POSIX", $types);
1N/A__END__
1N/A */
1N/A
1N/A switch (len) {
1N/A case 7:
1N/A /* Names all of length 7. */
1N/A /* S_ISBLK S_ISCHR S_ISDIR S_ISREG */
1N/A /* Offset 5 gives the best switch position. */
1N/A switch (name[5]) {
1N/A case 'E':
1N/A if (memEQ(name, "S_ISREG", 7)) {
1N/A /* ^ */
1N/A#ifdef S_ISREG
1N/A *arg_result = S_ISREG(*arg_result);
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A case 'H':
1N/A if (memEQ(name, "S_ISCHR", 7)) {
1N/A /* ^ */
1N/A#ifdef S_ISCHR
1N/A *arg_result = S_ISCHR(*arg_result);
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A case 'I':
1N/A if (memEQ(name, "S_ISDIR", 7)) {
1N/A /* ^ */
1N/A#ifdef S_ISDIR
1N/A *arg_result = S_ISDIR(*arg_result);
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A case 'L':
1N/A if (memEQ(name, "S_ISBLK", 7)) {
1N/A /* ^ */
1N/A#ifdef S_ISBLK
1N/A *arg_result = S_ISBLK(*arg_result);
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A }
1N/A break;
1N/A case 8:
1N/A /* Names all of length 8. */
1N/A /* S_ISFIFO WSTOPSIG WTERMSIG */
1N/A /* Offset 3 gives the best switch position. */
1N/A switch (name[3]) {
1N/A case 'O':
1N/A if (memEQ(name, "WSTOPSIG", 8)) {
1N/A /* ^ */
1N/A#ifdef WSTOPSIG
1N/A int i = *arg_result;
1N/A *arg_result = WSTOPSIG(WMUNGE(i));
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A case 'R':
1N/A if (memEQ(name, "WTERMSIG", 8)) {
1N/A /* ^ */
1N/A#ifdef WTERMSIG
1N/A int i = *arg_result;
1N/A *arg_result = WTERMSIG(WMUNGE(i));
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A case 'S':
1N/A if (memEQ(name, "S_ISFIFO", 8)) {
1N/A /* ^ */
1N/A#ifdef S_ISFIFO
1N/A *arg_result = S_ISFIFO(*arg_result);
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A }
1N/A break;
1N/A case 9:
1N/A if (memEQ(name, "WIFEXITED", 9)) {
1N/A#ifdef WIFEXITED
1N/A int i = *arg_result;
1N/A *arg_result = WIFEXITED(WMUNGE(i));
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A case 10:
1N/A if (memEQ(name, "WIFSTOPPED", 10)) {
1N/A#ifdef WIFSTOPPED
1N/A int i = *arg_result;
1N/A *arg_result = WIFSTOPPED(WMUNGE(i));
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A case 11:
1N/A /* Names all of length 11. */
1N/A /* WEXITSTATUS WIFSIGNALED */
1N/A /* Offset 1 gives the best switch position. */
1N/A switch (name[1]) {
1N/A case 'E':
1N/A if (memEQ(name, "WEXITSTATUS", 11)) {
1N/A /* ^ */
1N/A#ifdef WEXITSTATUS
1N/A int i = *arg_result;
1N/A *arg_result = WEXITSTATUS(WMUNGE(i));
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A case 'I':
1N/A if (memEQ(name, "WIFSIGNALED", 11)) {
1N/A /* ^ */
1N/A#ifdef WIFSIGNALED
1N/A int i = *arg_result;
1N/A *arg_result = WIFSIGNALED(WMUNGE(i));
1N/A return PERL_constant_ISIV;
1N/A#else
1N/A return PERL_constant_NOTDEF;
1N/A#endif
1N/A }
1N/A break;
1N/A }
1N/A break;
1N/A }
1N/A return PERL_constant_NOTFOUND;
1N/A}
1N/A
1N/Astatic void
1N/Arestore_sigmask(pTHX_ SV *osset_sv)
1N/A{
1N/A /* Fortunately, restoring the signal mask can't fail, because
1N/A * there's nothing we can do about it if it does -- we're not
1N/A * supposed to return -1 from sigaction unless the disposition
1N/A * was unaffected.
1N/A */
1N/A sigset_t *ossetp = (sigset_t *) SvPV_nolen( osset_sv );
1N/A (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
1N/A}
1N/A
1N/AMODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
1N/A
1N/APOSIX::SigSet
1N/Anew(packname = "POSIX::SigSet", ...)
1N/A char * packname
1N/A CODE:
1N/A {
1N/A int i;
1N/A New(0, RETVAL, 1, sigset_t);
1N/A sigemptyset(RETVAL);
1N/A for (i = 1; i < items; i++)
1N/A sigaddset(RETVAL, SvIV(ST(i)));
1N/A }
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Avoid
1N/ADESTROY(sigset)
1N/A POSIX::SigSet sigset
1N/A CODE:
1N/A Safefree(sigset);
1N/A
1N/ASysRet
1N/Asigaddset(sigset, sig)
1N/A POSIX::SigSet sigset
1N/A int sig
1N/A
1N/ASysRet
1N/Asigdelset(sigset, sig)
1N/A POSIX::SigSet sigset
1N/A int sig
1N/A
1N/ASysRet
1N/Asigemptyset(sigset)
1N/A POSIX::SigSet sigset
1N/A
1N/ASysRet
1N/Asigfillset(sigset)
1N/A POSIX::SigSet sigset
1N/A
1N/Aint
1N/Asigismember(sigset, sig)
1N/A POSIX::SigSet sigset
1N/A int sig
1N/A
1N/A
1N/AMODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
1N/A
1N/APOSIX::Termios
1N/Anew(packname = "POSIX::Termios", ...)
1N/A char * packname
1N/A CODE:
1N/A {
1N/A#ifdef I_TERMIOS
1N/A New(0, RETVAL, 1, struct termios);
1N/A#else
1N/A not_here("termios");
1N/A RETVAL = 0;
1N/A#endif
1N/A }
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Avoid
1N/ADESTROY(termios_ref)
1N/A POSIX::Termios termios_ref
1N/A CODE:
1N/A#ifdef I_TERMIOS
1N/A Safefree(termios_ref);
1N/A#else
1N/A not_here("termios");
1N/A#endif
1N/A
1N/ASysRet
1N/Agetattr(termios_ref, fd = 0)
1N/A POSIX::Termios termios_ref
1N/A int fd
1N/A CODE:
1N/A RETVAL = tcgetattr(fd, termios_ref);
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/ASysRet
1N/Asetattr(termios_ref, fd = 0, optional_actions = 0)
1N/A POSIX::Termios termios_ref
1N/A int fd
1N/A int optional_actions
1N/A CODE:
1N/A RETVAL = tcsetattr(fd, optional_actions, termios_ref);
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aspeed_t
1N/Acfgetispeed(termios_ref)
1N/A POSIX::Termios termios_ref
1N/A
1N/Aspeed_t
1N/Acfgetospeed(termios_ref)
1N/A POSIX::Termios termios_ref
1N/A
1N/Atcflag_t
1N/Agetiflag(termios_ref)
1N/A POSIX::Termios termios_ref
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A RETVAL = termios_ref->c_iflag;
1N/A#else
1N/A not_here("getiflag");
1N/A RETVAL = 0;
1N/A#endif
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Atcflag_t
1N/Agetoflag(termios_ref)
1N/A POSIX::Termios termios_ref
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A RETVAL = termios_ref->c_oflag;
1N/A#else
1N/A not_here("getoflag");
1N/A RETVAL = 0;
1N/A#endif
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Atcflag_t
1N/Agetcflag(termios_ref)
1N/A POSIX::Termios termios_ref
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A RETVAL = termios_ref->c_cflag;
1N/A#else
1N/A not_here("getcflag");
1N/A RETVAL = 0;
1N/A#endif
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Atcflag_t
1N/Agetlflag(termios_ref)
1N/A POSIX::Termios termios_ref
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A RETVAL = termios_ref->c_lflag;
1N/A#else
1N/A not_here("getlflag");
1N/A RETVAL = 0;
1N/A#endif
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Acc_t
1N/Agetcc(termios_ref, ccix)
1N/A POSIX::Termios termios_ref
1N/A int ccix
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A if (ccix >= NCCS)
1N/A croak("Bad getcc subscript");
1N/A RETVAL = termios_ref->c_cc[ccix];
1N/A#else
1N/A not_here("getcc");
1N/A RETVAL = 0;
1N/A#endif
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/ASysRet
1N/Acfsetispeed(termios_ref, speed)
1N/A POSIX::Termios termios_ref
1N/A speed_t speed
1N/A
1N/ASysRet
1N/Acfsetospeed(termios_ref, speed)
1N/A POSIX::Termios termios_ref
1N/A speed_t speed
1N/A
1N/Avoid
1N/Asetiflag(termios_ref, iflag)
1N/A POSIX::Termios termios_ref
1N/A tcflag_t iflag
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A termios_ref->c_iflag = iflag;
1N/A#else
1N/A not_here("setiflag");
1N/A#endif
1N/A
1N/Avoid
1N/Asetoflag(termios_ref, oflag)
1N/A POSIX::Termios termios_ref
1N/A tcflag_t oflag
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A termios_ref->c_oflag = oflag;
1N/A#else
1N/A not_here("setoflag");
1N/A#endif
1N/A
1N/Avoid
1N/Asetcflag(termios_ref, cflag)
1N/A POSIX::Termios termios_ref
1N/A tcflag_t cflag
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A termios_ref->c_cflag = cflag;
1N/A#else
1N/A not_here("setcflag");
1N/A#endif
1N/A
1N/Avoid
1N/Asetlflag(termios_ref, lflag)
1N/A POSIX::Termios termios_ref
1N/A tcflag_t lflag
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A termios_ref->c_lflag = lflag;
1N/A#else
1N/A not_here("setlflag");
1N/A#endif
1N/A
1N/Avoid
1N/Asetcc(termios_ref, ccix, cc)
1N/A POSIX::Termios termios_ref
1N/A int ccix
1N/A cc_t cc
1N/A CODE:
1N/A#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
1N/A if (ccix >= NCCS)
1N/A croak("Bad setcc subscript");
1N/A termios_ref->c_cc[ccix] = cc;
1N/A#else
1N/A not_here("setcc");
1N/A#endif
1N/A
1N/A
1N/AMODULE = POSIX PACKAGE = POSIX
1N/A
1N/AINCLUDE: const-xs.inc
1N/A
1N/Avoid
1N/Aint_macro_int(sv, iv)
1N/A PREINIT:
1N/A dXSTARG;
1N/A STRLEN len;
1N/A int type;
1N/A INPUT:
1N/A SV * sv;
1N/A const char * s = SvPV(sv, len);
1N/A IV iv;
1N/A PPCODE:
1N/A /* Change this to int_macro_int(s, len, &iv, &nv);
1N/A if you need to return both NVs and IVs */
1N/A type = int_macro_int(s, len, &iv);
1N/A /* Return 1 or 2 items. First is error message, or undef if no error.
1N/A Second, if present, is found value */
1N/A switch (type) {
1N/A case PERL_constant_NOTFOUND:
1N/A sv = sv_2mortal(newSVpvf("%s is not a valid POSIX macro", s));
1N/A EXTEND(SP, 1);
1N/A PUSHs(&PL_sv_undef);
1N/A PUSHs(sv);
1N/A break;
1N/A case PERL_constant_NOTDEF:
1N/A sv = sv_2mortal(newSVpvf(
1N/A "Your vendor has not defined POSIX macro %s, used", s));
1N/A EXTEND(SP, 1);
1N/A PUSHs(&PL_sv_undef);
1N/A PUSHs(sv);
1N/A break;
1N/A case PERL_constant_ISIV:
1N/A PUSHi(iv);
1N/A break;
1N/A default:
1N/A sv = sv_2mortal(newSVpvf(
1N/A "Unexpected return type %d while processing POSIX macro %s, used",
1N/A type, s));
1N/A EXTEND(SP, 1);
1N/A PUSHs(&PL_sv_undef);
1N/A PUSHs(sv);
1N/A }
1N/A
1N/Aint
1N/Aisalnum(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!isalnum(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aisalpha(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!isalpha(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aiscntrl(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!iscntrl(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aisdigit(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!isdigit(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aisgraph(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!isgraph(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aislower(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!islower(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aisprint(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!isprint(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aispunct(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!ispunct(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aisspace(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!isspace(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aisupper(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!isupper(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Aint
1N/Aisxdigit(charstring)
1N/A SV * charstring
1N/A PREINIT:
1N/A STRLEN len;
1N/A CODE:
1N/A unsigned char *s = (unsigned char *) SvPV(charstring, len);
1N/A unsigned char *e = s + len;
1N/A for (RETVAL = 1; RETVAL && s < e; s++)
1N/A if (!isxdigit(*s))
1N/A RETVAL = 0;
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/ASysRet
1N/Aopen(filename, flags = O_RDONLY, mode = 0666)
1N/A char * filename
1N/A int flags
1N/A Mode_t mode
1N/A CODE:
1N/A if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
1N/A TAINT_PROPER("open");
1N/A RETVAL = open(filename, flags, mode);
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/A
1N/AHV *
1N/Alocaleconv()
1N/A CODE:
1N/A#ifdef HAS_LOCALECONV
1N/A struct lconv *lcbuf;
1N/A RETVAL = newHV();
1N/A sv_2mortal((SV*)RETVAL);
1N/A if ((lcbuf = localeconv())) {
1N/A /* the strings */
1N/A if (lcbuf->decimal_point && *lcbuf->decimal_point)
1N/A hv_store(RETVAL, "decimal_point", 13,
1N/A newSVpv(lcbuf->decimal_point, 0), 0);
1N/A if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
1N/A hv_store(RETVAL, "thousands_sep", 13,
1N/A newSVpv(lcbuf->thousands_sep, 0), 0);
1N/A#ifndef NO_LOCALECONV_GROUPING
1N/A if (lcbuf->grouping && *lcbuf->grouping)
1N/A hv_store(RETVAL, "grouping", 8,
1N/A newSVpv(lcbuf->grouping, 0), 0);
1N/A#endif
1N/A if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
1N/A hv_store(RETVAL, "int_curr_symbol", 15,
1N/A newSVpv(lcbuf->int_curr_symbol, 0), 0);
1N/A if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
1N/A hv_store(RETVAL, "currency_symbol", 15,
1N/A newSVpv(lcbuf->currency_symbol, 0), 0);
1N/A if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
1N/A hv_store(RETVAL, "mon_decimal_point", 17,
1N/A newSVpv(lcbuf->mon_decimal_point, 0), 0);
1N/A#ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
1N/A if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
1N/A hv_store(RETVAL, "mon_thousands_sep", 17,
1N/A newSVpv(lcbuf->mon_thousands_sep, 0), 0);
1N/A#endif
1N/A#ifndef NO_LOCALECONV_MON_GROUPING
1N/A if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
1N/A hv_store(RETVAL, "mon_grouping", 12,
1N/A newSVpv(lcbuf->mon_grouping, 0), 0);
1N/A#endif
1N/A if (lcbuf->positive_sign && *lcbuf->positive_sign)
1N/A hv_store(RETVAL, "positive_sign", 13,
1N/A newSVpv(lcbuf->positive_sign, 0), 0);
1N/A if (lcbuf->negative_sign && *lcbuf->negative_sign)
1N/A hv_store(RETVAL, "negative_sign", 13,
1N/A newSVpv(lcbuf->negative_sign, 0), 0);
1N/A /* the integers */
1N/A if (lcbuf->int_frac_digits != CHAR_MAX)
1N/A hv_store(RETVAL, "int_frac_digits", 15,
1N/A newSViv(lcbuf->int_frac_digits), 0);
1N/A if (lcbuf->frac_digits != CHAR_MAX)
1N/A hv_store(RETVAL, "frac_digits", 11,
1N/A newSViv(lcbuf->frac_digits), 0);
1N/A if (lcbuf->p_cs_precedes != CHAR_MAX)
1N/A hv_store(RETVAL, "p_cs_precedes", 13,
1N/A newSViv(lcbuf->p_cs_precedes), 0);
1N/A if (lcbuf->p_sep_by_space != CHAR_MAX)
1N/A hv_store(RETVAL, "p_sep_by_space", 14,
1N/A newSViv(lcbuf->p_sep_by_space), 0);
1N/A if (lcbuf->n_cs_precedes != CHAR_MAX)
1N/A hv_store(RETVAL, "n_cs_precedes", 13,
1N/A newSViv(lcbuf->n_cs_precedes), 0);
1N/A if (lcbuf->n_sep_by_space != CHAR_MAX)
1N/A hv_store(RETVAL, "n_sep_by_space", 14,
1N/A newSViv(lcbuf->n_sep_by_space), 0);
1N/A if (lcbuf->p_sign_posn != CHAR_MAX)
1N/A hv_store(RETVAL, "p_sign_posn", 11,
1N/A newSViv(lcbuf->p_sign_posn), 0);
1N/A if (lcbuf->n_sign_posn != CHAR_MAX)
1N/A hv_store(RETVAL, "n_sign_posn", 11,
1N/A newSViv(lcbuf->n_sign_posn), 0);
1N/A }
1N/A#else
1N/A localeconv(); /* A stub to call not_here(). */
1N/A#endif
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Achar *
1N/Asetlocale(category, locale = 0)
1N/A int category
1N/A char * locale
1N/A CODE:
1N/A RETVAL = setlocale(category, locale);
1N/A if (RETVAL) {
1N/A#ifdef USE_LOCALE_CTYPE
1N/A if (category == LC_CTYPE
1N/A#ifdef LC_ALL
1N/A || category == LC_ALL
1N/A#endif
1N/A )
1N/A {
1N/A char *newctype;
1N/A#ifdef LC_ALL
1N/A if (category == LC_ALL)
1N/A newctype = setlocale(LC_CTYPE, NULL);
1N/A else
1N/A#endif
1N/A newctype = RETVAL;
1N/A new_ctype(newctype);
1N/A }
1N/A#endif /* USE_LOCALE_CTYPE */
1N/A#ifdef USE_LOCALE_COLLATE
1N/A if (category == LC_COLLATE
1N/A#ifdef LC_ALL
1N/A || category == LC_ALL
1N/A#endif
1N/A )
1N/A {
1N/A char *newcoll;
1N/A#ifdef LC_ALL
1N/A if (category == LC_ALL)
1N/A newcoll = setlocale(LC_COLLATE, NULL);
1N/A else
1N/A#endif
1N/A newcoll = RETVAL;
1N/A new_collate(newcoll);
1N/A }
1N/A#endif /* USE_LOCALE_COLLATE */
1N/A#ifdef USE_LOCALE_NUMERIC
1N/A if (category == LC_NUMERIC
1N/A#ifdef LC_ALL
1N/A || category == LC_ALL
1N/A#endif
1N/A )
1N/A {
1N/A char *newnum;
1N/A#ifdef LC_ALL
1N/A if (category == LC_ALL)
1N/A newnum = setlocale(LC_NUMERIC, NULL);
1N/A else
1N/A#endif
1N/A newnum = RETVAL;
1N/A new_numeric(newnum);
1N/A }
1N/A#endif /* USE_LOCALE_NUMERIC */
1N/A }
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/A
1N/ANV
1N/Aacos(x)
1N/A NV x
1N/A
1N/ANV
1N/Aasin(x)
1N/A NV x
1N/A
1N/ANV
1N/Aatan(x)
1N/A NV x
1N/A
1N/ANV
1N/Aceil(x)
1N/A NV x
1N/A
1N/ANV
1N/Acosh(x)
1N/A NV x
1N/A
1N/ANV
1N/Afloor(x)
1N/A NV x
1N/A
1N/ANV
1N/Afmod(x,y)
1N/A NV x
1N/A NV y
1N/A
1N/Avoid
1N/Afrexp(x)
1N/A NV x
1N/A PPCODE:
1N/A int expvar;
1N/A /* (We already know stack is long enough.) */
1N/A PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
1N/A PUSHs(sv_2mortal(newSViv(expvar)));
1N/A
1N/ANV
1N/Aldexp(x,exp)
1N/A NV x
1N/A int exp
1N/A
1N/ANV
1N/Alog10(x)
1N/A NV x
1N/A
1N/Avoid
1N/Amodf(x)
1N/A NV x
1N/A PPCODE:
1N/A NV intvar;
1N/A /* (We already know stack is long enough.) */
1N/A PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
1N/A PUSHs(sv_2mortal(newSVnv(intvar)));
1N/A
1N/ANV
1N/Asinh(x)
1N/A NV x
1N/A
1N/ANV
1N/Atan(x)
1N/A NV x
1N/A
1N/ANV
1N/Atanh(x)
1N/A NV x
1N/A
1N/ASysRet
1N/Asigaction(sig, optaction, oldaction = 0)
1N/A int sig
1N/A SV * optaction
1N/A POSIX::SigAction oldaction
1N/A CODE:
1N/A#if defined(WIN32) || defined(NETWARE)
1N/A RETVAL = not_here("sigaction");
1N/A#else
1N/A# This code is really grody because we're trying to make the signal
1N/A# interface look beautiful, which is hard.
1N/A
1N/A {
1N/A POSIX__SigAction action;
1N/A GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
1N/A struct sigaction act;
1N/A struct sigaction oact;
1N/A sigset_t sset;
1N/A SV *osset_sv;
1N/A sigset_t osset;
1N/A POSIX__SigSet sigset;
1N/A SV** svp;
1N/A SV** sigsvp;
1N/A if (sig == 0 && SvPOK(ST(0))) {
1N/A char *s = SvPVX(ST(0));
1N/A int i = whichsig(s);
1N/A
1N/A if (i < 0 && memEQ(s, "SIG", 3))
1N/A i = whichsig(s + 3);
1N/A if (i < 0) {
1N/A if (ckWARN(WARN_SIGNAL))
1N/A Perl_warner(aTHX_ packWARN(WARN_SIGNAL),
1N/A "No such signal: SIG%s", s);
1N/A XSRETURN_UNDEF;
1N/A }
1N/A else
1N/A sig = i;
1N/A }
1N/A sigsvp = hv_fetch(GvHVn(siggv),
1N/A PL_sig_name[sig],
1N/A strlen(PL_sig_name[sig]),
1N/A TRUE);
1N/A
1N/A /* Check optaction and set action */
1N/A if(SvTRUE(optaction)) {
1N/A if(sv_isa(optaction, "POSIX::SigAction"))
1N/A action = (HV*)SvRV(optaction);
1N/A else
1N/A croak("action is not of type POSIX::SigAction");
1N/A }
1N/A else {
1N/A action=0;
1N/A }
1N/A
1N/A /* sigaction() is supposed to look atomic. In particular, any
1N/A * signal handler invoked during a sigaction() call should
1N/A * see either the old or the new disposition, and not something
1N/A * in between. We use sigprocmask() to make it so.
1N/A */
1N/A sigfillset(&sset);
1N/A RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
1N/A if(RETVAL == -1)
1N/A XSRETURN_UNDEF;
1N/A ENTER;
1N/A /* Restore signal mask no matter how we exit this block. */
1N/A osset_sv = newSVpv((char *)(&osset), sizeof(sigset_t));
1N/A SAVEFREESV( osset_sv );
1N/A SAVEDESTRUCTOR_X(restore_sigmask, osset_sv);
1N/A
1N/A RETVAL=-1; /* In case both oldaction and action are 0. */
1N/A
1N/A /* Remember old disposition if desired. */
1N/A if (oldaction) {
1N/A svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
1N/A if(!svp)
1N/A croak("Can't supply an oldaction without a HANDLER");
1N/A if(SvTRUE(*sigsvp)) { /* TBD: what if "0"? */
1N/A sv_setsv(*svp, *sigsvp);
1N/A }
1N/A else {
1N/A sv_setpv(*svp, "DEFAULT");
1N/A }
1N/A RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
1N/A if(RETVAL == -1)
1N/A XSRETURN_UNDEF;
1N/A /* Get back the mask. */
1N/A svp = hv_fetch(oldaction, "MASK", 4, TRUE);
1N/A if (sv_isa(*svp, "POSIX::SigSet")) {
1N/A IV tmp = SvIV((SV*)SvRV(*svp));
1N/A sigset = INT2PTR(sigset_t*, tmp);
1N/A }
1N/A else {
1N/A New(0, sigset, 1, sigset_t);
1N/A sv_setptrobj(*svp, sigset, "POSIX::SigSet");
1N/A }
1N/A *sigset = oact.sa_mask;
1N/A
1N/A /* Get back the flags. */
1N/A svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
1N/A sv_setiv(*svp, oact.sa_flags);
1N/A
1N/A /* Get back whether the old handler used safe signals. */
1N/A svp = hv_fetch(oldaction, "SAFE", 4, TRUE);
1N/A sv_setiv(*svp, oact.sa_handler == PL_csighandlerp);
1N/A }
1N/A
1N/A if (action) {
1N/A /* Safe signals use "csighandler", which vectors through the
1N/A PL_sighandlerp pointer when it's safe to do so.
1N/A (BTW, "csighandler" is very different from "sighandler".) */
1N/A svp = hv_fetch(action, "SAFE", 4, FALSE);
1N/A act.sa_handler = (*svp && SvTRUE(*svp))
1N/A ? PL_csighandlerp : PL_sighandlerp;
1N/A
1N/A /* Vector new Perl handler through %SIG.
1N/A (The core signal handlers read %SIG to dispatch.) */
1N/A svp = hv_fetch(action, "HANDLER", 7, FALSE);
1N/A if (!svp)
1N/A croak("Can't supply an action without a HANDLER");
1N/A sv_setsv(*sigsvp, *svp);
1N/A
1N/A /* This call actually calls sigaction() with almost the
1N/A right settings, including appropriate interpretation
1N/A of DEFAULT and IGNORE. However, why are we doing
1N/A this when we're about to do it again just below? XXX */
1N/A mg_set(*sigsvp);
1N/A
1N/A /* And here again we duplicate -- DEFAULT/IGNORE checking. */
1N/A if(SvPOK(*svp)) {
1N/A char *s=SvPVX(*svp);
1N/A if(strEQ(s,"IGNORE")) {
1N/A act.sa_handler = SIG_IGN;
1N/A }
1N/A else if(strEQ(s,"DEFAULT")) {
1N/A act.sa_handler = SIG_DFL;
1N/A }
1N/A }
1N/A
1N/A /* Set up any desired mask. */
1N/A svp = hv_fetch(action, "MASK", 4, FALSE);
1N/A if (svp && sv_isa(*svp, "POSIX::SigSet")) {
1N/A IV tmp = SvIV((SV*)SvRV(*svp));
1N/A sigset = INT2PTR(sigset_t*, tmp);
1N/A act.sa_mask = *sigset;
1N/A }
1N/A else
1N/A sigemptyset(& act.sa_mask);
1N/A
1N/A /* Set up any desired flags. */
1N/A svp = hv_fetch(action, "FLAGS", 5, FALSE);
1N/A act.sa_flags = svp ? SvIV(*svp) : 0;
1N/A
1N/A /* Don't worry about cleaning up *sigsvp if this fails,
1N/A * because that means we tried to disposition a
1N/A * nonblockable signal, in which case *sigsvp is
1N/A * essentially meaningless anyway.
1N/A */
1N/A RETVAL = sigaction(sig, & act, (struct sigaction *)0);
1N/A if(RETVAL == -1)
1N/A XSRETURN_UNDEF;
1N/A }
1N/A
1N/A LEAVE;
1N/A }
1N/A#endif
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/ASysRet
1N/Asigpending(sigset)
1N/A POSIX::SigSet sigset
1N/A
1N/ASysRet
1N/Asigprocmask(how, sigset, oldsigset = 0)
1N/A int how
1N/A POSIX::SigSet sigset
1N/A POSIX::SigSet oldsigset = NO_INIT
1N/AINIT:
1N/A if ( items < 3 ) {
1N/A oldsigset = 0;
1N/A }
1N/A else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
1N/A IV tmp = SvIV((SV*)SvRV(ST(2)));
1N/A oldsigset = INT2PTR(POSIX__SigSet,tmp);
1N/A }
1N/A else {
1N/A New(0, oldsigset, 1, sigset_t);
1N/A sigemptyset(oldsigset);
1N/A sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
1N/A }
1N/A
1N/ASysRet
1N/Asigsuspend(signal_mask)
1N/A POSIX::SigSet signal_mask
1N/A
1N/Avoid
1N/A_exit(status)
1N/A int status
1N/A
1N/ASysRet
1N/Aclose(fd)
1N/A int fd
1N/A
1N/ASysRet
1N/Adup(fd)
1N/A int fd
1N/A
1N/ASysRet
1N/Adup2(fd1, fd2)
1N/A int fd1
1N/A int fd2
1N/A
1N/ASV *
1N/Alseek(fd, offset, whence)
1N/A int fd
1N/A Off_t offset
1N/A int whence
1N/A CODE:
1N/A Off_t pos = PerlLIO_lseek(fd, offset, whence);
1N/A RETVAL = sizeof(Off_t) > sizeof(IV)
1N/A ? newSVnv((NV)pos) : newSViv((IV)pos);
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Avoid
1N/Anice(incr)
1N/A int incr
1N/A PPCODE:
1N/A errno = 0;
1N/A if ((incr = nice(incr)) != -1 || errno == 0) {
1N/A if (incr == 0)
1N/A XPUSHs(sv_2mortal(newSVpvn("0 but true", 10)));
1N/A else
1N/A XPUSHs(sv_2mortal(newSViv(incr)));
1N/A }
1N/A
1N/Avoid
1N/Apipe()
1N/A PPCODE:
1N/A int fds[2];
1N/A if (pipe(fds) != -1) {
1N/A EXTEND(SP,2);
1N/A PUSHs(sv_2mortal(newSViv(fds[0])));
1N/A PUSHs(sv_2mortal(newSViv(fds[1])));
1N/A }
1N/A
1N/ASysRet
1N/Aread(fd, buffer, nbytes)
1N/A PREINIT:
1N/A SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
1N/A INPUT:
1N/A int fd
1N/A size_t nbytes
1N/A char * buffer = sv_grow( sv_buffer, nbytes+1 );
1N/A CLEANUP:
1N/A if (RETVAL >= 0) {
1N/A SvCUR(sv_buffer) = RETVAL;
1N/A SvPOK_only(sv_buffer);
1N/A *SvEND(sv_buffer) = '\0';
1N/A SvTAINTED_on(sv_buffer);
1N/A }
1N/A
1N/ASysRet
1N/Asetpgid(pid, pgid)
1N/A pid_t pid
1N/A pid_t pgid
1N/A
1N/Apid_t
1N/Asetsid()
1N/A
1N/Apid_t
1N/Atcgetpgrp(fd)
1N/A int fd
1N/A
1N/ASysRet
1N/Atcsetpgrp(fd, pgrp_id)
1N/A int fd
1N/A pid_t pgrp_id
1N/A
1N/Avoid
1N/Auname()
1N/A PPCODE:
1N/A#ifdef HAS_UNAME
1N/A struct utsname buf;
1N/A if (uname(&buf) >= 0) {
1N/A EXTEND(SP, 5);
1N/A PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
1N/A PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
1N/A PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
1N/A PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
1N/A PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
1N/A }
1N/A#else
1N/A uname((char *) 0); /* A stub to call not_here(). */
1N/A#endif
1N/A
1N/ASysRet
1N/Awrite(fd, buffer, nbytes)
1N/A int fd
1N/A char * buffer
1N/A size_t nbytes
1N/A
1N/ASV *
1N/Atmpnam()
1N/A PREINIT:
1N/A STRLEN i;
1N/A int len;
1N/A CODE:
1N/A RETVAL = newSVpvn("", 0);
1N/A SvGROW(RETVAL, L_tmpnam);
1N/A len = strlen(tmpnam(SvPV(RETVAL, i)));
1N/A SvCUR_set(RETVAL, len);
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Avoid
1N/Aabort()
1N/A
1N/Aint
1N/Amblen(s, n)
1N/A char * s
1N/A size_t n
1N/A
1N/Asize_t
1N/Ambstowcs(s, pwcs, n)
1N/A wchar_t * s
1N/A char * pwcs
1N/A size_t n
1N/A
1N/Aint
1N/Ambtowc(pwc, s, n)
1N/A wchar_t * pwc
1N/A char * s
1N/A size_t n
1N/A
1N/Aint
1N/Awcstombs(s, pwcs, n)
1N/A char * s
1N/A wchar_t * pwcs
1N/A size_t n
1N/A
1N/Aint
1N/Awctomb(s, wchar)
1N/A char * s
1N/A wchar_t wchar
1N/A
1N/Aint
1N/Astrcoll(s1, s2)
1N/A char * s1
1N/A char * s2
1N/A
1N/Avoid
1N/Astrtod(str)
1N/A char * str
1N/A PREINIT:
1N/A double num;
1N/A char *unparsed;
1N/A PPCODE:
1N/A SET_NUMERIC_LOCAL();
1N/A num = strtod(str, &unparsed);
1N/A PUSHs(sv_2mortal(newSVnv(num)));
1N/A if (GIMME == G_ARRAY) {
1N/A EXTEND(SP, 1);
1N/A if (unparsed)
1N/A PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
1N/A else
1N/A PUSHs(&PL_sv_undef);
1N/A }
1N/A
1N/Avoid
1N/Astrtol(str, base = 0)
1N/A char * str
1N/A int base
1N/A PREINIT:
1N/A long num;
1N/A char *unparsed;
1N/A PPCODE:
1N/A num = strtol(str, &unparsed, base);
1N/A#if IVSIZE <= LONGSIZE
1N/A if (num < IV_MIN || num > IV_MAX)
1N/A PUSHs(sv_2mortal(newSVnv((double)num)));
1N/A else
1N/A#endif
1N/A PUSHs(sv_2mortal(newSViv((IV)num)));
1N/A if (GIMME == G_ARRAY) {
1N/A EXTEND(SP, 1);
1N/A if (unparsed)
1N/A PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
1N/A else
1N/A PUSHs(&PL_sv_undef);
1N/A }
1N/A
1N/Avoid
1N/Astrtoul(str, base = 0)
1N/A char * str
1N/A int base
1N/A PREINIT:
1N/A unsigned long num;
1N/A char *unparsed;
1N/A PPCODE:
1N/A num = strtoul(str, &unparsed, base);
1N/A#if IVSIZE <= LONGSIZE
1N/A if (num > IV_MAX)
1N/A PUSHs(sv_2mortal(newSVnv((double)num)));
1N/A else
1N/A#endif
1N/A PUSHs(sv_2mortal(newSViv((IV)num)));
1N/A if (GIMME == G_ARRAY) {
1N/A EXTEND(SP, 1);
1N/A if (unparsed)
1N/A PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
1N/A else
1N/A PUSHs(&PL_sv_undef);
1N/A }
1N/A
1N/Avoid
1N/Astrxfrm(src)
1N/A SV * src
1N/A CODE:
1N/A {
1N/A STRLEN srclen;
1N/A STRLEN dstlen;
1N/A char *p = SvPV(src,srclen);
1N/A srclen++;
1N/A ST(0) = sv_2mortal(NEWSV(800,srclen*4+1));
1N/A dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
1N/A if (dstlen > srclen) {
1N/A dstlen++;
1N/A SvGROW(ST(0), dstlen);
1N/A strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
1N/A dstlen--;
1N/A }
1N/A SvCUR(ST(0)) = dstlen;
1N/A SvPOK_only(ST(0));
1N/A }
1N/A
1N/ASysRet
1N/Amkfifo(filename, mode)
1N/A char * filename
1N/A Mode_t mode
1N/A CODE:
1N/A TAINT_PROPER("mkfifo");
1N/A RETVAL = mkfifo(filename, mode);
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/ASysRet
1N/Atcdrain(fd)
1N/A int fd
1N/A
1N/A
1N/ASysRet
1N/Atcflow(fd, action)
1N/A int fd
1N/A int action
1N/A
1N/A
1N/ASysRet
1N/Atcflush(fd, queue_selector)
1N/A int fd
1N/A int queue_selector
1N/A
1N/ASysRet
1N/Atcsendbreak(fd, duration)
1N/A int fd
1N/A int duration
1N/A
1N/Achar *
1N/Aasctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
1N/A int sec
1N/A int min
1N/A int hour
1N/A int mday
1N/A int mon
1N/A int year
1N/A int wday
1N/A int yday
1N/A int isdst
1N/A CODE:
1N/A {
1N/A struct tm mytm;
1N/A init_tm(&mytm); /* XXX workaround - see init_tm() above */
1N/A mytm.tm_sec = sec;
1N/A mytm.tm_min = min;
1N/A mytm.tm_hour = hour;
1N/A mytm.tm_mday = mday;
1N/A mytm.tm_mon = mon;
1N/A mytm.tm_year = year;
1N/A mytm.tm_wday = wday;
1N/A mytm.tm_yday = yday;
1N/A mytm.tm_isdst = isdst;
1N/A RETVAL = asctime(&mytm);
1N/A }
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/Along
1N/Aclock()
1N/A
1N/Achar *
1N/Actime(time)
1N/A Time_t &time
1N/A
1N/Avoid
1N/Atimes()
1N/A PPCODE:
1N/A struct tms tms;
1N/A clock_t realtime;
1N/A realtime = times( &tms );
1N/A EXTEND(SP,5);
1N/A PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
1N/A PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
1N/A PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
1N/A PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
1N/A PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
1N/A
1N/Adouble
1N/Adifftime(time1, time2)
1N/A Time_t time1
1N/A Time_t time2
1N/A
1N/ASysRetLong
1N/Amktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
1N/A int sec
1N/A int min
1N/A int hour
1N/A int mday
1N/A int mon
1N/A int year
1N/A int wday
1N/A int yday
1N/A int isdst
1N/A CODE:
1N/A {
1N/A struct tm mytm;
1N/A init_tm(&mytm); /* XXX workaround - see init_tm() above */
1N/A mytm.tm_sec = sec;
1N/A mytm.tm_min = min;
1N/A mytm.tm_hour = hour;
1N/A mytm.tm_mday = mday;
1N/A mytm.tm_mon = mon;
1N/A mytm.tm_year = year;
1N/A mytm.tm_wday = wday;
1N/A mytm.tm_yday = yday;
1N/A mytm.tm_isdst = isdst;
1N/A RETVAL = mktime(&mytm);
1N/A }
1N/A OUTPUT:
1N/A RETVAL
1N/A
1N/A#XXX: if $xsubpp::WantOptimize is always the default
1N/A# sv_setpv(TARG, ...) could be used rather than
1N/A# ST(0) = sv_2mortal(newSVpv(...))
1N/Avoid
1N/Astrftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
1N/A char * fmt
1N/A int sec
1N/A int min
1N/A int hour
1N/A int mday
1N/A int mon
1N/A int year
1N/A int wday
1N/A int yday
1N/A int isdst
1N/A CODE:
1N/A {
1N/A char *buf = my_strftime(fmt, sec, min, hour, mday, mon, year, wday, yday, isdst);
1N/A if (buf) {
1N/A ST(0) = sv_2mortal(newSVpv(buf, 0));
1N/A Safefree(buf);
1N/A }
1N/A }
1N/A
1N/Avoid
1N/Atzset()
1N/A
1N/Avoid
1N/Atzname()
1N/A PPCODE:
1N/A EXTEND(SP,2);
1N/A PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
1N/A PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
1N/A
1N/ASysRet
1N/Aaccess(filename, mode)
1N/A char * filename
1N/A Mode_t mode
1N/A
1N/Achar *
1N/Actermid(s = 0)
1N/A char * s = 0;
1N/A CODE:
1N/A#ifdef HAS_CTERMID_R
1N/A s = safemalloc((size_t) L_ctermid);
1N/A#endif
1N/A RETVAL = ctermid(s);
1N/A OUTPUT:
1N/A RETVAL
1N/A CLEANUP:
1N/A#ifdef HAS_CTERMID_R
1N/A Safefree(s);
1N/A#endif
1N/A
1N/Achar *
1N/Acuserid(s = 0)
1N/A char * s = 0;
1N/A
1N/ASysRetLong
1N/Afpathconf(fd, name)
1N/A int fd
1N/A int name
1N/A
1N/ASysRetLong
1N/Apathconf(filename, name)
1N/A char * filename
1N/A int name
1N/A
1N/ASysRet
1N/Apause()
1N/A
1N/ASysRet
1N/Asetgid(gid)
1N/A Gid_t gid
1N/A CLEANUP:
1N/A#ifndef WIN32
1N/A if (RETVAL >= 0) {
1N/A PL_gid = getgid();
1N/A PL_egid = getegid();
1N/A }
1N/A#endif
1N/A
1N/ASysRet
1N/Asetuid(uid)
1N/A Uid_t uid
1N/A CLEANUP:
1N/A#ifndef WIN32
1N/A if (RETVAL >= 0) {
1N/A PL_uid = getuid();
1N/A PL_euid = geteuid();
1N/A }
1N/A#endif
1N/A
1N/ASysRetLong
1N/Asysconf(name)
1N/A int name
1N/A
1N/Achar *
1N/Attyname(fd)
1N/A int fd
1N/A
1N/Avoid
1N/Agetcwd()
1N/A PPCODE:
1N/A {
1N/A dXSTARG;
1N/A getcwd_sv(TARG);
1N/A XSprePUSH; PUSHTARG;
1N/A }
1N/A
1N/ASysRet
1N/Alchown(uid, gid, path)
1N/A Uid_t uid
1N/A Gid_t gid
1N/A char * path
1N/A CODE:
1N/A#ifdef HAS_LCHOWN
1N/A /* yes, the order of arguments is different,
1N/A * but consistent with CORE::chown() */
1N/A RETVAL = lchown(path, uid, gid);
1N/A#else
1N/A RETVAL = not_here("lchown");
1N/A#endif
1N/A OUTPUT:
1N/A RETVAL