+/*-----------------------------------------------------------------*/
+/* createDumpFile - create the dump file */
+/*-----------------------------------------------------------------*/
+FILE *createDumpFile (int id) {
+ struct _dumpFiles *dumpFilesPtr=dumpFiles;
+ static int dumpIndex=0;
+ static char dumpIndexStr[32];
+
+ while (dumpFilesPtr->id) {
+ if (dumpFilesPtr->id==id)
+ break;
+ dumpFilesPtr++;
+ }
+
+ if (!dumpFilesPtr->id) {
+ fprintf (stdout, "internal error: createDumpFile: unknown dump file.\n");
+ exit (1);
+ }
+
+ sprintf(dumpIndexStr, ".%d", dumpIndex);
+ dumpIndex++;
+
+ if (!dumpFilesPtr->filePtr) {
+ // not used before, create it
+ strncpyz (scratchFileName, dstFileName, PATH_MAX);
+#if 0
+ strncatz (scratchFileName, dumpIndexStr, PATH_MAX);
+#endif
+ strncatz (scratchFileName, dumpFilesPtr->ext, PATH_MAX);
+ if (!(dumpFilesPtr->filePtr = fopen (scratchFileName, "w"))) {
+ werror (E_FILE_OPEN_ERR, scratchFileName);
+ exit (1);
+ }
+ }
+
+#if 0
+ fprintf(dumpFilesPtr->filePtr, "Dump file index: %d\n", dumpIndex);
+#endif
+
+ return dumpFilesPtr->filePtr;
+}
+
+/*-----------------------------------------------------------------*/
+/* closeDumpFiles - close possible opened dumpfiles */
+/*-----------------------------------------------------------------*/
+void closeDumpFiles() {
+ struct _dumpFiles *dumpFilesPtr;
+
+ for (dumpFilesPtr=dumpFiles; dumpFilesPtr->id; dumpFilesPtr++) {
+ if (dumpFilesPtr->filePtr) {
+ fclose (dumpFilesPtr->filePtr);
+ }
+ }
+}
+