aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-01-19 15:38:33 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-01-19 15:38:33 +0000
commitf210508b2286dabfe53b1522ffad36eb8b823a3c (patch)
tree5832e3e3adec51d77173b4d2992d0e2f39242be1 /src
parent32a3b93512d946dfcfeaafb7e49162c844c4f3ce (diff)
downloadluasocket-f210508b2286dabfe53b1522ffad36eb8b823a3c.tar.gz
luasocket-f210508b2286dabfe53b1522ffad36eb8b823a3c.tar.bz2
luasocket-f210508b2286dabfe53b1522ffad36eb8b823a3c.zip
Got rid of some of the typecasts...
Diffstat (limited to 'src')
-rw-r--r--src/mime.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/mime.c b/src/mime.c
index 6ed2787..e6284d2 100644
--- a/src/mime.c
+++ b/src/mime.c
@@ -21,8 +21,8 @@
21#define SP 0x20 21#define SP 0x20
22 22
23typedef unsigned char UC; 23typedef unsigned char UC;
24static const UC CRLF[2] = {CR, LF}; 24static const char CRLF[2] = {CR, LF};
25static const UC EQCRLF[3] = {'=', CR, LF}; 25static const char EQCRLF[3] = {'=', CR, LF};
26 26
27/*=========================================================================*\ 27/*=========================================================================*\
28* Internal function prototypes. 28* Internal function prototypes.
@@ -44,7 +44,7 @@ static void qpfill(UC *qpclass, UC *qpunbase);
44static void qpquote(UC c, luaL_Buffer *buffer); 44static void qpquote(UC c, luaL_Buffer *buffer);
45static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer); 45static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer);
46static size_t qpencode(UC c, UC *input, size_t size, 46static size_t qpencode(UC c, UC *input, size_t size,
47 const UC *marker, luaL_Buffer *buffer); 47 const char *marker, luaL_Buffer *buffer);
48 48
49/* code support functions */ 49/* code support functions */
50static luaL_reg func[] = { 50static luaL_reg func[] = {
@@ -118,18 +118,18 @@ static int mime_global_fmt(lua_State *L)
118 const UC *last = input + size; 118 const UC *last = input + size;
119 int length = (int) luaL_checknumber(L, 2); 119 int length = (int) luaL_checknumber(L, 2);
120 int left = (int) luaL_optnumber(L, 3, length); 120 int left = (int) luaL_optnumber(L, 3, length);
121 const UC *marker = (UC *) luaL_optstring(L, 4, (char *) CRLF); 121 const char *marker = luaL_optstring(L, 4, CRLF);
122 luaL_Buffer buffer; 122 luaL_Buffer buffer;
123 luaL_buffinit(L, &buffer); 123 luaL_buffinit(L, &buffer);
124 while (input < last) { 124 while (input < last) {
125 luaL_putchar(&buffer, *input++); 125 luaL_putchar(&buffer, *input++);
126 if (--left <= 0) { 126 if (--left <= 0) {
127 luaL_addstring(&buffer, (char *) marker); 127 luaL_addstring(&buffer, marker);
128 left = length; 128 left = length;
129 } 129 }
130 } 130 }
131 if (!input && left < length) { 131 if (!input && left < length) {
132 luaL_addstring(&buffer, (char *) marker); 132 luaL_addstring(&buffer, marker);
133 left = length; 133 left = length;
134 } 134 }
135 luaL_pushresult(&buffer); 135 luaL_pushresult(&buffer);
@@ -352,7 +352,7 @@ static void qpquote(UC c, luaL_Buffer *buffer)
352* Once we are sure, output the to the buffer, in the correct form. 352* Once we are sure, output the to the buffer, in the correct form.
353\*-------------------------------------------------------------------------*/ 353\*-------------------------------------------------------------------------*/
354static size_t qpencode(UC c, UC *input, size_t size, 354static size_t qpencode(UC c, UC *input, size_t size,
355 const UC *marker, luaL_Buffer *buffer) 355 const char *marker, luaL_Buffer *buffer)
356{ 356{
357 input[size++] = c; 357 input[size++] = c;
358 /* deal with all characters we can have */ 358 /* deal with all characters we can have */
@@ -362,7 +362,7 @@ static size_t qpencode(UC c, UC *input, size_t size,
362 case QP_CR: 362 case QP_CR:
363 if (size < 2) return size; 363 if (size < 2) return size;
364 if (input[1] == LF) { 364 if (input[1] == LF) {
365 luaL_addstring(buffer, (char *) marker); 365 luaL_addstring(buffer, marker);
366 return 0; 366 return 0;
367 } else qpquote(input[0], buffer); 367 } else qpquote(input[0], buffer);
368 break; 368 break;
@@ -372,7 +372,7 @@ static size_t qpencode(UC c, UC *input, size_t size,
372 /* if it is the last, quote it and we are done */ 372 /* if it is the last, quote it and we are done */
373 if (input[1] == CR && input[2] == LF) { 373 if (input[1] == CR && input[2] == LF) {
374 qpquote(input[0], buffer); 374 qpquote(input[0], buffer);
375 luaL_addstring(buffer, (char *) marker); 375 luaL_addstring(buffer, marker);
376 return 0; 376 return 0;
377 } else luaL_putchar(buffer, input[0]); 377 } else luaL_putchar(buffer, input[0]);
378 break; 378 break;
@@ -401,7 +401,7 @@ static void qppad(UC *input, size_t size, luaL_Buffer *buffer)
401 if (qpclass[input[i]] == QP_PLAIN) luaL_putchar(buffer, input[i]); 401 if (qpclass[input[i]] == QP_PLAIN) luaL_putchar(buffer, input[i]);
402 else qpquote(input[i], buffer); 402 else qpquote(input[i], buffer);
403 } 403 }
404 luaL_addstring(buffer, (char *) EQCRLF); 404 luaL_addstring(buffer, EQCRLF);
405} 405}
406 406
407/*-------------------------------------------------------------------------*\ 407/*-------------------------------------------------------------------------*\
@@ -420,7 +420,7 @@ static int mime_global_qp(lua_State *L)
420 const UC *input = (UC *) (lua_isnil(L, 1) ? NULL: 420 const UC *input = (UC *) (lua_isnil(L, 1) ? NULL:
421 luaL_checklstring(L, 1, &isize)); 421 luaL_checklstring(L, 1, &isize));
422 const UC *last = input + isize; 422 const UC *last = input + isize;
423 const UC *marker = (UC *) luaL_optstring(L, 3, (char *) CRLF); 423 const char *marker = luaL_optstring(L, 3, CRLF);
424 luaL_Buffer buffer; 424 luaL_Buffer buffer;
425 luaL_buffinit(L, &buffer); 425 luaL_buffinit(L, &buffer);
426 while (input < last) 426 while (input < last)
@@ -530,7 +530,7 @@ static int mime_global_qpfmt(lua_State *L)
530 /* if there's no room in this line for the quoted char, 530 /* if there's no room in this line for the quoted char,
531 * output a soft line break now */ 531 * output a soft line break now */
532 if (left <= 3) { 532 if (left <= 3) {
533 luaL_addstring(&buffer, (char *) EQCRLF); 533 luaL_addstring(&buffer, EQCRLF);
534 left = length; 534 left = length;
535 } 535 }
536 break; 536 break;
@@ -543,7 +543,7 @@ static int mime_global_qpfmt(lua_State *L)
543 default: 543 default:
544 /* if in last column, output a soft line break */ 544 /* if in last column, output a soft line break */
545 if (left <= 1) { 545 if (left <= 1) {
546 luaL_addstring(&buffer, (char *) EQCRLF); 546 luaL_addstring(&buffer, EQCRLF);
547 left = length; 547 left = length;
548 } 548 }
549 } 549 }
@@ -551,7 +551,7 @@ static int mime_global_qpfmt(lua_State *L)
551 input++; 551 input++;
552 } 552 }
553 if (!input && left < length) { 553 if (!input && left < length) {
554 luaL_addstring(&buffer, (char *) EQCRLF); 554 luaL_addstring(&buffer, EQCRLF);
555 left = length; 555 left = length;
556 } 556 }
557 luaL_pushresult(&buffer); 557 luaL_pushresult(&buffer);
@@ -569,15 +569,15 @@ static int mime_global_qpfmt(lua_State *L)
569\*-------------------------------------------------------------------------*/ 569\*-------------------------------------------------------------------------*/
570#define eolcandidate(c) (c == CR || c == LF) 570#define eolcandidate(c) (c == CR || c == LF)
571static size_t eolconvert(UC c, UC *input, size_t size, 571static size_t eolconvert(UC c, UC *input, size_t size,
572 const UC *marker, luaL_Buffer *buffer) 572 const char *marker, luaL_Buffer *buffer)
573{ 573{
574 input[size++] = c; 574 input[size++] = c;
575 /* deal with all characters we can deal */ 575 /* deal with all characters we can deal */
576 if (eolcandidate(input[0])) { 576 if (eolcandidate(input[0])) {
577 if (size < 2) return size; 577 if (size < 2) return size;
578 luaL_addstring(buffer, (char *) marker); 578 luaL_addstring(buffer, marker);
579 if (eolcandidate(input[1])) { 579 if (eolcandidate(input[1])) {
580 if (input[0] == input[1]) luaL_addstring(buffer, (char *) marker); 580 if (input[0] == input[1]) luaL_addstring(buffer, marker);
581 } else luaL_putchar(buffer, input[1]); 581 } else luaL_putchar(buffer, input[1]);
582 return 0; 582 return 0;
583 } else { 583 } else {
@@ -600,7 +600,7 @@ static int mime_global_eol(lua_State *L)
600 const UC *input = (UC *) (lua_isnil(L, 1)? NULL: 600 const UC *input = (UC *) (lua_isnil(L, 1)? NULL:
601 luaL_checklstring(L, 1, &isize)); 601 luaL_checklstring(L, 1, &isize));
602 const UC *last = input + isize; 602 const UC *last = input + isize;
603 const UC *marker = (UC *) luaL_optstring(L, 3, (char *) CRLF); 603 const char *marker = luaL_optstring(L, 3, CRLF);
604 luaL_Buffer buffer; 604 luaL_Buffer buffer;
605 luaL_buffinit(L, &buffer); 605 luaL_buffinit(L, &buffer);
606 while (input < last) 606 while (input < last)
@@ -612,7 +612,7 @@ static int mime_global_eol(lua_State *L)
612 asize = eolconvert(*input++, atom, asize, marker, &buffer); 612 asize = eolconvert(*input++, atom, asize, marker, &buffer);
613 /* if there is something in atom, it's one character, and it 613 /* if there is something in atom, it's one character, and it
614 * is a candidate. so we output a new line */ 614 * is a candidate. so we output a new line */
615 } else if (asize > 0) luaL_addstring(&buffer, (char *) marker); 615 } else if (asize > 0) luaL_addstring(&buffer, marker);
616 luaL_pushresult(&buffer); 616 luaL_pushresult(&buffer);
617 lua_pushlstring(L, (char *) atom, asize); 617 lua_pushlstring(L, (char *) atom, asize);
618 return 2; 618 return 2;