Skip to content

Commit

Permalink
Added arginfo stub for posix extension
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenreay authored and cmb69 committed Aug 14, 2019
1 parent 9436a2c commit f40cc41
Show file tree
Hide file tree
Showing 3 changed files with 278 additions and 168 deletions.
170 changes: 2 additions & 168 deletions ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
#include "php_posix.h"

#include "posix_arginfo.h"

#if HAVE_POSIX

Expand All @@ -52,172 +52,6 @@
ZEND_DECLARE_MODULE_GLOBALS(posix)
static PHP_MINFO_FUNCTION(posix);

/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_kill, 0, 0, 2)
ZEND_ARG_INFO(0, pid)
ZEND_ARG_INFO(0, sig)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_posix_getpid, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_posix_getppid, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_posix_getuid, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_setuid, 0, 0, 1)
ZEND_ARG_INFO(0, uid)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_posix_geteuid, 0)
ZEND_END_ARG_INFO()

#ifdef HAVE_SETEUID
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_seteuid, 0, 0, 1)
ZEND_ARG_INFO(0, uid)
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_INFO(arginfo_posix_getgid, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_setgid, 0, 0, 1)
ZEND_ARG_INFO(0, gid)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_posix_getegid, 0)
ZEND_END_ARG_INFO()

#ifdef HAVE_SETEGID
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_setegid, 0, 0, 1)
ZEND_ARG_INFO(0, gid)
ZEND_END_ARG_INFO()
#endif

#ifdef HAVE_GETGROUPS
ZEND_BEGIN_ARG_INFO(arginfo_posix_getgroups, 0)
ZEND_END_ARG_INFO()
#endif

#ifdef HAVE_GETLOGIN
ZEND_BEGIN_ARG_INFO(arginfo_posix_getlogin, 0)
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_INFO(arginfo_posix_getpgrp, 0)
ZEND_END_ARG_INFO()

#ifdef HAVE_SETSID
ZEND_BEGIN_ARG_INFO(arginfo_posix_setsid, 0)
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_setpgid, 0, 0, 2)
ZEND_ARG_INFO(0, pid)
ZEND_ARG_INFO(0, pgid)
ZEND_END_ARG_INFO()

#ifdef HAVE_GETPGID
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_getpgid, 0, 0, 1)
ZEND_ARG_INFO(0, pid)
ZEND_END_ARG_INFO()
#endif

#ifdef HAVE_GETSID
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_getsid, 0, 0, 1)
ZEND_ARG_INFO(0, pid)
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_INFO(arginfo_posix_uname, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_posix_times, 0)
ZEND_END_ARG_INFO()

#ifdef HAVE_CTERMID
ZEND_BEGIN_ARG_INFO(arginfo_posix_ctermid, 0)
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_ttyname, 0, 0, 1)
ZEND_ARG_INFO(0, fd)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_isatty, 0, 0, 1)
ZEND_ARG_INFO(0, fd)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_posix_getcwd, 0)
ZEND_END_ARG_INFO()

#ifdef HAVE_MKFIFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_mkfifo, 0, 0, 2)
ZEND_ARG_INFO(0, pathname)
ZEND_ARG_INFO(0, mode)
ZEND_END_ARG_INFO()
#endif

#ifdef HAVE_MKNOD
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_mknod, 0, 0, 2)
ZEND_ARG_INFO(0, pathname)
ZEND_ARG_INFO(0, mode)
ZEND_ARG_INFO(0, major)
ZEND_ARG_INFO(0, minor)
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_access, 0, 0, 1)
ZEND_ARG_INFO(0, file)
ZEND_ARG_INFO(0, mode)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_getgrnam, 0, 0, 1)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_getgrgid, 0, 0, 1)
ZEND_ARG_INFO(0, gid)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_getpwnam, 0, 0, 1)
ZEND_ARG_INFO(0, username)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_getpwuid, 0, 0, 1)
ZEND_ARG_INFO(0, uid)
ZEND_END_ARG_INFO()

#ifdef HAVE_GETRLIMIT
ZEND_BEGIN_ARG_INFO(arginfo_posix_getrlimit, 0)
ZEND_END_ARG_INFO()
#endif

#ifdef HAVE_SETRLIMIT
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_setrlimit, 0, 0, 3)
ZEND_ARG_INFO(0, resource)
ZEND_ARG_INFO(0, softlimit)
ZEND_ARG_INFO(0, hardlimit)
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_INFO(arginfo_posix_get_last_error, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_strerror, 0, 0, 1)
ZEND_ARG_INFO(0, errno)
ZEND_END_ARG_INFO()

#ifdef HAVE_INITGROUPS
ZEND_BEGIN_ARG_INFO_EX(arginfo_posix_initgroups, 0, 0, 2)
ZEND_ARG_INFO(0, name)
ZEND_ARG_INFO(0, base_group_id)
ZEND_END_ARG_INFO()
#endif
/* }}} */

/* {{{ posix_functions[]
*/
static const zend_function_entry posix_functions[] = {
Expand Down Expand Up @@ -302,7 +136,7 @@ static const zend_function_entry posix_functions[] = {
#endif

PHP_FE(posix_get_last_error, arginfo_posix_get_last_error)
PHP_FALIAS(posix_errno, posix_get_last_error, arginfo_posix_get_last_error)
PHP_FALIAS(posix_errno, posix_get_last_error, arginfo_posix_errno)
PHP_FE(posix_strerror, arginfo_posix_strerror)
#ifdef HAVE_INITGROUPS
PHP_FE(posix_initgroups, arginfo_posix_initgroups)
Expand Down
118 changes: 118 additions & 0 deletions ext/posix/posix.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php

function posix_kill(int $pid, int $sig): bool {}

function posix_getpid(): int {}

function posix_getppid(): int {}

function posix_getuid(): int {}

function posix_setuid(int $uid): bool {}

function posix_geteuid(): int {}

#ifdef HAVE_SETEUID
function posix_seteuid(int $uid): bool {}
#endif

function posix_getgid(): int {}

function posix_setgid(int $gid): bool {}

function posix_getegid(): int {}

#ifdef HAVE_SETEGID
function posix_setegid(int $gid): bool {}
#endif

#ifdef HAVE_GETGROUPS
/** @return array|false */
function posix_getgroups() {}
#endif

#ifdef HAVE_GETLOGIN
/** @return string|false */
function posix_getlogin() {}
#endif

function posix_getpgrp(): int {}

#ifdef HAVE_SETSID
function posix_setsid(): int {}
#endif

function posix_setpgid(int $pid, int $pgid): bool {}

#ifdef HAVE_GETPGID
/** @return int|false */
function posix_getpgid(int $pid) {}
#endif

#ifdef HAVE_GETSID
/** @return int|false */
function posix_getsid(int $pid) {}
#endif

/** @return array|false */
function posix_uname() {}

/** @return array|false */
function posix_times() {}


#ifdef HAVE_CTERMID
/** @return string|false */
function posix_ctermid() {}
#endif

/**
* @return string|false
*/
function posix_ttyname($fd) {}

function posix_isatty($fd): bool {}

/** @return string|false */
function posix_getcwd() {}

#ifdef HAVE_MKFIFO
function posix_mkfifo(string $pathname, int $mode): bool {}
#endif

#ifdef HAVE_MKNOD
function posix_mknod(string $pathname, int $mode, int $major = 0, int $minor = 0): bool {}
#endif

function posix_access(string $file, int $mode = 0): bool {}

/** @return array|false */
function posix_getgrnam(string $name) {}

/** @return array|false */
function posix_getgrgid(int $gid) {}

/** @return array|false */
function posix_getpwnam(string $username) {}

/** @return array|false */
function posix_getpwuid(int $uid) {}

#ifdef HAVE_GETRLIMIT
/** @return array|false */
function posix_getrlimit() {}
#endif

#ifdef HAVE_SETRLIMIT
function posix_setrlimit(int $resource, int $softlimit, int $hardlimit): bool {}
#endif

function posix_get_last_error(): int {}

function posix_errno(): int {}

function posix_strerror(int $errno): string {}

#ifdef HAVE_INITGROUPS
function posix_initgroups(string $name, int $base_group_id): bool {}
#endif
Loading

0 comments on commit f40cc41

Please sign in to comment.