|
@@ -40,18 +40,19 @@ static int send_tcp_request(int length, void *buffer, void *ptr) {
|
40
|
40
|
/**************************************************************************
|
41
|
41
|
RECV_TCP_CALLBACK - Receive data using TCP
|
42
|
42
|
**************************************************************************/
|
43
|
|
-static int recv_tcp_request(int length, const void *buffer, void *ptr) {
|
|
43
|
+static int recv_tcp_request(int length, const void *data, void *ptr) {
|
44
|
44
|
struct send_recv_state *state = (struct send_recv_state *)ptr;
|
|
45
|
+ const char *buffer = data;
|
45
|
46
|
|
46
|
47
|
/* Assume that the lines in an HTTP header do not straddle a packet */
|
47
|
48
|
/* boundary. This is probably a reasonable assumption */
|
48
|
49
|
if (state->recv_state == RESULT_CODE) {
|
49
|
50
|
while (length > 0) {
|
50
|
51
|
/* Find HTTP result code */
|
51
|
|
- if (*(const char *)buffer == ' ') {
|
52
|
|
- const char *ptr = ((const char *)buffer) + 1;
|
|
52
|
+ if (*buffer == ' ') {
|
|
53
|
+ const char *ptr = buffer + 1;
|
53
|
54
|
int rc = strtoul(ptr, &ptr, 10);
|
54
|
|
- if (ptr >= (const char *)buffer + length) {
|
|
55
|
+ if (ptr >= buffer + length) {
|
55
|
56
|
state->recv_state = ERROR;
|
56
|
57
|
DBG ( "HTTP got bad result code\n" );
|
57
|
58
|
return 0;
|
|
@@ -61,7 +62,7 @@ static int recv_tcp_request(int length, const void *buffer, void *ptr) {
|
61
|
62
|
DBG ( "HTTP got result code %d\n", rc );
|
62
|
63
|
goto header;
|
63
|
64
|
}
|
64
|
|
- ++(const char *)buffer;
|
|
65
|
+ ++buffer;
|
65
|
66
|
length--;
|
66
|
67
|
}
|
67
|
68
|
state->recv_state = ERROR;
|
|
@@ -88,7 +89,7 @@ static int recv_tcp_request(int length, const void *buffer, void *ptr) {
|
88
|
89
|
/* Find beginning of line */
|
89
|
90
|
while (length > 0) {
|
90
|
91
|
length--;
|
91
|
|
- if (*((const char *)buffer)++ == '\n')
|
|
92
|
+ if (*buffer++ == '\n')
|
92
|
93
|
break;
|
93
|
94
|
}
|
94
|
95
|
/* Check for end of header */
|
|
@@ -140,7 +141,7 @@ static int http ( char *url, struct sockaddr_in *server __unused,
|
140
|
141
|
|
141
|
142
|
tcp_transaction ( server->sin_addr.s_addr,
|
142
|
143
|
server->sin_port, &state,
|
143
|
|
- send_tcp_request, recv_tcp_request );
|
|
144
|
+ send_tcp_request, (int (*)(int, const void *, void *))recv_tcp_request );
|
144
|
145
|
}
|
145
|
146
|
|
146
|
147
|
if ( state.recv_state == MOVED ) {
|