root/ext/sockets/conversions.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef PHP_SOCK_CONVERSIONS_H
   2 #define PHP_SOCK_CONVERSIONS_H 1
   3 
   4 #include <php.h>
   5 
   6 #ifndef PHP_WIN32
   7 # include <netinet/in.h>
   8 # include <sys/socket.h>
   9 #else
  10 # include <Ws2tcpip.h>
  11 #endif
  12 
  13 #include "php_sockets.h"
  14 
  15 /* TYPE DEFINITIONS */
  16 struct err_s {
  17         int             has_error;
  18         char    *msg;
  19         int             level;
  20         int             should_free;
  21 };
  22 
  23 struct key_value {
  24         const char      *key;
  25         unsigned        key_size;
  26         void            *value;
  27 };
  28 
  29 /* the complete types of these two are not relevant to the outside */
  30 typedef struct _ser_context ser_context;
  31 typedef struct _res_context res_context;
  32 
  33 #define KEY_RECVMSG_RET "recvmsg_ret"
  34 
  35 typedef void (from_zval_write_field)(const zval *arr_value, char *field, ser_context *ctx);
  36 typedef void (to_zval_read_field)(const char *data, zval *zv, res_context *ctx);
  37 
  38 /* VARIABLE DECLARATIONS */
  39 extern const struct key_value empty_key_value_list[];
  40 
  41 /* AUX FUNCTIONS */
  42 void err_msg_dispose(struct err_s *err);
  43 void allocations_dispose(zend_llist **allocations);
  44 
  45 /* CONVERSION FUNCTIONS */
  46 void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx);
  47 void to_zval_read_int(const char *data, zval *zv, res_context *ctx);
  48 
  49 #ifdef IPV6_PKTINFO
  50 void from_zval_write_in6_pktinfo(const zval *container, char *in6_pktinfo_c, ser_context *ctx);
  51 void to_zval_read_in6_pktinfo(const char *data, zval *zv, res_context *ctx);
  52 #endif
  53 
  54 #ifdef SO_PASSCRED
  55 void from_zval_write_ucred(const zval *container, char *ucred_c, ser_context *ctx);
  56 void to_zval_read_ucred(const char *data, zval *zv, res_context *ctx);
  57 #endif
  58 
  59 #ifdef SCM_RIGHTS
  60 size_t calculate_scm_rights_space(const zval *arr, ser_context *ctx);
  61 void from_zval_write_fd_array(const zval *arr, char *int_arr, ser_context *ctx);
  62 void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx);
  63 #endif
  64 
  65 void from_zval_write_msghdr_send(const zval *container, char *msghdr_c, ser_context *ctx);
  66 void from_zval_write_msghdr_recv(const zval *container, char *msghdr_c, ser_context *ctx);
  67 void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx);
  68 
  69 /* ENTRY POINTS FOR CONVERSIONS */
  70 void *from_zval_run_conversions(const zval                              *container,
  71                                                                 php_socket                              *sock,
  72                                                                 from_zval_write_field   *writer,
  73                                                                 size_t                                  struct_size,
  74                                                                 const char                              *top_name,
  75                                                                 zend_llist                              **allocations /* out */,
  76                                                                 struct err_s                    *err /* in/out */);
  77 
  78 zval *to_zval_run_conversions(const char                                *structure,
  79                                                           to_zval_read_field            *reader,
  80                                                           const char                            *top_name,
  81                                                           const struct key_value        *key_value_pairs,
  82                                                           struct err_s                          *err, zval *zv);
  83 
  84 #endif

/* [<][>][^][v][top][bottom][index][help] */