2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Formats a message and makes sure the user will see it.
9 #include <aros/config.h>
10 #include <aros/arossupportbase.h>
14 #include <aros/system.h>
15 #include <proto/exec.h>
16 #include <proto/arossupport.h>
20 #include <exec/execbase.h>
22 #define AROSBase ((struct AROSBase *)(SysBase->DebugData))
24 /* Can't use ctypt.h *sigh* */
25 #define isdigit(x) ((x) >= '0' && (x) <= '9')
26 #define isprint(x) (((x) >= ' ' && (x) <= 128) || (x) >= 160)
28 /*****************************************************************************
31 #include <proto/arossupport.h>
40 Formats fmt with the specified arguments like printf() (and *not*
41 like RawDoFmt()) and uses a secure way to deliver the message to
42 the user; ie. the user *will* see this message no matter what.
45 fmt - printf()-style format string
48 The number of characters output.
51 This function is not part of a library and may thus be called
63 24-12-95 digulla created
65 ******************************************************************************/
71 result
= vkprintf (fmt
, ap
);
79 int vkprintf (const UBYTE
* fmt
, va_list args
)
83 static const char uhex
[] = "0123456789ABCDEF";
84 static const char lhex
[] = "0123456789abcdef";
91 RawPutChars ("(null)", 6);
118 width
= va_arg (args
, int);
125 while (isdigit(*fmt
)) fmt
++;
128 if (*fmt
== '.') fmt
++;
132 precision
= va_arg (args
, int);
137 precision
= atoi (fmt
);
139 while (isdigit(*fmt
) || *fmt
=='.' || *fmt
=='-' || *fmt
=='+')
151 char * str
= va_arg (args
, char *);
168 RawPutChars (str
, len
);
181 char puffer
[sizeof (void *)*2];
184 t
= sizeof (void *)*2;
185 val
= va_arg (args
, ULONG
);
189 puffer
[--t
] = lhex
[val
& 0x0F];
193 RawPutChars (puffer
, sizeof (void *)*2);
200 c
= va_arg (args
, int);
206 RawPutChars ("'\\0x", 4);
207 RawPutChar (lhex
[c
/ 16]);
208 RawPutChar (lhex
[c
& 15]);
218 if (fmt
[1] == 'u' || fmt
[1] == 'd' || fmt
[1] == 'x' || fmt
[1] == 'X')
223 lval
= va_arg (args
, LONG
);
225 val
= (lval
< 0) ? -lval
: lval
;
229 val
= va_arg (args
, ULONG
);
243 RawPutChars (fill
, (width
< 8) ? width
: 8);
256 if (*fmt
== 'd' || *fmt
== 'u')
272 puffer
[--t
] = lhex
[val
% 10];
277 else if (*fmt
== 'x')
281 puffer
[--t
] = lhex
[val
& 0x0F];
290 puffer
[--t
] = uhex
[val
& 0x0F];
300 RawPutChars (fill
, (width
< 8) ? width
: 8);
304 RawPutChars (&puffer
[t
], 32-t
);
312 lval
= va_arg (args
, int);
314 val
= (lval
< 0) ? -lval
: lval
;
318 val
= va_arg (args
, unsigned int);
332 fmt
++; /* Next char */
333 } /* while (*fmt); */