/* FIPS - the First nondestructive Interactive Partition Splitting program Module global.cpp RCS - Header: $Header: c:/daten/fips/source/main/RCS/global.cpp 1.4 1995/01/19 00:00:52 schaefer Exp schaefer $ Copyright (C) 1993 Arno Schaefer This program 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. This program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Report problems and direct all questions to: schaefer@rbg.informatik.th-darmstadt.de */ #include #include #include #include #include "version.h" #include "global.h" #define CTRL_C 3 global_vars global; /* ----------------------------------------------------------------------- */ /* Initialization of global variables */ /* ----------------------------------------------------------------------- */ global_vars::global_vars (void) { test_mode = false; verbose_mode = true; debug_mode = false; drive_number_cmdline = 0; } global_vars::~global_vars (void) { if (debug_mode) fclose (debugfile); } void exit_function (void) { printx ("\nBye!\n"); } void global_vars::open_debugfile (int argc,char *argv[]) { if ((debugfile = fopen ("fipsinfo.dbg","wt")) == NULL) { global.debug_mode = false; warning (true, "Can't open debug file"); } else { fprintf (debugfile,"FIPS debug file\n\n"); fprintf (debugfile,"The command was: "); while (argc--) fprintf (debugfile,argc ? "%s " : "%s", *argv++); fprintf (debugfile,"\n\nTranscript of session:\n"); } } /* ----------------------------------------------------------------------- */ /* Replacement for printf - prints to screen and debugfile */ /* ----------------------------------------------------------------------- */ void printx (char *fmt,...) { va_list ap; va_start (ap,fmt); vprintf (fmt,ap); if (global.debug_mode) vfprintf (global.debugfile,fmt,ap); va_end (ap); } /* ----------------------------------------------------------------------- */ /* Replacement for getch - exit when CTRL-C is pressed */ /* ----------------------------------------------------------------------- */ int getx (void) { int character = getch(); if (character == CTRL_C) { printx ("\n"); exit (0); } return (character); } /* ----------------------------------------------------------------------- */ /* Copyright notice and version number */ /* ----------------------------------------------------------------------- */ void notice (void) { printx ("\nFIPS version " FIPS_VERSION ", Copyright (C) 1993/94 Arno Schaefer\n\n"); printx ("DO NOT use FIPS in a multitasking environment like Windows, OS/2, Desqview,\n"); printx ("Novell Task manager or the Linux DOS emulator: boot from a DOS boot disk first.\n\n"); printx ("If you use OS/2 or a disk compressor, read the relevant sections in FIPS.DOC.\n\n"); printx ("FIPS comes with ABSOLUTELY NO WARRANTY, see file COPYING for details\n"); printx ("This is free software, and you are welcome to redistribute it\n"); printx ("under certain conditions; again see file COPYING for details.\n"); printx ("\nPress any Key\n"); getx(); } /* ----------------------------------------------------------------------- */ /* Hexdump binary data into a file */ /* ----------------------------------------------------------------------- */ void hexwrite (byte *buffer,int number,FILE *file) { for (int i=0;i