Source file: /~heha/hs/gputils64-210929.zip/libgputils/gpmessage.cpp

/* messaging functions
   Copyright 2003-2005	Craig Franklin
 */

#include "stdhdr.h"
#include "libgputils.h"
#include <stdarg.h>

bool gp_quiet           = false;
bool gp_message_disable = false;
bool gp_debug_disable   = true;

struct num_t gp_num,_real_num;

/*------------------------------------------------------------------------------------------------*/

FUNC(void) gp_vMessage(msg_type_t typ, const char* Format, va_list args) {
  char buffer[BUFSIZ];
  static const char*const Typ[]={"error","warning","message","debug"};
  assert((unsigned)typ<4);
  _real_num[typ]++;
  switch (typ) {
   case MSG_TYPE_DEBUG: if (gp_debug_disable) return; break;
   default: if (gp_message_disable) return;
  }
  gp_num[typ]++;
  if (gp_quiet) return;
  vsnprintf(buffer, sizeof buffer, Format, args);
  printf("%s: %s\n", Typ[typ], buffer);
}

CFUNC(void) gp_Message(msg_type_t typ, const char* Format, ...) {
  va_list va;
  va_start(va,Format);
  gp_vMessage(typ,Format,va);
  va_end(va);
}
Detected encoding: ASCII (7 bit)2