Subversion Repositories HelenOS-historic

Rev

Rev 1196 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1196 Rev 1198
Line 206... Line 206...
206
 * @param width
206
 * @param width
207
 * @param precision
207
 * @param precision
208
 * @param base Base to print the number in (should
208
 * @param base Base to print the number in (should
209
 *             be in range 2 .. 16).
209
 *             be in range 2 .. 16).
210
 * @param flags output modifiers
210
 * @param flags output modifiers
211
 * @return number of written characters or EOF
211
 * @return number of written characters or negative value on fail.
212
 *
-
 
213
 */
212
 */
214
static int print_number(__u64 num, int width, int precision, int base , __u64 flags)
213
static int print_number(__u64 num, int width, int precision, int base , __u64 flags)
215
{
214
{
216
    char *digits = digits_small;
215
    char *digits = digits_small;
217
    char d[PRINT_NUMBER_BUFFER_SIZE];   /* this is good enough even for base == 2, prefix and sign */
216
    char d[PRINT_NUMBER_BUFFER_SIZE];   /* this is good enough even for base == 2, prefix and sign */
Line 343... Line 342...
343
    }
342
    }
344
 
343
 
345
    return written;
344
    return written;
346
}
345
}
347
 
346
 
348
 
-
 
349
 
-
 
350
/** General formatted text print
347
/** General formatted text print
351
 *
348
 *
352
 * Print text formatted according the fmt parameter
349
 * Print string formatted according the fmt parameter
353
 * and variant arguments. Each formatting directive
350
 * and variant arguments. Each formatting directive
354
 * begins with \% (percentage) character and one of the
-
 
355
 * following character:
351
 * must have the following form:
356
 *
-
 
357
 * \%    Prints the percentage character.
-
 
358
 *
-
 
359
 * s    The next variant argument is treated as char*
-
 
360
 *      and printed as a NULL terminated string.
-
 
361
 *
-
 
362
 * c    The next variant argument is treated as a single char.
-
 
363
 *
-
 
364
 * p    The next variant argument is treated as a maximum
-
 
365
 *      bit-width integer with respect to architecture
352
 * % [ flags ] [ width ] [ .precision ] [ type ] conversion
366
 *      and printed in full hexadecimal width.
-
 
367
 *
-
 
368
 * P    As with 'p', but '0x' is prefixed.
-
 
369
 *
-
 
370
 * q    The next variant argument is treated as a 64b integer
-
 
371
 *      and printed in full hexadecimal width.
-
 
372
 *
-
 
373
 * Q    As with 'q', but '0x' is prefixed.
-
 
374
 *
-
 
375
 * l    The next variant argument is treated as a 32b integer
-
 
376
 *      and printed in full hexadecimal width.
-
 
377
 *
-
 
378
 * L    As with 'l', but '0x' is prefixed.
-
 
379
 *
-
 
380
 * w    The next variant argument is treated as a 16b integer
-
 
381
 *      and printed in full hexadecimal width.
-
 
382
 *
-
 
383
 * W    As with 'w', but '0x' is prefixed.
-
 
384
 *
-
 
385
 * b    The next variant argument is treated as a 8b integer
-
 
386
 *      and printed in full hexadecimal width.
-
 
387
 *
-
 
388
 * B    As with 'b', but '0x' is prefixed.
-
 
389
 *
353
 *
-
 
354
 * FLAGS:
-
 
355
 * #    Force to print prefix. For conversion %o is prefix 0, for %x and %X are prefixes 0x and 0X and for conversion %b is prefix 0b.
-
 
356
 * -    Align to left.
-
 
357
 * +    Print positive sign just as negative.
-
 
358
 *   (space)    If printed number is positive and '+' flag is not set, print space in place of sign.
-
 
359
 * 0    Print 0 as padding instead of spaces. Zeroes are placed between sign and the rest of number. This flag is ignored if '-' flag is specified.
-
 
360
 *
-
 
361
 * WIDTH:
-
 
362
 * Specify minimal width of printed argument. If it is bigger, width is ignored.
-
 
363
 * If width is specified with a '*' character instead of number, width is taken from parameter list.
-
 
364
 * Int parameter expected before parameter for processed conversion specification.
-
 
365
 * If this value is negative it is taken its absolute value and the '-' flag is set.
-
 
366
 *
-
 
367
 * PRECISION:
-
 
368
 * Value precision. For numbers it specifies minimum valid numbers.
-
 
369
 * Smaller numbers are printed with leading zeroes. Bigger numbers are not affected.
-
 
370
 * Strings with more than precision characters are cutted of.
390
 * d    The next variant argument is treated as integer
371
 * Just as width could be '*' used instead a number.
-
 
372
 * A int value is then expected in parameters. When both width and precision are specified using '*',
391
 *      and printed in standard decimal format (only significant
373
 * first parameter is used for width and second one for precision.
-
 
374
 *
-
 
375
 * TYPE:
-
 
376
 * hh   signed or unsigned char
-
 
377
 * h    signed or usigned short
-
 
378
 *  signed or usigned int (default value)
-
 
379
 * l    signed or usigned long int
-
 
380
 * ll   signed or usigned long long int
-
 
381
 * z    __native (non-standard extension)
-
 
382
 *
-
 
383
 *
392
 *      digits).
384
 * CONVERSIONS:
-
 
385
 *
-
 
386
 * %    Print percentage character.
-
 
387
 *
-
 
388
 * c    Print single character.
-
 
389
 *
-
 
390
 * s    Print zero terminated string. If a NULL value is passed as value, "(NULL)" is printed instead.
-
 
391
 *
-
 
392
 * P, p Print value of a pointer. Void * value is expected and it is printed in hexadecimal notation with prefix
-
 
393
 * ( as with %#X or %#x for 32bit or %#X / %#x for 64bit long pointers).
-
 
394
 *
-
 
395
 * b    Print value as unsigned binary number. Prefix is not printed by default. (Nonstandard extension.)
-
 
396
 *
-
 
397
 * o    Print value as unsigned octal number. Prefix is not printed by default.
393
 *
398
 *
394
 * x    The next variant argument is treated as integer
-
 
395
 *      and printed in standard hexadecimal format (only significant
399
 * d,i  Print signed decimal number. There is no difference between d and i conversion.
396
 *      digits).
-
 
397
 *
400
 *
398
 * X    As with 'x', but '0x' is prefixed.
401
 * u    Print unsigned decimal number.
399
 *
402
 *
-
 
403
 * X, x Print hexadecimal number with upper- or lower-case. Prefix is not printed by default.
-
 
404
 *
400
 * All other characters from fmt except the formatting directives
405
 * All other characters from fmt except the formatting directives
401
 * are printed in verbatim.
406
 * are printed in verbatim.
402
 *
407
 *
403
 * @param fmt Formatting NULL terminated string.
408
 * @param fmt Formatting NULL terminated string.
-
 
409
 * @return count of printed characters or negative value on fail.
404
 */
410
 */
405
int printf(const char *fmt, ...)
411
int printf(const char *fmt, ...)
406
{
412
{
407
    int irqpri;
413
    int irqpri;
408
    int i = 0, j = 0; /* i is index of currently processed char from fmt, j is index to the first not printed nonformating character */
414
    int i = 0, j = 0; /* i is index of currently processed char from fmt, j is index to the first not printed nonformating character */