minix/external/bsd/nvi/dist/common/trace.c
Lionel Sambuc 84d9c625bf Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
2014-07-28 17:05:06 +02:00

82 lines
1.3 KiB
C

/* $NetBSD: trace.c,v 1.3 2013/11/29 16:36:11 christos Exp $ */
/*-
* Copyright (c) 1996
* Rob Zimmermann. All rights reserved.
* Copyright (c) 1996
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
*/
#include "config.h"
#ifndef lint
static const char sccsid[] = "Id: trace.c,v 8.4 1997/08/03 15:04:23 bostic Exp (Berkeley) Date: 1997/08/03 15:04:23 ";
#endif /* not lint */
#include <sys/queue.h>
#include <bitstring.h>
#include <stdio.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "common.h"
#ifdef TRACE
static FILE *tfp;
/*
* vtrace_end --
* End tracing.
*
* PUBLIC: void vtrace_end __P((void));
*/
void
vtrace_end(void)
{
if (tfp != NULL && tfp != stderr)
(void)fclose(tfp);
}
/*
* vtrace_init --
* Initialize tracing.
*
* PUBLIC: void vtrace_init __P((const char *));
*/
void
vtrace_init(const char *name)
{
if (name == NULL || (tfp = fopen(name, "w")) == NULL)
tfp = stderr;
vtrace("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nTRACE\n");
}
/*
* vtrace --
* Debugging trace routine.
*
* PUBLIC: void vtrace __P((const char *, ...));
*/
void
vtrace(const char *fmt, ...)
{
va_list ap;
if (tfp == NULL)
vtrace_init(NULL);
va_start(ap, fmt);
(void)vfprintf(tfp, fmt, ap);
va_end(ap);
(void)fflush(tfp);
}
#endif