/* * status.h * ***************************************************************************** * * Status / Error / Warning Display for C * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ***************************************************************************** * * Author : Rajesh _ThE gReAt * Built on : Sunday, January 27, 2002, 10:10:09 AM * Last Modified on : Friday, February 08, 2002, 3:29:04 PM * * Known errors : Modifies / uses constants used by hprintf.h . * ***************************************************************************** * DISCLAIMER: ***************************************************************************** * * Programmers may incorporate any or all code into their programs, * giving proper credit within the source. Publication of the * source routines is permitted so long as proper credit is given * to Rajesh _ThE gReAt. * * Copyright (C) 2002, 2003 by Rajesh _ThE gReAt. You may use this program, or * code or tables extracted from it, as desired without restriction. * I can not and will not be held responsible for any damage caused from * the use of this software. * * Read license.txt from http://www.rajeshgoli.com/license.txt * or http://www.rajeshgoli.com/license.htm * before using / distributing / or any sort of use of my source * Also read my disclaimer http://www.rajeshgoli.com/disclaimer.htm * * YOU AGREE TO BE BOUND BY MY DISCLAIMER AND LICENSE BY IN ANY WAY * USING THIS FILE . * ***************************************************************************** * This source works with Turbo C 2.0 and Turbo C++ 3.0 and above. ***************************************************************************** * Rajesh _ThE gReAt is a synonym of Rajesh Goli * Source freely distributable *****************************************************************************/ #ifndef __STATUS_H #define __STATUS_H #endif #ifndef NORM_COLOR #define NORM_COLOR LIGHTGRAY #endif #ifndef WARNING_COLOR #define WARNING_COLOR LIGHTCYAN #endif #ifndef ERROR_COLOR #define ERROR_COLOR LIGHTRED #endif #ifndef STATUS_COLOR #define STATUS_COLOR LIGHTGREEN #endif #ifndef FATAL_COLOR #define FATAL_COLOR LIGHTRED + BLINK #endif #ifndef FATAL_TEXT #define FATAL_TEXT LIGHTRED #endif #ifndef __HPRINTF_H #include "hprintf.h" #endif #ifndef __CONIO_H #include "conio.h" #endif #ifndef __STRING_H #include "string.h" #endif #define ENDX 80 #ifndef DOESNT_FIT #define DOESNT_FIT -1 #endif #ifndef SUCCESS #define SUCCESS 1 #endif #define ERROR 0 #define ER ERROR #define STATUS 1 #define ST STATUS #define WARNING 2 #define WR WARNING #define FATAL 3 #define FT FATAL #ifndef STATX #define STATX 5 #endif #ifndef STATY #define STATY 23 #endif #define INIT_CLEAR_LINE int sx,sy; #define CLEAR_LINE sx = wherex(); sy = wherey(); while(wherex() <= ENDX - 1) printf(" "); printf(" "); gotoxy(sx,sy); int status(char *,short ,short ); #if(defined(AP)) int astatus(char *,short ,short ,int ,int ,...); #else int astatus(char *,short ,short ,int ,int); #endif int status(char *msg,short err_stat,short wait) { int x,y,len; INIT_CLEAR_LINE ; x = wherex(); y = wherey(); gotoxy(STATX,STATY); CLEAR_LINE ; if(*msg == NULL) { gotoxy(x,y); return SUCCESS; } if(err_stat == ERROR) len = strlen("ERROR : "); else if(err_stat == STATUS) len = strlen("Status : "); else if(err_stat == WARNING) len = strlen("WARNING : "); else if(err_stat == FATAL) len = strlen("!FATAL! : "); len += strlen(msg); if(wait) len += strlen(" : Hit a key to continue ..."); if( (len + STATX) > ENDX ) { gotoxy(x,y); return DOESNT_FIT; } if(err_stat == ERROR) __hprintf(" : ",NORM_COLOR,"<",">",ERROR_COLOR); else if(err_stat == STATUS) __hprintf(" : ",NORM_COLOR,"<",">",STATUS_COLOR); else if(err_stat == WARNING) __hprintf(" : ",NORM_COLOR,"<",">",WARNING_COLOR); else if(err_stat == FATAL) __hprintf("[FATAL] : ",NORM_COLOR,"<[",">]",FATAL_COLOR,FATAL_TEXT); printf("%s",msg); if(wait) { if(err_stat != FATAL) printf(" : Hit a key to continue ..."); else printf(" : Hit a key to halt ..."); getch(); gotoxy(STATX,STATY); CLEAR_LINE ; } gotoxy(x,y); return SUCCESS; } #ifndef __STDARG_H #include ENDX ) { gotoxy(x,y); return DOESNT_FIT; } if(err_stat == ERROR) __hprintf(" : ",normcolor,"<",">",hcolor); else if(err_stat == STATUS) __hprintf(" : ",normcolor,"<",">",hcolor); else if(err_stat == WARNING) __hprintf(" : ",normcolor,"<",">",hcolor); else if(err_stat == FATAL) #if(defined(AP)) __hprintf("[FATAL] : ",normcolor,"<[",">]",va_arg(ap,int),hcolor); #else __hprintf("[FATAL] : ",normcolor,"<[",">]",hcolor + BLINK,hcolor); #endif printf("%s",msg); if(wait) { if(err_stat != FATAL) printf(" : Hit a key to continue ..."); else printf(" : Hit a key to halt ..."); getch(); gotoxy(STATX,STATY); CLEAR_LINE ; } gotoxy(x,y); return SUCCESS; }