Mercurial > hg > th-libs
comparison th_network.c @ 146:0d2a46526349
Portability fixes.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 05 Jan 2015 22:39:50 +0200 |
parents | 51eec969b07a |
children | 0a085e2e8bf5 |
comparison
equal
deleted
inserted
replaced
145:fdea1c3acc53 | 146:0d2a46526349 |
---|---|
941 char *p; | 941 char *p; |
942 size_t offs, left; | 942 size_t offs, left; |
943 | 943 |
944 fprintf(f, | 944 fprintf(f, |
945 "\n--------------------------------------------------------------\n" | 945 "\n--------------------------------------------------------------\n" |
946 "err=%d, status=%d, got_bytes=%d, total_bytes=%d\n" | 946 "err=%d, status=%d, got_bytes=%zd, total_bytes=%zd\n" |
947 "buf=0x%p, in_ptr=0x%04x, ptr=0x%04x\n", | 947 "buf=0x%p, in_ptr=0x%04zx, ptr=0x%04zx\n", |
948 conn->err, conn->status, conn->base.got_bytes, conn->base.total_bytes, | 948 conn->err, conn->status, conn->base.got_bytes, conn->base.total_bytes, |
949 conn->base.buf, conn->base.in_ptr - conn->base.buf, conn->base.ptr - conn->base.buf); | 949 conn->base.buf, conn->base.in_ptr - conn->base.buf, conn->base.ptr - conn->base.buf); |
950 | 950 |
951 // Dump buffer contents as a hexdump | 951 // Dump buffer contents as a hexdump |
952 for (offs = 0, left = conn->base.total_bytes, p = conn->base.buf; p < conn->base.in_ptr;) | 952 for (offs = 0, left = conn->base.total_bytes, p = conn->base.buf; p < conn->base.in_ptr;) |
954 char buf[TH_DUMP_BYTES + 1]; | 954 char buf[TH_DUMP_BYTES + 1]; |
955 size_t bufoffs, amount = left < TH_DUMP_BYTES ? left : TH_DUMP_BYTES; | 955 size_t bufoffs, amount = left < TH_DUMP_BYTES ? left : TH_DUMP_BYTES; |
956 left -= amount; | 956 left -= amount; |
957 | 957 |
958 // Dump offs | xx xx xx xx | and fill string | 958 // Dump offs | xx xx xx xx | and fill string |
959 fprintf(f, "%04x | ", offs); | 959 fprintf(f, "%04zx | ", offs); |
960 for (bufoffs = 0; bufoffs < amount; offs++, bufoffs++, p++) | 960 for (bufoffs = 0; bufoffs < amount; offs++, bufoffs++, p++) |
961 { | 961 { |
962 fprintf(f, "%02x ", *p); | 962 fprintf(f, "%02x ", *p); |
963 buf[bufoffs] = th_isprint(*p) ? *p : '.'; | 963 buf[bufoffs] = th_isprint(*p) ? *p : '.'; |
964 } | 964 } |