Browse Source

Minor ZXCC Updates

- Added a missing call to trackFile.
- Corrected close functions in track.c to properly handle WIN32 variant.
patch
Wayne Warthen 4 years ago
parent
commit
dd22c54f32
  1. 21
      Tools/unix/zxcc/Build-OW.cmd
  2. 25
      Tools/unix/zxcc/Build-VC.cmd
  3. 11
      Tools/unix/zxcc/Clean.cmd
  4. 7
      Tools/unix/zxcc/ReadMe.txt
  5. 2
      Tools/unix/zxcc/cpmredir.c
  6. 35
      Tools/unix/zxcc/track.c
  7. 6
      Tools/unix/zxcc/zxcc.c
  8. BIN
      Tools/zxcc/zxcc-src.zip
  9. BIN
      Tools/zxcc/zxcc.exe
  10. BIN
      Tools/zxcc/zxcc_ft.exe
  11. BIN
      Tools/zxcc/zxccdbg.exe
  12. BIN
      Tools/zxcc/zxccdbg_ft.exe

21
Tools/unix/zxcc/Build-OW.cmd

@ -1,21 +0,0 @@
@echo off
setlocal
::
:: Edit WATCOM variable below as needed for your environment
::
set WATCOM=..\..\Tools\WATCOM2
set PATH=%WATCOM%\BINNT;%WATCOM%\BINW;%PATH%
set EDPATH=%WATCOM%\EDDAT
set INCLUDE=%WATCOM%\H;%WATCOM%\H\NT
copy config.h.windows config.h
cl /Fe"zxcc.exe" zxcc.c cpmdrv.c cpmglob.c cpmparse.c cpmredir.c drdos.c util.c track.c xlt.c zxbdos.c zxcbdos.c zxdbdos.c z80.c
if errorlevel 1 exit /b 255
cl /Fe"zxccdbg.exe" /DDEBUG zxcc.c cpmdrv.c cpmglob.c cpmparse.c cpmredir.c drdos.c util.c track.c xlt.c zxbdos.c zxcbdos.c zxdbdos.c z80.c
if errorlevel 1 exit /b 255
copy cpm\bios.bin .

25
Tools/unix/zxcc/Build-VC.cmd

@ -1,25 +0,0 @@
@echo off
setlocal
::
:: Visual Studio x86 Native Tools Command Prompt is assumed
::
:: Below configures VS2012 to target Windows XP.
:: Not sure if it will work in later versions of VS, but seems
:: to do no harm.
set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%
set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%
set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%
set CL=/D_USING_V110_SDK71_;%CL%
set LINK=/SUBSYSTEM:CONSOLE,5.01 %LINK%
copy config.h.windows config.h
cl -I. zxcc.c cpmdrv.c cpmglob.c cpmparse.c cpmredir.c drdos.c util.c xlt.c zxbdos.c zxcbdos.c zxdbdos.c z80.c dirent.c track.c
if errorlevel 1 exit /b 255
cl -I. /DDEBUG /Fe"zxccdbg.exe" zxcc.c cpmdrv.c cpmglob.c cpmparse.c cpmredir.c drdos.c util.c xlt.c zxbdos.c zxcbdos.c zxdbdos.c z80.c dirent.c track.c
if errorlevel 1 exit /b 255
copy cpm\bios.bin .

11
Tools/unix/zxcc/Clean.cmd

@ -1,11 +0,0 @@
@echo off
setlocal
if exist *.exe del *.exe
if exist *.obj del *.obj
if exist *.err del *.err
if exist *.o del *.o
if exist *.bin del *.bin
if exist zxcc del zxcc
if exist zxccdbg del zxccdbg
if exist config.h del config.h

7
Tools/unix/zxcc/ReadMe.txt

@ -84,3 +84,10 @@ January 9, 2022
--WBW 9:34 AM 2/10/2022
- Added a call to trackFile in fcb_close. I think it was always
supposed to be there. Was not causing any real problems other
than superfluous attempts by releaseFile to close files that
were already closed.
--WBW 3:58 PM 3/2/2022

2
Tools/unix/zxcc/cpmredir.c

@ -204,6 +204,8 @@ cpm_word fcb_close(cpm_byte* fcb)
}
#endif
trackFile(NULL, fcb, handle);
FCBRET(0);
}

35
Tools/unix/zxcc/track.c

@ -97,6 +97,8 @@
#ifdef FILETRACKER
#include "cpmint.h"
typedef struct _track {
struct _track* next;
int handle;
@ -115,10 +117,21 @@ static track_t* rmHandle(track_t* s) {
void releaseFile(char* fname) {
track_t* s = (track_t*)&openFiles;
DBGMSGV("releaseFile: \"%s\"\n", fname);
while (s->next)
if (strcmp(s->next->fname, fname) == 0) {
close(s->next->handle);
Msg("releaseFile closed file \"%s\"\n", s->next->fname);
DBGMSGV(" closing file #%i: \"%s\"\n", s->next->handle, s->next->fname);
#ifdef _WIN32
{
BOOL b;
b = CloseHandle((HANDLE)s->next->handle);
if (!b)
DBGMSGV(" failed to close file #%i (Error=%lu): %s\n", s->next->handle, GetLastError(), GetErrorStr(GetLastError()));
}
#else
if (close(s->next->handle))
DBGMSGV(" failed to close file #%i (errno=%lu): %s\n", s->next->handle, errno, strerror(errno));
#endif
s->next = rmHandle(s->next);
}
else
@ -127,14 +140,24 @@ void releaseFile(char* fname) {
int trackFile(char* fname, void* fcb, int fd) {
track_t* s = (track_t*)&openFiles;
Msg("trackFile: \"%s\", FCB=0x%X, Handle=%i\n", fname, (byte*)fcb - RAM, fd);
DBGMSGV("trackFile: \"%s\", FCB=0x%X, Handle=%i\n", fname, (byte*)fcb - RAM, fd);
while (s->next) { /* find any existing fcb or fd */
if (s->next->fcb == fcb || s->next->handle == fd) {
if (s->next->handle != fd) {
close(s->next->handle);
Msg(" closed file \"%s\", Handle=%i\n", s->next->fname, s->next->handle);
DBGMSGV(" closing file #%i: \"%s\"\n", s->next->handle, s->next->fname);
#ifdef _WIN32
{
BOOL b;
b = CloseHandle((HANDLE)s->next->handle);
if (!b)
DBGMSGV(" failed to close file #%i (Error=%lu): %s\n", s->next->handle, GetLastError(), GetErrorStr(GetLastError()));
}
#else
if (close(s->next->handle))
DBGMSGV(" failed to close file #%i (errno=%lu): %s\n", s->next->handle, errno, strerror(errno));
#endif
}
Msg(" released file \"%s\", Handle=%i\n", s->next->fname, s->next->handle);
DBGMSGV(" released file \"%s\", Handle=%i\n", s->next->fname, s->next->handle);
s->next = rmHandle(s->next); /* release the tracker */
}
else

6
Tools/unix/zxcc/zxcc.c

@ -306,6 +306,12 @@ int main(int ac, char** av)
fprintf(stderr, "Could not initialise CPMREDIR library\n");
zxcc_exit(1);
}
#ifdef FILETRACKER
DBGMSG("File tracking is ENABLED\n");
#else
DBGMSG("File tracking is DISABLED\n");
#endif
/* allow environment variables to override default locations */
/* two options are supported, explicit overrides for each directory

BIN
Tools/zxcc/zxcc-src.zip

Binary file not shown.

BIN
Tools/zxcc/zxcc.exe

Binary file not shown.

BIN
Tools/zxcc/zxcc_ft.exe

Binary file not shown.

BIN
Tools/zxcc/zxccdbg.exe

Binary file not shown.

BIN
Tools/zxcc/zxccdbg_ft.exe

Binary file not shown.
Loading…
Cancel
Save