#!/bin/sh # This is a shar archive. # The rest of this file is a shell script which will extract: # # debug.h error.c error.h # # To extract the files from this shell archive file simply # create a directory for this file, move the archive file # to it and enter the command # # sh filename # # The files will be extracted automatically. # Note: Do not use csh. # # Archive created: Mon Jul 30 23:14:39 EDT 1990 # echo x - debug.h sed 's/^X//' > debug.h << '!EOF!' #ifndef DEBUG_H #define DEBUG_H #ifdef __cplusplus extern "C" { #endif extern char *getenv(const char*); extern int atoi(const char*); #ifdef __cplusplus } #endif class debugC { int i; public: debugC() { char *x = getenv("DEBUG"); i = x ? atoi(x) : 0; } operator int() { return i; } }; static debugC debug; #endif /* DEBUG_H */ !EOF! ls -l debug.h echo x - error.c sed 's/^X//' > error.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // Error function. fmt is a printf-style format string. // The formatted message is written to the error // stream and then the function calls exit(1). #include #include extern void exit(int); void error(const char *fmt ...) { va_list ap; va_start(ap, fmt); char ch; // loop across format string while (ch = *fmt++) // output normal chars if (ch != '%') cerr.put(ch); else // found % sequence switch (ch = *fmt++) { // %% becomes a single % case '%': cerr.put('%'); break; // output string case 's': { char *s = va_arg(ap, char*); cerr << s; } break; // output decimal integer case 'd': { int s = va_arg(ap, int); cerr << s; } break; // output character case 'c': { int s = va_arg(ap, int); cerr.put(s); } break; default: cerr << "\nunknown % sequence: %" << chr(ch) << "\n"; break; } // all done va_end(ap); exit(1); } !EOF! ls -l error.c echo x - error.h sed 's/^X//' > error.h << '!EOF!' #ifndef ERRORH # define ERRORH void error(const char *fmt ...); #endif /* ERRORH */ !EOF! ls -l error.h # The following exit is to ensure that extra garbage # after the end of the shar file will be ignored. exit 0