Thread: [Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [412] vendor/libdsk/current
Brought to you by:
fredm
|
From: <fr...@us...> - 2007-07-01 02:41:09
|
Revision: 412
http://svn.sourceforge.net/fuse-for-macosx/?rev=412&view=rev
Author: fredm
Date: 2007-06-30 19:41:10 -0700 (Sat, 30 Jun 2007)
Log Message:
-----------
Load . into vendor/libdsk/current.
Modified Paths:
--------------
vendor/libdsk/current/ChangeLog
vendor/libdsk/current/configure
vendor/libdsk/current/configure.in
vendor/libdsk/current/doc/libdsk.lyx
vendor/libdsk/current/doc/libdsk.pdf
vendor/libdsk/current/doc/libdsk.txt
vendor/libdsk/current/include/libdsk.h
vendor/libdsk/current/lib/compsq.c
vendor/libdsk/current/lib/drvcpcem.c
vendor/libdsk/current/lib/drvcpcem.h
vendor/libdsk/current/lib/drvntwdm.c
vendor/libdsk/current/man/apriboot.1
vendor/libdsk/current/man/dskdump.1
vendor/libdsk/current/man/dskform.1
vendor/libdsk/current/man/dskid.1
vendor/libdsk/current/man/dskscan.1
vendor/libdsk/current/man/dsktrans.1
vendor/libdsk/current/man/dskutil.1
vendor/libdsk/current/man/md3serial.1
Modified: vendor/libdsk/current/ChangeLog
===================================================================
--- vendor/libdsk/current/ChangeLog 2007-07-01 02:20:49 UTC (rev 411)
+++ vendor/libdsk/current/ChangeLog 2007-07-01 02:41:10 UTC (rev 412)
@@ -1,3 +1,25 @@
+2006-11-18 John Elliott
+
+ * libdsk-1.1.11 released.
+
+2006-08-02 John Elliott
+
+ * cpcemu driver: Bug fix when a sector is not found and it has
+ to start searching again at the beginning of the track.
+
+2006-07-23 John Elliott
+
+ * libdsk-1.1.11 released.
+
+2006-07-02 Ramlaid <www.ramlaid.com>
+
+ * cpcemu driver: Modified so that the dsk_trkids() function more
+ accurately reflects the result from a real disk. Also exposed the
+ ST0-ST3 registers.
+ * SQ compression: Doesn't leak file handles if file not compressed.
+ * NTWDM driver: Uses the passed sector size in dsk_xread / dsk_xwrite
+ rather than the sector size in the geometry structure.
+
2006-04-18 John Elliott
* libdsk-1.1.10 released.
Modified: vendor/libdsk/current/configure
===================================================================
--- vendor/libdsk/current/configure 2007-07-01 02:20:49 UTC (rev 411)
+++ vendor/libdsk/current/configure 2007-07-01 02:41:10 UTC (rev 412)
@@ -814,8 +814,8 @@
NONENONEs,x,x, &&
program_prefix=${target_alias}-
-VERSION=1.1.10
-UPDATED='April 18, 2006'
+VERSION=1.1.12
+UPDATED='November 18, 2006'
am__api_version="1.4"
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
Modified: vendor/libdsk/current/configure.in
===================================================================
--- vendor/libdsk/current/configure.in 2007-07-01 02:20:49 UTC (rev 411)
+++ vendor/libdsk/current/configure.in 2007-07-01 02:41:10 UTC (rev 412)
@@ -2,8 +2,8 @@
AC_INIT(lib/dskopen.c)
AC_CONFIG_AUX_DIR(config)
AC_CANONICAL_SYSTEM
-VERSION=1.1.10
-UPDATED='April 18, 2006'
+VERSION=1.1.12
+UPDATED='November 18, 2006'
AM_INIT_AUTOMAKE(libdsk, $VERSION)
AM_CONFIG_HEADER(config.h)
Modified: vendor/libdsk/current/doc/libdsk.lyx
===================================================================
--- vendor/libdsk/current/doc/libdsk.lyx 2007-07-01 02:20:49 UTC (rev 411)
+++ vendor/libdsk/current/doc/libdsk.lyx 2007-07-01 02:41:10 UTC (rev 412)
@@ -26,7 +26,7 @@
\layout Title
-LibDsk v1.1.10
+LibDsk v1.1.12
\layout Author
John Elliott
@@ -136,6 +136,10 @@
For full details, see the file ChangeLog.
\layout Itemize
+Changes by Ramlaid <www.ramlaid.com> to the DSK and NTWDM drivers to improve
+ compatibility, and another fix to stop file handles leaking.
+\layout Itemize
+
Added a new driver:
\begin_inset Quotes eld
\end_inset
Modified: vendor/libdsk/current/doc/libdsk.pdf
===================================================================
(Binary files differ)
Modified: vendor/libdsk/current/doc/libdsk.txt
===================================================================
--- vendor/libdsk/current/doc/libdsk.txt 2007-07-01 02:20:49 UTC (rev 411)
+++ vendor/libdsk/current/doc/libdsk.txt 2007-07-01 02:41:10 UTC (rev 412)
@@ -1,4 +1,4 @@
-LibDsk v1.1.10
+LibDsk v1.1.12
John Elliott
@@ -198,6 +198,10 @@
For full details, see the file ChangeLog.
+ Changes by Ramlaid <www.ramlaid.com> to the DSK and
+ NTWDM drivers to improve compatibility, and another
+ fix to stop file handles leaking.
+
Added a new driver: "int25". This allows the DOS version
to run on Apricot PCs (which do not have an
IBM-compatible BIOS) and to access hard drive partitions.
Modified: vendor/libdsk/current/include/libdsk.h
===================================================================
--- vendor/libdsk/current/include/libdsk.h 2007-07-01 02:20:49 UTC (rev 411)
+++ vendor/libdsk/current/include/libdsk.h 2007-07-01 02:41:10 UTC (rev 412)
@@ -58,7 +58,7 @@
extern "C" {
#endif
-#define LIBDSK_VERSION "1.1.10"
+#define LIBDSK_VERSION "1.1.12"
/************************* TYPES ********************************/
Modified: vendor/libdsk/current/lib/compsq.c
===================================================================
--- vendor/libdsk/current/lib/compsq.c 2007-07-01 02:20:49 UTC (rev 411)
+++ vendor/libdsk/current/lib/compsq.c 2007-07-01 02:41:10 UTC (rev 412)
@@ -1,682 +1,686 @@
-/***************************************************************************
- * *
- * LIBDSK: General floppy and diskimage access library *
- * Copyright (C) 2002 John Elliott <jc...@se...> *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Library General Public *
- * License as published by the Free Software Foundation; either *
- * version 2 of the License, or (at your option) any later version. *
- * *
- * This library 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 *
- * Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; if not, write to the Free *
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, *
- * MA 02111-1307, USA *
- * *
- ***************************************************************************/
-
-/* Squeeze (Huffman) compression/decompression. This is entirely new code,
- * created by John Elliott to avoid possible licensing problems with the
- * Richard Greenlaw/Theo Pozzy code used in earlier releases.
- *
- * In brief: Richard Greenlaw's original code had no licence with it at all.
- * However, a file dated 1983 on the CP/M CDROM suggests that he
- * intended it as not-for-profit rather than true PD.
- *
- * Theo Pozzy's UNIX port of SQ (1985) implies that the code he used
- * is truly PD. But his belief that SQ was public domain may not
- * be correct in the light of the 1983 letter above.
- *
- * My thanks to Russell Marks for pointing this out.
- *
- * Note that my code is less sophisticated than Richard Greenlaw's original.
- * It doesn't, for example, try to deal with pathologically unbalanced
- * encoding trees (where a source byte encodes to more than 16 bits).
- *
- */
-
-#include "compi.h"
-#include "compsq.h"
-
-
-/******************************* compsq.c **********************************/
-typedef dsk_err_t (*RLEFUNC)(SQ_COMPRESS_DATA *self, int ch);
-
-
-
-/************************ RLE COMPRESSION FUNCTIONS ************************/
-static void rle_reset(SQ_COMPRESS_DATA *self)
-{
- self->rle_char = -1;
- self->rle_run = 0;
-}
-
-
-
-
-static dsk_err_t rle_flush(SQ_COMPRESS_DATA *self, RLEFUNC writer)
-{
- dsk_err_t err = DSK_ERR_OK;
-/* We encode sequences of >3 bytes using RLE. However, the RLE trigger byte
- * itself (0x90) is encoded as 2 bytes, and we can't encode sequences of it; it
- * would encode to (eg) 20 90 90 xx, and then decompress as (20 90 90) xx
- * when it was compressed as 20 (90 90 xx).
- */
- if ( self->rle_run > 3 && self->rle_char != RLECODE)
- {
- err = (*writer)(self, self->rle_char);
- if (!err) err = (*writer)(self, RLECODE);
- if (!err) err = (*writer)(self, self->rle_run);
- }
- else while (self->rle_run)
- {
- if (!err) err = (*writer)(self, self->rle_char);
- if (self->rle_char == RLECODE && !err) err = (*writer)(self, 0x00);
- --self->rle_run;
- }
- self->rle_run = 0;
- return err;
-}
-
-
-
-/* Generate an RLE stream from a file */
-static dsk_err_t rle_stream(SQ_COMPRESS_DATA *self, RLEFUNC writer)
-{
- int c;
- dsk_err_t err;
-
- while ( (c = fgetc(self->fp_in)) != EOF )
- {
- self->ck_sum += (unsigned char)c;
-/* If this character is the same as the last, increase the count. */
- if (c == self->rle_char)
- {
- ++self->rle_run;
- if (self->rle_run == 0xFF) /* Max length of run */
- { /* flush & start again */
- err = rle_flush(self, writer);
- if (err) return err;
- self->rle_char = -1;
- self->rle_run = 0;
- }
- }
- else
- {
-/* If not, write out what we've got and start again. */
- err = rle_flush(self, writer);
- if (err) return err;
- self->rle_char = c;
- self->rle_run = 1;
- }
- }
- if (ferror(self->fp_in)) return DSK_ERR_SYSERR;
-/* Write out what we've got; then EOF. */
- err = rle_flush(self, writer);
- if (err) return err;
- self->rle_char = SQ_EOF;
- self->rle_run = 1;
- err = rle_flush(self, writer);
- if (err) return err;
- rewind(self->fp_in);
- return DSK_ERR_OK;
-}
-
-
-/*
-static dsk_err_t rle_print(SQ_COMPRESS_DATA *self, int ch)
-{
- if (ch == '\r' || ch == '\n' || (ch > 0x1F && ch < 0x7F))
- fputc(ch, self->fp_out);
- else fprintf(self->fp_out, "<%02x>", ch);
- return DSK_ERR_OK;
-} */
-/******************* RLE COMPRESSION FUNCTIONS: END ************************/
-
-static dsk_err_t huf_counter(SQ_COMPRESS_DATA *self, int ch)
-{
- if (ch >= 0 && ch <= SQ_EOF) ++self->huf_count[ch + MAXNODE];
- else return DSK_ERR_COMPRESS;
-
- return DSK_ERR_OK;
-}
-
-/* Find the index of the smallest nonzero character count in huf_count.
- */
-static int huf_smallest(SQ_COMPRESS_DATA *self, int skip)
-{
- unsigned long mv = ~0UL;
- int n, mi = -1;
-
- for (n = 0; n < MAXLEAF + MAXNODE; n++)
- {
- if (n == skip) continue;
- if (self->huf_count[n] < mv && self->huf_count[n] > 0)
- {
- mv = self->huf_count[n];
- mi = n;
- }
- }
- return mi;
-}
-
-
-/* Add a node. */
-static void huf_addnode(SQ_COMPRESS_DATA *self, int n1, int n2)
-{
- short e_n1, e_n2;
-
- //printf("%04X:%04X\r\n", n1, n2);
-
- if (n1 < MAXNODE) e_n1 = n1; else e_n1 = MAXNODE - 1 - n1;
- if (n2 < MAXNODE) e_n2 = n2; else e_n2 = MAXNODE - 1 - n2;
-
- /* If parent not set, parent is MAXNODE */
- self->huf_node[self->huf_curnode].parent = MAXNODE;
- self->huf_node[self->huf_curnode].left = e_n1;
- self->huf_node[self->huf_curnode].right = e_n2;
-
-/* If nodes hold leaves, record them. If they hold other nodes, set parents. */
- if (n1 >= MAXNODE) self->huf_leaves[n1 - MAXNODE] = self->huf_curnode;
- else self->huf_node[n1].parent = self->huf_curnode;
- if (n2 >= MAXNODE) self->huf_leaves[n2 - MAXNODE] = self->huf_curnode;
- else self->huf_node[n2].parent = self->huf_curnode;
-
-}
-
-
-
-/* Generate the Huffman dictionary for a file */
-static dsk_err_t analyze(SQ_COMPRESS_DATA *self)
-{
- int n, n1, n2;
- dsk_err_t err;
-
- /* Initialise counters */
- self->ck_sum = 0;
- for (n = 0; n < MAXNODE + MAXLEAF; n++) self->huf_count[n] = 0;
- rle_reset(self);
- err = rle_stream(self, huf_counter);
- if (err) return err;
-
- /* Start allocating nodes from the end. That way, the root node,
- * the last to be populated, will have the lowest number. */
- self->huf_curnode = MAXNODE - 1;
- self->huf_nodecount = 0;
- for (n = 0; n < MAXNODE + MAXLEAF; n++) if (self->huf_count[n])
- ++self->huf_nodecount;
-
- /* Special case if there's only one node (empty file) */
- if (self->huf_nodecount == 1)
- {
- n1 = huf_smallest(self, -1);
- huf_addnode(self, n1, n1);
- self->huf_nodecount = 0;
- --self->huf_curnode;
- }
-
- /* huf_nodecount = number of leaves */
- while (self->huf_nodecount > 1)
- {
- n1 = huf_smallest(self, -1);
- n2 = huf_smallest(self, n1);
- /* We have n1 and n2: Two nodes to be combined */
- huf_addnode(self, n1, n2);
-
- self->huf_count[self->huf_curnode] =
- self->huf_count[n1] + self->huf_count[n2];
- self->huf_count[n1] = 0;
- self->huf_count[n2] = 0;
- --self->huf_curnode;
- --self->huf_nodecount;
- }
- /* self->huf_curnode is now the node before the root node */
- return DSK_ERR_OK;
-}
-
-static dsk_err_t writec(SQ_COMPRESS_DATA *self, unsigned char c)
-{
- if (fputc(c, self->fp_out) == EOF) return DSK_ERR_SYSERR;
-
- return DSK_ERR_OK;
-}
-
-
-static dsk_err_t writes(SQ_COMPRESS_DATA *self, unsigned short s)
-{
- dsk_err_t e;
-
- e = writec(self, (unsigned char)(s & 0xFF)); if (e) return e;
- e = writec(self, (unsigned char)((s >> 8) & 0xFF)); if (e) return e;
- return DSK_ERR_OK;
-}
-
-static unsigned char st_masks[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
-
-static dsk_err_t flipbits(SQ_COMPRESS_DATA *self)
-{
- int n, bit;
-
- for (n = self->huf_nbits - 1; n >= 0; n--)
- {
- bit = (self->huf_bits[n / 8] & st_masks[n % 8]);
-
- if (bit) self->huf_out |= st_masks[self->huf_nout];
- ++self->huf_nout;
- if (self->huf_nout == 8)
- {
- if (fputc(self->huf_out, self->fp_out) == EOF)
- return DSK_ERR_SYSERR;
- self->huf_nout = 0;
- self->huf_out = 0;
- }
- }
- return DSK_ERR_OK;
-}
-
-
-/* Add a bit to the output bitstream */
-static void pushbit(SQ_COMPRESS_DATA *self, int bit)
-{
- int offs = self->huf_nbits / 8;
- unsigned char mask = st_masks[self->huf_nbits % 8];
-
- if (offs >= sizeof(self->huf_bits)) return;
-
- if (bit) self->huf_bits[offs] |= mask;
- else self->huf_bits[offs] &= ~mask;
- ++self->huf_nbits;
-}
-
-
-static dsk_err_t huf_encode(SQ_COMPRESS_DATA *self, int ch)
-{
- unsigned short nodepos;
- signed short child;
-
- if (ch < 0 || ch > SQ_EOF) return DSK_ERR_COMPRESS;
- /* Now find where this character ended up in the tree */
- nodepos = self->huf_leaves[ch];
- self->huf_nbits = 0;
-
- child = (-1 - ch);
-
- do
- {
- if (self->huf_node[nodepos].left == child) pushbit(self, 0);
- else if (self->huf_node[nodepos].right == child) pushbit(self, 1);
- else return DSK_ERR_COMPRESS;
-
- child = nodepos;
- nodepos = self->huf_node[nodepos].parent;
- }
- while (nodepos < MAXNODE);
- /* self->huf_bits holds the output bitstream (in reverse order).
- * Now write it out to disc */
- return flipbits(self);
-}
-
-
-
-static dsk_err_t compress(SQ_COMPRESS_DATA *self)
-{
- char *s = self->sq_truename;
- dsk_err_t e;
- unsigned short dictbase;
- unsigned short dictlen;
- unsigned short dn;
-
- e = writes(self, MAGIC); if (e) return e; /* Magic */
- e = writes(self, self->ck_sum);
- if (e) return e; /* Source file checksum */
- do /* Filename */
- {
- e = writec(self, *s); if (e) return e;
- } while ( *(s++) );
-
- dictbase = self->huf_curnode + 1;
- /* Dictionary length = MAXNODE - dictbase */
- dictlen = MAXNODE - dictbase;
- e = writes(self, dictlen); if (e) return e;
- for (dn = dictbase; dn < MAXNODE; dn++)
- {
- short l = self->huf_node[dn].left;
- short r = self->huf_node[dn].right;
-
- if (l >= 0) l -= dictbase;
- if (r >= 0) r -= dictbase;
-
- e = writes(self, l);
- e = writes(self, r);
- }
- /* Dictionary written. Start spitting bytes. */
- self->huf_nout = 0;
- self->huf_out = 0;
- rle_reset(self);
- e = rle_stream(self, huf_encode); if (e) return e;
-
- /* Write any pending bits */
- if (self->huf_nout)
- {
- if (fputc(self->huf_out, self->fp_out) == EOF)
- return DSK_ERR_SYSERR;
- }
- fseek(self->fp_out, 2, SEEK_SET);
-
- return DSK_ERR_OK;
-}
-
-/* DEBUG CODE ONLY
-static dsk_err_t putter(SQ_COMPRESS_DATA *self, int ch)
-{
- if (fputc(ch, self->fp_out) == EOF) return DSK_ERR_SYSERR;
- return DSK_ERR_OK;
-} */
-
-static dsk_err_t squeeze(SQ_COMPRESS_DATA *self)
-{
- dsk_err_t err;
-
- err = analyze(self);
- if (err) return err;
- err = compress(self);
-
- return DSK_ERR_OK;
-}
-
-
-static dsk_err_t readc(SQ_COMPRESS_DATA *self, unsigned char *c)
-{
- int i;
-
- i = fgetc(self->fp_in);
- if (i == EOF) return DSK_ERR_SYSERR;
- *c = i;
- return DSK_ERR_OK;
-}
-
-
-static dsk_err_t readu(SQ_COMPRESS_DATA *self, unsigned short *u)
-{
- unsigned char c1, c2;
- dsk_err_t err;
-
- err = readc(self, &c1); if (err) return err;
- err = readc(self, &c2); if (err) return err;
-
- *u = ((c2 << 8) | c1);
- return DSK_ERR_OK;
-}
-
-
-
-static dsk_err_t reads(SQ_COMPRESS_DATA *self, signed short *s)
-{
- unsigned char c1, c2;
- dsk_err_t err;
-
- err = readc(self, &c1); if (err) return err;
- err = readc(self, &c2); if (err) return err;
-
- *s = ((c2 << 8) | c1);
- return DSK_ERR_OK;
-}
-
-static dsk_err_t ckputc(SQ_COMPRESS_DATA *self, unsigned char b)
-{
- if (fputc(b, self->fp_out) == EOF) return DSK_ERR_SYSERR;
- self->ck_sum += b;
- return DSK_ERR_OK;
-}
-
-static dsk_err_t wrbyte(SQ_COMPRESS_DATA *self, unsigned char b)
-{
- int n;
- dsk_err_t e;
-
- if (self->rle_run == 1)
- {
- /* Last byte was 0x90. The one before that is self->rle_char */
- if (b == 0)
- {
- /* xx 90 00 becomes xx 90 */
- if (self->rle_char != -1)
- {
- e = ckputc(self, (unsigned char)(self->rle_char)); if (e) return e;
- }
- e = ckputc(self, RLECODE); if (e) return e;
- }
- else
- {
- if (self->rle_char == -1) return DSK_ERR_SYSERR;
- for (n = 0; n < b; n++)
- {
- e = ckputc(self, (unsigned char)(self->rle_char)); if (e) return e;
- }
- }
- self->rle_run = 0;
- self->rle_char = -1;
- return DSK_ERR_OK;
- }
-
- if (b == RLECODE)
- {
- /* Retain rle_char */
- self->rle_run = 1;
- return DSK_ERR_OK;
- }
- /* No special characters */
- if (self->rle_char != -1)
- {
- e = ckputc(self, (unsigned char)(self->rle_char)); if (e) return e;
- }
- self->rle_char = b;
-
- return DSK_ERR_OK;
-}
-
-
-
-static dsk_err_t unsqueeze(SQ_COMPRESS_DATA *self)
-{
- dsk_err_t err;
- unsigned short magic, checksum;
- unsigned char c;
- unsigned short dictlen;
- unsigned short nd;
- unsigned short node;
- signed short code;
-
- self->ck_sum = 0;
- err = readu(self, &magic);
- if (err) return err;
- if (magic != MAGIC) return DSK_ERR_COMPRESS;
- err = readu(self, &checksum);
- /* Filename (skip) */
- do
- {
- err = readc(self, &c);
- if (err) return err;
- } while (c);
- /* Dictionary length */
- err = readu(self, &dictlen);
- if (err) return err;
- if (dictlen > MAXNODE) return DSK_ERR_COMPRESS;
- /* Dictionary */
- for (nd = 0; nd < dictlen; nd++)
- {
- err = reads(self, &self->huf_node[nd].left);
- if (err) return err;
- err = reads(self, &self->huf_node[nd].right);
- if (err) return err;
- }
- /* Now start decoding data */
- self->huf_out = 0;
- self->huf_nout = 8;
- node = 0;
- rle_reset(self);
-/* if dictlen == 0, the file is empty */
- if (dictlen) while (1)
- {
- if (self->huf_nout == 8)
- {
- self->huf_nout = 0;
- err = readc(self, &self->huf_out);
- if (err) return err;
- }
- code = self->huf_out & st_masks[self->huf_nout];
- ++self->huf_nout;
- if (code) code = self->huf_node[node].right;
- else code = self->huf_node[node].left;
-
- if (code < 0)
- {
- if (-1 - code == SQ_EOF) break; /* Reached EOF */
- err = wrbyte(self, (unsigned char)(-1 - code));
- if (err) return err;
- node = 0;
- }
- else node = code;
- }
- if (self->rle_char != -1)
- {
- err = ckputc(self, (unsigned char)(self->rle_char)); if (err) return err;
-
- }
- if (checksum != self->ck_sum) return DSK_ERR_COMPRESS;
- return DSK_ERR_OK;
-}
-
-
-/* This struct contains function pointers to the driver's functions, and the
- * size of its DSK_DRIVER subclass */
-
-COMPRESS_CLASS cc_sq =
-{
- sizeof(SQ_COMPRESS_DATA),
- "sq",
- "Squeeze (Huffman coding)",
- sq_open, /* open */
- sq_creat, /* create new */
- sq_commit, /* commit */
- sq_abort /* abort */
-};
-
-
-
-dsk_err_t sq_open(COMPRESS_DATA *self)
-{
- SQ_COMPRESS_DATA *sq_self;
- dsk_err_t err;
- unsigned short magic;
-
-
- /* Sanity check: Is this meant for our driver? */
- if (self->cd_class != &cc_sq) return DSK_ERR_BADPTR;
- sq_self = (SQ_COMPRESS_DATA *)self;
- sq_self->sq_truename = NULL;
- sq_self->fp_in = NULL;
- sq_self->fp_out = NULL;
-
- /* Open the file to decompress */
- err = comp_fopen(self, &sq_self->fp_in);
- if (err) return DSK_ERR_NOTME;
-
- /* Check for SQ signature */
- err = readu(sq_self, &magic);
- if (err) return err;
-
- if (magic != MAGIC)
- {
- fclose(sq_self->fp_in);
- return DSK_ERR_NOTME;
- }
- /* OK. This is a Squeezed file. Decompress it. */
- rewind(sq_self->fp_in);
- err = comp_mktemp(self, &sq_self->fp_out);
-
- if (!err) err = unsqueeze(sq_self);
- fclose(sq_self->fp_in);
- if (sq_self->fp_out) fclose(sq_self->fp_out);
- if (err && sq_self->sq_truename) free(sq_self->sq_truename);
- return err;
-}
-
-
-dsk_err_t sq_commit(COMPRESS_DATA *self)
-{
- SQ_COMPRESS_DATA *sq_self;
- dsk_err_t err = DSK_ERR_OK;
-
- if (self->cd_class != &cc_sq) return DSK_ERR_BADPTR;
- sq_self = (SQ_COMPRESS_DATA *)self;
-
- sq_self->fp_in = NULL;
- sq_self->fp_out = NULL;
- if (self->cd_cfilename && self->cd_ufilename)
- {
- sq_self->fp_in = fopen(self->cd_ufilename, "rb");
- sq_self->fp_out = fopen(self->cd_cfilename, "wb");
- if (!sq_self->fp_in || !sq_self->fp_out) err = DSK_ERR_SYSERR;
- else err = squeeze(sq_self);
- }
- if (sq_self->fp_in) fclose(sq_self->fp_in);
- if (sq_self->fp_out) fclose(sq_self->fp_out);
- if (sq_self->sq_truename) free(sq_self->sq_truename);
- sq_self->sq_truename = NULL;
-
- return err;
-}
-
-
-/* abort: Free truename */
-dsk_err_t sq_abort(COMPRESS_DATA *self)
-{
- SQ_COMPRESS_DATA *sq_self;
- if (self->cd_class != &cc_sq) return DSK_ERR_BADPTR;
- sq_self = (SQ_COMPRESS_DATA *)self;
-
- if (sq_self->sq_truename) free(sq_self->sq_truename);
- sq_self->sq_truename = NULL;
- return DSK_ERR_OK;
-}
-
-/* Create: Set up truename */
-dsk_err_t sq_creat(COMPRESS_DATA *self)
-{
- char *ss;
- SQ_COMPRESS_DATA *sq_self;
- if (self->cd_class != &cc_sq) return DSK_ERR_BADPTR;
- sq_self = (SQ_COMPRESS_DATA *)self;
-
- if (sq_self->sq_truename) free(sq_self->sq_truename);
- sq_self->sq_truename = NULL;
-
-/* Try to guess the true name of the file from the compressed name. This
- * can only be done for certain well-known name manglings. */
- sq_self->sq_truename = malloc(1 + strlen(self->cd_cfilename));
- if (!sq_self->sq_truename) return DSK_ERR_NOMEM;
-
- /* UNIX SQ squeezes files by appending ".SQ" */
- strcpy(sq_self->sq_truename, self->cd_cfilename);
- ss = strstr(sq_self->sq_truename, ".SQ");
- if (ss) *ss = 0;
-
- /* Convert .DQK back to .DSK */
- ss = strstr(sq_self->sq_truename, ".DQK");
- if (ss) memcpy(ss, ".DSK", 4);
-
- /* Convert .DQK back to .DSK */
- ss = strstr(sq_self->sq_truename, ".dqk");
- if (ss) memcpy(ss, ".dsk", 4);
-
- return DSK_ERR_OK;
-}
-
-
-
+/***************************************************************************
+ * *
+ * LIBDSK: General floppy and diskimage access library *
+ * Copyright (C) 2002 John Elliott <jc...@se...> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This library 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 *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the Free *
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, *
+ * MA 02111-1307, USA *
+ * *
+ ***************************************************************************/
+
+/* Squeeze (Huffman) compression/decompression. This is entirely new code,
+ * created by John Elliott to avoid possible licensing problems with the
+ * Richard Greenlaw/Theo Pozzy code used in earlier releases.
+ *
+ * In brief: Richard Greenlaw's original code had no licence with it at all.
+ * However, a file dated 1983 on the CP/M CDROM suggests that he
+ * intended it as not-for-profit rather than true PD.
+ *
+ * Theo Pozzy's UNIX port of SQ (1985) implies that the code he used
+ * is truly PD. But his belief that SQ was public domain may not
+ * be correct in the light of the 1983 letter above.
+ *
+ * My thanks to Russell Marks for pointing this out.
+ *
+ * Note that my code is less sophisticated than Richard Greenlaw's original.
+ * It doesn't, for example, try to deal with pathologically unbalanced
+ * encoding trees (where a source byte encodes to more than 16 bits).
+ *
+ */
+
+#include "compi.h"
+#include "compsq.h"
+
+
+/******************************* compsq.c **********************************/
+typedef dsk_err_t (*RLEFUNC)(SQ_COMPRESS_DATA *self, int ch);
+
+
+
+/************************ RLE COMPRESSION FUNCTIONS ************************/
+static void rle_reset(SQ_COMPRESS_DATA *self)
+{
+ self->rle_char = -1;
+ self->rle_run = 0;
+}
+
+
+
+
+static dsk_err_t rle_flush(SQ_COMPRESS_DATA *self, RLEFUNC writer)
+{
+ dsk_err_t err = DSK_ERR_OK;
+/* We encode sequences of >3 bytes using RLE. However, the RLE trigger byte
+ * itself (0x90) is encoded as 2 bytes, and we can't encode sequences of it; it
+ * would encode to (eg) 20 90 90 xx, and then decompress as (20 90 90) xx
+ * when it was compressed as 20 (90 90 xx).
+ */
+ if ( self->rle_run > 3 && self->rle_char != RLECODE)
+ {
+ err = (*writer)(self, self->rle_char);
+ if (!err) err = (*writer)(self, RLECODE);
+ if (!err) err = (*writer)(self, self->rle_run);
+ }
+ else while (self->rle_run)
+ {
+ if (!err) err = (*writer)(self, self->rle_char);
+ if (self->rle_char == RLECODE && !err) err = (*writer)(self, 0x00);
+ --self->rle_run;
+ }
+ self->rle_run = 0;
+ return err;
+}
+
+
+
+/* Generate an RLE stream from a file */
+static dsk_err_t rle_stream(SQ_COMPRESS_DATA *self, RLEFUNC writer)
+{
+ int c;
+ dsk_err_t err;
+
+ while ( (c = fgetc(self->fp_in)) != EOF )
+ {
+ self->ck_sum += (unsigned char)c;
+/* If this character is the same as the last, increase the count. */
+ if (c == self->rle_char)
+ {
+ ++self->rle_run;
+ if (self->rle_run == 0xFF) /* Max length of run */
+ { /* flush & start again */
+ err = rle_flush(self, writer);
+ if (err) return err;
+ self->rle_char = -1;
+ self->rle_run = 0;
+ }
+ }
+ else
+ {
+/* If not, write out what we've got and start again. */
+ err = rle_flush(self, writer);
+ if (err) return err;
+ self->rle_char = c;
+ self->rle_run = 1;
+ }
+ }
+ if (ferror(self->fp_in)) return DSK_ERR_SYSERR;
+/* Write out what we've got; then EOF. */
+ err = rle_flush(self, writer);
+ if (err) return err;
+ self->rle_char = SQ_EOF;
+ self->rle_run = 1;
+ err = rle_flush(self, writer);
+ if (err) return err;
+ rewind(self->fp_in);
+ return DSK_ERR_OK;
+}
+
+
+/*
+static dsk_err_t rle_print(SQ_COMPRESS_DATA *self, int ch)
+{
+ if (ch == '\r' || ch == '\n' || (ch > 0x1F && ch < 0x7F))
+ fputc(ch, self->fp_out);
+ else fprintf(self->fp_out, "<%02x>", ch);
+ return DSK_ERR_OK;
+} */
+/******************* RLE COMPRESSION FUNCTIONS: END ************************/
+
+static dsk_err_t huf_counter(SQ_COMPRESS_DATA *self, int ch)
+{
+ if (ch >= 0 && ch <= SQ_EOF) ++self->huf_count[ch + MAXNODE];
+ else return DSK_ERR_COMPRESS;
+
+ return DSK_ERR_OK;
+}
+
+/* Find the index of the smallest nonzero character count in huf_count.
+ */
+static int huf_smallest(SQ_COMPRESS_DATA *self, int skip)
+{
+ unsigned long mv = ~0UL;
+ int n, mi = -1;
+
+ for (n = 0; n < MAXLEAF + MAXNODE; n++)
+ {
+ if (n == skip) continue;
+ if (self->huf_count[n] < mv && self->huf_count[n] > 0)
+ {
+ mv = self->huf_count[n];
+ mi = n;
+ }
+ }
+ return mi;
+}
+
+
+/* Add a node. */
+static void huf_addnode(SQ_COMPRESS_DATA *self, int n1, int n2)
+{
+ short e_n1, e_n2;
+
+ //printf("%04X:%04X\r\n", n1, n2);
+
+ if (n1 < MAXNODE) e_n1 = n1; else e_n1 = MAXNODE - 1 - n1;
+ if (n2 < MAXNODE) e_n2 = n2; else e_n2 = MAXNODE - 1 - n2;
+
+ /* If parent not set, parent is MAXNODE */
+ self->huf_node[self->huf_curnode].parent = MAXNODE;
+ self->huf_node[self->huf_curnode].left = e_n1;
+ self->huf_node[self->huf_curnode].right = e_n2;
+
+/* If nodes hold leaves, record them. If they hold other nodes, set parents. */
+ if (n1 >= MAXNODE) self->huf_leaves[n1 - MAXNODE] = self->huf_curnode;
+ else self->huf_node[n1].parent = self->huf_curnode;
+ if (n2 >= MAXNODE) self->huf_leaves[n2 - MAXNODE] = self->huf_curnode;
+ else self->huf_node[n2].parent = self->huf_curnode;
+
+}
+
+
+
+/* Generate the Huffman dictionary for a file */
+static dsk_err_t analyze(SQ_COMPRESS_DATA *self)...
[truncated message content] |
|
From: <fr...@us...> - 2007-08-06 00:43:58
|
Revision: 442
http://fuse-for-macosx.svn.sourceforge.net/fuse-for-macosx/?rev=442&view=rev
Author: fredm
Date: 2007-08-05 17:43:48 -0700 (Sun, 05 Aug 2007)
Log Message:
-----------
Load . into vendor/libdsk/current.
Modified Paths:
--------------
vendor/libdsk/current/ChangeLog
vendor/libdsk/current/configure
vendor/libdsk/current/configure.in
vendor/libdsk/current/doc/libdsk.lyx
vendor/libdsk/current/doc/libdsk.pdf
vendor/libdsk/current/doc/libdsk.txt
vendor/libdsk/current/dos16ppd/Makefile
vendor/libdsk/current/dos32gcc/Makefile
vendor/libdsk/current/include/libdsk.h
vendor/libdsk/current/lib/Makefile.am
vendor/libdsk/current/lib/Makefile.in
vendor/libdsk/current/lib/drivers.h
vendor/libdsk/current/lib/drivers.inc
vendor/libdsk/current/lib/dsksgeom.c
vendor/libdsk/current/man/apriboot.1
vendor/libdsk/current/man/dskdump.1
vendor/libdsk/current/man/dskform.1
vendor/libdsk/current/man/dskid.1
vendor/libdsk/current/man/dskscan.1
vendor/libdsk/current/man/dsktrans.1
vendor/libdsk/current/man/dskutil.1
vendor/libdsk/current/man/md3serial.1
vendor/libdsk/current/tools/dsktrans.c
vendor/libdsk/current/win16bc5/libdsk.ide
vendor/libdsk/current/win16vc1/LIBDSK16.MAK
vendor/libdsk/current/win32bc5/libdsk.ide
vendor/libdsk/current/win32vc6/atlibdsk.dsp
vendor/libdsk/current/win32vc6/atlibdsk.h
vendor/libdsk/current/win32vc6/atlibdsk_i.c
vendor/libdsk/current/win32vc6/atlibdsk_p.c
vendor/libdsk/current/win32vc6/libdsk.dsp
Added Paths:
-----------
vendor/libdsk/current/lib/drvlogi.c
vendor/libdsk/current/lib/drvlogi.h
vendor/libdsk/current/lib/drvtele.c
vendor/libdsk/current/lib/drvtele.h
Property Changed:
----------------
vendor/libdsk/current/win32vc6/atlibdsk.dsp
vendor/libdsk/current/win32vc6/libdsk.dsp
Modified: vendor/libdsk/current/ChangeLog
===================================================================
--- vendor/libdsk/current/ChangeLog 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/ChangeLog 2007-08-06 00:43:48 UTC (rev 442)
@@ -1,6 +1,37 @@
+2007-07-27 John Elliott
+
+ * libdsk-1.1.14 released.
+
+2007-06-11 Stuart Brady
+
+ * Added a new geometry (FMT_TRDOS640).
+
+2007-06-10 John Elliott
+
+ * Updated the DOS and Windows projects with the new drivers
+ (the Teledisk one didn't compile under Win16).
+
+2007-06-09 John Elliott
+
+ * libdsk-1.1.13 released.
+
+ * New driver: Logical. This is a raw disc image as generated by
+ 'dsktrans -logical'; that is, it is arranged in logical sector order
+ rather than SIDES_ALT order. Useful for dealing with raw disc images
+ that were dumped in logical order.
+ * dsktrans: The -logical option has accordingly been deprecated,
+ since '-otype logical' should have the same effect.
+
+2007-06-02 John Elliott
+
+ * New driver: Teledisk, based on the file format documentation at
+ <http://www.fpns.net/willy/wteledsk.htm>. This driver is read-only.
+ No code from WTELEDSK has been used, because it's GPLed rather than
+ LGPLed.
+
2006-11-18 John Elliott
- * libdsk-1.1.11 released.
+ * libdsk-1.1.12 released.
2006-08-02 John Elliott
Modified: vendor/libdsk/current/configure
===================================================================
--- vendor/libdsk/current/configure 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/configure 2007-08-06 00:43:48 UTC (rev 442)
@@ -814,8 +814,8 @@
NONENONEs,x,x, &&
program_prefix=${target_alias}-
-VERSION=1.1.12
-UPDATED='November 18, 2006'
+VERSION=1.1.14
+UPDATED='July 27, 2007'
am__api_version="1.4"
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
Modified: vendor/libdsk/current/configure.in
===================================================================
--- vendor/libdsk/current/configure.in 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/configure.in 2007-08-06 00:43:48 UTC (rev 442)
@@ -2,8 +2,8 @@
AC_INIT(lib/dskopen.c)
AC_CONFIG_AUX_DIR(config)
AC_CANONICAL_SYSTEM
-VERSION=1.1.12
-UPDATED='November 18, 2006'
+VERSION=1.1.14
+UPDATED='July 27, 2007'
AM_INIT_AUTOMAKE(libdsk, $VERSION)
AM_CONFIG_HEADER(config.h)
Modified: vendor/libdsk/current/doc/libdsk.lyx
===================================================================
--- vendor/libdsk/current/doc/libdsk.lyx 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/doc/libdsk.lyx 2007-08-06 00:43:48 UTC (rev 442)
@@ -26,7 +26,7 @@
\layout Title
-LibDsk v1.1.12
+LibDsk v1.1.14
\layout Author
John Elliott
@@ -83,9 +83,12 @@
\begin_inset Quotes erd
\end_inset
- images;
+ images;
\layout Itemize
+Raw images in logical filesystem order;
+\layout Itemize
+
CPCEMU-format .DSK images (normal and extended);
\layout Itemize
@@ -103,6 +106,10 @@
NanoWasp-format disc images, used by the eponymous emulator.
\layout Itemize
+Disc images created by the Sydex imaging programs Teledisk and CopyQM (read
+ only in both cases).
+\layout Itemize
+
The floppy drive under Linux;
\layout Itemize
@@ -136,6 +143,25 @@
For full details, see the file ChangeLog.
\layout Itemize
+Added two new drivers:
+\begin_inset Quotes eld
+\end_inset
+
+teledisk
+\begin_inset Quotes erd
+\end_inset
+
+ and
+\begin_inset Quotes eld
+\end_inset
+
+logical
+\begin_inset Quotes erd
+\end_inset
+
+.
+\layout Itemize
+
Changes by Ramlaid <www.ramlaid.com> to the DSK and NTWDM drivers to improve
compatibility, and another fix to stop file handles leaking.
\layout Itemize
@@ -322,6 +348,23 @@
\begin_inset Quotes eld
\end_inset
+logical
+\begin_inset Quotes erd
+\end_inset
+
+ : Raw disc image in logical filesystem order.
+ Previous versions of LibDsk could generate such images (for example, by
+ using the now-deprecated
+\family typewriter
+ -logical
+\family default
+ option to dsktrans) but couldn't then write them back or use them in emulators.
+\layout Description
+
+
+\begin_inset Quotes eld
+\end_inset
+
floppy
\begin_inset Quotes erd
\end_inset
@@ -406,6 +449,18 @@
\begin_inset Quotes eld
\end_inset
+teledisk
+\begin_inset Quotes erd
+\end_inset
+
+ : Disc images created by Sydex's TeleDisk.
+ This is a read-only driver.
+\layout Description
+
+
+\begin_inset Quotes eld
+\end_inset
+
nanowasp
\begin_inset Quotes erd
\end_inset
@@ -2788,7 +2843,7 @@
Used to set callbacks from LibDsk to your own code, for LibDsk to display
messages during processing that may take time.
- The code should be used to set the text on the status line of your program
+ The code could be used to set the text on the status line of your program
window, for example.
\layout LyX-Code
@@ -6372,7 +6427,7 @@
\layout Itemize
-pDriver contains the pointer to our instance data.
+pDriver points to a DSK_DRIVER containing the pointer to your instance data.
\layout Itemize
name is the filename as passed to LibDsk, starting with
Modified: vendor/libdsk/current/doc/libdsk.pdf
===================================================================
(Binary files differ)
Modified: vendor/libdsk/current/doc/libdsk.txt
===================================================================
--- vendor/libdsk/current/doc/libdsk.txt 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/doc/libdsk.txt 2007-08-06 00:43:48 UTC (rev 442)
@@ -1,4 +1,4 @@
-LibDsk v1.1.12
+LibDsk v1.1.14
John Elliott
@@ -163,8 +163,10 @@
disc images transparently. It currently supports the
following disc image formats:
- Raw "dd if=foo of=bar" images;
+ Raw "dd if=foo of=bar" images;
+ Raw images in logical filesystem order;
+
CPCEMU-format .DSK images (normal and extended);
MYZ80-format hard drive images;
@@ -178,6 +180,9 @@
NanoWasp-format disc images, used by the eponymous emulator.
+ Disc images created by the Sydex imaging programs
+ Teledisk and CopyQM (read only in both cases).
+
The floppy drive under Linux;
The floppy drive under Windows. Windows support is a
@@ -198,6 +203,8 @@
For full details, see the file ChangeLog.
+ Added two new drivers: "teledisk" and "logical".
+
Changes by Ramlaid <www.ramlaid.com> to the DSK and
NTWDM drivers to improve compatibility, and another
fix to stop file handles leaking.
@@ -283,6 +290,12 @@
. On systems other than Linux, DOS or Windows, this
is also used to access the host system's floppy drive.
+ "logical" : Raw disc image in logical filesystem order.
+ Previous versions of LibDsk could generate such
+ images (for example, by using the now-deprecated
+ -logical option to dsktrans) but couldn't then write
+ them back or use them in emulators.
+
"floppy" : Host system's floppy drive (under Linux, DOS
or Windows).
@@ -301,6 +314,9 @@
"qm" : Disc images created by Sydex's CopyQM. This is a
read-only driver.
+ "teledisk" : Disc images created by Sydex's TeleDisk.
+ This is a read-only driver.
+
"nanowasp" : Disc image in the 400k Microbee format
used by the NanoWasp emulator. This is similar to "raw"
, but the tracks are stored in a different order.
@@ -1188,7 +1204,7 @@
Used to set callbacks from LibDsk to your own code, for
LibDsk to display messages during processing that may
-take time. The code should be used to set the text on
+take time. The code could be used to set the text on
the status line of your program window, for example.
typedef void (*DSK_REPORTFUNC)(const char *message);
@@ -2707,7 +2723,8 @@
Connect to a remote server.
- pDriver contains the pointer to our instance data.
+ pDriver points to a DSK_DRIVER containing the pointer
+ to your instance data.
name is the filename as passed to LibDsk, starting
with "driver:" and containing any connection parameters
Modified: vendor/libdsk/current/dos16ppd/Makefile
===================================================================
--- vendor/libdsk/current/dos16ppd/Makefile 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/dos16ppd/Makefile 2007-08-06 00:43:48 UTC (rev 442)
@@ -9,7 +9,8 @@
OBS7=drvcpcem.obj dskcheck.obj dskpars.obj dskwrite.obj dskcmt.obj
OBS8=drvadisk.obj drvrcpm.obj drvqm.obj crctable.obj dskretry.obj
OBS9=dskreprt.obj dskdirty.obj dskrtrd.obj dsktrkid.obj remote.obj
-OBSA=rpcfossl.obj crc16.obj drvint25.obj int25l.obj
+OBSA=rpcfossl.obj crc16.obj drvint25.obj int25l.obj drvtele.obj
+OBSB=drvlogi.obj
OBS10=dskid.obj utilopts.obj libdsk.lib
OBS11=dskform.obj utilopts.obj formname.obj libdsk.lib
OBS12=dsktrans.obj utilopts.obj formname.obj bootsec.obj libdsk.lib
@@ -47,7 +48,7 @@
$(CC) $(CFLAGS) $(OBS13)
libdsk.lib: $(OBS1) $(OBS2) $(OBS3) $(OBS4) $(OBS5) $(OBS6) $(OBS7) \
- $(OBS8) $(OBS9) $(OBSA)
+ $(OBS8) $(OBS9) $(OBSA) $(OBSB)
libr r $@ $(OBS1)
libr r $@ $(OBS2)
libr r $@ $(OBS3)
@@ -58,6 +59,7 @@
libr r $@ $(OBS8)
libr r $@ $(OBS9)
libr r $@ $(OBSA)
+ libr r $@ $(OBSB)
%.obj: %.as
$(CC) -c $(CFLAGS) $<
Modified: vendor/libdsk/current/dos32gcc/Makefile
===================================================================
--- vendor/libdsk/current/dos32gcc/Makefile 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/dos32gcc/Makefile 2007-08-06 00:43:48 UTC (rev 442)
@@ -10,7 +10,8 @@
drvcpcem.o dskcheck.o dskpars.o dskwrite.o dskretry.o \
drvadisk.o drvrcpm.o drvqm.o dskretry.o dskcmt.o \
dskreprt.o crctable.o dskdirty.o dskrtrd.o dsktrkid.o \
- remote.o rpcfossl.o crc16.o drvint25.o
+ remote.o rpcfossl.o crc16.o drvint25.o drvtele.o \
+ drvlogi.o
OBS1 = dskid.o utilopts.o libdsk.a
OBS2 = dskform.o utilopts.o formname.o libdsk.a
Modified: vendor/libdsk/current/include/libdsk.h
===================================================================
--- vendor/libdsk/current/include/libdsk.h 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/include/libdsk.h 2007-08-06 00:43:48 UTC (rev 442)
@@ -1,7 +1,7 @@
/***************************************************************************
* *
* LIBDSK: General floppy and diskimage access library *
- * Copyright (C) 2001-6 John Elliott <jc...@se...> *
+ * Copyright (C) 2001-7 John Elliott <jc...@se...> *
* *
* Modifications to add dsk_dirty() *
* (c) 2005 Philip Kendall <pak...@sr...> *
@@ -58,7 +58,7 @@
extern "C" {
#endif
-#define LIBDSK_VERSION "1.1.12"
+#define LIBDSK_VERSION "1.1.14"
/************************* TYPES ********************************/
@@ -148,6 +148,7 @@
FMT_BBC200, /* 10 sectors, 80 tracks, 1 side, FM */
FMT_MBEE400, /* 10 sectors, 80 tracks, 1 side */
FMT_MGT800, /* 10 sectors, 80 tracks, 2 sides out and out */
+ FMT_TRDOS640, /* 16 sectors, 256 bytes/sector, 2 sides */
FMT_UNKNOWN = -1
} dsk_format_t;
Modified: vendor/libdsk/current/lib/Makefile.am
===================================================================
--- vendor/libdsk/current/lib/Makefile.am 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/lib/Makefile.am 2007-08-06 00:43:48 UTC (rev 442)
@@ -29,7 +29,7 @@
# If interfaces have been removed set the right-hand number to 0.
#
#
-libdsk_la_LDFLAGS = -version-info 5:1:2
+libdsk_la_LDFLAGS = -version-info 5:3:2
libdsk_la_SOURCES = dskread.c dskwrite.c dskcheck.c dskstat.c \
dsklphys.c dskfmt.c dskopen.c dskpars.c \
dskerror.c dskseek.c dsksecid.c dskgeom.c \
@@ -57,10 +57,12 @@
drvdos16.h drvdos16.c \
drvdos32.h drvdos32.c \
drvcpcem.h drvcpcem.c \
+ drvlogi.h drvlogi.c \
drvposix.h drvposix.c \
drvnwasp.h drvnwasp.c \
drvadisk.h drvadisk.c \
drvrcpm.h drvrcpm.c \
+ drvtele.h drvtele.c \
drvmyz80.h drvmyz80.c \
drvcfi.h drvcfi.c \
drvqm.h drvqm.c
Modified: vendor/libdsk/current/lib/Makefile.in
===================================================================
--- vendor/libdsk/current/lib/Makefile.in 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/lib/Makefile.in 2007-08-06 00:43:48 UTC (rev 442)
@@ -114,8 +114,8 @@
# If interfaces have been removed set the right-hand number to 0.
#
#
-libdsk_la_LDFLAGS = -version-info 5:1:2
-libdsk_la_SOURCES = dskread.c dskwrite.c dskcheck.c dskstat.c dsklphys.c dskfmt.c dskopen.c dskpars.c dskerror.c dskseek.c dsksecid.c dskgeom.c dsktread.c dsksgeom.c dskjni.c dskreprt.c dskcmt.c dskretry.c dskdirty.c dsktrkid.c dskrtrd.c comp.h compi.h compress.h compress.inc compress.c compsq.c compsq.h compgz.c compgz.h compbz2.c compbz2.h crctable.c crctable.h crc16.c crc16.h rpccli.c rpcfuncs.h rpcmap.c rpcpack.c rpcserv.c remote.c remote.h remote.inc remall.h rpctios.c rpctios.h rpcfork.c rpcfork.h rpcfossl.c rpcfossl.h rpcwin32.c rpcwin32.h drv.h drvi.h drivers.h drivers.inc drvlinux.h drvlinux.c drvntwdm.h drvntwdm.c drvwin32.h drvwin32.c w95defs.h drvwin16.h drvwin16.c w16defs.h drvint25.h drvint25.c drvdos16.h drvdos16.c drvdos32.h drvdos32.c drvcpcem.h drvcpcem.c drvposix.h drvposix.c drvnwasp.h drvnwasp.c drvadisk.h drvadisk.c drvrcpm.h drvrcpm.c drvmyz80.h drvmyz80.c drvcfi.h drvcfi.c drvqm.h drvqm.c
+libdsk_la_LDFLAGS = -version-info 5:3:2
+libdsk_la_SOURCES = dskread.c dskwrite.c dskcheck.c dskstat.c dsklphys.c dskfmt.c dskopen.c dskpars.c dskerror.c dskseek.c dsksecid.c dskgeom.c dsktread.c dsksgeom.c dskjni.c dskreprt.c dskcmt.c dskretry.c dskdirty.c dsktrkid.c dskrtrd.c comp.h compi.h compress.h compress.inc compress.c compsq.c compsq.h compgz.c compgz.h compbz2.c compbz2.h crctable.c crctable.h crc16.c crc16.h rpccli.c rpcfuncs.h rpcmap.c rpcpack.c rpcserv.c remote.c remote.h remote.inc remall.h rpctios.c rpctios.h rpcfork.c rpcfork.h rpcfossl.c rpcfossl.h rpcwin32.c rpcwin32.h drv.h drvi.h drivers.h drivers.inc drvlinux.h drvlinux.c drvntwdm.h drvntwdm.c drvwin32.h drvwin32.c w95defs.h drvwin16.h drvwin16.c w16defs.h drvint25.h drvint25.c drvdos16.h drvdos16.c drvdos32.h drvdos32.c drvcpcem.h drvcpcem.c drvlogi.h drvlogi.c drvposix.h drvposix.c drvnwasp.h drvnwasp.c drvadisk.h drvadisk.c drvrcpm.h drvrcpm.c drvtele.h drvtele.c drvmyz80.h drvmyz80.c drvcfi.h drvcfi.c drvqm.h drvqm.c
JARCLASSES = $(CLASSDPRE)/Drive.class $(CLASSDPRE)/DskException.class $(CLASSDPRE)/FormatData.class $(CLASSDPRE)/FormatType.class $(CLASSDPRE)/Geometry.class $(CLASSDPRE)/Reporter.class $(CLASSDPRE)/LibDsk.class
@@ -141,8 +141,8 @@
compsq.lo compgz.lo compbz2.lo crctable.lo crc16.lo rpccli.lo rpcmap.lo \
rpcpack.lo rpcserv.lo remote.lo rpctios.lo rpcfork.lo rpcfossl.lo \
rpcwin32.lo drvlinux.lo drvntwdm.lo drvwin32.lo drvwin16.lo drvint25.lo \
-drvdos16.lo drvdos32.lo drvcpcem.lo drvposix.lo drvnwasp.lo drvadisk.lo \
-drvrcpm.lo drvmyz80.lo drvcfi.lo drvqm.lo
+drvdos16.lo drvdos32.lo drvcpcem.lo drvlogi.lo drvposix.lo drvnwasp.lo \
+drvadisk.lo drvrcpm.lo drvtele.lo drvmyz80.lo drvcfi.lo drvqm.lo
noinst_PROGRAMS = @LIBDSKJAR@
PROGRAMS = $(noinst_PROGRAMS)
@@ -325,6 +325,8 @@
../include/libdsk.h drv.h drvint25.h
drvlinux.lo drvlinux.o : drvlinux.c drvi.h ../config.h \
../include/libdsk.h drv.h drvlinux.h
+drvlogi.lo drvlogi.o : drvlogi.c ../include/libdsk.h drvi.h ../config.h \
+ drv.h drvlogi.h
drvmyz80.lo drvmyz80.o : drvmyz80.c ../include/libdsk.h drvi.h \
../config.h drv.h drvmyz80.h
drvntwdm.lo drvntwdm.o : drvntwdm.c drvi.h ../config.h \
@@ -337,6 +339,8 @@
drvqm.h crctable.h
drvrcpm.lo drvrcpm.o : drvrcpm.c ../include/libdsk.h drvi.h ../config.h \
drv.h drvrcpm.h
+drvtele.lo drvtele.o : drvtele.c drvi.h ../config.h ../include/libdsk.h \
+ drv.h drvtele.h
drvwin16.lo drvwin16.o : drvwin16.c drvi.h ../config.h \
../include/libdsk.h drv.h drvwin16.h
drvwin32.lo drvwin32.o : drvwin32.c drvi.h ../config.h \
Modified: vendor/libdsk/current/lib/drivers.h
===================================================================
--- vendor/libdsk/current/lib/drivers.h 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/lib/drivers.h 2007-08-06 00:43:48 UTC (rev 442)
@@ -32,6 +32,8 @@
extern DRV_CLASS dc_cfi; /* CFI driver */
extern DRV_CLASS dc_adisk; /* APRIDISK driver */
extern DRV_CLASS dc_qm; /* CopyQM driver */
+extern DRV_CLASS dc_tele; /* Teledisk driver */
+extern DRV_CLASS dc_logical; /* Raw, in logical sector order */
extern DRV_CLASS dc_rcpmfs; /* Reverse-CP/MFS driver */
extern DRV_CLASS dc_remote; /* All remote drivers */
#ifdef LINUXFLOPPY
Modified: vendor/libdsk/current/lib/drivers.inc
===================================================================
--- vendor/libdsk/current/lib/drivers.inc 2007-08-03 10:15:21 UTC (rev 441)
+++ vendor/libdsk/current/lib/drivers.inc 2007-08-06 00:43:48 UTC (rev 442)
@@ -61,6 +61,7 @@
* library. */
&dc_adisk, /* APRIDISK image */
&dc_qm, /* CopyQM */
+ &dc_tele, /* Teledisk */
/* 4. Raw files with no magic number. */
&dc_posix,
@@ -69,6 +70,7 @@
* explicitly specified. */
&dc_myz80,
&dc_nwasp,
+ &dc_logical,
&dc_cfi, /* RLE-compressed raw. The reasons that this isn't
* handled by the general compression system are:
* 1. No magic number, so can't autodetect.
Added: vendor/libdsk/current/lib/drvlogi.c
===================================================================
--- vendor/libdsk/current/lib/drvlogi.c (rev 0)
+++ vendor/libdsk/current/lib/drvlogi.c 2007-08-06 00:43:48 UTC (rev 442)
@@ -0,0 +1,262 @@
+/***************************************************************************
+ * *
+ * LIBDSK: General floppy and diskimage access library *
+ * Copyright (C) 2001,2007 John Elliott <jc...@se...> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This library 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 *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the Free *
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, *
+ * MA 02111-1307, USA *
+ * *
+ ***************************************************************************/
+
+/* This driver implements access to a flat file, like drvposix, but with the
+ * sides laid out in the order specified by the disk geometry. What you end
+ * up with is a logical filesystem image, hence the name. */
+
+#include <stdio.h>
+#include "libdsk.h"
+#include "drvi.h"
+#include "drvlogi.h"
+
+
+/* This struct contains function pointers to the driver's functions, and the
+ * size of its DSK_DRIVER subclass */
+
+DRV_CLASS dc_logical =
+{
+ sizeof(LOGICAL_DSK_DRIVER),
+ "logical",
+ "Raw file logical sector order",
+ logical_open, /* open */
+ logical_creat, /* create new */
+ logical_close, /* close */
+ logical_read, /* read sector, working from physical address */
+ logical_write, /* write sector, working from physical address */
+ logical_format, /* format track, physical */
+ NULL, /* get geometry */
+ NULL, /* sector ID */
+ logical_xseek, /* seek to track */
+ logical_status, /* drive status */
+};
+
+dsk_err_t logical_open(DSK_DRIVER *self, const char *filename)
+{
+ LOGICAL_DSK_DRIVER *lpxself;
+
+ /* Sanity check: Is this meant for our driver? */
+ if (self->dr_class != &dc_logical) return DSK_ERR_BADPTR;
+ lpxself = (LOGICAL_DSK_DRIVER *)self;
+
+ lpxself->lpx_fp = fopen(filename, "r+b");
+ if (!lpxself->lpx_fp)
+ {
+ lpxself->lpx_readonly = 1;
+ lpxself->lpx_fp = fopen(filename, "rb");
+ }
+ if (!lpxself->lpx_fp) return DSK_ERR_NOTME;
+/* v0.9.5: Record exact size, so we can tell if we're writing off the end
+ * of the file. Under Windows, writing off the end of the file fills the
+ * gaps with random data, which can cause mess to appear in the directory;
+ * and under UNIX, the entire directory is filled with zeroes. */
+ if (fseek(lpxself->lpx_fp, 0, SEEK_END)) return DSK_ERR_SYSERR;
+ lpxself->lpx_filesize = ftell(lpxself->lpx_fp);
+
+ return DSK_ERR_OK;
+}
+
+
+dsk_err_t logical_creat(DSK_DRIVER *self, const char *filename)
+{
+ LOGICAL_DSK_DRIVER *lpxself;
+
+ /* Sanity check: Is this meant for our driver? */
+ if (self->dr_class != &dc_logical) return DSK_ERR_BADPTR;
+ lpxself = (LOGICAL_DSK_DRIVER *)self;
+
+ lpxself->lpx_fp = fopen(filename, "w+b");
+ lpxself->lpx_readonly = 0;
+ if (!lpxself->lpx_fp) return DSK_ERR_SYSERR;
+ lpxself->lpx_filesize = 0;
+ return DSK_ERR_OK;
+}
+
+
+dsk_err_t logical_close(DSK_DRIVER *self)
+{
+ LOGICAL_DSK_DRIVER *lpxself;
+
+ if (self->dr_class != &dc_logical) return DSK_ERR_BADPTR;
+ lpxself = (LOGICAL_DSK_DRIVER *)self;
+
+ if (lpxself->lpx_fp)
+ {
+ if (fclose(lpxself->lpx_fp) == EOF) return DSK_ERR_SYSERR;
+ lpxself->lpx_fp = NULL;
+ }
+ return DSK_ERR_OK;
+}
+
+
+dsk_err_t logical_read(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
+ void *buf, dsk_pcyl_t cylinder,
+ dsk_phead_t head, dsk_psect_t sector)
+{
+ LOGICAL_DSK_DRIVER *lpxself;
+ dsk_lsect_t offset;
+ dsk_err_t err;
+
+ if (!buf || !self || !geom || self->dr_class != &dc_logical) return DSK_ERR_BADPTR;
+ lpxself = (LOGICAL_DSK_DRIVER *)self;
+
+ if (!lpxself->lpx_fp) return DSK_ERR_NOTRDY;
+
+ err = dg_ps2ls(geom, cylinder, head, sector, &offset);
+ if (err) return err;
+ offset *= geom->dg_secsize;
+
+ if (fseek(lpxself->lpx_fp, offset, SEEK_SET)) return DSK_ERR_SYSERR;
+
+ if (fread(buf, 1, geom->dg_secsize, lpxself->lpx_fp) < geom->dg_secsize)
+ {
+ return DSK_ERR_NOADDR;
+ }
+ return DSK_ERR_OK;
+}
+
+
+static dsk_err_t seekto(LOGICAL_DSK_DRIVER *self, unsigned long offset)
+{
+ /* 0.9.5: Fill any "holes" in the file with 0xE5. Otherwise, UNIX would
+ * fill them with zeroes and Windows would fill them with whatever
+ * happened to be lying around */
+ if (self->lpx_filesize < offset)
+ {
+ if (fseek(self->lpx_fp, self->lpx_filesize, SEEK_SET)) return DSK_ERR_SYSERR;
+ while (self->lpx_filesize < offset)
+ {
+ if (fputc(0xE5, self->lpx_fp) == EOF) return DSK_ERR_SYSERR;
+ ++self->lpx_filesize;
+ }
+ }
+ if (fseek(self->lpx_fp, offset, SEEK_SET)) return DSK_ERR_SYSERR;
+ return DSK_ERR_OK;
+}
+
+dsk_err_t logical_write(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
+ const void *buf, dsk_pcyl_t cylinder,
+ dsk_phead_t head, dsk_psect_t sector)
+{
+ LOGICAL_DSK_DRIVER *lpxself;
+ dsk_lsect_t offset;
+ dsk_err_t err;
+
+ if (!buf || !self || !geom || self->dr_class != &dc_logical) return DSK_ERR_BADPTR;
+ lpxself = (LOGICAL_DSK_DRIVER *)self;
+
+ if (!lpxself->lpx_fp) return DSK_ERR_NOTRDY;
+ if (lpxself->lpx_readonly) return DSK_ERR_RDONLY;
+
+ err = dg_ps2ls(geom, cylinder, head, sector, &offset);
+ if (err) return err;
+ offset *= geom->dg_secsize;
+
+ err = seekto(lpxself, offset);
+ if (err) return err;
+
+ if (fwrite(buf, 1, geom->dg_secsize, lpxself->lpx_fp) < geom->dg_secsize)
+ {
+ return DSK_ERR_NOADDR;
+ }
+ if (lpxself->lpx_filesize < offset + geom->dg_secsize)
+ lpxself->lpx_filesize = offset + geom->dg_secsize;
+ return DSK_ERR_OK;
+}
+
+
+dsk_err_t logical_format(DSK_DRIVER *self, DSK_GEOMETRY *geom,
+ dsk_pcyl_t cylinder, dsk_phead_t head,
+ const DSK_FORMAT *format, unsigned char filler)
+{
+/*
+ * Note that we completely ignore the "format" parameter, since raw LOGICAL
+ * images don't hold track headers.
+ */
+ LOGICAL_DSK_DRIVER *lpxself;
+ dsk_lsect_t offset;
+ unsigned long trklen;
+ dsk_err_t err;
+
+ (void)format;
+ if (!self || !geom || self->dr_class != &dc_logical) return DSK_ERR_BADPTR;
+ lpxself = (LOGICAL_DSK_DRIVER *)self;
+
+ if (!lpxself->lpx_fp) return DSK_ERR_NOTRDY;
+ if (lpxself->lpx_readonly) return DSK_ERR_RDONLY;
+
+ trklen = geom->dg_sectors * geom->dg_secsize;
+
+ err = dg_ps2ls(geom, cylinder, head, geom->dg_secbase, &offset);
+ if (err) return err;
+ offset *= geom->dg_secsize;
+
+ err = seekto(lpxself, offset);
+ if (err) return err;
+ if (lpxself->lpx_filesize < offset + trklen)
+ lpxself->lpx_filesize = offset + trklen;
+
+ while (trklen--)
+ if (fputc(filler, lpxself->lpx_fp) == EOF) return DSK_ERR_SYSERR;
+
+ return DSK_ERR_OK;
+}
+
+
+
+dsk_err_t logical_xseek(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
+ dsk_pcyl_t cylinder, dsk_phead_t head)
+{
+ LOGICAL_DSK_DRIVER *lpxself;
+ dsk_err_t err;
+ long offset;
+
+ if (!self || !geom || self->dr_class != &dc_logical) return DSK_ERR_BADPTR;
+ lpxself = (LOGICAL_DSK_DRIVER *)self;
+
+ if (!lpxself->lpx_fp) return DSK_ERR_NOTRDY;
+
+ if (cylinder >= geom->dg_cylinders || head >= geom->dg_heads)
+ return DSK_ERR_SEEKFAIL;
+
+ err = dg_ps2ls(geom, cylinder, head, geom->dg_secbase, &offset);
+ if (err) return err;
+ offset *= geom->dg_secsize;
+
+ if (fseek(lpxself->lpx_fp, offset, SEEK_SET)) return DSK_ERR_SEEKFAIL;
+
+ return DSK_ERR_OK;
+}
+
+dsk_err_t logical_status(DSK_DRIVER *self, const DSK_GEOMETRY *geom,
+ dsk_phead_t head, unsigned char *result)
+{
+ LOGICAL_DSK_DRIVER *lpxself;
+
+ if (!self || !geom || self->dr_class != &dc_logical) return DSK_ERR_BADPTR;
+ lpxself = (LOGICAL_DSK_DRIVER *)self;
+
+ if (!lpxself->lpx_fp) *result &= ~DSK_ST3_READY;
+ if (lpxself->lpx_readonly) *result |= DSK_ST3_RO;
+ return DSK_ERR_OK;
+}
+
Added: vendor/libdsk/current/lib/drvlogi.h
===================================================================
--- vendor/libdsk/current/lib/drvlogi.h (rev 0)
+++ vendor/libdsk/current/lib/drvlogi.h 2007-08-06 00:43:48 UTC (rev 442)
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * *
+ * LIBDSK: General floppy and diskimage access library *
+ * Copyright (C) 2001, 2007 John Elliott <jc...@se...> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This library 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 ...
[truncated message content] |