C99 support it and also Visual Studio VS 2015 and after.
No more need for PRIsize format.
#define PRIu64 "llu"
#endif
#endif
-
- /*
- * MSVC's support library doesn't support %zu to print a size_t until
- * Visual Studio 2017, but supports %Iu earlier, so use that.
- */
- #define PRIsize "Iu"
#elif defined(__MINGW32__) || !defined(_WIN32)
/*
* Compiler is MinGW or target is UN*X or MS-DOS. Just use
* <inttypes.h>.
*/
#include <inttypes.h>
-
- /*
- * Assume the support library supports %zu; it's required by C99.
- */
- #define PRIsize "zu"
#endif
#endif /* pcap/pcap-inttypes.h */
errno, "error reading dump file");
} else {
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "truncated dump file; tried to read %" PRIsize " file header bytes, only got %" PRIsize,
+ "truncated dump file; tried to read %zu file header bytes, only got %zu",
sizeof(magic), amt_read);
}
return (NULL);
errno, "error reading dump file");
} else {
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "truncated dump file; tried to read %" PRIsize " file header bytes, only got %" PRIsize,
+ "truncated dump file; tried to read %zu file header bytes, only got %zu",
sizeof(hdr), amt_read);
}
*err = 1;
} else {
if (amt_read != 0) {
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "truncated dump file; tried to read %" PRIsize " header bytes, only got %" PRIsize,
+ "truncated dump file; tried to read %zu header bytes, only got %zu",
ps->hdrsize, amt_read);
return (-1);
}
* the read finished.
*/
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+ "truncated dump file; tried to read %u captured bytes, only got %zu",
p->snapshot, amt_read);
}
return (-1);
"error reading dump file");
} else {
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+ "truncated dump file; tried to read %u captured bytes, only got %zu",
hdr->caplen, bytes_read);
}
return (-1);
"error reading dump file");
} else {
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+ "truncated dump file; tried to read %u captured bytes, only got %zu",
hdr->caplen, amt_read);
}
return (-1);
if (amt_read == 0 && !fail_on_eof)
return (0); /* EOF */
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "truncated dump file; tried to read %" PRIsize " bytes, only got %" PRIsize,
+ "truncated dump file; tried to read %zu bytes, only got %zu",
bytes_to_read, amt_read);
}
return (-1);
if (bhdr.total_length < sizeof(struct block_header) +
sizeof(struct block_trailer)) {
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "block in pcapng dump file has a length of %u < %" PRIsize,
+ "block in pcapng dump file has a length of %u < %zu",
bhdr.total_length,
sizeof(struct block_header) + sizeof(struct block_trailer));
return (-1);
* No. Report that as an error.
*/
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "block in pcapng dump file has a length of %u that is not a multiple of 4" PRIsize,
+ "block in pcapng dump file has a length of %u that is not a multiple of 4",
bhdr.total_length);
return (-1);
}
*/
if (total_length < sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)) {
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "Section Header Block in pcapng dump file has a length of %u < %" PRIsize,
+ "Section Header Block in pcapng dump file has a length of %u < %zu",
total_length,
sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer));
*err = 1;