root/ext/sockets/php_sockets.h

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

INCLUDED FROM


   1 /*
   2    +----------------------------------------------------------------------+
   3    | PHP Version 5                                                        |
   4    +----------------------------------------------------------------------+
   5    | Copyright (c) 1997-2016 The PHP Group                                |
   6    +----------------------------------------------------------------------+
   7    | This source file is subject to version 3.01 of the PHP license,      |
   8    | that is bundled with this package in the file LICENSE, and is        |
   9    | available through the world-wide-web at the following url:           |
  10    | http://www.php.net/license/3_01.txt                                  |
  11    | If you did not receive a copy of the PHP license and are unable to   |
  12    | obtain it through the world-wide-web, please send a note to          |
  13    | license@php.net so we can mail you a copy immediately.               |
  14    +----------------------------------------------------------------------+
  15    | Authors: Chris Vandomelen <chrisv@b0rked.dhs.org>                    |
  16    |          Sterling Hughes  <sterling@php.net>                         |
  17    |                                                                      |
  18    | WinSock: Daniel Beulshausen <daniel@php4win.de>                      |
  19    +----------------------------------------------------------------------+
  20  */
  21 
  22 #ifndef PHP_SOCKETS_H
  23 #define PHP_SOCKETS_H
  24 
  25 /* $Id$ */
  26 
  27 #if HAVE_CONFIG_H
  28 # include "config.h"
  29 #endif
  30 
  31 #if HAVE_SOCKETS
  32 
  33 #include <php.h>
  34 #ifdef PHP_WIN32
  35 # include "windows_common.h"
  36 #endif
  37 
  38 extern zend_module_entry sockets_module_entry;
  39 #define phpext_sockets_ptr &sockets_module_entry
  40 
  41 #ifdef PHP_WIN32
  42 #include <Winsock2.h>
  43 #else
  44 #if HAVE_SYS_SOCKET_H
  45 #include <sys/socket.h>
  46 #endif
  47 #endif
  48 
  49 #ifndef PHP_WIN32
  50 typedef int PHP_SOCKET;
  51 # define PHP_SOCKETS_API PHPAPI
  52 #else
  53 # define PHP_SOCKETS_API __declspec(dllexport)
  54 typedef SOCKET PHP_SOCKET;
  55 #endif
  56 
  57 typedef struct {
  58         PHP_SOCKET      bsd_socket;
  59         int                     type;
  60         int                     error;
  61         int                     blocking;
  62         zval            *zstream;
  63 } php_socket;
  64 
  65 #ifdef PHP_WIN32
  66 struct  sockaddr_un {
  67         short   sun_family;
  68         char    sun_path[108];
  69 };
  70 #endif
  71 
  72 PHP_SOCKETS_API int php_sockets_le_socket(void);
  73 
  74 #define php_sockets_le_socket_name "Socket"
  75 
  76 #define PHP_SOCKET_ERROR(socket, msg, errn) \
  77                 do { \
  78                         int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \
  79                         (socket)->error = _err; \
  80                         SOCKETS_G(last_error) = _err; \
  81                         if (_err != EAGAIN && _err != EWOULDBLOCK && _err != EINPROGRESS) { \
  82                                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, _err, sockets_strerror(_err TSRMLS_CC)); \
  83                         } \
  84                 } while (0)
  85 
  86 ZEND_BEGIN_MODULE_GLOBALS(sockets)
  87         int last_error;
  88         char *strerror_buf;
  89 ZEND_END_MODULE_GLOBALS(sockets)
  90 
  91 #ifdef ZTS
  92 #define SOCKETS_G(v) TSRMG(sockets_globals_id, zend_sockets_globals *, v)
  93 #else
  94 #define SOCKETS_G(v) (sockets_globals.v)
  95 #endif
  96 
  97 ZEND_EXTERN_MODULE_GLOBALS(sockets);
  98 
  99 enum sockopt_return {
 100         SOCKOPT_ERROR,
 101         SOCKOPT_CONTINUE,
 102         SOCKOPT_SUCCESS
 103 };
 104 
 105 char *sockets_strerror(int error TSRMLS_DC);
 106 php_socket *socket_import_file_descriptor(PHP_SOCKET sock TSRMLS_DC);
 107 
 108 #else
 109 #define phpext_sockets_ptr NULL
 110 #endif
 111 
 112 #if defined(_AIX) && !defined(HAVE_SA_SS_FAMILY)
 113 # define ss_family __ss_family
 114 #endif
 115 
 116 #endif
 117 
 118 /*
 119  * Local variables:
 120  * tab-width: 4
 121  * c-basic-offset: 4
 122  * End:
 123  */
 124 

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