aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoritsmattkc <itsmattkc@gmail.com>2020-07-30 11:55:44 +1000
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-08-09 08:36:13 +0200
commit664d0feb7b776591bce8ad7ac9c75437d4acde5f (patch)
treeed93376ee7d8d0284077ef4266944dc31d06b5ef
parent5bc323849569a629aa0d187074a9644dde678c12 (diff)
zbarcam: attempt to merge stdout o_binary calls into one
-rw-r--r--zbarcam/zbarcam.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/zbarcam/zbarcam.c b/zbarcam/zbarcam.c
index 4e41346..7bc790b 100644
--- a/zbarcam/zbarcam.c
+++ b/zbarcam/zbarcam.c
@@ -132,10 +132,6 @@ static void data_handler (zbar_image_t *img, const void *userdata)
continue;
}
else if(format == RAW) {
-#ifdef _WIN32
- _setmode(_fileno(stdout), _O_BINARY);
-#endif
-
if(fwrite(zbar_symbol_get_data(sym),
zbar_symbol_get_data_length(sym),
1, stdout) != 1)
@@ -312,11 +308,17 @@ int main (int argc, const char *argv[])
(display && zbar_processor_set_visible(proc, 1)))
return(zbar_processor_error_spew(proc, 0));
- if(format == XML) {
#ifdef _WIN32
+ if(format == XML || format == RAW) {
fflush(stdout);
- _setmode(_fileno(stdout), _O_BINARY);
+ if(_setmode(_fileno(stdout), _O_BINARY) == -1) {
+ fprintf(stderr, "ERROR: failed to set stdout mode: %i\n\n", errno);
+ return(usage(1));
+ }
+ }
#endif
+
+ if(format == XML) {
printf(xml_head, video_device);
fflush(stdout);
}

Privacy Policy