debug.c revision 34192
134192Sjdp/*-
234192Sjdp * Copyright 1996-1998 John D. Polstra.
334192Sjdp * All rights reserved.
434192Sjdp *
534192Sjdp * Redistribution and use in source and binary forms, with or without
634192Sjdp * modification, are permitted provided that the following conditions
734192Sjdp * are met:
834192Sjdp * 1. Redistributions of source code must retain the above copyright
934192Sjdp *    notice, this list of conditions and the following disclaimer.
1034192Sjdp * 2. Redistributions in binary form must reproduce the above copyright
1134192Sjdp *    notice, this list of conditions and the following disclaimer in the
1234192Sjdp *    documentation and/or other materials provided with the distribution.
1334192Sjdp *
1434192Sjdp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1534192Sjdp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1634192Sjdp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1734192Sjdp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1834192Sjdp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1934192Sjdp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2034192Sjdp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2134192Sjdp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2234192Sjdp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2334192Sjdp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2434192Sjdp *
2534192Sjdp *      $Id: debug.c,v 1.1 1998/03/05 21:05:48 jdp Exp $
2634192Sjdp */
2734192Sjdp
2834192Sjdp/*
2934192Sjdp * Support for printing debugging messages.
3034192Sjdp */
3134192Sjdp
3234192Sjdp#include <stdarg.h>
3334192Sjdp#include <stdio.h>
3434192Sjdp
3534192Sjdp#include "debug.h"
3634192Sjdp
3734192Sjdpint debug = 0;
3834192Sjdp
3934192Sjdpvoid
4034192Sjdpdebug_printf(const char *format, ...)
4134192Sjdp{
4234192Sjdp    if (debug) {
4334192Sjdp	va_list ap;
4434192Sjdp	va_start(ap, format);
4534192Sjdp
4634192Sjdp	fflush(stdout);
4734192Sjdp	vfprintf(stderr, format, ap);
4834192Sjdp	putc('\n', stderr);
4934192Sjdp
5034192Sjdp	va_end(ap);
5134192Sjdp    }
5234192Sjdp}
53