View | Details | Raw Unified | Return to bug 138055
Collapse All | Expand All

(-)Makefile (+1 lines)
Lines 7-12 Link Here
7
7
8
PORTNAME=	luasocket
8
PORTNAME=	luasocket
9
PORTVERSION=	2.0.2
9
PORTVERSION=	2.0.2
10
PORTREVISION=	1
10
CATEGORIES=	net
11
CATEGORIES=	net
11
MASTER_SITES=	http://luaforge.net/frs/download.php/2664/
12
MASTER_SITES=	http://luaforge.net/frs/download.php/2664/
12
PKGNAMEPREFIX=	${LUA_PKGNAMEPREFIX}
13
PKGNAMEPREFIX=	${LUA_PKGNAMEPREFIX}
(-)files/patch-src_buffer_c (+233 lines)
Added Link Here
1
diff -ru src/buffer.c src/buffer.c
2
--- src/buffer.c	2008-08-20 06:16:42 +0000
3
+++ src/buffer.c	2008-08-20 06:30:15 +0000
4
@@ -33,7 +33,7 @@
5
 /*-------------------------------------------------------------------------*\
6
 * Initializes module
7
 \*-------------------------------------------------------------------------*/
8
-int buffer_open(lua_State *L) {
9
+int ls_buffer_open(lua_State *L) {
10
     (void) L;
11
     return 0;
12
 }
13
@@ -41,7 +41,7 @@
14
 /*-------------------------------------------------------------------------*\
15
 * Initializes C structure 
16
 \*-------------------------------------------------------------------------*/
17
-void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
18
+void ls_buffer_init(p_buffer buf, p_io io, p_timeout tm) {
19
 	buf->first = buf->last = 0;
20
     buf->io = io;
21
     buf->tm = tm;
22
@@ -52,7 +52,7 @@
23
 /*-------------------------------------------------------------------------*\
24
 * object:getstats() interface
25
 \*-------------------------------------------------------------------------*/
26
-int buffer_meth_getstats(lua_State *L, p_buffer buf) {
27
+int ls_buffer_meth_getstats(lua_State *L, p_buffer buf) {
28
     lua_pushnumber(L, buf->received);
29
     lua_pushnumber(L, buf->sent);
30
     lua_pushnumber(L, timeout_gettime() - buf->birthday);
31
@@ -62,7 +62,7 @@
32
 /*-------------------------------------------------------------------------*\
33
 * object:setstats() interface
34
 \*-------------------------------------------------------------------------*/
35
-int buffer_meth_setstats(lua_State *L, p_buffer buf) {
36
+int ls_buffer_meth_setstats(lua_State *L, p_buffer buf) {
37
     buf->received = (long) luaL_optnumber(L, 2, buf->received); 
38
     buf->sent = (long) luaL_optnumber(L, 3, buf->sent); 
39
     if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4);
40
@@ -73,7 +73,7 @@
41
 /*-------------------------------------------------------------------------*\
42
 * object:send() interface
43
 \*-------------------------------------------------------------------------*/
44
-int buffer_meth_send(lua_State *L, p_buffer buf) {
45
+int ls_buffer_meth_send(lua_State *L, p_buffer buf) {
46
     int top = lua_gettop(L);
47
     int err = IO_DONE;
48
     size_t size = 0, sent = 0;
49
@@ -106,7 +106,7 @@
50
 /*-------------------------------------------------------------------------*\
51
 * object:receive() interface
52
 \*-------------------------------------------------------------------------*/
53
-int buffer_meth_receive(lua_State *L, p_buffer buf) {
54
+int ls_buffer_meth_receive(lua_State *L, p_buffer buf) {
55
     int err = IO_DONE, top = lua_gettop(L);
56
     luaL_Buffer b;
57
     size_t size;
58
@@ -149,7 +149,7 @@
59
 /*-------------------------------------------------------------------------*\
60
 * Determines if there is any data in the read buffer
61
 \*-------------------------------------------------------------------------*/
62
-int buffer_isempty(p_buffer buf) {
63
+int ls_buffer_isempty(p_buffer buf) {
64
     return buf->first >= buf->last;
65
 }
66
 
67
@@ -244,7 +244,7 @@
68
 static void buffer_skip(p_buffer buf, size_t count) {
69
     buf->received += count;
70
     buf->first += count;
71
-    if (buffer_isempty(buf)) 
72
+    if (ls_buffer_isempty(buf)) 
73
         buf->first = buf->last = 0;
74
 }
75
 
76
@@ -256,7 +256,7 @@
77
     int err = IO_DONE;
78
     p_io io = buf->io;
79
     p_timeout tm = buf->tm;
80
-    if (buffer_isempty(buf)) {
81
+    if (ls_buffer_isempty(buf)) {
82
         size_t got;
83
         err = io->recv(io->ctx, buf->data, BUF_SIZE, &got, tm);
84
         buf->first = 0;
85
diff -ru src/buffer.h src/buffer.h
86
--- src/buffer.h	2008-08-20 06:16:42 +0000
87
+++ src/buffer.h	2008-08-20 06:30:15 +0000
88
@@ -36,12 +36,12 @@
89
 } t_buffer;
90
 typedef t_buffer *p_buffer;
91
 
92
-int buffer_open(lua_State *L);
93
-void buffer_init(p_buffer buf, p_io io, p_timeout tm);
94
-int buffer_meth_send(lua_State *L, p_buffer buf);
95
-int buffer_meth_receive(lua_State *L, p_buffer buf);
96
-int buffer_meth_getstats(lua_State *L, p_buffer buf);
97
-int buffer_meth_setstats(lua_State *L, p_buffer buf);
98
-int buffer_isempty(p_buffer buf);
99
+int ls_buffer_open(lua_State *L);
100
+void ls_buffer_init(p_buffer buf, p_io io, p_timeout tm);
101
+int ls_buffer_meth_send(lua_State *L, p_buffer buf);
102
+int ls_buffer_meth_receive(lua_State *L, p_buffer buf);
103
+int ls_buffer_meth_getstats(lua_State *L, p_buffer buf);
104
+int ls_buffer_meth_setstats(lua_State *L, p_buffer buf);
105
+int ls_buffer_isempty(p_buffer buf);
106
 
107
 #endif /* BUF_H */
108
diff -ru src/luasocket.c src/luasocket.c
109
--- src/luasocket.c	2008-08-20 06:16:42 +0000
110
+++ src/luasocket.c	2008-08-20 06:30:15 +0000
111
@@ -51,7 +51,7 @@
112
     {"auxiliar", auxiliar_open},
113
     {"except", except_open},
114
     {"timeout", timeout_open},
115
-    {"buffer", buffer_open},
116
+    {"buffer", ls_buffer_open},
117
     {"inet", inet_open},
118
     {"tcp", tcp_open},
119
     {"udp", udp_open},
120
diff -ru src/tcp.c src/tcp.c
121
--- src/tcp.c	2008-08-20 06:16:42 +0000
122
+++ src/tcp.c	2008-08-20 06:30:15 +0000
123
@@ -104,22 +104,22 @@
124
 \*-------------------------------------------------------------------------*/
125
 static int meth_send(lua_State *L) {
126
     p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
127
-    return buffer_meth_send(L, &tcp->buf);
128
+    return ls_buffer_meth_send(L, &tcp->buf);
129
 }
130
 
131
 static int meth_receive(lua_State *L) {
132
     p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
133
-    return buffer_meth_receive(L, &tcp->buf);
134
+    return ls_buffer_meth_receive(L, &tcp->buf);
135
 }
136
 
137
 static int meth_getstats(lua_State *L) {
138
     p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
139
-    return buffer_meth_getstats(L, &tcp->buf);
140
+    return ls_buffer_meth_getstats(L, &tcp->buf);
141
 }
142
 
143
 static int meth_setstats(lua_State *L) {
144
     p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
145
-    return buffer_meth_setstats(L, &tcp->buf);
146
+    return ls_buffer_meth_setstats(L, &tcp->buf);
147
 }
148
 
149
 /*-------------------------------------------------------------------------*\
150
@@ -152,7 +152,7 @@
151
 static int meth_dirty(lua_State *L)
152
 {
153
     p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
154
-    lua_pushboolean(L, !buffer_isempty(&tcp->buf));
155
+    lua_pushboolean(L, !ls_buffer_isempty(&tcp->buf));
156
     return 1;
157
 }
158
 
159
@@ -176,7 +176,7 @@
160
         io_init(&clnt->io, (p_send) socket_send, (p_recv) socket_recv, 
161
                 (p_error) socket_ioerror, &clnt->sock);
162
         timeout_init(&clnt->tm, -1, -1);
163
-        buffer_init(&clnt->buf, &clnt->io, &clnt->tm);
164
+        ls_buffer_init(&clnt->buf, &clnt->io, &clnt->tm);
165
         return 1;
166
     } else {
167
         lua_pushnil(L); 
168
@@ -329,7 +329,7 @@
169
         io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv, 
170
                 (p_error) socket_ioerror, &tcp->sock);
171
         timeout_init(&tcp->tm, -1, -1);
172
-        buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
173
+        ls_buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
174
         return 1;
175
     } else {
176
         lua_pushnil(L);
177
diff -ru src/unix.c src/unix.c
178
--- src/unix.c	2008-08-20 06:16:42 +0000
179
+++ src/unix.c	2008-08-20 06:30:15 +0000
180
@@ -105,22 +105,22 @@
181
 \*-------------------------------------------------------------------------*/
182
 static int meth_send(lua_State *L) {
183
     p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
184
-    return buffer_meth_send(L, &un->buf);
185
+    return ls_buffer_meth_send(L, &un->buf);
186
 }
187
 
188
 static int meth_receive(lua_State *L) {
189
     p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
190
-    return buffer_meth_receive(L, &un->buf);
191
+    return ls_buffer_meth_receive(L, &un->buf);
192
 }
193
 
194
 static int meth_getstats(lua_State *L) {
195
     p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
196
-    return buffer_meth_getstats(L, &un->buf);
197
+    return ls_buffer_meth_getstats(L, &un->buf);
198
 }
199
 
200
 static int meth_setstats(lua_State *L) {
201
     p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
202
-    return buffer_meth_setstats(L, &un->buf);
203
+    return ls_buffer_meth_setstats(L, &un->buf);
204
 }
205
 
206
 /*-------------------------------------------------------------------------*\
207
@@ -149,7 +149,7 @@
208
 
209
 static int meth_dirty(lua_State *L) {
210
     p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
211
-    lua_pushboolean(L, !buffer_isempty(&un->buf));
212
+    lua_pushboolean(L, !ls_buffer_isempty(&un->buf));
213
     return 1;
214
 }
215
 
216
@@ -172,7 +172,7 @@
217
         io_init(&clnt->io, (p_send)socket_send, (p_recv)socket_recv, 
218
                 (p_error) socket_ioerror, &clnt->sock);
219
         timeout_init(&clnt->tm, -1, -1);
220
-        buffer_init(&clnt->buf, &clnt->io, &clnt->tm);
221
+        ls_buffer_init(&clnt->buf, &clnt->io, &clnt->tm);
222
         return 1;
223
     } else {
224
         lua_pushnil(L); 
225
@@ -346,7 +346,7 @@
226
         io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv, 
227
                 (p_error) socket_ioerror, &un->sock);
228
         timeout_init(&un->tm, -1, -1);
229
-        buffer_init(&un->buf, &un->io, &un->tm);
230
+        ls_buffer_init(&un->buf, &un->io, &un->tm);
231
         return 1;
232
     } else {
233
         lua_pushnil(L);

Return to bug 138055