2 Copyright © 1995-2007, 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>
16 #include <proto/exec.h>
17 #include <proto/arossupport.h>
21 #include <exec/execbase.h>
23 #define AROSBase ((struct AROSBase *)(SysBase->DebugData))
25 /* Can't use ctypt.h *sigh* */
26 #define isdigit(x) ((x) >= '0' && (x) <= '9')
27 #define isprint(x) (((x) >= ' ' && (x) <= 128) || (x) >= 160)
29 /*****************************************************************************
32 #include <proto/arossupport.h>
41 Formats fmt with the specified arguments like printf() (and *not*
42 like RawDoFmt()) and uses a secure way to deliver the message to
43 the user; ie. the user *will* see this message no matter what.
46 fmt - printf()-style format string
49 The number of characters output.
52 This function is not part of a library and may thus be called
64 24-12-95 digulla created
66 ******************************************************************************/
72 result
= vkprintf (fmt
, ap
);
80 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
=='+')
150 #ifndef AROS_FAST_BPTR
152 char * str
= va_arg (args
, char *);
156 str
= (char *)((unsigned long)str
<< 2);
166 RawPutChars (str
, len
);
173 char * str
= va_arg (args
, char *);
190 RawPutChars (str
, len
);
203 char puffer
[sizeof (void *)*2];
206 t
= sizeof (void *)*2;
207 val
= va_arg (args
, IPTR
);
211 puffer
[--t
] = lhex
[val
& 0x0F];
215 RawPutChars (puffer
, sizeof (void *)*2);
222 c
= va_arg (args
, int);
228 RawPutChars ("'\\0x", 4);
229 RawPutChar (lhex
[c
/ 16]);
230 RawPutChar (lhex
[c
& 15]);
240 if (fmt
[1] == 'u' || fmt
[1] == 'd' || fmt
[1] == 'x' || fmt
[1] == 'X')
245 lval
= va_arg (args
, LONG
);
247 val
= (lval
< 0) ? -lval
: lval
;
251 val
= va_arg (args
, ULONG
);
265 RawPutChars (fill
, (width
< 8) ? width
: 8);
278 if (*fmt
== 'd' || *fmt
== 'u')
294 puffer
[--t
] = lhex
[val
% 10];
299 else if (*fmt
== 'x')
303 puffer
[--t
] = lhex
[val
& 0x0F];
312 puffer
[--t
] = uhex
[val
& 0x0F];
322 RawPutChars (fill
, (width
< 8) ? width
: 8);
326 RawPutChars (&puffer
[t
], 32-t
);
334 lval
= va_arg (args
, int);
336 val
= (lval
< 0) ? -lval
: lval
;
340 val
= va_arg (args
, unsigned int);
354 fmt
++; /* Next char */
355 } /* while (*fmt); */