Commit b921c068 authored by Kai Vehmanen's avatar Kai Vehmanen

Added a workaround for platforms such as VC6 that do not support %z modifier...

Added a workaround for platforms such as VC6 that do not support %z modifier for printing size/ssize_t (a C99 feature).

darcs-hash:20060908122054-7659e-52de5c77b938dc5bdd943465763d9fd7b66a4a56.gz
parent b488cd3e
......@@ -127,6 +127,8 @@ AC_DEFINE([LLU], ["%llu"], [Define to format (%llu) for unsigned long long])dnl
AC_DEFINE([LLI], ["%lli"], [Define to format (%lli) for long long])dnl
AC_DEFINE([LLX], ["%llx"], [Define to format (%llx) for long long hex])dnl
])
AC_DEFINE([MOD_ZD], ["%zd"], [Define printf() modifier for ssize_t])
AC_DEFINE([MOD_ZU], ["%zu"], [Define printf() modifier for size_t])
### checks for structures
### ---------------------
......
......@@ -101,7 +101,7 @@ issize_t auth_digest_challenge_get(su_home_t *home,
auth_struct_copy(ac0, ac, sizeof(ac));
SU_DEBUG_5(("%s(): got %zd\n", "auth_digest_challenge_get", n));
SU_DEBUG_5(("%s(): got "MOD_ZD"\n", "auth_digest_challenge_get", n));
return n;
}
......@@ -178,7 +178,7 @@ issize_t auth_digest_response_get(su_home_t *home,
auth_struct_copy(ar0, ar, sizeof(ar));
SU_DEBUG_7(("%s: %zd\n", "auth_digest_response_get", n));
SU_DEBUG_7(("%s: "MOD_ZD"\n", "auth_digest_response_get", n));
return n;
}
......
......@@ -198,7 +198,7 @@ int main(int argc, char *argv[])
fprintf(stdout, "sip flags = %x\n", sip->sip_flags);
if (m < 0) {
fprintf(stderr, "sip_test_msg: parsing error (%zd)\n", n);
fprintf(stderr, "sip_test_msg: parsing error ("MOD_ZD")\n", n);
exit(1);
}
......
......@@ -744,7 +744,7 @@ int soa_set_capability_sdp(soa_session_t *ss,
sdp_session_t const *sdp,
char const *str, issize_t len)
{
SU_DEBUG_9(("soa_set_capability_sdp(%s::%p, %p, %p, %zd) called\n",
SU_DEBUG_9(("soa_set_capability_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
return soa_set_sdp(ss, soa_capability_sdp_kind, sdp, str, len);
......@@ -844,7 +844,7 @@ int soa_set_user_sdp(soa_session_t *ss,
sdp_session_t const *sdp,
char const *str, issize_t len)
{
SU_DEBUG_9(("soa_set_user_sdp(%s::%p, %p, %p, %zd) called\n",
SU_DEBUG_9(("soa_set_user_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
return soa_set_sdp(ss, soa_user_sdp_kind, sdp, str, len);
......@@ -910,7 +910,7 @@ int soa_set_remote_sdp(soa_session_t *ss,
sdp_session_t const *sdp,
char const *str, issize_t len)
{
SU_DEBUG_9(("soa_set_remote_sdp(%s::%p, %p, %p, %zd) called\n",
SU_DEBUG_9(("soa_set_remote_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
return soa_set_sdp(ss, soa_remote_sdp_kind, sdp, str, len);
......
......@@ -324,7 +324,7 @@ static int new_test_msg(tp_test_t *tt, msg_t **retval,
su_md5_update(md5sum, payload->pl_data, payload->pl_len);
}
TEST_1(l = msg_content_length_format(home, "%zu", (size_t)(N * payload->pl_len)));
TEST_1(l = msg_content_length_format(home, MOD_ZU, (size_t)(N * payload->pl_len)));
TEST(msg_header_insert(msg, (void *)tst, (msg_header_t *)l), 0);
su_md5_digest(md5sum, digest);
......@@ -734,7 +734,7 @@ static int udp_test(tp_test_t *tt)
TEST_1(pl = msg_payload_make(home, payload));
TEST(msg_header_insert(msg, (void *)tst, (msg_header_t *)pl), 0);
TEST_1(l = msg_content_length_format(home, "%zu", (size_t)pl->pl_len));
TEST_1(l = msg_content_length_format(home, MOD_ZU, (size_t)pl->pl_len));
TEST(msg_header_insert(msg, (void *)tst, (msg_header_t *)l), 0);
TEST_1(md5 = msg_content_md5_make(home, "R6nitdrtJFpxYzrPaSXfrA=="));
......
......@@ -2754,7 +2754,7 @@ void tport_deliver(tport_t *self,
self->tp_rlogged = msg;
}
SU_DEBUG_7(("%s(%p): %smsg %p (%zu bytes)"
SU_DEBUG_7(("%s(%p): %smsg %p ("MOD_ZU" bytes)"
" from " TPN_FORMAT " next=%p\n",
__func__, self, error ? "bad " : "",
msg, (size_t)msg_size(msg),
......
......@@ -141,7 +141,7 @@ void tport_stamp(tport_t const *self, msg_t *msg,
inet_ntop(su->su_family, SU_ADDR(su), name, sizeof(name));
snprintf(stamp, 128,
"%s %zd bytes %s %s/[%s]:%u%s%s at %02u:%02u:%02u.%06lu:\n",
"%s "MOD_ZU" bytes %s %s/[%s]:%u%s%s at %02u:%02u:%02u.%06lu:\n",
what, (size_t)n, via, self->tp_name->tpn_proto,
name, ntohs(su->su_port), label[0] ? label : "", comp,
hour, minute, second, now.tv_usec);
......@@ -246,5 +246,5 @@ void tport_log_msg(tport_t *self, msg_t *msg,
truncated = logged;
if (truncated)
su_log(" *** message truncated at %zu ***\n", truncated);
su_log(" *** message truncated at "MOD_ZU" ***\n", truncated);
}
......@@ -155,7 +155,7 @@ int tport_recv_stun_dgram(tport_t const *self,
}
else
SU_DEBUG_7(("tport(%p): recv_stun_dgram(): "
"ignoring request with %zu bytes\n", self, n));
"ignoring request with "MOD_ZU" bytes\n", self, n));
}
else if (request[0] == 0 && self->tp_master->mr_stun_server) {
tport_stun_server_vtable_t const *vst = tport_stun_server_vtable;
......
......@@ -457,3 +457,8 @@
#endif
#endif // VC8+
#endif
/* size_t/ssize_t modifiers
* ref: http://msdn2.microsoft.com/en-us/library/tcxf1dw6.aspx */
#define MOD_ZD "%ld"
#define MOD_ZU "%lu"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment