xref: /PHP-5.4/ext/sockets/php_sockets.h (revision c0d060f5)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2014 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_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 #ifndef PHP_WIN32
41 typedef int PHP_SOCKET;
42 # define PHP_SOCKETS_API PHPAPI
43 #else
44 # define PHP_SOCKETS_API __declspec(dllexport)
45 typedef SOCKET PHP_SOCKET;
46 #endif
47 
48 typedef struct {
49 	PHP_SOCKET	bsd_socket;
50 	int			type;
51 	int			error;
52 	int			blocking;
53 	zval		*zstream;
54 } php_socket;
55 
56 #ifdef PHP_WIN32
57 struct	sockaddr_un {
58 	short	sun_family;
59 	char	sun_path[108];
60 };
61 #endif
62 
63 PHP_SOCKETS_API int php_sockets_le_socket(void);
64 
65 #define php_sockets_le_socket_name "Socket"
66 
67 ZEND_BEGIN_MODULE_GLOBALS(sockets)
68 	int last_error;
69 	char *strerror_buf;
70 ZEND_END_MODULE_GLOBALS(sockets)
71 
72 #ifdef ZTS
73 #define SOCKETS_G(v) TSRMG(sockets_globals_id, zend_sockets_globals *, v)
74 #else
75 #define SOCKETS_G(v) (sockets_globals.v)
76 #endif
77 
78 #else
79 #define phpext_sockets_ptr NULL
80 #endif
81 
82 #endif
83 
84 /*
85  * Local variables:
86  * tab-width: 4
87  * c-basic-offset: 4
88  * End:
89  */
90 
91