mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Refactoring: move stuff to new conversions.c
This commit is contained in:
@@ -43,6 +43,6 @@ if test "$PHP_SOCKETS" != "no"; then
|
||||
AC_DEFINE(HAVE_SA_SS_FAMILY,1,[Whether you have sockaddr_storage.ss_family])
|
||||
fi
|
||||
|
||||
PHP_NEW_EXTENSION([sockets], [sockets.c multicast.c sockaddr_conv.c sendrecvmsg.c], [$ext_shared])
|
||||
PHP_NEW_EXTENSION([sockets], [sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c], [$ext_shared])
|
||||
PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h])
|
||||
fi
|
||||
|
||||
1477
ext/sockets/conversions.c
Normal file
1477
ext/sockets/conversions.c
Normal file
File diff suppressed because it is too large
Load Diff
78
ext/sockets/conversions.h
Normal file
78
ext/sockets/conversions.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef PHP_SOCK_CONVERSIONS_H
|
||||
#define PHP_SOCK_CONVERSIONS_H 1
|
||||
|
||||
#include <php.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include "php_sockets.h"
|
||||
|
||||
/* TYPE DEFINITIONS */
|
||||
struct err_s {
|
||||
int has_error;
|
||||
char *msg;
|
||||
int level;
|
||||
int should_free;
|
||||
};
|
||||
|
||||
struct key_value {
|
||||
const char *key;
|
||||
unsigned key_size;
|
||||
void *value;
|
||||
};
|
||||
|
||||
/* the complete types of these two are not relevant to the outside */
|
||||
typedef struct _ser_context ser_context;
|
||||
typedef struct _res_context res_context;
|
||||
|
||||
#define KEY_RECVMSG_RET "recvmsg_ret"
|
||||
|
||||
typedef void (from_zval_write_field)(const zval *arr_value, char *field, ser_context *ctx);
|
||||
typedef void (to_zval_read_field)(const char *data, zval *zv, res_context *ctx);
|
||||
|
||||
/* VARIABLE DECLARATIONS */
|
||||
extern const struct key_value empty_key_value_list[];
|
||||
|
||||
/* AUX FUNCTIONS */
|
||||
void err_msg_dispose(struct err_s *err TSRMLS_DC);
|
||||
void allocations_dispose(zend_llist **allocations);
|
||||
|
||||
/* CONVERSION FUNCTIONS */
|
||||
void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx);
|
||||
void to_zval_read_int(const char *data, zval *zv, res_context *ctx);
|
||||
|
||||
#ifdef IPV6_PKTINFO
|
||||
void from_zval_write_in6_pktinfo(const zval *container, char *in6_pktinfo_c, ser_context *ctx);
|
||||
void to_zval_read_in6_pktinfo(const char *data, zval *zv, res_context *ctx);
|
||||
#endif
|
||||
|
||||
#ifdef SO_PASSCRED
|
||||
void from_zval_write_ucred(const zval *container, char *ucred_c, ser_context *ctx);
|
||||
void to_zval_read_ucred(const char *data, zval *zv, res_context *ctx);
|
||||
#endif
|
||||
|
||||
#ifdef SCM_RIGHTS
|
||||
size_t calculate_scm_rights_space(const zval *arr, ser_context *ctx);
|
||||
void from_zval_write_fd_array(const zval *arr, char *int_arr, ser_context *ctx);
|
||||
void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx);
|
||||
#endif
|
||||
|
||||
void from_zval_write_msghdr_send(const zval *container, char *msghdr_c, ser_context *ctx);
|
||||
void from_zval_write_msghdr_recv(const zval *container, char *msghdr_c, ser_context *ctx);
|
||||
void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx);
|
||||
|
||||
/* ENTRY POINTS FOR CONVERSIONS */
|
||||
void *from_zval_run_conversions(const zval *container,
|
||||
php_socket *sock,
|
||||
from_zval_write_field *writer,
|
||||
size_t struct_size,
|
||||
const char *top_name,
|
||||
zend_llist **allocations /* out */,
|
||||
struct err_s *err /* in/out */);
|
||||
|
||||
zval *to_zval_run_conversions(const char *structure,
|
||||
to_zval_read_field *reader,
|
||||
const char *top_name,
|
||||
const struct key_value *key_value_pairs,
|
||||
struct err_s *err);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,10 @@
|
||||
#include <php.h>
|
||||
#ifndef PHP_SENDRECVMSG_H
|
||||
#define PHP_SENDRECVMSG_H 1
|
||||
|
||||
#include <php.h>
|
||||
#include "conversions.h"
|
||||
|
||||
/* for sockets.c */
|
||||
PHP_FUNCTION(socket_sendmsg);
|
||||
PHP_FUNCTION(socket_recvmsg);
|
||||
PHP_FUNCTION(socket_cmsg_space);
|
||||
@@ -9,3 +14,23 @@ void php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS);
|
||||
|
||||
int php_do_setsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname, zval **arg4);
|
||||
int php_do_getsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname, zval *result);
|
||||
|
||||
/* for conversions.c */
|
||||
typedef struct {
|
||||
int cmsg_level; /* originating protocol */
|
||||
int cmsg_type; /* protocol-specific type */
|
||||
} anc_reg_key;
|
||||
|
||||
typedef size_t (calculate_req_space)(const zval *value, ser_context *ctx);
|
||||
|
||||
typedef struct {
|
||||
socklen_t size; /* size of native structure */
|
||||
socklen_t var_el_size; /* size of repeatable component */
|
||||
calculate_req_space *calc_space;
|
||||
from_zval_write_field *from_array;
|
||||
to_zval_read_field *to_array;
|
||||
} ancillary_reg_entry;
|
||||
|
||||
ancillary_reg_entry *get_ancillary_reg_entry(int cmsg_level, int msg_type);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user