Deleted Added
sdiff udiff text old ( 18018 ) new ( 20425 )
full compact
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * $Id: show.c,v 1.3 1996/09/01 10:21:43 peter Exp $
37 */
38
39#ifndef lint
40static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95";
41#endif /* not lint */
42
43#include <stdio.h>
44#if __STDC__
45#include <stdarg.h>
46#else
47#include <varargs.h>
48#endif

--- 215 unchanged lines hidden (view full) ---

264 int i;
265
266 for (i = 0 ; i < amount ; i++) {
267 if (pfx && i == amount - 1)
268 fputs(pfx, fp);
269 putc('\t', fp);
270 }
271}
272#endif
273
274
275
276/*
277 * Debugging stuff.
278 */
279
280
281FILE *tracefile;
282
283#if DEBUG == 2
284int debug = 1;
285#else
286int debug = 0;
287#endif
288
289
290void
291trputc(c)
292 int c;
293{
294#ifdef DEBUG
295 if (tracefile == NULL)
296 return;
297 putc(c, tracefile);
298 if (c == '\n')
299 fflush(tracefile);
300#endif
301}
302
303void
304#if __STDC__
305shtrace(const char *fmt, ...)
306#else
307shtrace(va_alist)
308 va_dcl
309#endif
310{
311#ifdef DEBUG
312 va_list va;
313#if __STDC__
314 va_start(va, fmt);
315#else
316 char *fmt;
317 va_start(va);
318 fmt = va_arg(va, char *);
319#endif
320 if (tracefile != NULL) {
321 (void) vfprintf(tracefile, fmt, va);
322 if (strchr(fmt, '\n'))
323 (void) fflush(tracefile);
324 }
325 va_end(va);
326#endif
327}
328
329
330void
331trputs(s)
332 char *s;
333{
334#ifdef DEBUG
335 if (tracefile == NULL)
336 return;
337 fputs(s, tracefile);
338 if (strchr(s, '\n'))
339 fflush(tracefile);
340#endif
341}
342
343
344#ifdef DEBUG
345static void
346trstring(s)
347 char *s;
348{
349 register char *p;
350 char c;
351
352 if (tracefile == NULL)

--- 23 unchanged lines hidden (view full) ---

376 putc(*p >> 3 & 07, tracefile);
377 putc(*p & 07, tracefile);
378 }
379 break;
380 }
381 }
382 putc('"', tracefile);
383}
384#endif
385
386
387void
388trargs(ap)
389 char **ap;
390{
391#ifdef DEBUG
392 if (tracefile == NULL)
393 return;
394 while (*ap) {
395 trstring(*ap++);
396 if (*ap)
397 putc(' ', tracefile);
398 else
399 putc('\n', tracefile);
400 }
401 fflush(tracefile);
402#endif
403}
404
405
406void
407opentrace() {
408#ifdef DEBUG
409 char s[100];
410 char *getenv();
411#ifdef O_APPEND
412 int flags;
413#endif
414
415 if (!debug)
416 return;

--- 17 unchanged lines hidden (view full) ---

434 return;
435 }
436#ifdef O_APPEND
437 if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)
438 fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
439#endif
440 fputs("\nTracing started.\n", tracefile);
441 fflush(tracefile);
442#endif /* DEBUG */
443}