}
/* CONVERSIONS for integers */
-static long from_zval_integer_common(const zval *arr_value, ser_context *ctx)
+static php_int_t from_zval_integer_common(const zval *arr_value, ser_context *ctx)
{
- long ret = 0;
+ php_int_t ret = 0;
zval lzval;
ZVAL_NULL(&lzval);
case IS_OBJECT:
case IS_STRING: {
- long lval;
+ php_int_t lval;
double dval;
convert_to_string(&lzval);
}
void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ php_int_t lval;
int ival;
lval = from_zval_integer_common(arr_value, ctx);
}
static void from_zval_write_uint32(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ php_int_t lval;
uint32_t ival;
lval = from_zval_integer_common(arr_value, ctx);
}
static void from_zval_write_net_uint16(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ php_int_t lval;
uint16_t ival;
lval = from_zval_integer_common(arr_value, ctx);
}
static void from_zval_write_sa_family(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ php_int_t lval;
sa_family_t ival;
lval = from_zval_integer_common(arr_value, ctx);
}
static void from_zval_write_pid_t(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ php_int_t lval;
pid_t ival;
lval = from_zval_integer_common(arr_value, ctx);
}
static void from_zval_write_uid_t(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ php_int_t lval;
uid_t ival;
lval = from_zval_integer_common(arr_value, ctx);
}
if (CMSG_LEN(entry->size) > cmsg->cmsg_len) {
do_to_zval_err(ctx, "the cmsghdr structure is unexpectedly small; "
- "expected a length of at least %ld, but got %ld",
- (long)CMSG_LEN(entry->size), (long)cmsg->cmsg_len);
+ "expected a length of at least %pd, but got %pd",
+ (php_int_t)CMSG_LEN(entry->size), (php_int_t)cmsg->cmsg_len);
return;
}
}
static void from_zval_write_msghdr_buffer_size(const zval *elem, char *msghdr_c, ser_context *ctx)
{
- long lval;
+ php_int_t lval;
struct msghdr *msghdr = (struct msghdr *)msghdr_c;
lval = from_zval_integer_common(elem, ctx);
}
if (lval < 0 || lval > MAX_USER_BUFF_SIZE) {
- do_from_zval_err(ctx, "the buffer size must be between 1 and %ld; "
- "given %ld", (long)MAX_USER_BUFF_SIZE, lval);
+ do_from_zval_err(ctx, "the buffer size must be between 1 and %pd; "
+ "given %pd", (php_int_t)MAX_USER_BUFF_SIZE, lval);
return;
}
if (*cmsg_len < data_offset) {
do_to_zval_err(ctx, "length of cmsg is smaller than its data member "
- "offset (%ld vs %ld)", (long)*cmsg_len, (long)data_offset);
+ "offset (%pd vs %pd)", (php_int_t)*cmsg_len, (php_int_t)data_offset);
return;
}
num_elems = (*cmsg_len - data_offset) / sizeof(int);
{
zval *zsocket,
*zmsg;
- long flags = 0;
+ php_int_t flags = 0;
php_socket *php_sock;
struct msghdr *msghdr;
zend_llist *allocations;
ssize_t res;
/* zmsg should be passed by ref */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra|l", &zsocket, &zmsg, &flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra|i", &zsocket, &zmsg, &flags) == FAILURE) {
return;
}
{
zval *zsocket,
*zmsg;
- long flags = 0;
+ php_int_t flags = 0;
php_socket *php_sock;
ssize_t res;
struct msghdr *msghdr;
struct err_s err = {0};
//ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra/|l",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra/|i",
&zsocket, &zmsg, &flags) == FAILURE) {
return;
}
RETURN_FALSE;
}
- RETURN_INT((long)res);
+ RETURN_INT((php_int_t)res);
}
PHP_FUNCTION(socket_cmsg_space)
{
- long level,
+ php_int_t level,
type,
n = 0;
ancillary_reg_entry *entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|l",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ii|i",
&level, &type, &n) == FAILURE) {
return;
}
entry = get_ancillary_reg_entry(level, type);
if (entry == NULL) {
- php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The pair level %ld/type %ld is "
+ php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The pair level %pd/type %pd is "
"not supported by PHP", level, type);
return;
}
- if (entry->var_el_size > 0 && n > (LONG_MAX - (long)entry->size -
- (long)CMSG_SPACE(0) - 15L) / entry->var_el_size) {
+ if (entry->var_el_size > 0 && n > (PHP_INT_MAX - (php_int_t)entry->size -
+ (php_int_t)CMSG_SPACE(0) - 15L) / entry->var_el_size) {
/* the -15 is to account for any padding CMSG_SPACE may add after the data */
php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The value for the "
- "third argument (%ld) is too large", n);
+ "third argument (%pd) is too large", n);
return;
}
php_socket *php_sock;
zval new_hash;
int num = 0;
- ulong num_key;
+ php_uint_t num_key;
zend_string *key;
if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
fd_set rfds, wfds, efds;
PHP_SOCKET max_fd = 0;
int retval, sets = 0;
- long usec = 0;
+ php_int_t usec = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!a/!a/!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!a/!a/!z!|i", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE) {
return;
}
PHP_FUNCTION(socket_create_listen)
{
php_socket *php_sock;
- long port, backlog = 128;
+ php_int_t port, backlog = 128;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &port, &backlog) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i|i", &port, &backlog) == FAILURE) {
return;
}
{
zval *arg1;
php_socket *php_sock;
- long backlog = 0;
+ php_int_t backlog = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, &backlog) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|i", &arg1, &backlog) == FAILURE) {
return;
}
zval *arg1;
php_socket *php_sock;
int retval, str_len;
- long length = 0;
+ php_int_t length = 0;
char *str;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &str, &str_len, &length) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|i", &arg1, &str, &str_len, &length) == FAILURE) {
return;
}
php_socket *php_sock;
zend_string *tmpbuf;
int retval;
- long length, type = PHP_BINARY_READ;
+ php_int_t length, type = PHP_BINARY_READ;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &length, &type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri|i", &arg1, &length, &type) == FAILURE) {
return;
}
Creates an endpoint for communication in the domain specified by domain, of type specified by type */
PHP_FUNCTION(socket_create)
{
- long arg1, arg2, arg3;
+ php_int_t arg1, arg2, arg3;
php_socket *php_sock = php_create_socket();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &arg1, &arg2, &arg3) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &arg1, &arg2, &arg3) == FAILURE) {
efree(php_sock);
return;
}
&& arg1 != AF_INET6
#endif
&& arg1 != AF_INET) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket domain [%ld] specified for argument 1, assuming AF_INET", arg1);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket domain [%pd] specified for argument 1, assuming AF_INET", arg1);
arg1 = AF_INET;
}
if (arg2 > 10) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket type [%ld] specified for argument 2, assuming SOCK_STREAM", arg2);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket type [%pd] specified for argument 2, assuming SOCK_STREAM", arg2);
arg2 = SOCK_STREAM;
}
php_socket *php_sock;
char *addr;
int retval, addr_len;
- long port = 0;
+ php_int_t port = 0;
int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "rs|l", &arg1, &addr, &addr_len, &port) == FAILURE) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "rs|i", &arg1, &addr, &addr_len, &port) == FAILURE) {
return;
}
Returns a string describing an error */
PHP_FUNCTION(socket_strerror)
{
- long arg1;
+ php_int_t arg1;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &arg1) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &arg1) == FAILURE) {
return;
}
php_socket *php_sock;
char *addr;
int addr_len;
- long port = 0;
- long retval = 0;
+ php_int_t port = 0;
+ php_int_t retval = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &addr, &addr_len, &port) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|i", &arg1, &addr, &addr_len, &port) == FAILURE) {
return;
}
zend_string *recv_buf;
php_socket *php_sock;
int retval;
- long len, flags;
+ php_int_t len, flags;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/ll", &php_sock_res, &buf, &len, &flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/ii", &php_sock_res, &buf, &len, &flags) == FAILURE) {
return;
}
zval *arg1;
php_socket *php_sock;
int buf_len, retval;
- long len, flags;
+ php_int_t len, flags;
char *buf;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsll", &arg1, &buf, &buf_len, &len, &flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsii", &arg1, &buf, &buf_len, &len, &flags) == FAILURE) {
return;
}
#endif
socklen_t slen;
int retval;
- long arg3, arg4;
+ php_int_t arg3, arg4;
char *address;
zend_string *recv_buf;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/llz/|z/", &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/iiz/|z/", &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
return;
}
struct sockaddr_in6 sin6;
#endif
int retval, buf_len, addr_len;
- long len, flags, port = 0;
+ php_int_t len, flags, port = 0;
char *buf, *addr;
int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "rslls|l", &arg1, &buf, &buf_len, &len, &flags, &addr, &addr_len, &port) == FAILURE) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "rsiis|i", &arg1, &buf, &buf_len, &len, &flags, &addr, &addr_len, &port) == FAILURE) {
return;
}
socklen_t optlen;
php_socket *php_sock;
int other_val;
- long level, optname;
+ php_int_t level, optname;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &arg1, &level, &optname) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rii", &arg1, &level, &optname) == FAILURE) {
return;
}
#else
struct timeval tv;
#endif
- long level, optname;
+ php_int_t level, optname;
void *opt_ptr;
HashTable *opt_ht;
zval *l_onoff, *l_linger;
zval *sec, *usec;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllz", &arg1, &level, &optname, &arg4) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "riiz", &arg1, &level, &optname, &arg4) == FAILURE) {
return;
}
zval retval[2], *fds_array_zval;
php_socket *php_sock[2];
PHP_SOCKET fds_array[2];
- long domain, type, protocol;
+ php_int_t domain, type, protocol;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllz/", &domain, &type, &protocol, &fds_array_zval) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iiiz/", &domain, &type, &protocol, &fds_array_zval) == FAILURE) {
return;
}
&& domain != AF_INET6
#endif
&& domain != AF_UNIX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket domain [%ld] specified for argument 1, assuming AF_INET", domain);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket domain [%pd] specified for argument 1, assuming AF_INET", domain);
domain = AF_INET;
}
if (type > 10) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket type [%ld] specified for argument 2, assuming SOCK_STREAM", type);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket type [%pd] specified for argument 2, assuming SOCK_STREAM", type);
type = SOCK_STREAM;
}
PHP_FUNCTION(socket_shutdown)
{
zval *arg1;
- long how_shutdown = 2;
+ php_int_t how_shutdown = 2;
php_socket *php_sock;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, &how_shutdown) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|i", &arg1, &how_shutdown) == FAILURE) {
return;
}