forked from krakjoe/stat
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zend_stat_io.h
67 lines (56 loc) · 2.76 KB
/
zend_stat_io.h
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
/*
+----------------------------------------------------------------------+
| stat |
+----------------------------------------------------------------------+
| Copyright (c) Joe Watkins 2019 |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.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 |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: krakjoe |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_STAT_IO_H
# define ZEND_STAT_IO_H
#include "zend_stat_buffer.h"
#include "zend_stat_strings.h"
#include <pthread.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
typedef enum {
ZEND_STAT_IO_UNKNOWN,
ZEND_STAT_IO_UNIX,
ZEND_STAT_IO_TCP,
ZEND_STAT_IO_FAILED
} zend_stat_io_type_t;
typedef struct _zend_stat_io_t zend_stat_io_t;
typedef void (zend_stat_io_routine_t) (zend_stat_io_t *io, int client);
struct _zend_stat_io_t {
zend_stat_io_type_t type;
int descriptor;
struct sockaddr *address;
zend_bool closed;
pthread_t thread;
zend_stat_buffer_t *buffer;
zend_stat_io_routine_t *routine;
};
zend_bool zend_stat_io_write(int fd, char *message, size_t length);
zend_bool zend_stat_io_write_string(int fd, zend_stat_string_t *string);
zend_bool zend_stat_io_write_int(int fd, zend_long num);
zend_bool zend_stat_io_write_double(int fd, double num);
#define zend_stat_io_write_ex(s, v, l, a) if (!zend_stat_io_write(s, v, l)) a
#define zend_stat_io_write_string_ex(s, v, a) if (!zend_stat_io_write_string(s, v)) a
#define zend_stat_io_write_int_ex(s, i, a) if (!zend_stat_io_write_int(s, i)) a
#define zend_stat_io_write_double_ex(s, d, a) if (!zend_stat_io_write_double(s, d)) a
#define zend_stat_io_write_literal_ex(s, v, a) if (!zend_stat_io_write(s, v, sizeof(v)-1)) a
zend_bool zend_stat_io_startup(zend_stat_io_t *io, char *uri, zend_stat_buffer_t *buffer, zend_stat_io_routine_t *routine);
zend_bool zend_stat_io_closed(zend_stat_io_t *io);
void zend_stat_io_shutdown(zend_stat_io_t *io);
#endif /* ZEND_STAT_IO_H */