POSIX-1003

 view release on metacpan or  search on metacpan

1003.xs  view on Meta::CPAN

#ifdef HAS_RLIMIT
#ifdef HAS_RLIMIT_64

void
_getrlimit(resource)
	int		resource;
    PROTOTYPE: $
    PREINIT:
	struct rlimit64	rlim;
	int		result;
    PPCODE:
	/* on linux, rlim64_t is a __UQUAD_TYPE */
	result = getrlimit64(resource, &rlim);
	XPUSHs(sv_2mortal(newSVuv(rlim.rlim_cur)));
	XPUSHs(sv_2mortal(newSVuv(rlim.rlim_max)));
	XPUSHs(result==-1 ? &PL_sv_no : &PL_sv_yes);

SV *
_setrlimit(resource, cur, max)
	int		resource;
	unsigned long   cur;

1003.xs  view on Meta::CPAN

#else /* HAS_RLIMIT_64 */


void
_getrlimit(resource)
	int		resource;
    PROTOTYPE: $
    PREINIT:
	struct rlimit	rlim;
	int		result;
    PPCODE:
	/* on linux, rlim64_t is a __ULONGWORD_TYPE */
	result = getrlimit(resource, &rlim);
	XPUSHs(sv_2mortal(newSVuv(rlim.rlim_cur)));
	XPUSHs(sv_2mortal(newSVuv(rlim.rlim_max)));
	XPUSHs(result==-1 ? &PL_sv_no : &PL_sv_yes);

SV *
_setrlimit(resource, cur, max)
	int		resource;
	unsigned long   cur;

1003.xs  view on Meta::CPAN

    OUTPUT:
	RETVAL

#endif /* HAS_RLIMIT_64 */
#else  /* HAS_RLIMIT */

void
_getrlimit(resource)
	int		resource;
    PROTOTYPE: $
    PPCODE:
	XPUSHs(&PL_sv_undef);
	XPUSHs(&PL_sv_undef);
	XPUSHs(&PL_sv_no);

SV *
_setrlimit(resource, cur, max)
	int		resource;
	unsigned long   cur;
	unsigned long	max;
    PROTOTYPE: $$$

1003.xs  view on Meta::CPAN

    PREINIT:
	struct pollfd * fds;
	HV            * ret;
	char          * key;
        char            key_str[16];
	int             rc;
        HE            * entry;
        I32		len;
	int		j;
        int             nfd;
    PPCODE:
#ifdef HAS_POLL
	nfd = hv_iterinit(handles);
	Newx(fds, nfd, struct pollfd);
	for(j=0; j < nfd; j++)
        {   /* Get hash key into 'C' space */
            entry          = hv_iternext(handles);
	    key            = hv_iterkey(entry, &len);
            if(len > 15) len = 15;    /* fd-num is always small */
	    strncpy(key_str, key, len);
            key_str[len]   = 0;

1003.xs  view on Meta::CPAN

        RETVAL = fill_user();
    OUTPUT:
        RETVAL

void
setuid(uid)
        uid_t           uid
    PROTOTYPE: $
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETUID
	result  = setuid(uid);
#ifdef CACHE_UID
	PL_uid  = getuid();
	PL_euid = geteuid();
#endif
#else
	errno   = ENOSYS;
	result  = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));

uid_t
getuid()
    PROTOTYPE:
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETUID
	result = getuid();
#else
	errno  = ENOSYS;
	result = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));

int
setgid(gid)
        gid_t           gid
    PROTOTYPE: $
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETUID
	result = setgid(gid);
#else
	errno  = ENOSYS;
	result = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));

gid_t
getgid()
    PROTOTYPE:
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETUID
	result = getgid();
#ifdef CACHE_UID
	PL_gid  = getgid();
	PL_egid = getegid();
#endif
#else
	errno  = ENOSYS;
	result = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));


int
seteuid(euid)
        uid_t           euid
    PROTOTYPE: $
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETEUID
	result  = seteuid(euid);
#ifdef CACHE_UID
	PL_euid = geteuid();
#endif
#else
	errno   = ENOSYS;
	result  = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));

uid_t
geteuid()
    PROTOTYPE:
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETEUID
	result  = geteuid();
#ifdef CACHE_UID
	PL_egid = getegid();
#endif
#else
	errno   = ENOSYS;
	result  = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));


int
setegid(egid)
        gid_t           egid
    PROTOTYPE: $
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETEUID
	result = setegid(egid);
#else
	errno  = ENOSYS;
	result = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));

gid_t
getegid()
    PROTOTYPE:
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETEUID
	result = getegid();
#else
	errno  = ENOSYS;
	result = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));


int
setreuid(ruid, euid)
        uid_t           ruid
        uid_t           euid
    PROTOTYPE: $$
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETREUID
	result  = setreuid(ruid, euid);
#ifdef CACHE_UID
	PL_uid  = getuid();
	PL_euid = geteuid();
#endif
#else
	errno   = ENOSYS;
	result  = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));

int
setregid(rgid, egid)
        gid_t           rgid
        gid_t           egid
    PROTOTYPE: $$
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETREGID
	result = setregid(rgid, egid);
#ifdef CACHE_UID
	PL_gid  = getgid();
	PL_egid = getegid();
#endif
#else
	errno  = ENOSYS;
	result = -1;
#endif

1003.xs  view on Meta::CPAN



int
setresuid(ruid, euid, suid)
        uid_t           ruid
        uid_t           euid
        uid_t           suid
    PROTOTYPE: $$$
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETRESUID
	result  = setresuid(ruid, euid, suid);
#ifdef CACHE_UID
	PL_uid  = getuid();
	PL_euid = geteuid();
#endif
#else
	errno  = ENOSYS;
	result = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));

void
getresuid()
    PROTOTYPE:
    INIT:
        uid_t           ruid;
        uid_t           euid;
        uid_t           suid;
	int		result;
    PPCODE:
#ifdef HAS_SETRESUID
	result = getresuid(&ruid, &euid, &suid);
	if(result==0) {
	    XPUSHs(sv_2mortal(newSVuv(ruid)));
	    XPUSHs(sv_2mortal(newSVuv(euid)));
	    XPUSHs(sv_2mortal(newSVuv(suid)));
	}
#else
	errno  = ENOSYS;
#endif


int
setresgid(rgid, egid, sgid)
        gid_t           rgid
        gid_t           egid
        gid_t           sgid
    PROTOTYPE: $$$
    INIT:
	int		result;
    PPCODE:
#ifdef HAS_SETRESGID
	result = setresgid(rgid, egid, sgid);
#ifdef CACHE_UID
	PL_gid  = getgid();
	PL_egid = getegid();
#endif
#else
	errno  = ENOSYS;
	result = -1;
#endif
	XPUSHs(result==-1 ? &PL_sv_undef : sv_2mortal(newSViv(result)));

void
getresgid()
    PROTOTYPE:
    INIT:
        gid_t           rgid;
        gid_t           egid;
        gid_t           sgid;
	int		result;
   PPCODE:
#ifdef HAS_SETRESUID
	result = getresgid(&rgid, &egid, &sgid);
	if(result==0) {
	    XPUSHs(sv_2mortal(newSVuv(rgid)));
	    XPUSHs(sv_2mortal(newSVuv(egid)));
	    XPUSHs(sv_2mortal(newSVuv(sgid)));
	}
#else
	errno  = ENOSYS;
#endif

void
getgroups()
    PROTOTYPE:
    INIT:
	gid_t	grouplist[_NGROUPS];
	int	nr_groups;
    PPCODE:
#ifdef HAS_GETGROUPS
	nr_groups = getgroups(_NGROUPS, grouplist);
	if(nr_groups >= 0) {
	    int nr;
	    for(nr = 0; nr < nr_groups; nr++)
	        XPUSHs(sv_2mortal(newSVuv(grouplist[nr])));
	}
#else
	errno  = ENOSYS;
#endif

1003.xs  view on Meta::CPAN

        RETVAL

void
_strptime(input, format)
    const char *input
    const char *format
    PREINIT:
#ifdef I_TIME
        struct tm t  = { -1,-1,-1,-1,-1,-1,-1,-1 };
#endif
    PPCODE:
#ifdef HAS_STRPTIME
        strptime(input, format, &t);
        if(t.tm_sec  == -1) XPUSHs(&PL_sv_undef); else mXPUSHi(t.tm_sec);
        if(t.tm_min  == -1) XPUSHs(&PL_sv_undef); else mXPUSHi(t.tm_min);
        if(t.tm_hour == -1) XPUSHs(&PL_sv_undef); else mXPUSHi(t.tm_hour);
        if(t.tm_mday == -1) XPUSHs(&PL_sv_undef); else mXPUSHi(t.tm_mday);
        if(t.tm_mon  == -1) XPUSHs(&PL_sv_undef); else mXPUSHi(t.tm_mon);
        if(t.tm_year == -1) XPUSHs(&PL_sv_undef); else mXPUSHi(t.tm_year);
        if(t.tm_wday == -1) XPUSHs(&PL_sv_undef); else mXPUSHi(t.tm_wday);
        if(t.tm_yday == -1) XPUSHs(&PL_sv_undef); else mXPUSHi(t.tm_yday);

1003.xs  view on Meta::CPAN

    int  mon
    int  year
    int  wday
    int  yday
    int  isdst
    PREINIT:
#ifdef I_TIME
        struct tm t;
        time_t    ts;
#endif
    PPCODE:
#ifdef HAS_MKTIME
        t.tm_sec  = sec;
        t.tm_min  = min;
        t.tm_hour = hour;
        t.tm_mday = mday;
        t.tm_mon  = mon;
        t.tm_year = year;
        t.tm_wday = wday;
        t.tm_yday = yday;
        t.tm_isdst = isdst;

1003.xs  view on Meta::CPAN

        RETVAL

void
_own_ex(function, fd, pid, type)
        int   function
        int   fd
        pid_t pid
        int   type
    PROTOTYPE: $$$$
    INIT:
    PPCODE:
#ifdef HAS_FCNTL_OWN_EX
        {   struct f_owner_ex ex;
	    ex.type  = type;
            ex.pid   = pid;

            if(fcntl(fd, function, &ex)==-1)
                return;

            XPUSHs(sv_2mortal(newSVuv(ex.type)));
            XPUSHs(sv_2mortal(newSVuv(ex.pid)));



( run in 0.403 second using v1.01-cache-2.11-cpan-5511b514fd6 )