Rev 1229 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1229 | Rev 1249 | ||
---|---|---|---|
Line 78... | Line 78... | ||
78 | } |
78 | } |
79 | 79 | ||
80 | return counter; |
80 | return counter; |
81 | } |
81 | } |
82 | 82 | ||
83 | /** Print one string without appending '\n' to the end. |
83 | /** Print one string without appending newline to the end. |
84 | * |
84 | * |
85 | * Do not use this function directly - printflock is not locked here. |
85 | * Do not use this function directly - printflock is not locked here. |
86 | * |
86 | * |
87 | */ |
87 | */ |
88 | static int putstr(const char *str) |
88 | static int putstr(const char *str) |
Line 353... | Line 353... | ||
353 | return written; |
353 | return written; |
354 | } |
354 | } |
355 | 355 | ||
356 | /** Print formatted string. |
356 | /** Print formatted string. |
357 | * |
357 | * |
358 | * Print string formatted according to the @fmt parameter |
358 | * Print string formatted according to the fmt parameter |
359 | * and variadic arguments. Each formatting directive |
359 | * and variadic arguments. Each formatting directive |
360 | * must have the following form: |
360 | * must have the following form: |
- | 361 | * |
|
361 | * % [ flags ] [ width ] [ .precision ] [ type ] conversion |
362 | * \% [ FLAGS ] [ WIDTH ] [ .PRECISION ] [ TYPE ] CONVERSION |
- | 363 | * |
|
- | 364 | * FLAGS:@n |
|
- | 365 | * "#" Force to print prefix. |
|
- | 366 | * For conversion \%o the prefix is 0, for %x and \%X prefixes are 0x and 0X |
|
- | 367 | * and for conversion \%b the prefix is 0b. |
|
- | 368 | * |
|
- | 369 | * "-" Align to left. |
|
362 | * |
370 | * |
363 | * FLAGS: |
- | |
364 | * # Force to print prefix. |
- | |
365 | * For conversion %o the prefix is 0, for %x and %X prefixes are 0x and 0X and for conversion %b the prefix is 0b. |
- | |
366 | * - Align to left. |
- | |
367 | * + Print positive sign just as negative. |
371 | * "+" Print positive sign just as negative. |
- | 372 | * |
|
368 | * (space) If the printed number is positive and '+' flag is not set, print space in place of sign. |
373 | * " " If the printed number is positive and "+" flag is not set, print space in |
- | 374 | * place of sign. |
|
- | 375 | * |
|
369 | * 0 Print 0 as padding instead of spaces. Zeroes are placed between sign and the rest of the number. |
376 | * "0" Print 0 as padding instead of spaces. Zeroes are placed between sign and the |
370 | * This flag is ignored if '-' flag is specified. |
377 | * rest of the number. This flag is ignored if "-" flag is specified. |
371 | * |
378 | * |
372 | * WIDTH: |
379 | * WIDTH:@n |
373 | * Specify minimal width of printed argument. If it is bigger, width is ignored. |
380 | * Specify minimal width of printed argument. If it is bigger, width is ignored. |
374 | * If width is specified with a '*' character instead of number, width is taken from parameter list. |
381 | * If width is specified with a "*" character instead of number, width is taken from |
375 | * And integer parameter is expected before parameter for processed conversion specification. |
382 | * parameter list. And integer parameter is expected before parameter for processed |
376 | * If this value is negative its absolute value is taken and the '-' flag is set. |
383 | * conversion specification. If this value is negative its absolute value is taken |
- | 384 | * and the "-" flag is set. |
|
377 | * |
385 | * |
378 | * PRECISION: |
386 | * PRECISION:@n |
379 | * Value precision. For numbers it specifies minimum valid numbers. |
387 | * Value precision. For numbers it specifies minimum valid numbers. |
380 | * Smaller numbers are printed with leading zeroes. Bigger numbers are not affected. |
388 | * Smaller numbers are printed with leading zeroes. Bigger numbers are not affected. |
381 | * Strings with more than precision characters are cut off. |
389 | * Strings with more than precision characters are cut off. |
382 | * Just as with width, an '*' can be used used instead of a number. |
390 | * Just as with width, an "*" can be used used instead of a number. |
383 | * An integer value is then expected in parameters. When both width and precision are specified using '*', |
391 | * An integer value is then expected in parameters. When both width and precision |
384 | * first parameter is used for width and second one for precision. |
392 | * are specified using "*", the first parameter is used for width and the second one |
385 | * |
- | |
386 | * TYPE: |
- | |
387 | * hh signed or unsigned char |
- | |
388 | * h signed or usigned short |
393 | * for precision. |
389 | * signed or usigned int (default value) |
- | |
390 | * l signed or usigned long int |
- | |
391 | * ll signed or usigned long long int |
- | |
392 | * z __native (non-standard extension) |
- | |
393 | * |
394 | * |
- | 395 | * TYPE:@n |
|
- | 396 | * "hh" Signed or unsigned char.@n |
|
- | 397 | * "h" Signed or usigned short.@n |
|
- | 398 | * "" Signed or usigned int (default value).@n |
|
- | 399 | * "l" Signed or usigned long int.@n |
|
- | 400 | * "ll" Signed or usigned long long int.@n |
|
- | 401 | * "z" __native (non-standard extension).@n |
|
394 | * |
402 | * |
395 | * CONVERSIONS: |
- | |
396 | * |
403 | * |
- | 404 | * CONVERSION:@n |
|
397 | * % Print percentage character itself. |
405 | * % Print percentile character itself. |
398 | * |
406 | * |
399 | * c Print single character. |
407 | * c Print single character. |
400 | * |
408 | * |
401 | * s Print zero terminated string. If a NULL value is passed as value, "(NULL)" is printed instead. |
409 | * s Print zero terminated string. If a NULL value is passed as value, "(NULL)" is printed instead. |
402 | * |
410 | * |
403 | * P, p Print value of a pointer. Void * value is expected and it is printed in hexadecimal notation with prefix |
411 | * P, p Print value of a pointer. Void * value is expected and it is printed in hexadecimal notation with prefix |
404 | * (as with %#X or %#x for 32bit or %#X / %#x for 64bit long pointers). |
412 | * (as with \%#X or \%#x for 32bit or \%#X / \%#x for 64bit long pointers). |
405 | * |
413 | * |
406 | * b Print value as unsigned binary number. Prefix is not printed by default. (Nonstandard extension.) |
414 | * b Print value as unsigned binary number. Prefix is not printed by default. (Nonstandard extension.) |
407 | * |
415 | * |
408 | * o Print value as unsigned octal number. Prefix is not printed by default. |
416 | * o Print value as unsigned octal number. Prefix is not printed by default. |
409 | * |
417 | * |
Line 411... | Line 419... | ||
411 | * |
419 | * |
412 | * u Print unsigned decimal number. |
420 | * u Print unsigned decimal number. |
413 | * |
421 | * |
414 | * X, x Print hexadecimal number with upper- or lower-case. Prefix is not printed by default. |
422 | * X, x Print hexadecimal number with upper- or lower-case. Prefix is not printed by default. |
415 | * |
423 | * |
416 | * All other characters from @fmt except the formatting directives |
424 | * All other characters from fmt except the formatting directives |
417 | * are printed in verbatim. |
425 | * are printed in verbatim. |
418 | * |
426 | * |
419 | * @param fmt Formatting NULL terminated string. |
427 | * @param fmt Formatting NULL terminated string. |
420 | * @return Number of printed characters or negative value on failure. |
428 | * @return Number of printed characters or negative value on failure. |
421 | */ |
429 | */ |