diff --git a/setter/src/dos/attr.c b/setter/src/dos/attr.c index 3a25eff..55fbe0f 100644 --- a/setter/src/dos/attr.c +++ b/setter/src/dos/attr.c @@ -45,11 +45,11 @@ Copyright (C) 2011-2021 Natalia Portillo void FileAttributes(const char* path) { - char driveNo = path[0] - '@'; - unsigned total, actionTaken; - unsigned int rc, wRc, cRc; - int handle; - int i; + char driveNo = path[0] - '@'; + unsigned total, actionTaken; + unsigned int rc, wRc, cRc; + int handle; + int i; if(driveNo > 32) driveNo -= 32; @@ -74,12 +74,17 @@ void FileAttributes(const char* path) if(!rc) { - wRc = _dos_write(handle, (void*)dos_attrs[i].contents, strlen(dos_attrs[i].contents), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr(dos_attrs[i].filename, dos_attrs[i].attr); + wRc = _dos_write(handle, (void*)dos_attrs[i].contents, strlen(dos_attrs[i].contents), &actionTaken); + cRc = _dos_close(handle); + rc = _dos_setfileattr(dos_attrs[i].filename, dos_attrs[i].attr); } - printf("\t%s: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", dos_attrs[i].description, dos_attrs[i].filename, rc, wRc, cRc); + printf("\t%s: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", + dos_attrs[i].description, + dos_attrs[i].filename, + rc, + wRc, + cRc); } } diff --git a/setter/src/dos/attr.h b/setter/src/dos/attr.h index 874691e..ecc5646 100644 --- a/setter/src/dos/attr.h +++ b/setter/src/dos/attr.h @@ -36,10 +36,10 @@ Copyright (C) 2011-2021 Natalia Portillo typedef struct { - char filename[9]; - char contents[170]; - char description[63]; - unsigned int attr; + char filename[9]; + char contents[170]; + char description[63]; + unsigned int attr; } dos_attr_tests_t; #define KNOWN_DOS_ATTRS 16 @@ -50,34 +50,67 @@ static const dos_attr_tests_t dos_attrs[KNOWN_DOS_ATTRS] = { {"SYSTEM", "This file has the system attribute set.\n", "File with system attribute", _A_SYSTEM}, {"HIDDEN", "This file has the hidden attribute set.\n", "File with hidden attribute", _A_HIDDEN}, {"READONLY", "This file has the read-only attribute set.\n", "File with read-only attribute", _A_RDONLY}, - {"HIDDREAD", "This file has the hidden attribute set.\n" - "This file has the read-only attribute set.\n", "File with hidden, read-only attributes", _A_HIDDEN | _A_RDONLY}, - {"SYSTREAD", "This file has the system attribute set.\n" - "This file has the read-only attribute set.\n", "File with system, read-only attributes", _A_SYSTEM | _A_RDONLY}, - {"SYSTHIDD", "This file has the system attribute set.\n" - "This file has the hidden attribute set.\n", "File with system, hidden attributes", _A_SYSTEM | _A_HIDDEN}, - {"SYSRDYHD", "This file has the system attribute set.\n" - "This file has the read-only attribute set.\n" - "This file has the hidden attribute set.\n", "File with system, read-only, hidden attributes", _A_SYSTEM | _A_RDONLY | _A_HIDDEN}, - {"ARCHREAD", "This file has the archived attribute set.\n" - "This file has the read-only attribute set.\n", "File with archived, read-only attributes", _A_ARCH | _A_RDONLY}, - {"ARCHHIDD", "This file has the archived attribute set.\n" - "This file has the hidden attribute set.\n", "File with archived, hidden attributes", _A_ARCH | _A_HIDDEN}, - {"ARCHDRDY", "This file has the archived attribute set.\n" - "This file has the hidden attribute set.\n" - "This file has the read-only attribute set.\n", "File with archived, hidden, read-only attributes", _A_ARCH | _A_HIDDEN | _A_RDONLY}, - {"ARCHSYST", "This file has the archived attribute set.\n" - "This file has the system attribute set.\n", "File with archived, system attributes", _A_ARCH | _A_SYSTEM}, - {"ARSYSRDY", "This file has the archived attribute set.\n" - "This file has the system attribute set.\n" - "This file has the read-only attribute set.\n", "File with archived, system, read-only attributes", _A_ARCH | _A_SYSTEM | _A_RDONLY}, - {"ARCSYSHD", "This file has the archived attribute set.\n" - "This file has the system attribute set.\n" - "This file has the hidden attribute set.\n", "File with archived, system, hidden attributes", _A_ARCH | _A_SYSTEM | _A_HIDDEN}, - {"ARSYHDRD", "This file has the archived attribute set.\n" - "This file has the system attribute set.\n" - "This file has the hidden attribute set.\n" - "This file has the read-only attribute set.\n", "File with all (archived, system, hidden, read-only) attributes", _A_ARCH | _A_SYSTEM | _A_HIDDEN | _A_RDONLY}, + {"HIDDREAD", + "This file has the hidden attribute set.\n" + "This file has the read-only attribute set.\n", + "File with hidden, read-only attributes", + _A_HIDDEN | _A_RDONLY}, + {"SYSTREAD", + "This file has the system attribute set.\n" + "This file has the read-only attribute set.\n", + "File with system, read-only attributes", + _A_SYSTEM | _A_RDONLY}, + {"SYSTHIDD", + "This file has the system attribute set.\n" + "This file has the hidden attribute set.\n", + "File with system, hidden attributes", + _A_SYSTEM | _A_HIDDEN}, + {"SYSRDYHD", + "This file has the system attribute set.\n" + "This file has the read-only attribute set.\n" + "This file has the hidden attribute set.\n", + "File with system, read-only, hidden attributes", + _A_SYSTEM | _A_RDONLY | _A_HIDDEN}, + {"ARCHREAD", + "This file has the archived attribute set.\n" + "This file has the read-only attribute set.\n", + "File with archived, read-only attributes", + _A_ARCH | _A_RDONLY}, + {"ARCHHIDD", + "This file has the archived attribute set.\n" + "This file has the hidden attribute set.\n", + "File with archived, hidden attributes", + _A_ARCH | _A_HIDDEN}, + {"ARCHDRDY", + "This file has the archived attribute set.\n" + "This file has the hidden attribute set.\n" + "This file has the read-only attribute set.\n", + "File with archived, hidden, read-only attributes", + _A_ARCH | _A_HIDDEN | _A_RDONLY}, + {"ARCHSYST", + "This file has the archived attribute set.\n" + "This file has the system attribute set.\n", + "File with archived, system attributes", + _A_ARCH | _A_SYSTEM}, + {"ARSYSRDY", + "This file has the archived attribute set.\n" + "This file has the system attribute set.\n" + "This file has the read-only attribute set.\n", + "File with archived, system, read-only attributes", + _A_ARCH | _A_SYSTEM | _A_RDONLY}, + {"ARCSYSHD", + "This file has the archived attribute set.\n" + "This file has the system attribute set.\n" + "This file has the hidden attribute set.\n", + "File with archived, system, hidden attributes", + _A_ARCH | _A_SYSTEM | _A_HIDDEN}, + {"ARSYHDRD", + "This file has the archived attribute set.\n" + "This file has the system attribute set.\n" + "This file has the hidden attribute set.\n" + "This file has the read-only attribute set.\n", + "File with all (archived, system, hidden, read-only) attributes", + _A_ARCH | _A_SYSTEM | _A_HIDDEN | _A_RDONLY}, }; #endif // SETTER_SRC_DOS_ATTR_H_ diff --git a/setter/src/dos/deleted.c b/setter/src/dos/deleted.c index 055126a..8903f96 100644 --- a/setter/src/dos/deleted.c +++ b/setter/src/dos/deleted.c @@ -44,12 +44,12 @@ Copyright (C) 2011-2021 Natalia Portillo void DeleteFiles(const char* path) { - char driveNo = path[0] - '@'; - unsigned int rc; - char filename[9]; - short pos; - unsigned total; - int handle; + char driveNo = path[0] - '@'; + unsigned int rc; + char filename[9]; + short pos; + unsigned total; + int handle; if(driveNo > 32) driveNo -= 32; diff --git a/setter/src/dos/dirdepth.c b/setter/src/dos/dirdepth.c index 642c2cc..2cde2b7 100644 --- a/setter/src/dos/dirdepth.c +++ b/setter/src/dos/dirdepth.c @@ -44,11 +44,11 @@ Copyright (C) 2011-2021 Natalia Portillo void DirectoryDepth(const char* path) { - char driveNo = path[0] - '@'; - unsigned int rc ; - unsigned total; - char filename[9]; - int pos = 2; + char driveNo = path[0] - '@'; + unsigned int rc; + unsigned total; + char filename[9]; + int pos = 2; if(driveNo > 32) driveNo -= 32; diff --git a/setter/src/dos/dos.c b/setter/src/dos/dos.c index 4b0d9dc..9999374 100644 --- a/setter/src/dos/dos.c +++ b/setter/src/dos/dos.c @@ -35,19 +35,19 @@ Copyright (C) 2011-2021 Natalia Portillo #include #elif defined(__DJGPP__) #include -#include #include +#include #endif #include "dos.h" -unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *diskspace) +unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t* diskspace) { #if defined(__WATCOM__) - char drivePath[4]; - union REGS regs; - struct SREGS sregs; - struct diskfree_ex_t *copy; + char drivePath[4]; + union REGS regs; + struct SREGS sregs; + struct diskfree_ex_t* copy; copy = malloc(sizeof(struct diskfree_ex_t)); @@ -82,7 +82,7 @@ unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *disks else if(regs.w.cflag) { free(copy); - errno = EINVAL; + errno = EINVAL; _doserrno = regs.w.ax; return -1; } @@ -90,12 +90,12 @@ unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *disks memcpy(diskspace, copy, sizeof(struct diskfree_ex_t)); free(copy); - errno = 0; + errno = 0; _doserrno = regs.w.ax; return 0; #elif defined(__DJGPP__) - char drivePath[4]; + char drivePath[4]; __dpmi_regs regs; drivePath[0] = (drive & 0xFF) + '@'; @@ -106,32 +106,30 @@ unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *disks // Use transferBuffer[0] for drivePath and transferBuffer[16] for diskfree_ex_t dosmemput(drivePath, 0, __tb); - regs.x.ds = - regs.x.ax = 0x7303; - regs.x.ds = __tb >> 4; + regs.x.ds = __tb >> 4; regs.x.dx = __tb & 0x0F; - regs.x.es = (__tb + 16) >> 4; + regs.x.es = (__tb + 16) >> 4; regs.x.di = (__tb + 16) & 0x0F; regs.x.cx = sizeof(struct diskfree_ex_t); - __dpmi_int (0x21, ®s); + __dpmi_int(0x21, ®s); - if(regs.h.al == 0 && !(regs.x.flags & 1)) - { - errno = ENOSYS; - return -1; - } - else if(regs.x.flags & 1) - { - errno = EINVAL; - _doserrno = regs.x.ax; - return -1; - } + if(regs.h.al == 0 && !(regs.x.flags & 1)) + { + errno = ENOSYS; + return -1; + } + else if(regs.x.flags & 1) + { + errno = EINVAL; + _doserrno = regs.x.ax; + return -1; + } dosmemget(__tb + 16, sizeof(struct diskfree_ex_t), diskspace); - errno = 0; + errno = 0; _doserrno = regs.x.ax; return 0; diff --git a/setter/src/dos/dos.h b/setter/src/dos/dos.h index 1bacb1d..f632d75 100644 --- a/setter/src/dos/dos.h +++ b/setter/src/dos/dos.h @@ -61,7 +61,7 @@ typedef struct diskfree_ex_t unsigned char reserved[8]; } diskfree_ex; -unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *diskspace); +unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t* diskspace); #if defined(__WATCOM__) #pragma pack(__pop) diff --git a/setter/src/dos/filename.c b/setter/src/dos/filename.c index c4203bc..9b93de8 100644 --- a/setter/src/dos/filename.c +++ b/setter/src/dos/filename.c @@ -45,12 +45,12 @@ Copyright (C) 2011-2021 Natalia Portillo void Filenames(const char* path) { - char driveNo = path[0] - '@'; - unsigned int rc, wRc = 0, cRc = 0; - unsigned actionTaken, total; - int handle; - char message[300]; - int pos; + char driveNo = path[0] - '@'; + unsigned int rc, wRc = 0, cRc = 0; + unsigned actionTaken, total; + int handle; + char message[300]; + int pos; if(driveNo > 32) driveNo -= 32; diff --git a/setter/src/dos/files.c b/setter/src/dos/files.c index 26484a8..5dc92dc 100644 --- a/setter/src/dos/files.c +++ b/setter/src/dos/files.c @@ -44,12 +44,12 @@ Copyright (C) 2011-2021 Natalia Portillo void MillionFiles(const char* path) { - char driveNo = path[0] - '@'; - unsigned int rc; - char filename[9]; + char driveNo = path[0] - '@'; + unsigned int rc; + char filename[9]; unsigned int pos; - int handle; - unsigned total; + int handle; + unsigned total; if(driveNo > 32) driveNo -= 32; diff --git a/setter/src/dos/frag.c b/setter/src/dos/frag.c index 67e8f5d..1f695e3 100644 --- a/setter/src/dos/frag.c +++ b/setter/src/dos/frag.c @@ -47,14 +47,14 @@ Copyright (C) 2011-2021 Natalia Portillo void Fragmentation(const char* path, size_t clusterSize) { - unsigned int halfCluster = clusterSize / 2; - unsigned int quarterCluster = clusterSize / 4; - unsigned int twoCluster = clusterSize * 2; - unsigned int threeQuartersCluster = halfCluster + quarterCluster; - unsigned int twoAndThreeQuartCluster = threeQuartersCluster + twoCluster; + unsigned int halfCluster = clusterSize / 2; + unsigned int quarterCluster = clusterSize / 4; + unsigned int twoCluster = clusterSize * 2; + unsigned int threeQuartersCluster = halfCluster + quarterCluster; + unsigned int twoAndThreeQuartCluster = threeQuartersCluster + twoCluster; unsigned char* buffer; char driveNo = path[0] - '@'; - unsigned int rc, wRc = 0, cRc = 0; + unsigned int rc, wRc = 0, cRc = 0; unsigned total, actionTaken = 0; int handle; long i; diff --git a/setter/src/dos/time.c b/setter/src/dos/time.c index 7702373..4531bba 100644 --- a/setter/src/dos/time.c +++ b/setter/src/dos/time.c @@ -46,13 +46,13 @@ Copyright (C) 2011-2021 Natalia Portillo void Timestamps(const char* path) { - char driveNo = path[0] - '@'; - unsigned int rc, wRc = 0, cRc = 0, tRc = 0; - unsigned actionTaken, total; - int handle; - char message[300]; - union REGS regs; - int i; + char driveNo = path[0] - '@'; + unsigned int rc, wRc = 0, cRc = 0, tRc = 0; + unsigned actionTaken, total; + int handle; + char message[300]; + union REGS regs; + int i; if(driveNo > 32) driveNo -= 32; @@ -99,7 +99,8 @@ void Timestamps(const char* path) cRc = _dos_close(handle); } - printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", dos_times[i].filename, rc, wRc, cRc, tRc); + printf( + "\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", dos_times[i].filename, rc, wRc, cRc, tRc); } } diff --git a/setter/src/dos/volume.c b/setter/src/dos/volume.c index ba97124..251783e 100644 --- a/setter/src/dos/volume.c +++ b/setter/src/dos/volume.c @@ -30,20 +30,20 @@ Copyright (C) 2011-2021 Natalia Portillo #if defined(__DOS__) || defined(MSDOS) #include +#include #include #include #include -#include #include "../include/defs.h" #include "dos.h" void GetVolumeInfo(const char* path, size_t* clusterSize) { - char driveNo = path[0] - '@'; - struct diskfree_t oldFreeSpace; - struct diskfree_ex_t freeSpace; - unsigned int rc; + char driveNo = path[0] - '@'; + struct diskfree_t oldFreeSpace; + struct diskfree_ex_t freeSpace; + unsigned int rc; memset(&oldFreeSpace, 0, sizeof(struct diskfree_t)); memset(&freeSpace, 0, sizeof(struct diskfree_ex_t)); @@ -57,15 +57,15 @@ void GetVolumeInfo(const char* path, size_t* clusterSize) if(errno == ENOSYS) { rc = _dos_getdiskfree(driveNo, &oldFreeSpace); - freeSpace.sectorsPerCluster = oldFreeSpace.sectors_per_cluster; - freeSpace.freeClusters = oldFreeSpace.avail_clusters; - freeSpace.bytesPerSector = oldFreeSpace.bytes_per_sector; - freeSpace.totalClusters = oldFreeSpace.total_clusters; + freeSpace.sectorsPerCluster = oldFreeSpace.sectors_per_cluster; + freeSpace.freeClusters = oldFreeSpace.avail_clusters; + freeSpace.bytesPerSector = oldFreeSpace.bytes_per_sector; + freeSpace.totalClusters = oldFreeSpace.total_clusters; } else { - printf("Error %d requesting volume information.\n", _doserrno); - return; + printf("Error %d requesting volume information.\n", _doserrno); + return; } }