#ifndef _ERROR_H_ #define _ERROR_H_ // // $Id$ //----------------------------------------------------------------------- // // (c) Copyright 2002 by GATS, Inc., // 11864 Canon Blvd, Suite 101, Newport News VA 23606 // // All Rights Reserved. No part of this software or publication may be // reproduced, stored in a retrieval system, or transmitted, in any form // or by any means, electronic, mechanical, photocopying, recording, or // otherwise without the prior written permission of GATS, Inc. // //----------------------------------------------------------------------- // // Module: Error.h // // Author: John Burton // // Date: Wed Nov 13 16:17:53 2002 // //----------------------------------------------------------------------- // // Modification History: // // $Log$ // //----------------------------------------------------------------------- // //----------------------------------------------------------------------- // Include Files: //----------------------------------------------------------------------- // #include #include #include #include // //----------------------------------------------------------------------- // Defines, Macros and Type Definitions: //----------------------------------------------------------------------- // #define ERROR(strExit,...) Error(__func__,__FILE__,__LINE__,strExit, ## __VA_ARGS__) #define WARNING(strExit,...) Warning(__func__,__FILE__,__LINE__,strExit, ## __VA_ARGS__) // //----------------------------------------------------------------------- // Class Definitions: //----------------------------------------------------------------------- // // //----------------------------------------------------------------------- // Function Prototypes: //----------------------------------------------------------------------- // void Error(const char *func, ...) { va_list ap; char *fmt; char *file; int line; va_start(ap,func); file = va_arg(ap, char *); line = va_arg(ap, int); fmt = va_arg(ap, char *); fprintf(stderr,"%s::%s (line %d): ",func,file,line); vfprintf(stderr,fmt, ap); va_end(ap); if(errno != 0) perror(""); fprintf(stderr, "\n\n"); exit(-1); } void Warning(const char *func, ...) { va_list ap; char *fmt; char *file; int line; va_start(ap,func); file = va_arg(ap, char *); line = va_arg(ap, int); fmt = va_arg(ap, char *); fprintf(stderr,"%s::%s (line %d): ",func,file,line); vfprintf(stderr,fmt, ap); va_end(ap); if(errno != 0) perror(""); fprintf(stderr, "\n\n"); } #endif