Return to php_sockets.h CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / sockets |
1.1 ! misho 1: /* ! 2: +----------------------------------------------------------------------+ ! 3: | PHP Version 5 | ! 4: +----------------------------------------------------------------------+ ! 5: | Copyright (c) 1997-2012 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: php_sockets.h 321634 2012-01-01 13:15:04Z felipe $ */ ! 26: ! 27: #if HAVE_SOCKETS ! 28: ! 29: extern zend_module_entry sockets_module_entry; ! 30: #define phpext_sockets_ptr &sockets_module_entry ! 31: ! 32: #ifdef PHP_WIN32 ! 33: #include <winsock.h> ! 34: #else ! 35: #if HAVE_SYS_SOCKET_H ! 36: #include <sys/socket.h> ! 37: #endif ! 38: #endif ! 39: ! 40: PHP_MINIT_FUNCTION(sockets); ! 41: PHP_MINFO_FUNCTION(sockets); ! 42: PHP_RSHUTDOWN_FUNCTION(sockets); ! 43: ! 44: PHP_FUNCTION(socket_select); ! 45: PHP_FUNCTION(socket_create_listen); ! 46: #ifdef HAVE_SOCKETPAIR ! 47: PHP_FUNCTION(socket_create_pair); ! 48: #endif ! 49: PHP_FUNCTION(socket_accept); ! 50: PHP_FUNCTION(socket_set_nonblock); ! 51: PHP_FUNCTION(socket_set_block); ! 52: PHP_FUNCTION(socket_listen); ! 53: PHP_FUNCTION(socket_close); ! 54: PHP_FUNCTION(socket_write); ! 55: PHP_FUNCTION(socket_read); ! 56: PHP_FUNCTION(socket_getsockname); ! 57: PHP_FUNCTION(socket_getpeername); ! 58: PHP_FUNCTION(socket_create); ! 59: PHP_FUNCTION(socket_connect); ! 60: PHP_FUNCTION(socket_strerror); ! 61: PHP_FUNCTION(socket_bind); ! 62: PHP_FUNCTION(socket_recv); ! 63: PHP_FUNCTION(socket_send); ! 64: PHP_FUNCTION(socket_recvfrom); ! 65: PHP_FUNCTION(socket_sendto); ! 66: PHP_FUNCTION(socket_get_option); ! 67: PHP_FUNCTION(socket_set_option); ! 68: #ifdef HAVE_SHUTDOWN ! 69: PHP_FUNCTION(socket_shutdown); ! 70: #endif ! 71: PHP_FUNCTION(socket_last_error); ! 72: PHP_FUNCTION(socket_clear_error); ! 73: ! 74: #ifndef PHP_WIN32 ! 75: typedef int PHP_SOCKET; ! 76: # define PHP_SOCKETS_API PHPAPI ! 77: #else ! 78: # define PHP_SOCKETS_API __declspec(dllexport) ! 79: typedef SOCKET PHP_SOCKET; ! 80: #endif ! 81: ! 82: typedef struct { ! 83: PHP_SOCKET bsd_socket; ! 84: int type; ! 85: int error; ! 86: int blocking; ! 87: } php_socket; ! 88: ! 89: #ifdef PHP_WIN32 ! 90: struct sockaddr_un { ! 91: short sun_family; ! 92: char sun_path[108]; ! 93: }; ! 94: #endif ! 95: ! 96: PHP_SOCKETS_API int php_sockets_le_socket(void); ! 97: ! 98: #define php_sockets_le_socket_name "Socket" ! 99: ! 100: /* Prototypes */ ! 101: #ifdef ilia_0 /* not needed, only causes a compiler warning */ ! 102: static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC); ! 103: static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct sockaddr *la TSRMLS_DC); ! 104: static int php_read(php_socket *sock, void *buf, size_t maxlen, int flags); ! 105: static char *php_strerror(int error TSRMLS_DC); ! 106: #endif ! 107: ! 108: ZEND_BEGIN_MODULE_GLOBALS(sockets) ! 109: int last_error; ! 110: char *strerror_buf; ! 111: ZEND_END_MODULE_GLOBALS(sockets) ! 112: ! 113: #ifdef ZTS ! 114: #define SOCKETS_G(v) TSRMG(sockets_globals_id, zend_sockets_globals *, v) ! 115: #else ! 116: #define SOCKETS_G(v) (sockets_globals.v) ! 117: #endif ! 118: ! 119: #else ! 120: #define phpext_sockets_ptr NULL ! 121: #endif ! 122: ! 123: #endif ! 124: ! 125: /* ! 126: * Local variables: ! 127: * tab-width: 4 ! 128: * c-basic-offset: 4 ! 129: * End: ! 130: */ ! 131: