1 /* -----------------------------------------------------------------------------
4 * This file provides some I/O routines so that WAD can produce
5 * debugging output without using buffered I/O.
7 * Author(s) : David Beazley (beazley@cs.uchicago.edu)
9 * Copyright (C) 2000. The University of Chicago.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * See the file COPYING for a complete copy of the LGPL.
26 * ----------------------------------------------------------------------------- */
31 static char cvs[] = "$Id: io.c 10001 2007-10-17 21:33:57Z wsfulton $";
33 /* Utility functions used to generate strings that are guaranteed not to
34 rely upon malloc() and related functions */
36 char *wad_format_hex(unsigned long u, int leading) {
37 static char result[64];
42 for (i = 0; i < (sizeof(unsigned long)*2); i++) {
51 if (!u && !leading) break;
57 char *wad_format_unsigned(unsigned long u, int width) {
58 static char result[128];
59 static char digits[] = "0123456789";
66 *(--c) = digits[digit];
75 for (i = count; i < width; i++) {
82 char *wad_format_signed(signed long s, int width) {
83 static char result[128];
89 u = (unsigned long) (-s);
91 u = (unsigned long) s;
94 u = (unsigned long) s;
97 wad_strcat(result, wad_format_unsigned(u,width));
102 void wad_printf(const char *fmt, ...) {
105 vfprintf(stderr,fmt,ap);