/*****************************************************************/ /** Microsoft LAN Manager **/ /** Copyright(c) Microsoft Corp., 1990 **/ /*****************************************************************/ /*** MAIN.C - Main entrypoint for DAMAGE * * This program is a graphic-oriented utility to display and change * file system structures. It is called "damage" because its primary * use will be to corrupt file system structures to test CHKDSK's * recovery skills. It has an option to disallow changes, though, * so that it can be used purely informationally. * * Modification history: * G.A. Jones 09/07/88 Original for Pinball testing. * G.A. Jones 09/08/88 Added get_object call. * G.A. Jones 09/13/88 Added pathname buffer. * G.A. Jones 09/19/88 Bug in parse_args - /D not recognized. * G.A. Jones 09/20/88 Message fixes. * G.A. Jones 09/21/88 Added hotfix support. * S. Hern 02/06/89 Added ability to to dump the SB_CDDAT * as a time.h-format asciiz string (/t) * S. Hern 04/20/89 Allow switching for redirected input * davidbro 04/20/89 changed /r redirection behavior * S. Hern 04/25/89 changed /r redirection behavior (see * usage code) * davidbro 05/21/89 added code to mark bad sectors on exit * davidbro 05/22/89 added /l: switch support */ #include #include #include #include #include "defs.h" #include "types.h" #include "globals.h" static USHORT dump_sb_cddat = 0; /*** error_msg - display error message * * This function is called to display a message to the standard * error device. * * error_msg (str) * * ENTRY str - pointer to message * * EXIT No return value * * CALLS fprintf * fflush */ void error_msg (str) UCHAR *str; { fprintf (stderr, "%s\n", str); /* display the message to the error handle */ fflush (stderr); /* flush the buffer to the console */ } /*** exit_error - print informative message and exit * * exit_error (code) * * ENTRY code - error code number, defined in DEFS.H * * CALLS exit * error_msg * close_disk * * EFFECTS Deallocates memory * Unlocks and closes disk * Exits program * * WARNINGS Does not return */ void exit_error (USHORT code) { UCHAR scratchbuf [80]; #ifdef TRACE fprintf (stderr, "exit_error (%d)\n", code); fflush (stderr); #endif if (code <= MAX_ERROR_CODE) error_msg (error_messages [code]); /* display appropriate message */ else { sprintf (scratchbuf, unknown_error_str, code); error_msg ((UCHAR *)scratchbuf); /* display "unknown code" message */ } close_disk (); /* unlock disk, close our handle */ exit (code); } void usage () { printf (version_str); printf (timestamp_str, __DATE__, __TIME__); printf ("Usage: DAMAGE [d:] [/D]\n"); printf (" d: - Pinball drive to access\n"); printf (" /D - Allow changes\n"); printf (" /R - Redirect input\n"); printf (" /R: - Replay keystrokes from \n"); printf (" /K: - Save keystrokes to \n"); printf (" /L: - Log command output file\n"); exit (1); } void parse_args (argc, argv) USHORT argc; UCHAR *argv []; { UCHAR *p; USHORT i; _getcwd (disk_name, 80); if (argc < 2) usage (); for (i=1; ispb.SPB_HFMAX; memset (curpath, '\0', 1024); if (dump_sb_cddat) printf ("%s", get_time (((struct SuperSpare *)currobj.mem)->sb.SB_CDDAT)); else display (); close_disk (); if (szKeySave != NULL) fclose(fpSave); if (szKeyReplay != NULL) fclose(fpReplay); if (szLogFile != NULL) fclose(fpLog); exit (0); }