summaryrefslogtreecommitdiff
path: root/pjlib-util/src
diff options
context:
space:
mode:
authorRiza Sulistyo <riza@teluu.com>2013-06-19 06:47:43 +0000
committerRiza Sulistyo <riza@teluu.com>2013-06-19 06:47:43 +0000
commitd7aa4332dae06ae890053dd13239ddabee46b86c (patch)
tree34c599b317369bcc33827d5ee1200604a6599164 /pjlib-util/src
parent7949b9e53b97281cfa4526ffe5cf7c7d887b7025 (diff)
Re #1680: Add initial support for Win64
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4537 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib-util/src')
-rw-r--r--pjlib-util/src/pjlib-util-test/encryption.c10
-rw-r--r--pjlib-util/src/pjlib-util-test/http_client.c7
-rw-r--r--pjlib-util/src/pjlib-util-test/resolver_test.c14
-rw-r--r--pjlib-util/src/pjlib-util/base64.c4
-rw-r--r--pjlib-util/src/pjlib-util/cli.c16
-rw-r--r--pjlib-util/src/pjlib-util/cli_console.c15
-rw-r--r--pjlib-util/src/pjlib-util/cli_telnet.c23
-rw-r--r--pjlib-util/src/pjlib-util/crc32.c2
-rw-r--r--pjlib-util/src/pjlib-util/dns.c4
-rw-r--r--pjlib-util/src/pjlib-util/dns_server.c12
-rw-r--r--pjlib-util/src/pjlib-util/http_client.c23
-rw-r--r--pjlib-util/src/pjlib-util/pcap.c4
-rw-r--r--pjlib-util/src/pjlib-util/resolver.c9
-rw-r--r--pjlib-util/src/pjlib-util/scanner.c7
-rw-r--r--pjlib-util/src/pjlib-util/sha1.c5
-rw-r--r--pjlib-util/src/pjlib-util/srv_resolver.c2
-rw-r--r--pjlib-util/src/pjlib-util/xml.c6
17 files changed, 85 insertions, 78 deletions
diff --git a/pjlib-util/src/pjlib-util-test/encryption.c b/pjlib-util/src/pjlib-util-test/encryption.c
index d9af3d9f..4298aa39 100644
--- a/pjlib-util/src/pjlib-util-test/encryption.c
+++ b/pjlib-util/src/pjlib-util-test/encryption.c
@@ -468,7 +468,7 @@ static int crc32_test(void)
for (i=0; i<PJ_ARRAY_SIZE(crc32_test_data); ++i) {
pj_crc32_context ctx;
pj_uint32_t crc0, crc1;
- unsigned len;
+ pj_size_t len;
len = pj_ansi_strlen(crc32_test_data[i].input);
crc0 = pj_crc32_calc((pj_uint8_t*)crc32_test_data[i].input, len);
@@ -591,7 +591,7 @@ static int base64_test(void)
if (base64_test_vec[i].flag & ENCODE) {
out_len = sizeof(output);
rc = pj_base64_encode((pj_uint8_t*)base64_test_vec[i].base256,
- strlen(base64_test_vec[i].base256),
+ (int)strlen(base64_test_vec[i].base256),
output, &out_len);
if (rc != PJ_SUCCESS)
return -90;
@@ -712,7 +712,7 @@ int encryption_benchmark()
double total_len;
input_len = 2048;
- total_len = input_len * LOOP;
+ total_len = (unsigned)input_len * LOOP;
pool = pj_pool_create(mem, "enc", input_len+256, 0, NULL);
if (!pool)
return PJ_ENOMEM;
@@ -726,7 +726,7 @@ int encryption_benchmark()
/* Dry run */
for (i=0; i<PJ_ARRAY_SIZE(algorithms); ++i) {
algorithms[i].init_context(&context);
- algorithms[i].update(&context, input, input_len);
+ algorithms[i].update(&context, input, (unsigned)input_len);
algorithms[i].final(&context, digest);
}
@@ -738,7 +738,7 @@ int encryption_benchmark()
pj_get_timestamp(&t1);
algorithms[i].init_context(&context);
for (j=0; j<LOOP; ++j) {
- algorithms[i].update(&context, input, input_len);
+ algorithms[i].update(&context, input, (unsigned)input_len);
}
algorithms[i].final(&context, digest);
pj_get_timestamp(&t2);
diff --git a/pjlib-util/src/pjlib-util-test/http_client.c b/pjlib-util/src/pjlib-util-test/http_client.c
index dc2fe5f1..ed182065 100644
--- a/pjlib-util/src/pjlib-util-test/http_client.c
+++ b/pjlib-util/src/pjlib-util-test/http_client.c
@@ -76,7 +76,7 @@ static int server_thread(void *p)
while (!thread_quit) {
PJ_FD_ZERO(&rset);
PJ_FD_SET(srv->sock, &rset);
- rc = pj_sock_select(srv->sock+1, &rset, NULL, NULL, &timeout);
+ rc = pj_sock_select((int)srv->sock+1, &rset, NULL, NULL, &timeout);
if (rc != 1) {
continue;
}
@@ -93,7 +93,7 @@ static int server_thread(void *p)
while (!thread_quit) {
PJ_FD_ZERO(&rset);
PJ_FD_SET(newsock, &rset);
- rc = pj_sock_select(newsock+1, &rset, NULL, NULL, &timeout);
+ rc = pj_sock_select((int)newsock+1, &rset, NULL, NULL, &timeout);
if (rc != 1) {
PJ_LOG(3,("http test", "client timeout"));
continue;
@@ -115,7 +115,8 @@ static int server_thread(void *p)
if (srv->action == ACTION_IGNORE) {
continue;
} else if (srv->action == ACTION_REPLY) {
- unsigned send_size = 0, ctr = 0;
+ pj_size_t send_size = 0;
+ unsigned ctr = 0;
pj_ansi_sprintf(pkt, "HTTP/1.0 200 OK\r\n");
if (srv->send_content_length) {
pj_ansi_sprintf(pkt + pj_ansi_strlen(pkt),
diff --git a/pjlib-util/src/pjlib-util-test/resolver_test.c b/pjlib-util/src/pjlib-util-test/resolver_test.c
index ebe466e9..e68efe4f 100644
--- a/pjlib-util/src/pjlib-util-test/resolver_test.c
+++ b/pjlib-util/src/pjlib-util-test/resolver_test.c
@@ -111,7 +111,7 @@ static int print_name(pj_uint8_t *pkt, int size,
return 2;
} else {
if (tab->count < MAX_LABEL) {
- tab->a[tab->count].pos = (p-pkt);
+ tab->a[tab->count].pos = (unsigned)(p-pkt);
tab->a[tab->count].label.ptr = (char*)(p+1);
tab->a[tab->count].label.slen = name->slen;
++tab->count;
@@ -136,7 +136,7 @@ static int print_name(pj_uint8_t *pkt, int size,
*p = (pj_uint8_t)label.slen;
pj_memcpy(p+1, label.ptr, label.slen);
- size -= (label.slen+1);
+ size -= (int)(label.slen+1);
p += (label.slen+1);
if (endlabel != endname && *endlabel == '.')
@@ -149,7 +149,7 @@ static int print_name(pj_uint8_t *pkt, int size,
*p++ = '\0';
- return p-pos;
+ return (int)(p-pos);
}
static int print_rr(pj_uint8_t *pkt, int size, pj_uint8_t *pos,
@@ -232,7 +232,7 @@ static int print_rr(pj_uint8_t *pkt, int size, pj_uint8_t *pos,
return -1;
}
- return p-pos;
+ return (int)(p-pos);
}
static int print_packet(const pj_dns_parsed_packet *rec, pj_uint8_t *pkt,
@@ -319,7 +319,7 @@ static int print_packet(const pj_dns_parsed_packet *rec, pj_uint8_t *pkt,
size -= len;
}
- return p - pkt;
+ return (int)(p - pkt);
}
@@ -339,7 +339,7 @@ static int server_thread(void *p)
PJ_FD_ZERO(&rset);
PJ_FD_SET(srv->sock, &rset);
- rc = pj_sock_select(srv->sock+1, &rset, NULL, NULL, &timeout);
+ rc = pj_sock_select((int)(srv->sock+1), &rset, NULL, NULL, &timeout);
if (rc != 1)
continue;
@@ -355,7 +355,7 @@ static int server_thread(void *p)
PJ_LOG(5,(THIS_FILE, "Server %d processing packet", srv - &g_server[0]));
srv->pkt_count++;
- rc = pj_dns_parse_packet(pool, pkt, pkt_len, &req);
+ rc = pj_dns_parse_packet(pool, pkt, (unsigned)pkt_len, &req);
if (rc != PJ_SUCCESS) {
app_perror("server error parsing packet", rc);
continue;
diff --git a/pjlib-util/src/pjlib-util/base64.c b/pjlib-util/src/pjlib-util/base64.c
index 6e77e806..b28e7527 100644
--- a/pjlib-util/src/pjlib-util/base64.c
+++ b/pjlib-util/src/pjlib-util/base64.c
@@ -116,7 +116,7 @@ PJ_DEF(pj_status_t) pj_base64_encode(const pj_uint8_t *input, int in_len,
po += 4;
}
- *out_len = po - output;
+ *out_len = (int)(po - output);
return PJ_SUCCESS;
}
@@ -125,7 +125,7 @@ PJ_DEF(pj_status_t) pj_base64_decode(const pj_str_t *input,
pj_uint8_t *out, int *out_len)
{
const char *buf = input->ptr;
- int len = input->slen;
+ int len = (int)input->slen;
int i, j, k;
int c[4];
diff --git a/pjlib-util/src/pjlib-util/cli.c b/pjlib-util/src/pjlib-util/cli.c
index 7b3548bb..deb04365 100644
--- a/pjlib-util/src/pjlib-util/cli.c
+++ b/pjlib-util/src/pjlib-util/cli.c
@@ -319,9 +319,9 @@ PJ_DEF(void) pj_cli_write_log(pj_cli_t *cli,
}
}
-PJ_DECL(void) pj_cli_sess_write_msg(pj_cli_sess *sess,
- const char *buffer,
- int len)
+PJ_DEF(void) pj_cli_sess_write_msg(pj_cli_sess *sess,
+ const char *buffer,
+ pj_size_t len)
{
struct pj_cli_front_end *fe;
@@ -507,7 +507,7 @@ static pj_cli_cmd_spec *get_cmd_name(const pj_cli_t *cli,
}
pj_strcat(&cmd_val, cmd);
return (pj_cli_cmd_spec *)pj_hash_get(cli->cmd_name_hash, cmd_val.ptr,
- cmd_val.slen, NULL);
+ (unsigned)cmd_val.slen, NULL);
}
/* Add command to the command hash */
@@ -530,7 +530,7 @@ static void add_cmd_name(pj_cli_t *cli, pj_cli_cmd_spec *group,
pj_strdup(cli->pool, &add_cmd, &cmd_val);
pj_hash_set(cli->pool, cli->cmd_name_hash, cmd_val.ptr,
- cmd_val.slen, 0, cmd);
+ (unsigned)cmd_val.slen, 0, cmd);
}
/**
@@ -845,7 +845,7 @@ PJ_DEF(pj_status_t) pj_cli_sess_parse(pj_cli_sess *sess,
{
pj_scanner scanner;
pj_str_t str;
- int len;
+ pj_size_t len;
pj_cli_cmd_spec *cmd;
pj_cli_cmd_spec *next_cmd;
pj_status_t status = PJ_SUCCESS;
@@ -887,7 +887,7 @@ PJ_DEF(pj_status_t) pj_cli_sess_parse(pj_cli_sess *sess,
PJ_TRY {
val->argc = 0;
while (!pj_scan_is_eof(&scanner)) {
- info->err_pos = scanner.curptr - scanner.begin;
+ info->err_pos = (int)(scanner.curptr - scanner.begin);
if (*scanner.curptr == '\'' || *scanner.curptr == '"' ||
*scanner.curptr == '{')
{
@@ -944,7 +944,7 @@ PJ_DEF(pj_status_t) pj_cli_sess_parse(pj_cli_sess *sess,
data.ptr[data.slen] = ' ';
data.ptr[data.slen+1] = 0;
- info->err_pos = pj_ansi_strlen(cmdline);
+ info->err_pos = (int)pj_ansi_strlen(cmdline);
}
}
diff --git a/pjlib-util/src/pjlib-util/cli_console.c b/pjlib-util/src/pjlib-util/cli_console.c
index 9c7dbc63..65e2d896 100644
--- a/pjlib-util/src/pjlib-util/cli_console.c
+++ b/pjlib-util/src/pjlib-util/cli_console.c
@@ -57,12 +57,12 @@ struct cli_console_fe
};
static void console_write_log(pj_cli_front_end *fe, int level,
- const char *data, int len)
+ const char *data, pj_size_t len)
{
struct cli_console_fe * cfe = (struct cli_console_fe *)fe;
if (cfe->sess->log_level > level)
- printf("%.*s", len, data);
+ printf("%.*s", (int)len, data);
}
static void console_quit(pj_cli_front_end *fe, pj_cli_sess *req)
@@ -197,7 +197,7 @@ static void send_err_arg(pj_cli_sess *sess,
{
pj_str_t send_data;
char data_str[256];
- unsigned len;
+ pj_size_t len;
unsigned i;
struct cli_console_fe *fe = (struct cli_console_fe *)sess->fe;
@@ -261,7 +261,7 @@ static void send_ambi_arg(pj_cli_sess *sess,
pj_bool_t with_return)
{
unsigned i;
- unsigned len;
+ pj_size_t len;
pj_str_t send_data;
char data[1028];
struct cli_console_fe *fe = (struct cli_console_fe *)sess->fe;
@@ -466,7 +466,7 @@ static int readline_thread(void * p)
printf("%s", fe->cfg.prompt_str.ptr);
while (!fe->thread_quit) {
- unsigned input_len = 0;
+ pj_size_t input_len = 0;
pj_str_t input_str;
char *recv_buf = fe->input.buf;
pj_bool_t is_valid = PJ_TRUE;
@@ -478,8 +478,9 @@ static int readline_thread(void * p)
* If exit is desired end script with q for quit
*/
/* Reopen stdin/stdout/stderr to /dev/console */
-#if defined(PJ_WIN32) && PJ_WIN32!=0 && \
- (!defined(PJ_WIN32_WINCE) || PJ_WIN32_WINCE==0)
+#if ((defined(PJ_WIN32) && PJ_WIN32!=0) || \
+ (defined(PJ_WIN64) && PJ_WIN64!=0)) && \
+ (!defined(PJ_WIN32_WINCE) || PJ_WIN32_WINCE==0)
if (freopen ("CONIN$", "r", stdin) == NULL) {
#else
if (1) {
diff --git a/pjlib-util/src/pjlib-util/cli_telnet.c b/pjlib-util/src/pjlib-util/cli_telnet.c
index 631ede51..f0124ea3 100644
--- a/pjlib-util/src/pjlib-util/cli_telnet.c
+++ b/pjlib-util/src/pjlib-util/cli_telnet.c
@@ -33,6 +33,7 @@
#include <pj/compat/socket.h>
#if (defined(PJ_WIN32) && PJ_WIN32!=0) || \
+ (defined(PJ_WIN64) && PJ_WIN64!=0) || \
(defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0)
#define EADDRINUSE WSAEADDRINUSE
@@ -687,7 +688,7 @@ static void send_err_arg(cli_telnet_sess *sess,
{
pj_str_t send_data;
char data_str[256];
- unsigned len;
+ pj_size_t len;
unsigned i;
cli_telnet_fe *fe = (cli_telnet_fe *)sess->base.fe;
@@ -760,7 +761,7 @@ static void send_ambi_arg(cli_telnet_sess *sess,
pj_bool_t with_last_cmd)
{
unsigned i;
- unsigned len;
+ pj_size_t len;
pj_str_t send_data;
char data[1028];
cli_telnet_fe *fe = (cli_telnet_fe *)sess->base.fe;
@@ -992,7 +993,7 @@ static pj_bool_t handle_tab(cli_telnet_sess *sess)
status = pj_cli_sess_parse(&sess->base, (char *)&sess->rcmd->rbuf, cmd_val,
pool, &info);
- len = pj_ansi_strlen((char *)sess->rcmd->rbuf);
+ len = (unsigned)pj_ansi_strlen((char *)sess->rcmd->rbuf);
switch (status) {
case PJ_CLI_EINVARG:
@@ -1033,7 +1034,7 @@ static pj_bool_t handle_tab(cli_telnet_sess *sess)
pj_memcpy(&sess->rcmd->rbuf[len], info.hint[0].name.ptr,
info.hint[0].name.slen);
- len += info.hint[0].name.slen;
+ len += (unsigned)info.hint[0].name.slen;
sess->rcmd->rbuf[len] = 0;
}
} else {
@@ -1166,7 +1167,7 @@ static pj_bool_t handle_up_down(cli_telnet_sess *sess, pj_bool_t is_up)
telnet_sess_send(sess, &send_data);
pj_ansi_strncpy((char*)&sess->rcmd->rbuf, history->ptr, history->slen);
sess->rcmd->rbuf[history->slen] = 0;
- sess->rcmd->len = history->slen;
+ sess->rcmd->len = (unsigned)history->slen;
sess->rcmd->cur_pos = sess->rcmd->len;
return PJ_TRUE;
}
@@ -1256,9 +1257,9 @@ static pj_status_t telnet_sess_send(cli_telnet_sess *sess,
if (clen < sz) {
pj_ansi_snprintf((char *)sess->buf + CLI_TELNET_BUF_SIZE,
MAX_CUT_MSG_LEN, CUT_MSG);
- sess->buf_len = CLI_TELNET_BUF_SIZE +
+ sess->buf_len = (unsigned)(CLI_TELNET_BUF_SIZE +
pj_ansi_strlen((char *)sess->buf+
- CLI_TELNET_BUF_SIZE);
+ CLI_TELNET_BUF_SIZE));
} else
sess->buf_len += clen;
} else if (status == PJ_SUCCESS && sz < str->slen) {
@@ -1294,13 +1295,13 @@ static pj_status_t telnet_sess_send_with_format(cli_telnet_sess *sess,
PJ_TRY {
while (!pj_scan_is_eof(&scanner)) {
pj_scan_get_until_ch(&scanner, '\n', &out_str);
- str_len = scanner.curptr - str_begin;
+ str_len = (int)(scanner.curptr - str_begin);
if (*scanner.curptr == '\n') {
if ((str_len > 1) && (out_str.ptr[str_len-2] == '\r'))
{
continue;
} else {
- int str_pos = str_begin - scanner.begin;
+ int str_pos = (int)(str_begin - scanner.begin);
if (str_len > 0) {
pj_str_t s;
@@ -1316,7 +1317,7 @@ static pj_status_t telnet_sess_send_with_format(cli_telnet_sess *sess,
}
} else {
pj_str_t s;
- int str_pos = str_begin - scanner.begin;
+ int str_pos = (int)(str_begin - scanner.begin);
pj_strset(&s, &str->ptr[str_pos], str_len);
telnet_sess_send(sess, &s);
@@ -1358,7 +1359,7 @@ static void telnet_sess_destroy(pj_cli_sess *sess)
}
static void telnet_fe_write_log(pj_cli_front_end *fe, int level,
- const char *data, int len)
+ const char *data, pj_size_t len)
{
cli_telnet_fe *tfe = (cli_telnet_fe *)fe;
pj_cli_sess *sess;
diff --git a/pjlib-util/src/pjlib-util/crc32.c b/pjlib-util/src/pjlib-util/crc32.c
index 3d634645..947eec19 100644
--- a/pjlib-util/src/pjlib-util/crc32.c
+++ b/pjlib-util/src/pjlib-util/crc32.c
@@ -159,7 +159,7 @@ PJ_DEF(pj_uint32_t) pj_crc32_update(pj_crc32_context *ctx,
{
pj_uint32_t crc = ctx->crc_state ^ CRC32_NEGL;
- for( ; (((unsigned long)data) & 0x03) && nbytes > 0; --nbytes) {
+ for( ; (((unsigned long)(pj_ssize_t)data) & 0x03) && nbytes > 0; --nbytes) {
crc = crc_tab[CRC32_INDEX(crc) ^ *data++] ^ CRC32_SHIFTED(crc);
}
diff --git a/pjlib-util/src/pjlib-util/dns.c b/pjlib-util/src/pjlib-util/dns.c
index 4cefaffb..3d78159a 100644
--- a/pjlib-util/src/pjlib-util/dns.c
+++ b/pjlib-util/src/pjlib-util/dns.c
@@ -61,7 +61,7 @@ PJ_DEF(pj_status_t) pj_dns_make_query( void *packet,
{
pj_uint8_t *query, *p = (pj_uint8_t*)packet;
const char *startlabel, *endlabel, *endname;
- unsigned d;
+ pj_size_t d;
/* Sanity check */
PJ_ASSERT_RETURN(packet && size && qtype && name, PJ_EINVAL);
@@ -106,7 +106,7 @@ PJ_DEF(pj_status_t) pj_dns_make_query( void *packet,
p += 2;
/* Done, calculate length */
- *size = p - (pj_uint8_t*)packet;
+ *size = (unsigned)(p - (pj_uint8_t*)packet);
return 0;
}
diff --git a/pjlib-util/src/pjlib-util/dns_server.c b/pjlib-util/src/pjlib-util/dns_server.c
index 6d5b84f7..d86ea5a5 100644
--- a/pjlib-util/src/pjlib-util/dns_server.c
+++ b/pjlib-util/src/pjlib-util/dns_server.c
@@ -231,7 +231,7 @@ static int print_name(pj_uint8_t *pkt, int size,
return 2;
} else {
if (tab->count < MAX_LABEL) {
- tab->a[tab->count].pos = (p-pkt);
+ tab->a[tab->count].pos = (unsigned)(p-pkt);
tab->a[tab->count].label.ptr = (char*)(p+1);
tab->a[tab->count].label.slen = name->slen;
++tab->count;
@@ -256,7 +256,7 @@ static int print_name(pj_uint8_t *pkt, int size,
*p = (pj_uint8_t)label.slen;
pj_memcpy(p+1, label.ptr, label.slen);
- size -= (label.slen+1);
+ size -= (int)(label.slen+1);
p += (label.slen+1);
if (endlabel != endname && *endlabel == '.')
@@ -269,7 +269,7 @@ static int print_name(pj_uint8_t *pkt, int size,
*p++ = '\0';
- return p-pos;
+ return (int)(p-pos);
}
static int print_rr(pj_uint8_t *pkt, int size, pj_uint8_t *pos,
@@ -352,7 +352,7 @@ static int print_rr(pj_uint8_t *pkt, int size, pj_uint8_t *pos,
return -1;
}
- return p-pos;
+ return (int)(p-pos);
}
static int print_packet(const pj_dns_parsed_packet *rec, pj_uint8_t *pkt,
@@ -432,7 +432,7 @@ static int print_packet(const pj_dns_parsed_packet *rec, pj_uint8_t *pkt,
size -= len;
}
- return p - pkt;
+ return (int)(p - pkt);
}
@@ -457,7 +457,7 @@ static pj_bool_t on_data_recvfrom(pj_activesock_t *asock,
srv = (pj_dns_server*) pj_activesock_get_user_data(asock);
pool = pj_pool_create(srv->pf, "dnssrvrx", 512, 256, NULL);
- status = pj_dns_parse_packet(pool, data, size, &req);
+ status = pj_dns_parse_packet(pool, data, (unsigned)size, &req);
if (status != PJ_SUCCESS) {
char addrinfo[PJ_INET6_ADDRSTRLEN+10];
pj_sockaddr_print(src_addr, addrinfo, sizeof(addrinfo), 3);
diff --git a/pjlib-util/src/pjlib-util/http_client.c b/pjlib-util/src/pjlib-util/http_client.c
index cf96a2df..941683ef 100644
--- a/pjlib-util/src/pjlib-util/http_client.c
+++ b/pjlib-util/src/pjlib-util/http_client.c
@@ -229,7 +229,7 @@ static pj_bool_t http_on_data_sent(pj_activesock_t *asock,
return PJ_FALSE;
if (sent <= 0) {
- hreq->error = (sent < 0 ? -sent : PJLIB_UTIL_EHTTPLOST);
+ hreq->error = (sent < 0 ? (pj_status_t)-sent : PJLIB_UTIL_EHTTPLOST);
pj_http_req_cancel(hreq, PJ_TRUE);
return PJ_FALSE;
}
@@ -773,7 +773,7 @@ PJ_DEF(void) pj_http_req_param_default(pj_http_req_param *param)
* user:passwd part of an URI. If user:passwd part is not
* present, NULL will be returned.
*/
-static char *get_url_at_pos(const char *str, long len)
+static char *get_url_at_pos(const char *str, pj_size_t len)
{
const char *end = str + len;
const char *p = str;
@@ -801,7 +801,7 @@ PJ_DEF(pj_status_t) pj_http_req_parse_url(const pj_str_t *url,
pj_http_url *hurl)
{
pj_scanner scanner;
- int len = url->slen;
+ pj_size_t len = url->slen;
PJ_USE_EXCEPTION;
if (!len) return -1;
@@ -973,7 +973,7 @@ PJ_DEF(pj_status_t) pj_http_req_create(pj_pool_t *pool,
/* Remove "username:password@" from the URL */
pj_assert(user_pos != 0 && user_pos < at_pos);
user_pos += 2;
- removed_len = at_pos + 1 - user_pos;
+ removed_len = (int)(at_pos + 1 - user_pos);
pj_memmove(user_pos, at_pos+1, hreq->url.ptr+hreq->url.slen-at_pos-1);
hreq->url.slen -= removed_len;
@@ -1159,12 +1159,12 @@ static pj_status_t auth_respond_basic(pj_http_req *hreq)
else
phdr->name = pj_str("Proxy-Authorization");
- len = PJ_BASE256_TO_BASE64_LEN(user_pass.slen) + 10;
+ len = (int)(PJ_BASE256_TO_BASE64_LEN(user_pass.slen) + 10);
phdr->value.ptr = (char*)pj_pool_alloc(hreq->pool, len);
phdr->value.slen = 0;
pj_strcpy2(&phdr->value, "Basic ");
- len -= phdr->value.slen;
+ len -= (int)phdr->value.slen;
pj_base64_encode((pj_uint8_t*)user_pass.ptr, (int)user_pass.slen,
phdr->value.ptr + phdr->value.slen, &len);
phdr->value.slen += len;
@@ -1175,7 +1175,8 @@ static pj_status_t auth_respond_basic(pj_http_req *hreq)
/** Length of digest string. */
#define MD5_STRLEN 32
/* A macro just to get rid of type mismatch between char and unsigned char */
-#define MD5_APPEND(pms,buf,len) pj_md5_update(pms, (const pj_uint8_t*)buf, len)
+#define MD5_APPEND(pms,buf,len) pj_md5_update(pms, (const pj_uint8_t*)buf, \
+ (unsigned)len)
/* Transform digest to string.
* output must be at least PJSIP_MD5STRLEN+1 bytes.
@@ -1337,7 +1338,7 @@ static pj_status_t auth_respond_digest(pj_http_req *hreq)
phdr->name = pj_str("Proxy-Authorization");
/* Allocate space for the header */
- len = 8 + /* Digest */
+ len = (int)(8 + /* Digest */
16 + hreq->param.auth_cred.username.slen + /* username= */
12 + chal->realm.slen + /* realm= */
12 + chal->nonce.slen + /* nonce= */
@@ -1348,7 +1349,7 @@ static pj_status_t auth_respond_digest(pj_http_req *hreq)
8 + /* nc=.. */
30 + /* cnonce= */
12 + chal->opaque.slen + /* opaque=".." */
- 0;
+ 0);
phdr->value.ptr = (char*)pj_pool_alloc(hreq->pool, len);
/* Configure buffer to temporarily store the digest */
@@ -1537,8 +1538,8 @@ static pj_status_t http_req_start_sending(pj_http_req *hreq)
/* Header field "Content-Length" */
pj_utoa(hreq->param.reqdata.total_size ?
- hreq->param.reqdata.total_size:
- hreq->param.reqdata.size, buf);
+ (unsigned long)hreq->param.reqdata.total_size:
+ (unsigned long)hreq->param.reqdata.size, buf);
str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "%s: %s\r\n",
CONTENT_LENGTH, buf);
}
diff --git a/pjlib-util/src/pjlib-util/pcap.c b/pjlib-util/src/pjlib-util/pcap.c
index bf45b714..2ddcc59b 100644
--- a/pjlib-util/src/pjlib-util/pcap.c
+++ b/pjlib-util/src/pjlib-util/pcap.c
@@ -228,14 +228,14 @@ PJ_DEF(pj_status_t) pj_pcap_read_udp(pj_pcap_file *file,
} tmp;
unsigned rec_incl;
pj_ssize_t sz;
- unsigned sz_read = 0;
+ pj_size_t sz_read = 0;
pj_status_t status;
TRACE_((file->obj_name, "Reading packet.."));
/* Read PCAP packet header */
sz = sizeof(tmp.rec);
- status = read_file(file, &tmp.rec, &sz);
+ status = read_file(file, &tmp.rec, &sz);
if (status != PJ_SUCCESS) {
TRACE_((file->obj_name, "read_file() error: %d", status));
return status;
diff --git a/pjlib-util/src/pjlib-util/resolver.c b/pjlib-util/src/pjlib-util/resolver.c
index b6576fd6..cbe2efff 100644
--- a/pjlib-util/src/pjlib-util/resolver.c
+++ b/pjlib-util/src/pjlib-util/resolver.c
@@ -672,7 +672,8 @@ static pj_status_t transmit_query(pj_dns_resolver *resolver,
*/
static void init_res_key(struct res_key *key, int type, const pj_str_t *name)
{
- unsigned i, len;
+ unsigned i;
+ pj_size_t len;
char *dst = key->name;
const char *src = name->ptr;
@@ -883,8 +884,8 @@ PJ_DEF(pj_status_t) pj_dns_parse_a_response(const pj_dns_parsed_packet *pkt,
{
enum { MAX_SEARCH = 20 };
pj_str_t hostname, alias = {NULL, 0}, *resname;
- unsigned bufstart = 0;
- unsigned bufleft = sizeof(rec->buf_);
+ pj_size_t bufstart = 0;
+ pj_size_t bufleft = sizeof(rec->buf_);
unsigned i, ansidx, search_cnt=0;
PJ_ASSERT_RETURN(pkt && rec, PJ_EINVAL);
@@ -1346,7 +1347,7 @@ static void on_read_complete(pj_ioqueue_key_t *key,
if (bytes_read < 0) {
char errmsg[PJ_ERR_MSG_SIZE];
- status = -bytes_read;
+ status = (pj_status_t)-bytes_read;
pj_strerror(status, errmsg, sizeof(errmsg));
PJ_LOG(4,(resolver->name.ptr,
"DNS resolver read error from %s:%d: %s",
diff --git a/pjlib-util/src/pjlib-util/scanner.c b/pjlib-util/src/pjlib-util/scanner.c
index 0343ba5c..f31a19f5 100644
--- a/pjlib-util/src/pjlib-util/scanner.c
+++ b/pjlib-util/src/pjlib-util/scanner.c
@@ -111,8 +111,9 @@ PJ_DEF(void) pj_cis_invert( pj_cis_t *cis )
}
}
-PJ_DEF(void) pj_scan_init( pj_scanner *scanner, char *bufstart, int buflen,
- unsigned options, pj_syn_err_func_ptr callback )
+PJ_DEF(void) pj_scan_init( pj_scanner *scanner, char *bufstart,
+ pj_size_t buflen, unsigned options,
+ pj_syn_err_func_ptr callback )
{
PJ_CHECK_STACK();
@@ -549,7 +550,7 @@ PJ_DEF(void) pj_scan_get_until_chr( pj_scanner *scanner,
const char *until_spec, pj_str_t *out)
{
register char *s = scanner->curptr;
- int speclen;
+ pj_size_t speclen;
if (s >= scanner->end) {
pj_scan_syntax_err(scanner);
diff --git a/pjlib-util/src/pjlib-util/sha1.c b/pjlib-util/src/pjlib-util/sha1.c
index d36e34e0..a707a968 100644
--- a/pjlib-util/src/pjlib-util/sha1.c
+++ b/pjlib-util/src/pjlib-util/sha1.c
@@ -209,8 +209,9 @@ PJ_DEF(void) pj_sha1_update(pj_sha1_context* context,
pj_size_t i, j;
j = (context->count[0] >> 3) & 63;
- if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
- context->count[1] += (len >> 29);
+ if ((context->count[0] += (pj_uint32_t)len << 3) < (len << 3))
+ context->count[1]++;
+ context->count[1] += ((pj_uint32_t)len >> 29);
if ((j + len) > 63) {
pj_memcpy(&context->buffer[j], data, (i = 64-j));
SHA1_Transform(context->state, context->buffer);
diff --git a/pjlib-util/src/pjlib-util/srv_resolver.c b/pjlib-util/src/pjlib-util/srv_resolver.c
index 7a1a99a6..609c56e0 100644
--- a/pjlib-util/src/pjlib-util/srv_resolver.c
+++ b/pjlib-util/src/pjlib-util/srv_resolver.c
@@ -102,7 +102,7 @@ PJ_DEF(pj_status_t) pj_dns_srv_resolve( const pj_str_t *domain_name,
pj_dns_srv_resolver_cb *cb,
pj_dns_srv_async_query **p_query)
{
- int len;
+ pj_size_t len;
pj_str_t target_name;
pj_dns_srv_async_query *query_job;
pj_status_t status;
diff --git a/pjlib-util/src/pjlib-util/xml.c b/pjlib-util/src/pjlib-util/xml.c
index f1bfaf78..654dd559 100644
--- a/pjlib-util/src/pjlib-util/xml.c
+++ b/pjlib-util/src/pjlib-util/xml.c
@@ -235,7 +235,7 @@ static int xml_print_node( const pj_xml_node *node, int indent,
*p++ = ' ';
*p++ = '/';
*p++ = '>';
- return p-buf;
+ return (int)(p-buf);
}
/* Enclosing '>' */
@@ -287,7 +287,7 @@ static int xml_print_node( const pj_xml_node *node, int indent,
#undef SIZE_LEFT
- return p - buf;
+ return (int)(p-buf);
}
PJ_DEF(int) pj_xml_print(const pj_xml_node *node, char *buf, pj_size_t len,
@@ -304,7 +304,7 @@ PJ_DEF(int) pj_xml_print(const pj_xml_node *node, char *buf, pj_size_t len,
if ((int)len < prolog.slen)
return -1;
pj_memcpy(buf, prolog.ptr, prolog.slen);
- prolog_len = prolog.slen;
+ prolog_len = (int)prolog.slen;
}
printed = xml_print_node(node, 0, buf+prolog_len, len-prolog_len) + prolog_len;