add some files that got lost in the update

This commit is contained in:
Kalamatee 2021-01-18 22:48:49 +00:00 committed by deadwood
parent cdf3e77db4
commit dc2b36cbda
9 changed files with 212 additions and 115 deletions

View File

@ -32,31 +32,6 @@
extern struct Env adfEnv;
#if !defined(__AROS__)
/*
* Disabled on AROS - tmpPath causes a
* NULL pointer acees, and path() is unused.
*
*/
char* path(struct Volume *vol, SECTNUM parent)
{
struct bEntryBlock entryBlk;
char *tmpPath;
int len;
tmpPath = NULL;
adfReadEntryBlock(vol, parent, &entryBlk);
len = min(entryBlk.nameLen, MAXNAMELEN);
memcpy(tmpPath,entryBlk.name,len);
tmpPath[len]='\0';
/* if (entryBlk.parent!=vol->rootBlock) {
return(strcat(path(vol,entryBlk.parent), tmpPath));
}
else
*/ return(tmpPath);
}
#endif
/*
*
*

View File

@ -1,20 +1,32 @@
/*
* adf_nativ.c
*
* file
* $Id$
*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ADFLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include "adf_str.h"
#include "adf_nativ.h"
#include "adf_err.h"
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"adf_str.h"
#include"adf_nativ.h"
#include"adf_err.h"
extern struct Env adfEnv;
@ -23,17 +35,11 @@ extern struct Env adfEnv;
*
* must fill 'dev->size'
*/
static RETCODE myInitDevice(struct Device* dev, char* name,BOOL ro)
RETCODE myInitDevice(struct Device* dev, char* name,BOOL ro)
{
struct nativeDevice* nDev;
int fd;
off_t size;
fd = open(name, (ro ? O_RDONLY : O_RDWR));
if (fd < 0) {
(*adfEnv.eFct)("myInitDevice : open");
return RC_ERROR;
}
nDev = (struct nativeDevice*)dev->nativeDev;
nDev = (struct nativeDevice*)malloc(sizeof(struct nativeDevice));
if (!nDev) {
@ -48,14 +54,7 @@ static RETCODE myInitDevice(struct Device* dev, char* name,BOOL ro)
/* mount device as read only */
dev->readOnly = TRUE;
nDev->fd = fdopen(fd, ro ? "rb" : "wb+");
size = lseek(fd, 0, SEEK_END);
dev->sectors = 61;
dev->heads = 126;
dev->cylinders = size / 512 / dev->sectors / dev->heads;
dev->size = dev->cylinders * dev->heads * dev->sectors * 512;
dev->isNativeDev = TRUE;
dev->size = 0;
return RC_OK;
}
@ -65,16 +64,9 @@ static RETCODE myInitDevice(struct Device* dev, char* name,BOOL ro)
* myReadSector
*
*/
static RETCODE myReadSector(struct Device *dev, long n, int size, unsigned char* buf)
RETCODE myReadSector(struct Device *dev, int32_t n, int size, uint8_t* buf)
{
struct nativeDevice *nDev = dev->nativeDev;
int fd = fileno(nDev->fd);
if (lseek(fd, (off_t)n * 512, SEEK_SET) != (off_t)-1)
if (read(fd, buf, size) == size)
return RC_OK;
return RC_ERROR;
return RC_OK;
}
@ -82,16 +74,9 @@ static RETCODE myReadSector(struct Device *dev, long n, int size, unsigned char*
* myWriteSector
*
*/
static RETCODE myWriteSector(struct Device *dev, long n, int size, unsigned char* buf)
RETCODE myWriteSector(struct Device *dev, int32_t n, int size, uint8_t* buf)
{
struct nativeDevice *nDev = dev->nativeDev;
int fd = fileno(nDev->fd);
if (lseek(fd, (off_t)n * 512, SEEK_SET) != (off_t)-1)
if (write(fd, buf, size) == size)
return RC_OK;
return RC_ERROR;
return RC_OK;
}
@ -100,28 +85,18 @@ static RETCODE myWriteSector(struct Device *dev, long n, int size, unsigned char
*
* free native device
*/
static RETCODE myReleaseDevice(struct Device *dev)
RETCODE myReleaseDevice(struct Device *dev)
{
struct nativeDevice* nDev;
nDev = (struct nativeDevice*)dev->nativeDev;
fclose(nDev->fd);
free(nDev);
free(nDev);
return RC_OK;
}
/*
* myIsDevNative
*
*/
BOOL myIsDevNative(char *devName)
{
return (strncmp(devName,"/dev/",5)==0);
}
/*
* adfInitNativeFct
*
@ -139,4 +114,13 @@ void adfInitNativeFct()
nFct->adfIsDevNative = myIsDevNative;
}
/*
* myIsDevNative
*
*/
BOOL myIsDevNative(char *devName)
{
return (strncmp(devName,"/dev/",5)==0);
}
/*##########################################################################*/

View File

@ -1,7 +1,24 @@
/*
* adf_nativ_.h
* adf_nativ.h
*
* $ID$
*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ADFLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* file
*/
#ifndef ADF_NATIV_H
@ -17,7 +34,7 @@
#endif
#ifndef RETCODE
#define RETCODE long
#define RETCODE int32_t
#endif
struct nativeDevice{
@ -28,9 +45,9 @@ struct nativeFunctions{
/* called by adfMount() */
RETCODE (*adfInitDevice)(struct Device*, char*,BOOL);
/* called by adfReadBlock() */
RETCODE (*adfNativeReadSector)(struct Device*, long, int, unsigned char*);
RETCODE (*adfNativeReadSector)(struct Device*, int32_t, int, uint8_t*);
/* called by adfWriteBlock() */
RETCODE (*adfNativeWriteSector)(struct Device*, long, int, unsigned char*);
RETCODE (*adfNativeWriteSector)(struct Device*, int32_t, int, uint8_t*);
/* called by adfMount() */
BOOL (*adfIsDevNative)(char*);
/* called by adfUnMount() */
@ -39,6 +56,13 @@ struct nativeFunctions{
void adfInitNativeFct();
RETCODE myReadSector(struct Device *dev, int32_t n, int size, uint8_t* buf);
RETCODE myWriteSector(struct Device *dev, int32_t n, int size, uint8_t* buf);
RETCODE myInitDevice(struct Device *dev, char* name,BOOL);
RETCODE myReleaseDevice(struct Device *dev);
BOOL myIsDevNative(char*);
#endif /* ADF_NATIV_H */
/*#######################################################################################*/

View File

@ -1,12 +1,30 @@
/* Win32/adf_nativ.c - Win32 specific drive-access routines for ADFLib
*
* Modified for Win32 by Dan Sutherland <dan@chromerhino.demon.co.uk>
*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ADFLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
// Modified 29/8/00 by Gary Harris.
// - Added a third, Boolean argument to Win32InitDevice() to avoid a compilation warning
// caused by the mismatch with the number of arguments in ADFLib's adfInitDevice().
/* Modified 29/8/00 by Gary Harris.
** - Added a third, Boolean argument to Win32InitDevice() to avoid a compilation warning
** caused by the mismatch with the number of arguments in ADFLib's adfInitDevice().
*/
#include <windows.h>
#include <stdlib.h>
@ -30,13 +48,13 @@ RETCODE Win32InitDevice(struct Device* dev, char* lpstrName, BOOL ro)
nDev = (struct nativeDevice*)malloc(sizeof(struct nativeDevice));
if (!nDev) {
(*adfEnv.eFct)("Win32InitDevice : malloc");
return FALSE;
return RC_ERROR; /* BV */
}
/* convert device name to something usable by Win32 functions */
if (strlen(lpstrName) != 3) {
(*adfEnv.eFct)("Win32InitDevice : invalid drive specifier");
return FALSE;
return RC_ERROR; /* BV */
}
strTempName[0] = lpstrName[1];
@ -47,7 +65,7 @@ RETCODE Win32InitDevice(struct Device* dev, char* lpstrName, BOOL ro)
if (nDev->hDrv == NULL) {
(*adfEnv.eFct)("Win32InitDevice : NT4OpenDrive");
return FALSE;
return RC_ERROR; /* BV */
}
dev->size = NT4GetDriveSize(nDev->hDrv);
@ -66,7 +84,7 @@ RETCODE Win32ReadSector(struct Device *dev, long n, int size, unsigned char* buf
if (! NT4ReadSector(tDev->hDrv, n, size, buf)) {
(*adfEnv.eFct)("Win32InitDevice : NT4ReadSector");
return FALSE;
return RC_ERROR; /* BV */
}
return RC_OK;
@ -81,7 +99,7 @@ RETCODE Win32WriteSector(struct Device *dev, long n, int size, unsigned char* bu
if (! NT4WriteSector(tDev->hDrv, n, size, buf)) {
(*adfEnv.eFct)("Win32InitDevice : NT4WriteSector");
return FALSE;
return RC_ERROR; /* BV */
}
return RC_OK;
@ -95,7 +113,7 @@ RETCODE Win32ReleaseDevice(struct Device *dev)
nDev = (struct nativeDevice*)dev->nativeDev;
if (! NT4CloseDrive(nDev->hDrv))
return FALSE;
return RC_ERROR; /* BV */
free(nDev);

View File

@ -2,6 +2,23 @@
*
* Win32 specific drive access routines for ADFLib
* Copyright 1999 by Dan Sutherland <dan@chromerhino.demon.co.uk>
*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ADFLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef ADF_NATIV_H
@ -22,8 +39,7 @@
struct nativeDevice{
FILE *fd; /* needed by adf_dump.c */
void *hDrv;
char path[4096]; // Add a path variable for the Opus info dialogue.
}; // This modifies the standard ADFLib.
};
struct nativeFunctions{
RETCODE (*adfInitDevice)(struct Device*, char*, BOOL);

View File

@ -1,9 +1,27 @@
// An ADFLib function for Windows which displays a dialogue box containing details about
// the current disk file.
// Converted from adfVolumeInfo(), part of ADFLib by Laurent Clevy.
//
// Gary Harris
// 30/8/00
/* An ADFLib function for Windows which displays a dialogue box containing details about
** the current disk file.
** Converted from adfVolumeInfo(), part of ADFLib by Laurent Clevy.
**
** Gary Harris
** 30/8/00
*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ADFLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "../ADF_raw.h"
@ -11,12 +29,13 @@
void adfVolumeInfoWin(HWND hWnd, struct Volume *vol)
// Windows version of adfVolumeInfo().
// Input: Receives a handle to the window on which to display the dialogue and a pointer
// to a ADFLib Volume structure.
// Output: Nil. Displays a windows dialogue containing the disk file data.
/* Windows version of adfVolumeInfo().
** Input: Receives a handle to the window on which to display the dialogue and a pointer
** to a ADFLib Volume structure.
** Output: Nil. Displays a windows dialogue containing the disk file data.
*/
{
char szTemp[50], szAdfInfo[500]; // Info string.
char szTemp[50], szAdfInfo[500]; /* Info string. */
struct bRootBlock root;
char diskName[35];

View File

@ -1,4 +1,31 @@
#ifndef DEFENDIAN_H
#define DEFENDIAN_H
#define LITT_ENDIAN 1
/*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ADFLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef _MSC_VER
#undef printf
#define printf
#undef putchar
#define putchar
#endif
#endif /* DEFENDIAN_H */

View File

@ -3,6 +3,22 @@
* Copyright 1999 by Dan Sutherland <dan@chromerhino.demon.co.uk>
*
* These routines only currently work with drives <2GB and 512 bytes per sector
*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ADFLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <windows.h>
@ -43,6 +59,8 @@ BOOL NT4CloseDrive(HANDLE hDrv)
{
DWORD dwRet;
if( hDrv==NULL ) return TRUE; /* BV */
if (! DeviceIoControl(hDrv, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0,
&dwRet, NULL))
return FALSE;
@ -114,9 +132,9 @@ ULONG NT4GetDriveSize(HANDLE hDrv)
size = dgGeom.Cylinders.LowPart * dgGeom.TracksPerCylinder *
dgGeom.SectorsPerTrack * dgGeom.BytesPerSector;
printf("Total sectors: %i\n", dgGeom.Cylinders.LowPart * dgGeom.TracksPerCylinder * dgGeom.SectorsPerTrack);
printf("Byte size: %i\n", size);
/* BV */
/* printf("Total sectors: %i\n", dgGeom.Cylinders.LowPart * dgGeom.TracksPerCylinder * dgGeom.SectorsPerTrack);
** printf("Byte size: %i\n", size);
*/
return size;
}

View File

@ -1,6 +1,22 @@
/* nt4_dev.h - prototypes for NT4 direct drive access functions
*
* Copyright 1999 by Dan Sutherland
*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ADFLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
HANDLE NT4OpenDrive(char *strDrive);