From d1a2599715987ab45d407eb6980831e7fc58d59c Mon Sep 17 00:00:00 2001 From: Eric Claeys <83164203+EricClaeys@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:04:13 -0500 Subject: [PATCH] Update ASI_functions.cpp: allow cc_file to go to stdout If "file" is "-" the output goes to stdout. Also, put ");" on separate line to make it more obvious what's happening and to keep vi happy. --- src/ASI_functions.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/ASI_functions.cpp b/src/ASI_functions.cpp index d166000c0..41f5d57b9 100644 --- a/src/ASI_functions.cpp +++ b/src/ASI_functions.cpp @@ -1325,11 +1325,20 @@ void saveCameraInfo( char *camModel = getCameraModel(cameraInfo.Name); char *sn = getSerialNumber(cameraInfo.CameraID); - FILE *f = fopen(file, "w"); - if (f == NULL) + FILE *f = NULL; + if (strcmp(file, "-") == 0) { - Log(0, "%s: ERROR: Unable to open '%s': %s\n", CG.ME, file, strerror(errno)); - closeUp(EXIT_ERROR_STOP); + f = stdout; + file = "stdout"; + } + else + { + f = fopen(file, "w"); + if (f == NULL) + { + Log(0, "%s: ERROR: Unable to open '%s': %s\n", CG.ME, file, strerror(errno)); + closeUp(EXIT_ERROR_STOP); + } } Log(4, "saveCameraInfo(): saving to %s\n", file); @@ -1364,10 +1373,11 @@ void saveCameraInfo( fprintf(f, "\t\t{ \"value\" : \"%s\", \"label\" : \"%s\" }", getCameraModel(cC->Name), #ifdef IS_RPi - skipType(cC->Sensor)); + skipType(cC->Sensor) #else - getCameraModel(cC->Name)); + getCameraModel(cC->Name) #endif + ); numThisType++; }