2000-05-06 21:34:20 +02:00
|
|
|
/****************************************************************/
|
|
|
|
/* */
|
|
|
|
/* syspack.c */
|
|
|
|
/* */
|
|
|
|
/* System Disk Byte Order Packing Functions */
|
|
|
|
/* */
|
|
|
|
/* Copyright (c) 1995 */
|
|
|
|
/* Pasquale J. Villani */
|
|
|
|
/* All Rights Reserved */
|
|
|
|
/* */
|
|
|
|
/* This file is part of DOS-C. */
|
|
|
|
/* */
|
|
|
|
/* DOS-C 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, or (at your option) any later version. */
|
|
|
|
/* */
|
|
|
|
/* DOS-C 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 DOS-C; see the file COPYING. If not, */
|
|
|
|
/* write to the Free Software Foundation, 675 Mass Ave, */
|
|
|
|
/* Cambridge, MA 02139, USA. */
|
|
|
|
/* */
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
#include "portab.h"
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
#ifdef VERSION_STRINGS
|
2001-11-18 15:01:12 +01:00
|
|
|
static BYTE *syspackRcsId =
|
|
|
|
"$Id$";
|
2000-05-06 21:34:20 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NONNATIVE
|
2002-05-09 00:49:35 +02:00
|
|
|
UDWORD getlong(REG VOID * vp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
return (((UBYTE *) vp)[0] & 0xff) +
|
|
|
|
((((UBYTE *) vp)[1] & 0xff) << 8) +
|
|
|
|
((((UBYTE *) vp)[2] & 0xff) << 16) +
|
|
|
|
((((UBYTE *) vp)[3] & 0xff) << 24);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
UWORD getword(REG VOID * vp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
return (((UBYTE *) vp)[0] & 0xff) + ((((UBYTE *) vp)[1] & 0xff) << 8);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
UBYTE getbyte(VOID * vp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
return *((BYTE *) vp);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
UWORD fgetword(REG VOID FAR * vp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
return (((UBYTE FAR *) vp)[0] & 0xff) + ((((UBYTE FAR *) vp)[1] & 0xff) << 8);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
UDWORD fgetlong(REG VOID FAR * vp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
return (((UBYTE *) vp)[0] & 0xff) +
|
|
|
|
((((UBYTE *) vp)[1] & 0xff) << 8) +
|
|
|
|
((((UBYTE *) vp)[2] & 0xff) << 16) +
|
|
|
|
((((UBYTE *) vp)[3] & 0xff) << 24);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
UBYTE fgetbyte(VOID FAR * vp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
return *((UBYTE FAR *) vp);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
VOID fputlong(VOID FAR * vp, UDWORD l)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
REG UBYTE FAR *bp = (UBYTE FAR *) vp;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
bp[0] = l & 0xff;
|
|
|
|
bp[1] = (l >> 8) & 0xff;
|
|
|
|
bp[2] = (l >> 16) & 0xff;
|
|
|
|
bp[3] = (l >> 24) & 0xff;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
VOID fputword(VOID FAR * vp, UWORD w)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
REG UBYTE FAR *bp = (UBYTE FAR *) vp;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
bp[0] = w & 0xff;
|
|
|
|
bp[1] = (w >> 8) & 0xff;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
VOID fputbyte(VOID FAR * vp, UBYTE b)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-05-09 00:49:35 +02:00
|
|
|
*(UBYTE FAR *) vp = b;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
VOID getdirent(UBYTE FAR * vp, struct dirent FAR * dp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-18 00:26:45 +01:00
|
|
|
fmemcpy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE);
|
|
|
|
fmemcpy(dp->dir_ext, &vp[DIR_EXT], FEXT_SIZE);
|
2002-05-09 00:49:35 +02:00
|
|
|
dp->dir_attrib = fgetbyte(&vp[DIR_ATTRIB]);
|
|
|
|
dp->dir_time = fgetword(&vp[DIR_TIME]);
|
|
|
|
dp->dir_date = fgetword(&vp[DIR_DATE]);
|
|
|
|
dp->dir_start = fgetword(&vp[DIR_START]);
|
|
|
|
dp->dir_size = fgetlong(&vp[DIR_SIZE]);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
VOID putdirent(struct dirent FAR * dp, UBYTE FAR * vp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
REG COUNT i;
|
|
|
|
REG BYTE FAR *p;
|
|
|
|
|
2001-11-18 00:26:45 +01:00
|
|
|
fmemcpy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE);
|
|
|
|
fmemcpy(&vp[DIR_EXT], dp->dir_ext, FEXT_SIZE);
|
2002-05-09 00:49:35 +02:00
|
|
|
fputbyte(&vp[DIR_ATTRIB], dp->dir_attrib);
|
|
|
|
fputword(&vp[DIR_TIME], dp->dir_time);
|
|
|
|
fputword(&vp[DIR_DATE], dp->dir_date);
|
|
|
|
fputword(&vp[DIR_START], dp->dir_start);
|
|
|
|
fputlong(&vp[DIR_SIZE], dp->dir_size);
|
|
|
|
for (i = 0, p = (UBYTE FAR *) & vp[DIR_RESERVED]; i < 10; i++)
|
2000-05-06 21:34:20 +02:00
|
|
|
*p++ = NULL;
|
|
|
|
}
|
2001-11-04 20:47:39 +01:00
|
|
|
#endif
|
2001-11-18 00:26:45 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Log: syspack.c,v - for newer entries see "cvs log syspack.c"
|
|
|
|
*
|
|
|
|
* Revision 1.1.1.1 1999/03/29 15:42:21 jprice
|
|
|
|
* New version without IPL.SYS
|
|
|
|
*
|
|
|
|
* Revision 1.3 1999/02/01 01:43:28 jprice
|
|
|
|
* Fixed findfirst function to find volume label with Windows long filenames
|
|
|
|
*
|
|
|
|
* Revision 1.2 1999/01/22 04:15:28 jprice
|
|
|
|
* Formating
|
|
|
|
*
|
|
|
|
* Revision 1.1.1.1 1999/01/20 05:51:00 jprice
|
|
|
|
* Imported sources
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Rev 1.4 04 Jan 1998 23:14:38 patv
|
|
|
|
* Changed Log for strip utility
|
|
|
|
*
|
|
|
|
* Rev 1.3 29 May 1996 21:15:12 patv
|
|
|
|
* bug fixes for v0.91a
|
|
|
|
*
|
|
|
|
* Rev 1.2 01 Sep 1995 17:48:42 patv
|
|
|
|
* First GPL release.
|
|
|
|
*
|
|
|
|
* Rev 1.1 30 Jul 1995 20:50:26 patv
|
|
|
|
* Eliminated version strings in ipl
|
|
|
|
*
|
|
|
|
* Rev 1.0 02 Jul 1995 8:05:34 patv
|
|
|
|
* Initial revision.
|
|
|
|
*/
|