about summary refs log tree commit diff stats
path: root/src/luasocket/buffer.h
blob: a0901fcc868905a4fb8ec30fbd9171611ca216eb (plain) (blame)
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
#ifndef BUF_H
#define BUF_H 
/*=========================================================================*\
* Input/Output interface for Lua programs
* LuaSocket toolkit
*
* Line patterns require buffering. Reading one character at a time involves
* too many system calls and is very slow. This module implements the
* LuaSocket interface for input/output on connected objects, as seen by 
* Lua programs. 
*
* Input is buffered. Output is *not* buffered because there was no simple
* way of making sure the buffered output data would ever be sent.
*
* The module is built on top of the I/O abstraction defined in io.h and the
* timeout management is done with the timeout.h interface.
\*=========================================================================*/
#include "luasocket.h"
#include "io.h"
#include "timeout.h"

/* buffer size in bytes */
#define BUF_SIZE 8192

/* buffer control structure */
typedef struct t_buffer_ {
    double birthday;        /* throttle support info: creation time, */
    size_t sent, received;  /* bytes sent, and bytes received */
    p_io io;                /* IO driver used for this buffer */
    p_timeout tm;           /* timeout management for this buffer */
    size_t first, last;     /* index of first and last bytes of stored data */
    char data[BUF_SIZE];    /* storage space for buffer data */
} t_buffer;
typedef t_buffer *p_buffer;

#ifndef _WIN32
#pragma GCC visibility push(hidden)
#endif

int buffer_open(lua_State *L);
void buffer_init(p_buffer buf, p_io io, p_timeout tm);
int buffer_meth_getstats(lua_State *L, p_buffer buf);
int buffer_meth_setstats(lua_State *L, p_buffer buf);
int buffer_meth_send(lua_State *L, p_buffer buf);
int buffer_meth_receive(lua_State *L, p_buffer buf);
int buffer_isempty(p_buffer buf);

#ifndef _WIN32
#pragma GCC visibility pop
#endif

#endif /* BUF_H */
tter Kartik K. Agaram <vc@akkartik.com> 2015-05-25 22:27:19 -0700 1459' href='/akkartik/mu/commit/html/047jump_label.cc.html?h=main&id=c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008'>c5ffb6e1 ^
db1f56c8 ^
76755b28 ^
65361948 ^

4690ce81 ^
a654e4ec ^

4690ce81 ^
0ca56ed8 ^
4690ce81 ^
dcc060c7 ^
0e4a335e ^
4690ce81 ^

0e4a335e ^
dcc060c7 ^
0e4a335e ^

65361948 ^
a654e4ec ^
76755b28 ^
4690ce81 ^




65361948 ^

4690ce81 ^




65361948 ^

4690ce81 ^

65361948 ^

4690ce81 ^
76755b28 ^
4690ce81 ^
65361948 ^





a654e4ec ^
4690ce81 ^
2f02189d ^
0e4a335e ^
9542bb11 ^

4690ce81 ^


2f02189d ^
0e4a335e ^


4690ce81 ^
2f02189d ^
0e4a335e ^


dcc060c7 ^
65361948 ^

4690ce81 ^
0ca56ed8 ^
0e4a335e ^

65361948 ^
4690ce81 ^
65361948 ^

c5ffb6e1 ^
f344b250 ^
65361948 ^






4690ce81 ^
65361948 ^

4690ce81 ^
f344b250 ^
65361948 ^






4690ce81 ^
65361948 ^

9570363a ^
f344b250 ^
65361948 ^






4690ce81 ^
65361948 ^
f344b250 ^


c5ffb6e1 ^
f344b250 ^
65361948 ^
f344b250 ^
65361948 ^


0e4a335e ^
4690ce81 ^













76755b28 ^

4690ce81 ^
0e4a335e ^
f344b250 ^
0e4a335e ^
f344b250 ^
0e4a335e ^
76755b28 ^
0e4a335e ^

76755b28 ^
4690ce81 ^
0e4a335e ^
f344b250 ^


0e4a335e ^
f344b250 ^
0e4a335e ^
f344b250 ^
0e4a335e ^
2f02189d ^
65361948 ^


a654e4ec ^
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219