home *** CD-ROM | disk | FTP | other *** search
- Path: comp-sources-3b1
- From: dave@galaxia.network23.com (David H. Brierley)
- Subject: v02i007: fdcopy: floppy disk copy program, Part01/01
- Newsgroups: comp.sources.3b1
- Approved: dave@galaxia.network23.com
- X-Checksum-Snefru: df142178 d2520e76 ce247b12 8c6d0e9c
-
- Submitted-by: dave@galaxia.network23.com (David H. Brierley)
- Posting-number: Volume 2, Issue 7
- Archive-name: fdcopy/part01
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 1)."
- # Contents: MANIFEST README.fdcopy fdcopy.c makefile
- # Wrapped by dave@galaxia on Mon Jun 22 22:59:19 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'MANIFEST' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MANIFEST'\"
- else
- echo shar: Extracting \"'MANIFEST'\" \(220 characters\)
- sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
- X File Name Archive # Description
- X-----------------------------------------------------------
- X MANIFEST 1
- X README.fdcopy 1
- X fdcopy.c 1
- X makefile 1
- END_OF_FILE
- if test 220 -ne `wc -c <'MANIFEST'`; then
- echo shar: \"'MANIFEST'\" unpacked with wrong size!
- fi
- # end of 'MANIFEST'
- fi
- if test -f 'README.fdcopy' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README.fdcopy'\"
- else
- echo shar: Extracting \"'README.fdcopy'\" \(3619 characters\)
- sed "s/^X//" >'README.fdcopy' <<'END_OF_FILE'
- XProgram: fdcopy
- XAuthor: David H. Brierley
- X dave@galaxia.network23.com
- X
- XCopyright 1992 David H. Brierley, All Rights Reserved
- X
- XNOTE: This software is currently in beta-test status and could potentially
- Xcrash your system. See warnings at end of this README for details.
- X
- XFdcopy is a program which was designed and developed for running on an
- XAT&T 3B1 computer which will duplicate virtually any disk which is
- Xphysically readable on the 3B1 floppy disk drive. The stock 3B1 floppy
- Xdrive can read any 5.25" disk which is formatted with 8, 9, or 10 sectors
- Xper track, 40 cylinders per disk. It is also possible to replace the
- Xfloppy drive with a low density 3.5" drive (up to 10 sectors per track,
- X80 cylinders) or with a 720K 5.25" drive (up to 10 sectors per track, 80
- Xcylinders).
- X
- XIn its normal mode of operation the program uses a curses based interface
- Xwhich allows you to set all the required parameters for the copy. This
- Xinterface generally obviates the need for a man page and hence none is
- Xprovided. If you really enjoy specifying lots of command line options,
- Xor if you really abhor using the curses interface, here is a list of the
- Xcommand line options that are available. Note that the first two options
- Xon the list are only available via the command line. In the case of the
- X"-n" option the reason should be obvious, in the case of the "-z" option
- XI don't remember why this is so.
- X
- X-n = dont use curses interface (command line only)
- X-z = use verbose mode when formatting floppy (command line only)
- X-c nn = number of cylinders in source disk
- X-h nn = number of heads
- X-s nn = number of sectors per track
- X-v = verify target disk after making copy
- X-f = format traget disk before making copy
- X-m = make multiple copies of source disk
- X
- XThe default value for the -z flag is controlled by a compile-time option.
- XRead the source file for details. The -v, -f, and -m options are all off
- Xbe default.
- X
- XThe default number of cylinders is a compile-time option. The program will
- Xautomatically determine the number of cylinders present on the source disk,
- Xup to the number specified by the -c option (or the default). The default
- Xnumber of sectors is 10 and the program will automatically sense if the
- Xdisk actually has less than this number. The default number of heads is 2
- Xand the program has never been tested with any other value.
- X
- XThis program has been successfully used to duplicate 3b1 floppies, using the
- Xstock floppy drive, a 720K 3.5" drive, and a 720K 5.25" drive. It has also
- Xbeen used to duplicate MS-DOS floppies in each of those formats and IMAGEN
- Xsystem disks.
- X
- X
- XWARNING! WARNING! WARNING! Danger Will Robinson!
- X
- XDue to either a bug in the gd driver or the complete lack of documentation
- Xof how to use the special ioctl() interface for direct access to the floppy
- Xdrive, if you use this program to duplicate a floppy with more than 80
- Xcylinders (ie. a 3.5" floppy formatted to 84 cylinders) there is a high
- Xprobability that your system will "panic" and print some totally meaningless
- Xnumbers on the screen and wait for you to press the reset button. The bug
- Xonly seems to manifest itself when you let the program dynamically figure
- Xout how many cylinders there are on the disk so the workaround is to specify
- Xexactly how many cylinders you have on the source disk. If you can figure
- Xout what I'm doing wrong, or if you have access to the source and can tell
- Xme how the ioctl interface is supposed to work, I would appreciate hearing
- Xfrom you.
- X
- XDespite the warnings, for the cases where the program works correctly it is
- Xa really handy program. I use it all the time to duplicate MS-DOS disks.
- END_OF_FILE
- if test 3619 -ne `wc -c <'README.fdcopy'`; then
- echo shar: \"'README.fdcopy'\" unpacked with wrong size!
- fi
- # end of 'README.fdcopy'
- fi
- if test -f 'fdcopy.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fdcopy.c'\"
- else
- echo shar: Extracting \"'fdcopy.c'\" \(15050 characters\)
- sed "s/^X//" >'fdcopy.c' <<'END_OF_FILE'
- X#include <stdio.h>
- X#include <curses.h>
- X#include <ctype.h>
- X#include <sys/types.h>
- X#include <fcntl.h>
- X#include <errno.h>
- X#include <malloc.h>
- X#include <memory.h>
- X#include <string.h>
- X#include <stdlib.h>
- X#include <unistd.h>
- X/*
- X * F_LOCK in unistd.h conflicts with F_LOCK in gdioctl.h
- X * sys/gdioctl.h includes sys/param.h which redefines NULL
- X */
- X#undef F_LOCK
- X#undef NULL
- X#include <sys/gdioctl.h>
- X
- X/*
- X * Define IV_VERBOSE if you want the iv command run in verbose mode when
- X * formatting the target disk.
- X */
- X/* #define IV_VERBOSE */
- X
- X/*
- X * Define the size of a standard sector on the floppy.
- X */
- X#define SECTOR 512
- X
- X/*
- X * Define the default number of cylinders on a floppy.
- X */
- X#define DEFAULT_CYLS 80
- X
- X/*
- X * Define the name of the floppy device.
- X */
- X#define FLOPPY "/dev/rfp020"
- X
- X/*
- X * Some extra defines that are handy for dealing with curses input
- X */
- X#define ENTER 012
- X#define RETURN 015
- X#define ESCAPE 033
- X
- X
- X/* fdcopy.c */
- Xint main (int argc, char *argv[]);
- Xint init_floppy (int fd, int ncyl, int nheads, int nsect);
- Xvoid wait_for_return (char *msg);
- Xint set_sectors (int fd, int cyls, int hds, int sect);
- Xint read_source (int fd, int cyls, int hds, int sect, char *buf);
- Xint write_target (int cyls, int hds, int sect, char *buf, int vflg);
- Xvoid format_disk (int cyls, int hds, int sect, int verbose);
- Xvoid set_options (int *c, int *h, int *s, int *v, int *f, int *m);
- Xint yes_or_no (char *msg);
- X
- X/* external routines */
- Xextern int getopt (int argc, char *argv[], char *key);
- Xextern char *mktemp (char *key);
- X
- Xint
- Xmain (int argc, char *argv[])
- X{
- X int fd_floppy;
- X char *buf;
- X int blksize;
- X unsigned int bufsize;
- X int cyls;
- X int save_cyls;
- X int heads;
- X int sectors;
- X int verify;
- X int fmt_flag;
- X int no_curses;
- X int multi_copy;
- X int rc;
- X int re_format;
- X int iv_verbose;
- X int optc;
- X extern char *optarg;
- X
- X cyls = DEFAULT_CYLS;
- X heads = 2;
- X sectors = 10;
- X multi_copy = no_curses = fmt_flag = verify = 0;
- X#ifdef IV_VERBOSE
- X iv_verbose = 1;
- X#else
- X iv_verbose = 0;
- X#endif
- X
- X while ((optc = getopt (argc, argv, "c:h:s:vfnmz")) != EOF) {
- X switch (optc) {
- X case 'c':
- X cyls = atoi (optarg);
- X break;
- X case 'h':
- X heads = atoi (optarg);
- X break;
- X case 's':
- X sectors = atoi (optarg);
- X break;
- X case 'v':
- X verify = 1;
- X break;
- X case 'f':
- X fmt_flag = 1;
- X break;
- X case 'n':
- X no_curses = 1;
- X break;
- X case 'm':
- X multi_copy = 1;
- X break;
- X case 'z':
- X iv_verbose = 1 - iv_verbose;
- X break;
- X }
- X }
- X
- X if (no_curses == 0) {
- X set_options (&cyls, &heads, §ors, &verify, &fmt_flag, &multi_copy);
- X }
- X
- X wait_for_return ("Insert source floppy and press RETURN: ");
- X
- X if ((fd_floppy = open (FLOPPY, O_RDONLY)) == -1) {
- X (void) printf ("Open of %s failed\n", FLOPPY);
- X exit (1);
- X }
- X
- X sectors = set_sectors (fd_floppy, cyls, heads, sectors);
- X blksize = (sectors * heads) * SECTOR;
- X save_cyls = cyls;
- X buf = NULL;
- X while (cyls > 0) {
- X bufsize = blksize * cyls;
- X if ((buf = malloc (bufsize)) != NULL) {
- X break;
- X }
- X --cyls;
- X }
- X if (buf == NULL) {
- X (void) printf ("Error: unable to allocate buffer space\n");
- X exit (1);
- X }
- X if (save_cyls != cyls) {
- X (void) printf ("Disk geometry of %d heads", heads);
- X (void) printf (" and %d sectors limits", sectors);
- X (void) printf (" number of cylinders to %d.\n", cyls);
- X }
- X
- X cyls = read_source (fd_floppy, cyls, heads, sectors, buf);
- X (void) close (fd_floppy);
- X
- X re_format = 0;
- X do {
- X wait_for_return ("Insert target floppy and press RETURN: ");
- X if (fmt_flag || re_format) {
- X format_disk (cyls, heads, sectors, iv_verbose);
- X re_format = 0;
- X }
- X rc = write_target (cyls, heads, sectors, buf, verify);
- X if (rc) {
- X re_format = yes_or_no ("Do you want to reformat and try again");
- X if (re_format) {
- X continue;
- X }
- X }
- X if (rc || multi_copy) {
- X multi_copy = yes_or_no ("Make another copy");
- X }
- X } while (re_format || multi_copy);
- X
- X return (0);
- X
- X}
- X
- Xint
- Xinit_floppy (int fd, int ncyl, int nheads, int nsect)
- X{
- X
- X static struct gdctl gdbuf;
- X
- X if (ioctl (fd, GDGETA, &gdbuf) == -1) {
- X ioctl (fd, GDDISMNT, &gdbuf);
- X return (1);
- X }
- X
- X gdbuf.params.cyls = ncyl;
- X gdbuf.params.heads = nheads;
- X gdbuf.params.psectrk = nsect;
- X gdbuf.params.pseccyl = gdbuf.params.psectrk * gdbuf.params.heads;
- X gdbuf.params.flags = 1; /* disk type flag */
- X gdbuf.params.step = 0; /* step rate for contoller */
- X gdbuf.params.sectorsz = SECTOR; /* sector size */
- X
- X if (ioctl (fd, GDSETA, &gdbuf) < 0) {
- X ioctl (fd, GDDISMNT, &gdbuf);
- X return (2);
- X }
- X
- X return (0);
- X}
- X
- Xvoid
- Xwait_for_return (char *msg)
- X{
- X static char testbuf[2];
- X int ch;
- X
- X (void) printf ("%s", msg);
- X (void) fflush (stdout);
- X while (1) {
- X if (read (0, testbuf, 1) != 1) {
- X (void) printf ("\nError on input.\n");
- X exit (1);
- X }
- X ch = testbuf[0] & 0x7f;
- X if ((ch == '\r') || (ch == '\n')) {
- X break;
- X }
- X }
- X
- X}
- X
- Xint
- Xset_sectors (int fd, int cyls, int hds, int sect)
- X{
- X int rc;
- X long lpos;
- X static char testbuf[SECTOR];
- X
- X for (; sect > 0; --sect) {
- X if ((rc = init_floppy (fd, cyls, hds, sect)) != 0) {
- X (void) printf ("init_floppy returned %d\n", rc);
- X exit (1);
- X }
- X lpos = (sect - 1) * SECTOR;
- X if (lseek (fd, lpos, 0) == -1) {
- X perror ("fdcopy");
- X (void) fprintf (stderr,
- X "Unable to seek to beginning of sector %d\n",
- X sect);
- X exit (1);
- X }
- X if (read (fd, testbuf, SECTOR) == SECTOR) {
- X if (lseek (fd, 0L, 0) == -1) {
- X perror ("fdcopy");
- X (void) fprintf (stderr,
- X "Unable to seek to location zero on disk\n");
- X exit (1);
- X }
- X break;
- X }
- X }
- X
- X if (sect < 1) {
- X (void) fprintf (stderr,
- X "Unable to determine number of sectors per track\n");
- X exit (1);
- X }
- X (void) printf ("Floppy is formatted with %d sectors per track\n",
- X sect);
- X
- X return (sect);
- X
- X}
- X
- Xint
- Xread_source (int fd, int cyls, int hds, int sect, char *buf)
- X{
- X char *bufp;
- X int cylno;
- X long lpos;
- X int rc;
- X int save_errno;
- X int blksize;
- X static char testbuf[SECTOR];
- X struct fdrq *command;
- X
- X save_errno = rc = 0;
- X bufp = buf;
- X blksize = (sect * hds) * SECTOR;
- X
- X (void) printf ("Reading source disk: %d cylinders, %d heads, %d sectors\n",
- X cyls, hds, sect);
- X
- X for (cylno = 0; cylno < cyls; ++cylno) {
- X (void) printf ("%3d\r", cylno);
- X (void) fflush (stdout);
- X lpos = cylno * blksize;
- X if (lseek (fd, lpos, 0) == -1) {
- X save_errno = errno;
- X (void) printf ("Unable to seek to location %ld\n", lpos);
- X break;
- X }
- X rc = read (fd, testbuf, SECTOR);
- X if (rc != SECTOR) {
- X save_errno = errno;
- X (void) printf ("Error reading block at cylinder %d, rc=%d\n",
- X cylno, rc);
- X break;
- X }
- X (void) memset (testbuf, 0x11, SECTOR);
- X command = (struct fdrq *) testbuf;
- X command -> cmd = F_READADR;
- X command -> cyl = cylno;
- X command -> sec = 2;
- X command -> count = 6;
- X rc = ioctl (fd, GDCMD, testbuf);
- X if (rc == -1) {
- X (void) printf ("Error reading track address at cylinder %d\n",
- X cylno);
- X break;
- X }
- X if (command -> cyl != cylno) {
- X (void) printf ("Disk has %d cylinders\n", cylno);
- X break;
- X }
- X if (lseek (fd, lpos, 0) == -1) {
- X save_errno = errno;
- X (void) printf ("Unable to seek to location %ld\n", lpos);
- X break;
- X }
- X if ((rc = read (fd, bufp, blksize)) != blksize) {
- X save_errno = errno;
- X (void) printf ("Error reading cylinder %d, blksize = %d, rc = %d\n",
- X cylno, blksize, rc);
- X break;
- X }
- X bufp += blksize;
- X }
- X
- X if (rc == -1) {
- X errno = save_errno;
- X perror ("fdcopy");
- X exit (1);
- X }
- X
- X return (cylno);
- X
- X}
- X
- Xint
- Xwrite_target (int cyls, int hds, int sect, char *buf, int vflg)
- X{
- X int rc;
- X int cylno;
- X long lpos;
- X char *bufp;
- X char *vbuf;
- X int fd;
- X int blksize;
- X int save_errno;
- X
- X if ((fd = open (FLOPPY, O_RDWR)) == -1) {
- X (void) printf ("Open of %s failed\n", FLOPPY);
- X return (1);
- X }
- X
- X if ((rc = init_floppy (fd, cyls, hds, sect)) != 0) {
- X (void) printf ("init_floppy returned %d\n", rc);
- X (void) close (fd);
- X return (1);
- X }
- X
- X bufp = buf;
- X save_errno = 0;
- X blksize = (sect * hds) * SECTOR;
- X
- X (void) printf ("Writing target disk: %d cylinders, %d heads, %d sectors\n",
- X cyls, hds, sect);
- X
- X for (cylno = 0; cylno < cyls; ++cylno) {
- X (void) printf ("%3d\r", cylno);
- X (void) fflush (stdout);
- X lpos = cylno * blksize;
- X if (lseek (fd, lpos, 0) == -1) {
- X save_errno = errno;
- X (void) printf ("Unable to seek to location %ld\n", lpos);
- X break;
- X }
- X if ((rc = write (fd, bufp, blksize)) != blksize) {
- X save_errno = errno;
- X (void) printf ("Error writing cylinder %d, rc = %d\n", cylno, rc);
- X break;
- X }
- X bufp += blksize;
- X }
- X
- X if (rc == -1) {
- X errno = save_errno;
- X perror ("fdcopy");
- X (void) close (fd);
- X return (1);
- X }
- X
- X if (vflg) {
- X (void) printf ("Verifying duplicate\n");
- X if ((vbuf = malloc (blksize)) == NULL) {
- X perror ("fdcopy");
- X (void) fprintf (stderr,
- X "Unable to allocate dynamic buffer of %d bytes\n",
- X blksize);
- X exit (1);
- X }
- X bufp = buf;
- X for (cylno = 0; cylno < cyls; ++cylno) {
- X (void) printf ("%3d\r", cylno);
- X (void) fflush (stdout);
- X lpos = cylno * blksize;
- X if (lseek (fd, lpos, 0) == -1) {
- X save_errno = errno;
- X (void) printf ("Unable to seek to location %ld\n", lpos);
- X break;
- X }
- X if ((rc = read (fd, vbuf, blksize)) != blksize) {
- X save_errno = errno;
- X (void) printf ("Error reading cylinder %d, blksize=%d, rc=%d\n",
- X cylno, blksize, rc);
- X break;
- X }
- X if ((rc = memcmp (vbuf, bufp, blksize)) != 0) {
- X (void) printf ("Data compare error at cylinder %d, rc=%d\n",
- X cylno, rc);
- X rc = -1;
- X save_errno = EIO;
- X break;
- X }
- X bufp += blksize;
- X }
- X if (rc == -1) {
- X errno = save_errno;
- X perror ("fdcopy");
- X (void) close (fd);
- X return (1);
- X }
- X (void) printf ("Floppy verified successfully.\n");
- X (void) free (vbuf);
- X }
- X
- X (void) close (fd);
- X return (0);
- X
- X}
- X
- Xvoid
- Xformat_disk (int cyls, int hds, int sect, int verbose)
- X{
- X FILE *fp_iv;
- X static char filename[32];
- X static char cmd_buff[128];
- X char vflag;
- X int rc;
- X
- X (void) strcpy (filename, "/tmp/iv_XXXXXX");
- X (void) mktemp (filename);
- X
- X if ((fp_iv = fopen (filename, "w")) == NULL) {
- X perror ("fdcopy");
- X (void) fprintf (stderr, "Unable to format target disk\n");
- X exit (1);
- X }
- X
- X (void) fprintf (fp_iv, "type FD\n");
- X (void) fprintf (fp_iv, "name floppy\n");
- X (void) fprintf (fp_iv, "cylinders %d\n", cyls);
- X (void) fprintf (fp_iv, "heads %d\n", hds);
- X (void) fprintf (fp_iv, "sectors %d\n", sect);
- X (void) fprintf (fp_iv, "steprate 0\n");
- X (void) fprintf (fp_iv, "$\n");
- X if ((sect % 2) == 1) {
- X (void) fprintf (fp_iv, "badblocktable 1\n");
- X }
- X (void) fprintf (fp_iv, "$\n");
- X (void) fprintf (fp_iv, "$\n");
- X (void) fprintf (fp_iv, "0\n");
- X (void) fprintf (fp_iv, "1\n");
- X (void) fprintf (fp_iv, "$\n");
- X (void) fprintf (fp_iv, "$\n");
- X
- X if (fclose (fp_iv) == -1) {
- X perror ("fdcopy");
- X (void) fprintf (stderr, "Unable to format target disk\n");
- X exit (1);
- X }
- X
- X vflag = (verbose) ? 'v' : ' ';
- X
- X (void) sprintf (cmd_buff, "iv -i%c %s %s", vflag, FLOPPY, filename);
- X
- X (void) printf ("Formatting target floppy: ");
- X (void) printf ("%d cylinders, %d heads, %d sectors\n",
- X cyls, hds, sect);
- X (void) printf ("+ %s\n", cmd_buff);
- X
- X rc = system (cmd_buff);
- X (void) printf ("Format done: exit status = %d\n", rc);
- X (void) unlink (filename);
- X
- X}
- X
- Xvoid
- Xset_options (int *cyls, int *hds, int *sect, int *vflag, int *fmt, int *multi)
- X{
- X int line;
- X int pos;
- X char value[8];
- X int ch;
- X int quit_flag = 0;
- X
- X (void) initscr ();
- X (void) keypad (stdscr, TRUE);
- X (void) noecho ();
- X (void) cbreak ();
- X (void) nonl ();
- X
- X (void) clear ();
- X (void) move (2, 23);
- X (void) addstr ("UNIX-pc Floppy Duplication Program");
- X (void) move (3, 24);
- X (void) addstr ("Copyright 1991 David H. Brierley");
- X
- X line = 6;
- X pos = 0;
- X value[pos] = '\0';
- X
- X while (quit_flag == 0) {
- X if (line < 6) {
- X line = 11;
- X }
- X if (line > 11) {
- X line = 6;
- X }
- X (void) move (6, 0);
- X if (*cyls == DEFAULT_CYLS) {
- X (void) printw ("* ");
- X }
- X else {
- X (void) printw ("%-3d", *cyls);
- X }
- X (void) printw ("\tcylinders (* == determine disk size dynamically)");
- X (void) move (7, 0);
- X (void) printw ("%-3d\theads", *hds);
- X (void) move (8, 0);
- X (void) printw ("%-3d\tsectors per track", *sect);
- X (void) move (9, 0);
- X (void) printw ("%-3s\tverify duplicate after copy",
- X (*vflag) ? "yes" : "no");
- X (void) move (10, 0);
- X (void) printw ("%-3s\tformat target disk before making duplicate",
- X (*fmt) ? "yes" : "no");
- X (void) move (11, 0);
- X (void) printw ("%-3s\tmake multiple copies", (*multi) ? "yes" : "no");
- X (void) move (13, 0);
- X (void) printw ("Use arrow keys to move up/down. Press ESC to quit");
- X (void) move (line, pos);
- X (void) refresh ();
- X ch = getch ();
- X switch (ch) {
- X case KEY_UP:
- X if (pos == 0) {
- X line--;
- X continue;
- X }
- X break;
- X case RETURN:
- X case ENTER:
- X line++;
- X pos = 0;
- X continue;
- X case KEY_DOWN:
- X if (pos == 0) {
- X line++;
- X continue;
- X }
- X break;
- X case ESCAPE:
- X if (pos == 0) {
- X quit_flag = 1;
- X continue;
- X }
- X break;
- X }
- X if (isupper (ch)) {
- X ch = tolower (ch);
- X }
- X if ((line == 6) && (ch == '*')) {
- X *cyls = DEFAULT_CYLS;
- X line++;
- X continue;
- X }
- X if (line >= 9) {
- X if ((ch == 'y') || (ch == 'n')) {
- X if (ch == 'y') {
- X ch = 1;
- X }
- X else {
- X ch = 0;
- X }
- X switch (line) {
- X case 9:
- X *vflag = ch;
- X break;
- X case 10:
- X *fmt = ch;
- X break;
- X case 11:
- X *multi = ch;
- X break;
- X }
- X ++line;
- X }
- X else {
- X beep ();
- X }
- X continue;
- X }
- X if (!isdigit (ch)) {
- X beep ();
- X continue;
- X }
- X value[pos] = ch;
- X pos++;
- X value[pos] = '\0';
- X ch = atoi (value);
- X switch (line) {
- X case 6:
- X *cyls = ch;
- X break;
- X case 7:
- X *hds = ch;
- X break;
- X case 8:
- X *sect = ch;
- X break;
- X }
- X }
- X
- X (void) move (12, 0);
- X (void) clrtoeol ();
- X (void) move (12, 0);
- X (void) refresh ();
- X (void) endwin ();
- X
- X}
- X
- Xint
- Xyes_or_no (char *msg)
- X{
- X static char buffer[64];
- X
- X (void) printf ("%s? (y/n) ", msg);
- X (void) fflush (stdout);
- X if (fgets (buffer, 64, stdin) == NULL) {
- X return (0);
- X }
- X
- X switch (buffer[0]) {
- X case 'y':
- X case 'Y':
- X return (1);
- X case 'n':
- X case 'N':
- X return (0);
- X }
- X
- X return (yes_or_no (msg));
- X
- X}
- END_OF_FILE
- if test 15050 -ne `wc -c <'fdcopy.c'`; then
- echo shar: \"'fdcopy.c'\" unpacked with wrong size!
- fi
- # end of 'fdcopy.c'
- fi
- if test -f 'makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile'\"
- else
- echo shar: Extracting \"'makefile'\" \(571 characters\)
- sed "s/^X//" >'makefile' <<'END_OF_FILE'
- X#
- X# Makefile for fdcopy program
- X#
- X# compile using gcc and link using ccc front end to take advantage of shlib.
- X#
- X# if you have problems using ccc, or if you don't have ccc, you can try
- X# using gcc with the -shlib option or just using straight gcc and ignoring
- X# the shared library.
- X#
- XCC = gcc
- XCOPTS = -Wall -fstrength-reduce -fpcc-struct-return
- XLD = ccc
- XLDFLAGS =
- XGNULIB = /usr/local/lib/gcc-gnulib
- X
- XDEF =
- XDEBUG = -g
- XOPTIMIZE = -O
- XCFLAGS = $(COPTS) $(DEF) $(DEBUG) $(OPTIMIZE)
- X
- Xfdcopy : fdcopy.o
- X $(LD) $(LDFLAGS) fdcopy.o $(GNULIB) -lcurses
- X mv a.out fdcopy
- END_OF_FILE
- if test 571 -ne `wc -c <'makefile'`; then
- echo shar: \"'makefile'\" unpacked with wrong size!
- fi
- # end of 'makefile'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- David H. Brierley
- Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
- Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
- %% Can I be excused, my brain is full. **
-