Debug doesn't track error.
After displaying second file program seems to go into endless loop taking 25% of processor with no other output.
Code:
/*
24/01/2017 09:40
*/
#include <stdio.h>
#include <sys\stat.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <dos.h>
#include <conio.h>
#include <ctype.h>
#include <io.h>
#include <math.h>
#include <dir.h>
#include <errno.h>
#include <process.h>
#define uint unsigned int
#define uchar unsigned char
#define byte unsigned char
#define ulong unsigned long
FILE *outfileF, // to write DTB files
*outfileR,
*infile;
uint iFdata[3000], /* DTB extracted data */
itemp[3000],
iRdata[3000];
int main( void)
{
struct _finddata_t ffblk;
intptr_t handle = 0;
char *dir_buffer, cdir[64];
int ii = 0, in, i, iLen, iSum;
char csFileF[14], csFileR[14]; /* corrected file names */
printf("\n Churns out two files from your AL2ooo 001 data files [hit enter]");
getch();
dir_buffer =_getcwd( (char *)&cdir, sizeof(cdir));
if( !dir_buffer) {
printf("\n ! ERROR ! obtaining current disc directory!");
printf("\n .. any key ..");
getch();
exit(-1);
}
printf("\nDirectory: %s\n", cdir);
handle = _findfirst("*.001", &ffblk);
if( handle == -i) { printf("\nNO FILES!\n"); exit(-1);}
while( handle && !ii ) { // ii set by _findnext()
if( !ii) {
printf("\n%12s ",ffblk.name);
for( i = 0x0; ffblk.name[i] != '.'; ++i )
csFileF[i] = csFileR[i] = ffblk.name[i];
csFileF[i] = csFileR[i] = 0;
strncat(csFileF, "F.dtb", 5);
strncat(csFileR, "R.dtb", 5);
printf(" File: %i \n", handle);
printf("%s ",csFileF);
printf("%s\n",csFileR);
infile = fopen(ffblk.name, "r");
if( infile ) {
i = fseek( infile, 0x80L, SEEK_SET);
if(!i) {
in = fread(&iLen, 2, 1, infile);
printf("[%d]AL100 bytes %x[%d]\n", in, iLen, iLen);
}
else
{ printf( "\n!!ERROR READING FILE!! %s\n", ffblk.name); fclose(infile); exit(-1); }
}
printf("...next..");
ii = _findnext(handle,&ffblk);
printf("[%d]is..%12s %i\n",ii, ffblk.name, handle);
if( ii == -1 )
printf("an error: %s\n", strerror(errno));
// exit(-1);
}
} // while( handle...
_findclose(handle);
return( 0);
}/* ..end.. main() */