Read schemas in binary on Windows

This commit is contained in:
Jonah Beckford 2023-06-22 12:11:03 -07:00
parent 25784e3ccf
commit c662042a60

View file

@ -14,6 +14,10 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <ctype.h> #include <ctype.h>
#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#endif
struct value { struct value {
struct Type t; struct Type t;
@ -1317,6 +1321,14 @@ int main() {
uint64_t total_len=0; uint64_t total_len=0;
struct capn_segment *current_seg; struct capn_segment *current_seg;
#ifdef _WIN32
/* schemas need to be read in binary mode, not default text mode */
if(_setmode(_fileno( stdin ), _O_BINARY)==-1) {
fprintf(stderr, "failed to set stdin to binary mode\n");
return -1;
}
#endif
if (capn_init_fp(&capn, stdin, 0)==-1) { if (capn_init_fp(&capn, stdin, 0)==-1) {
fprintf(stderr, "failed to read schema from stdin\n"); fprintf(stderr, "failed to read schema from stdin\n");
return -1; return -1;