#include <ctype.h>
#include <errno.h>
+#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <signal.h>
json_destroy(record);
}
+static void
+set_binary_mode(FILE *stream OVS_UNUSED)
+{
+#ifdef _WIN32
+ fflush(stream);
+ /* On Windows set binary mode on the file descriptor to avoid
+ * translation (i.e. CRLF line endings). */
+ if (_setmode(_fileno(stream), O_BINARY) == -1) {
+ ovs_fatal(errno, "could not set binary mode on fd %d",
+ _fileno(stream));
+ }
+#endif
+}
+
static void
do_backup(struct jsonrpc *rpc, const char *database,
int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
ovs_fatal(0, "not writing backup to a terminal; "
"please redirect stdout to a file");
}
+ set_binary_mode(stdout);
/* Get schema. */
struct ovsdb_schema *schema = fetch_schema(rpc, database);
ovs_fatal(0, "not reading backup from a terminal; "
"please redirect stdin from a file");
}
+ set_binary_mode(stdin);
struct ovsdb *backup;
check_ovsdb_error(ovsdb_file_open("/dev/stdin", true, &backup, NULL));