summaryrefslogtreecommitdiff
path: root/ext/standard/fsock.h
blob: f5d36fc98c4d1ede27db7ceb163640c8b17ea8f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
   +----------------------------------------------------------------------+
   | PHP version 4.0                                                      |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2001 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.02 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available at through the world-wide-web at                           |
   | http://www.php.net/license/2_02.txt.                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Authors: Paul Panotzki - Bunyip Information Systems                  |
   |          Jim Winstead (jimw@php.net)                                 |
   |          Wez Furlong                                                 |
   +----------------------------------------------------------------------+
*/

/* $Id$ */

/* Synced with php 3.0 revision 1.24 1999-06-18 [ssb] */

#ifndef FSOCK_H
#define FSOCK_H

#include "file.h"

#define PHP_FSOCK_CHUNK_SIZE 8192

#include "php_network.h"

#if HAVE_PHP_STREAM
extern php_stream_ops php_stream_socket_ops;
#endif

/* stream->abstract points to an instance of this */
struct php_sockbuf {
	int socket;
	unsigned char *readbuf;
	size_t readbuflen;
	size_t readpos;
	size_t writepos;
	struct php_sockbuf *next;
	struct php_sockbuf *prev;
	char eof;
	char persistent;
	char is_blocked;
	size_t chunk_size;
	struct timeval timeout;
	char timeout_event;
#if HAVE_PHP_STREAM
	php_stream * stream;
#endif
};

typedef struct php_sockbuf php_sockbuf;

PHP_FUNCTION(fsockopen);
PHP_FUNCTION(pfsockopen);

PHPAPI int php_lookup_hostname(const char *addr, struct in_addr *in);
PHPAPI char *php_sock_fgets(char *buf, size_t maxlen, int socket);
PHPAPI size_t php_sock_fread(char *buf, size_t maxlen, int socket);
PHPAPI int php_sock_feof(int socket);
PHPAPI int php_sock_fgetc(int socket);
PHPAPI int php_is_persistent_sock(int);
PHPAPI int php_sockset_blocking(int socket, int mode);
PHPAPI void php_sockset_timeout(int socket, struct timeval *timeout);
PHPAPI int php_sockdestroy(int socket);
PHPAPI int php_sock_close(int socket);
PHPAPI size_t php_sock_set_def_chunk_size(size_t size);
PHPAPI void php_msock_destroy(int *data);
PHPAPI void php_cleanup_sockbuf(int persistent TSRMLS_DC);

PHPAPI struct php_sockbuf *php_get_socket(int socket);

PHP_RSHUTDOWN_FUNCTION(fsock);

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim: sw=4 ts=4
 */
#endif /* FSOCK_H */