comparison gfxconv.c @ 488:49f0ce2cc347

Error printing cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 12 Nov 2012 22:02:47 +0200
parents b89598501cec
children fca3c240ccac
comparison
equal deleted inserted replaced
487:b89598501cec 488:49f0ce2cc347
3 * Programmed and designed by Matti 'ccr' Hamalainen 3 * Programmed and designed by Matti 'ccr' Hamalainen
4 * (C) Copyright 2012 Tecnic Software productions (TNSP) 4 * (C) Copyright 2012 Tecnic Software productions (TNSP)
5 * 5 *
6 * Please read file 'COPYING' for information on license and distribution. 6 * Please read file 'COPYING' for information on license and distribution.
7 */ 7 */
8 #include <errno.h>
9 #include "dmlib.h" 8 #include "dmlib.h"
10 #include "dmargs.h" 9 #include "dmargs.h"
11 #include "dmfile.h" 10 #include "dmfile.h"
12 #include "dmmutex.h" 11 #include "dmmutex.h"
13 #include "libgfx.h" 12 #include "libgfx.h"
1060 if (optOutFilename == NULL) 1059 if (optOutFilename == NULL)
1061 outFile = stdout; 1060 outFile = stdout;
1062 else 1061 else
1063 if ((outFile = fopen(optOutFilename, "w")) == NULL) 1062 if ((outFile = fopen(optOutFilename, "w")) == NULL)
1064 { 1063 {
1065 int res = errno; 1064 int res = dmGetErrno();
1066 dmError("Error opening output file '%s'. (%s)\n", 1065 dmError("Error opening output file '%s', %d: %s\n",
1067 optOutFilename, strerror(res)); 1066 optOutFilename, res, dmErrorStr(res));
1068 goto error; 1067 goto error;
1069 } 1068 }
1070 1069
1071 while (!feof(inFile) && !error && (optItemCount < 0 || itemCount < optItemCount)) 1070 while (!feof(inFile) && !error && (optItemCount < 0 || itemCount < optItemCount))
1072 { 1071 {
1246 inFile = stdin; 1245 inFile = stdin;
1247 } 1246 }
1248 else 1247 else
1249 if ((inFile = fopen(optInFilename, "rb")) == NULL) 1248 if ((inFile = fopen(optInFilename, "rb")) == NULL)
1250 { 1249 {
1251 int res = errno; 1250 int res = dmGetErrno();
1252 dmError("Error opening input file '%s'. (%s)\n", 1251 dmError("Error opening input file '%s', %d: %s\n",
1253 optInFilename, strerror(res)); 1252 optInFilename, res, dmErrorStr(res));
1254 goto error; 1253 goto error;
1255 } 1254 }
1256 1255
1257 if (dmReadDataFile(inFile, NULL, &dataBuf, &dataSize) != 0) 1256 if (dmReadDataFile(inFile, NULL, &dataBuf, &dataSize) != 0)
1258 goto error; 1257 goto error;
1301 } 1300 }
1302 1301
1303 // Skip, if needed 1302 // Skip, if needed
1304 if (fseek(inFile, optInSkip, SEEK_SET) != 0) 1303 if (fseek(inFile, optInSkip, SEEK_SET) != 0)
1305 { 1304 {
1306 int res = errno; 1305 int res = dmGetErrno();
1307 dmError("Could not seek to file position %d (0x%x): %s\n", 1306 dmError("Could not seek to file position %d (0x%x): %s\n",
1308 optInSkip, optInSkip, strerror(res)); 1307 optInSkip, optInSkip, dmErrorStr(res));
1309 goto error; 1308 goto error;
1310 } 1309 }
1311 1310
1312 int inFormat = dmGetConvFormat(optInFormat, optInSubFormat), 1311 int inFormat = dmGetConvFormat(optInFormat, optInSubFormat),
1313 outFormat = dmGetConvFormat(optOutFormat, optOutSubFormat); 1312 outFormat = dmGetConvFormat(optOutFormat, optOutSubFormat);