Skip to content

Commit

Permalink
Update ASI_functions.cpp: allow cc_file to go to stdout
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EricClaeys authored Jun 2, 2024
1 parent 319aa9f commit d1a2599
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/ASI_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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++;
}
Expand Down

0 comments on commit d1a2599

Please sign in to comment.