From 8d94472903d973b0edc957a0fb31f272c2225846 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 10 Feb 2010 10:45:07 +0000 Subject: More ticket #1018: fixed some more warnings about pointer conversions, or errors if the library is compiled in C++ mode (thanks Atik Khan for the report) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3095 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib-util/src/pjlib-util-test/http_client.c | 34 +++++++++++++++++++--------- pjlib-util/src/pjlib-util/http_client.c | 24 +++++++++++--------- 2 files changed, 36 insertions(+), 22 deletions(-) (limited to 'pjlib-util') diff --git a/pjlib-util/src/pjlib-util-test/http_client.c b/pjlib-util/src/pjlib-util-test/http_client.c index e31caf25..6796a272 100644 --- a/pjlib-util/src/pjlib-util-test/http_client.c +++ b/pjlib-util/src/pjlib-util-test/http_client.c @@ -67,7 +67,7 @@ static int server_thread(void *p) pj_sock_t newsock; while (!thread_quit) { - char *pkt = pj_pool_alloc(pool, srv->buf_size); + char *pkt = (char*)pj_pool_alloc(pool, srv->buf_size); pj_ssize_t pkt_len; int rc; pj_fd_set_t rset; @@ -154,7 +154,7 @@ static void on_send_data(pj_http_req *hreq, } send_size += sendsz; - sdata = pj_pool_alloc(pool, sendsz); + sdata = (char*)pj_pool_alloc(pool, sendsz); pj_create_random_string(sdata, sendsz); pj_ansi_sprintf(sdata, "\nSegment #%d\n", ++counter); *data = sdata; @@ -418,11 +418,23 @@ int http_client_test2() param.timeout.msec = 50; #endif - pj_http_headers_add_elmt2(¶m.headers, "Accept", - "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"); - pj_http_headers_add_elmt2(¶m.headers, "Accept-Language", "en-sg"); - pj_http_headers_add_elmt2(¶m.headers, "User-Agent", - "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"); + pj_http_headers_add_elmt2(¶m.headers, (char*)"Accept", + (char*)"image/gif, image/x-xbitmap, image/jpeg, " + "image/pjpeg, application/x-ms-application," + " application/vnd.ms-xpsdocument, " + "application/xaml+xml, " + "application/x-ms-xbap, " + "application/x-shockwave-flash, " + "application/vnd.ms-excel, " + "application/vnd.ms-powerpoint, " + "application/msword, */*"); + pj_http_headers_add_elmt2(¶m.headers, (char*)"Accept-Language", + (char*)"en-sg"); + pj_http_headers_add_elmt2(¶m.headers, (char*)"User-Agent", + (char*)"Mozilla/4.0 (compatible; MSIE 7.0; " + "Windows NT 6.0; SLCC1; " + ".NET CLR 2.0.50727; " + ".NET CLR 3.0.04506)"); if (pj_http_req_create(pool, &url, timer_heap, ioqueue, ¶m, &hcb, &http_req)) return -43; @@ -522,8 +534,8 @@ int http_client_test_put1() #endif pj_http_req_param_default(¶m); - pj_strset2(¶m.method, "PUT"); - data = pj_pool_alloc(pool, length); + pj_strset2(¶m.method, (char*)"PUT"); + data = (char*)pj_pool_alloc(pool, length); pj_create_random_string(data, length); pj_ansi_sprintf(data, "PUT test\n"); param.reqdata.data = data; @@ -612,7 +624,7 @@ int http_client_test_put2() #endif pj_http_req_param_default(¶m); - pj_strset2(¶m.method, "PUT"); + pj_strset2(¶m.method, (char*)"PUT"); total_size = 15383; send_size = 0; param.reqdata.total_size = total_size; @@ -693,7 +705,7 @@ int http_client_test_delete() #endif pj_http_req_param_default(¶m); - pj_strset2(¶m.method, "DELETE"); + pj_strset2(¶m.method, (char*)"DELETE"); if (pj_http_req_create(pool, &url, timer_heap, ioqueue, ¶m, &hcb, &http_req)) return -63; diff --git a/pjlib-util/src/pjlib-util/http_client.c b/pjlib-util/src/pjlib-util/http_client.c index 2b7585d5..bff68e2a 100644 --- a/pjlib-util/src/pjlib-util/http_client.c +++ b/pjlib-util/src/pjlib-util/http_client.c @@ -56,7 +56,7 @@ enum http_protocol PROTOCOL_HTTPS }; -static char *http_protocol_names[NUM_PROTOCOL] = +static const char *http_protocol_names[NUM_PROTOCOL] = { "HTTP", "HTTPS" @@ -75,7 +75,7 @@ enum http_method HTTP_DELETE }; -static char *http_method_names[3] = +static const char *http_method_names[3] = { "GET", "PUT", @@ -155,7 +155,7 @@ static pj_uint16_t get_http_default_port(const pj_str_t *protocol) return 0; } -static char * get_protocol(const pj_str_t *protocol) +static const char * get_protocol(const pj_str_t *protocol) { int i; @@ -469,7 +469,7 @@ static pj_status_t http_response_parse(pj_pool_t *pool, { pj_size_t i; char *cptr; - void *newdata; + char *newdata; pj_scanner scanner; pj_str_t s; pj_status_t status; @@ -501,7 +501,7 @@ static pj_status_t http_response_parse(pj_pool_t *pool, pj_bzero(response, sizeof(response)); response->content_length = -1; - newdata = pj_pool_alloc(pool, i); + newdata = (char*) pj_pool_alloc(pool, i); pj_memcpy(newdata, data, i); /* Parse the status-line. */ @@ -523,7 +523,7 @@ static pj_status_t http_response_parse(pj_pool_t *pool, PJ_END; /* Parse the response headers. */ - size = i - 2 - (scanner.curptr - (char *)newdata); + size = i - 2 - (scanner.curptr - newdata); if (size > 0) { status = http_headers_parse(scanner.curptr + 1, size, &response->headers); @@ -604,8 +604,8 @@ PJ_DEF(void) pj_http_req_param_default(pj_http_req_param *param) pj_assert(param); pj_bzero(param, sizeof(*param)); param->addr_family = pj_AF_INET(); - pj_strset2(¶m->method, http_method_names[HTTP_GET]); - pj_strset2(¶m->version, HTTP_1_0); + pj_strset2(¶m->method, (char*)http_method_names[HTTP_GET]); + pj_strset2(¶m->version, (char*)HTTP_1_0); param->timeout.msec = PJ_HTTP_DEFAULT_TIMEOUT; pj_time_val_normalize(¶m->timeout); } @@ -630,9 +630,11 @@ PJ_DEF(pj_status_t) pj_http_req_parse_url(const pj_str_t *url, /* Parse the protocol */ pj_scan_get_until_ch(&scanner, ':', &s); if (!pj_stricmp2(&s, http_protocol_names[PROTOCOL_HTTP])) { - pj_strset2(&hurl->protocol, http_protocol_names[PROTOCOL_HTTP]); + pj_strset2(&hurl->protocol, + (char*)http_protocol_names[PROTOCOL_HTTP]); } else if (!pj_stricmp2(&s, http_protocol_names[PROTOCOL_HTTPS])) { - pj_strset2(&hurl->protocol, http_protocol_names[PROTOCOL_HTTPS]); + pj_strset2(&hurl->protocol, + (char*)http_protocol_names[PROTOCOL_HTTPS]); } else { PJ_THROW(PJ_ENOTSUP); // unsupported protocol } @@ -912,7 +914,7 @@ static pj_status_t http_req_start_sending(pj_http_req *hreq) pkt.ptr[pkt.slen] = 0; TRACE_((THIS_FILE, "%s", pkt.ptr)); } else { - pkt.ptr = hreq->param.reqdata.data; + pkt.ptr = (char*)hreq->param.reqdata.data; pkt.slen = hreq->param.reqdata.size; } -- cgit v1.2.3