/***
 *** message printing tools
 *** Written by Koen Gadeyne (kmg@barco.be)
 ***
 ***/

#ifndef _MESSAGES_H
#define _MESSAGES_H

#include "vga_prg.h"   /* for SCREEN_ON */

void print_msg(char *format,...);

extern char* CommandName;
extern int debug_messages;

#define MSGTYP_ERR   3
#define MSGTYP_WARN  2
#define MSGTYP_MSG   1
#define MSGTYP_DBG   0

extern int msgtype;

/* the "do { ... } while (0)" construct allows us to use these macro's as if they were functions.
 * Otherwise you cannot ALWAYS place a ';' at the end of a message printing macro.
 */  

#ifndef NO_DEBUG
#  define PDEBUG(arg)  do { msgtype=MSGTYP_DBG ; print_msg arg; } while (0)
#else
#  define PDEBUG(arg)  do {} while (0)       /* avoids lost of warnings about empty statements */
#endif

/* PERROR() must switch screen back on, so you can read the error */
#define PERROR(arg)  do { msgtype=MSGTYP_ERR ; print_msg arg; if (vga_open) SCREEN_ON; exit (1); } while (0)

#define PWARNING(arg)  do { msgtype=MSGTYP_WARN ; print_msg arg; } while (0)

#define PMESSAGE(arg) do { msgtype=MSGTYP_MSG ; print_msg arg; } while (0)

#define PVERSION  PDEBUG(("%s version: %s", CommandName, VERSION));
    


#endif

