/* debug.c -- definitions for debugging
   $Id: debug.c,v 1.7 2001/08/22 22:44:51 dpelleg Exp $

   Dan Pelleg
*/

#include <stdarg.h>
#include "ambs.h"
#include "debug.h"

/* operation counters, for debug and bragging purposes */
int dbg_counter[DBG_COUNTER_NUM];

/* bit-mask of messages to be printed */
int debug_level;

#ifdef __cplusplus
int omanip_dbg::debug_level;
ofstream omanip_dbg::cnull("/dev/null");
#endif /* __cplusplus */

void dbg_printf(const char *format, ...)
{
  va_list ap;
  va_start(ap, format);
  vfprintf(stderr, format, ap);
  va_end(ap);
}

void get_debug_flags_from_names(const char *const flag_names[], int argc, char *argv[])
{
  int i;
  for(i=0; flag_names[i] && flag_names[i][0]; i++) {
	int temp = index_of_arg(flag_names[i], argc, argv);
	if(temp != -1)
	  debug_level |= (1 << i);
  }
}
