aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego.nehab@gmail.com>2015-03-03 19:01:00 -0300
committerDiego Nehab <diego.nehab@gmail.com>2015-03-03 19:01:00 -0300
commitbbcbbf845eca5a59419d1f092353fd4a3c980411 (patch)
tree5b6d2eedbb2077ad8b95bf27d6a1bea1cfc0792c
parent8396a0291b2d97bc837c4c55bb99f7f6777ce515 (diff)
parentd8f77cca6456cbd5f0e34460aa9d379c0ac06740 (diff)
downloadluasocket-bbcbbf845eca5a59419d1f092353fd4a3c980411.tar.gz
luasocket-bbcbbf845eca5a59419d1f092353fd4a3c980411.tar.bz2
luasocket-bbcbbf845eca5a59419d1f092353fd4a3c980411.zip
Merge pull request #119 from gatzka/master
Make casts const correct.
-rw-r--r--src/mime.c20
-rw-r--r--src/options.h3
-rw-r--r--src/udp.c2
3 files changed, 13 insertions, 12 deletions
diff --git a/src/mime.c b/src/mime.c
index 8edb750..d121e9e 100644
--- a/src/mime.c
+++ b/src/mime.c
@@ -111,7 +111,7 @@ static int mime_global_wrp(lua_State *L)
111{ 111{
112 size_t size = 0; 112 size_t size = 0;
113 int left = (int) luaL_checknumber(L, 1); 113 int left = (int) luaL_checknumber(L, 1);
114 const UC *input = (UC *) luaL_optlstring(L, 2, NULL, &size); 114 const UC *input = (const UC *) luaL_optlstring(L, 2, NULL, &size);
115 const UC *last = input + size; 115 const UC *last = input + size;
116 int length = (int) luaL_optnumber(L, 3, 76); 116 int length = (int) luaL_optnumber(L, 3, 76);
117 luaL_Buffer buffer; 117 luaL_Buffer buffer;
@@ -259,7 +259,7 @@ static int mime_global_b64(lua_State *L)
259{ 259{
260 UC atom[3]; 260 UC atom[3];
261 size_t isize = 0, asize = 0; 261 size_t isize = 0, asize = 0;
262 const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); 262 const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
263 const UC *last = input + isize; 263 const UC *last = input + isize;
264 luaL_Buffer buffer; 264 luaL_Buffer buffer;
265 /* end-of-input blackhole */ 265 /* end-of-input blackhole */
@@ -274,7 +274,7 @@ static int mime_global_b64(lua_State *L)
274 luaL_buffinit(L, &buffer); 274 luaL_buffinit(L, &buffer);
275 while (input < last) 275 while (input < last)
276 asize = b64encode(*input++, atom, asize, &buffer); 276 asize = b64encode(*input++, atom, asize, &buffer);
277 input = (UC *) luaL_optlstring(L, 2, NULL, &isize); 277 input = (const UC *) luaL_optlstring(L, 2, NULL, &isize);
278 /* if second part is nil, we are done */ 278 /* if second part is nil, we are done */
279 if (!input) { 279 if (!input) {
280 size_t osize = 0; 280 size_t osize = 0;
@@ -305,7 +305,7 @@ static int mime_global_unb64(lua_State *L)
305{ 305{
306 UC atom[4]; 306 UC atom[4];
307 size_t isize = 0, asize = 0; 307 size_t isize = 0, asize = 0;
308 const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); 308 const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
309 const UC *last = input + isize; 309 const UC *last = input + isize;
310 luaL_Buffer buffer; 310 luaL_Buffer buffer;
311 /* end-of-input blackhole */ 311 /* end-of-input blackhole */
@@ -320,7 +320,7 @@ static int mime_global_unb64(lua_State *L)
320 luaL_buffinit(L, &buffer); 320 luaL_buffinit(L, &buffer);
321 while (input < last) 321 while (input < last)
322 asize = b64decode(*input++, atom, asize, &buffer); 322 asize = b64decode(*input++, atom, asize, &buffer);
323 input = (UC *) luaL_optlstring(L, 2, NULL, &isize); 323 input = (const UC *) luaL_optlstring(L, 2, NULL, &isize);
324 /* if second is nil, we are done */ 324 /* if second is nil, we are done */
325 if (!input) { 325 if (!input) {
326 size_t osize = 0; 326 size_t osize = 0;
@@ -457,7 +457,7 @@ static int mime_global_qp(lua_State *L)
457 457
458 size_t asize = 0, isize = 0; 458 size_t asize = 0, isize = 0;
459 UC atom[3]; 459 UC atom[3];
460 const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); 460 const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
461 const UC *last = input + isize; 461 const UC *last = input + isize;
462 const char *marker = luaL_optstring(L, 3, CRLF); 462 const char *marker = luaL_optstring(L, 3, CRLF);
463 luaL_Buffer buffer; 463 luaL_Buffer buffer;
@@ -473,7 +473,7 @@ static int mime_global_qp(lua_State *L)
473 luaL_buffinit(L, &buffer); 473 luaL_buffinit(L, &buffer);
474 while (input < last) 474 while (input < last)
475 asize = qpencode(*input++, atom, asize, marker, &buffer); 475 asize = qpencode(*input++, atom, asize, marker, &buffer);
476 input = (UC *) luaL_optlstring(L, 2, NULL, &isize); 476 input = (const UC *) luaL_optlstring(L, 2, NULL, &isize);
477 /* if second part is nil, we are done */ 477 /* if second part is nil, we are done */
478 if (!input) { 478 if (!input) {
479 asize = qppad(atom, asize, &buffer); 479 asize = qppad(atom, asize, &buffer);
@@ -533,7 +533,7 @@ static int mime_global_unqp(lua_State *L)
533{ 533{
534 size_t asize = 0, isize = 0; 534 size_t asize = 0, isize = 0;
535 UC atom[3]; 535 UC atom[3];
536 const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); 536 const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
537 const UC *last = input + isize; 537 const UC *last = input + isize;
538 luaL_Buffer buffer; 538 luaL_Buffer buffer;
539 /* end-of-input blackhole */ 539 /* end-of-input blackhole */
@@ -548,7 +548,7 @@ static int mime_global_unqp(lua_State *L)
548 luaL_buffinit(L, &buffer); 548 luaL_buffinit(L, &buffer);
549 while (input < last) 549 while (input < last)
550 asize = qpdecode(*input++, atom, asize, &buffer); 550 asize = qpdecode(*input++, atom, asize, &buffer);
551 input = (UC *) luaL_optlstring(L, 2, NULL, &isize); 551 input = (const UC *) luaL_optlstring(L, 2, NULL, &isize);
552 /* if second part is nil, we are done */ 552 /* if second part is nil, we are done */
553 if (!input) { 553 if (!input) {
554 luaL_pushresult(&buffer); 554 luaL_pushresult(&buffer);
@@ -578,7 +578,7 @@ static int mime_global_qpwrp(lua_State *L)
578{ 578{
579 size_t size = 0; 579 size_t size = 0;
580 int left = (int) luaL_checknumber(L, 1); 580 int left = (int) luaL_checknumber(L, 1);
581 const UC *input = (UC *) luaL_optlstring(L, 2, NULL, &size); 581 const UC *input = (const UC *) luaL_optlstring(L, 2, NULL, &size);
582 const UC *last = input + size; 582 const UC *last = input + size;
583 int length = (int) luaL_optnumber(L, 3, 76); 583 int length = (int) luaL_optnumber(L, 3, 76);
584 luaL_Buffer buffer; 584 luaL_Buffer buffer;
diff --git a/src/options.h b/src/options.h
index 5657a06..b75db37 100644
--- a/src/options.h
+++ b/src/options.h
@@ -51,7 +51,8 @@ int opt_get_error(lua_State *L, p_socket ps);
51int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps); 51int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps);
52int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps); 52int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps);
53int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps); 53int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
54int opt_get_ip6_v6only(lua_State *L, p_socket ps); 54int opt_get_ip6_v6only(lua_State *L, p_socket ps);
55int opt_get_reuseport(lua_State *L, p_socket ps);
55 56
56/* invokes the appropriate option handler */ 57/* invokes the appropriate option handler */
57int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); 58int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps);
diff --git a/src/udp.c b/src/udp.c
index a9f2393..12e320a 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -131,7 +131,7 @@ int udp_open(lua_State *L)
131/*=========================================================================*\ 131/*=========================================================================*\
132* Lua methods 132* Lua methods
133\*=========================================================================*/ 133\*=========================================================================*/
134const char *udp_strerror(int err) { 134static const char *udp_strerror(int err) {
135 /* a 'closed' error on an unconnected means the target address was not 135 /* a 'closed' error on an unconnected means the target address was not
136 * accepted by the transport layer */ 136 * accepted by the transport layer */
137 if (err == IO_CLOSED) return "refused"; 137 if (err == IO_CLOSED) return "refused";