Subversion Repositories HelenOS-historic

Rev

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

Rev 1226 Rev 1229
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 '\n' to the end.
84
 *
84
 *
85
 * Dont 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)
89
{
89
{
90
    int count;
90
    int count;
Line 96... Line 96...
96
        putchar(str[count]);
96
        putchar(str[count]);
97
    }
97
    }
98
    return count;
98
    return count;
99
}
99
}
100
 
100
 
101
/** Print count characters from buffer to output
101
/** Print count characters from buffer to output.
102
 *
102
 *
-
 
103
 * @param buffer Address of the buffer with charaters to be printed.
-
 
104
 * @param count Number of characters to be printed.
-
 
105
 *
-
 
106
 * @return Number of characters printed.
103
 */
107
 */
104
static int putnchars(const char *buffer, __native count)
108
static int putnchars(const char *buffer, __native count)
105
{
109
{
106
    int i;
110
    int i;
107
    if (buffer == NULL) {
111
    if (buffer == NULL) {
Line 116... Line 120...
116
    return count;
120
    return count;
117
}
121
}
118
 
122
 
119
/** Print one formatted character
123
/** Print one formatted character
120
 *
124
 *
121
 * @param c character to print
125
 * @param c Character to print.
122
 * @param width
126
 * @param width
123
 * @param flags
127
 * @param flags
124
 * @return number of printed characters or EOF
128
 * @return Number of printed characters or EOF.
125
 */
129
 */
126
static int print_char(char c, int width, __u64 flags)
130
static int print_char(char c, int width, __u64 flags)
127
{
131
{
128
    int counter = 0;
132
    int counter = 0;
129
   
133
   
Line 347... Line 351...
347
    }
351
    }
348
 
352
 
349
    return written;
353
    return written;
350
}
354
}
351
 
355
 
352
/** General formatted text print
356
/** Print formatted string.
353
 *
357
 *
354
 * Print string formatted according to the fmt parameter
358
 * Print string formatted according to the @fmt parameter
355
 * and variadic arguments. Each formatting directive
359
 * and variadic arguments. Each formatting directive
356
 * must have the following form:
360
 * must have the following form:
357
 * % [ flags ] [ width ] [ .precision ] [ type ] conversion
361
 * % [ flags ] [ width ] [ .precision ] [ type ] conversion
358
 *
362
 *
359
 * FLAGS:
363
 * FLAGS:
360
 * #    Force to print prefix.
364
 * #    Force to print prefix.
361
 *  For conversion %o the prefix is 0, for %x and %X prefixes are 0x and 0X and for conversion %b the prefix is 0b.
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.
362
 * -    Align to left.
366
 * -    Align to left.
363
 * +    Print positive sign just as negative.
367
 * +    Print positive sign just as negative.
364
 *   (space)    If printed number is positive and '+' flag is not set, print space in place of sign.
368
 *   (space)    If the printed number is positive and '+' flag is not set, print space in place of sign.
365
 * 0    Print 0 as padding instead of spaces. Zeroes are placed between sign and the rest of number.
369
 * 0    Print 0 as padding instead of spaces. Zeroes are placed between sign and the rest of the number.
366
 *  This flag is ignored if '-' flag is specified.
370
 *  This flag is ignored if '-' flag is specified.
367
 *
371
 *
368
 * WIDTH:
372
 * WIDTH:
369
 * Specify minimal width of printed argument. If it is bigger, width is ignored.
373
 * Specify minimal width of printed argument. If it is bigger, width is ignored.
370
 * If width is specified with a '*' character instead of number, width is taken from parameter list.
374
 * If width is specified with a '*' character instead of number, width is taken from parameter list.
371
 * Int parameter expected before parameter for processed conversion specification.
375
 * And integer parameter is expected before parameter for processed conversion specification.
372
 * If this value is negative its absolute value is taken and the '-' flag is set.
376
 * If this value is negative its absolute value is taken and the '-' flag is set.
373
 *
377
 *
374
 * PRECISION:
378
 * PRECISION:
375
 * Value precision. For numbers it specifies minimum valid numbers.
379
 * Value precision. For numbers it specifies minimum valid numbers.
376
 * Smaller numbers are printed with leading zeroes. Bigger numbers are not affected.
380
 * Smaller numbers are printed with leading zeroes. Bigger numbers are not affected.
Line 388... Line 392...
388
 * z    __native (non-standard extension)
392
 * z    __native (non-standard extension)
389
 *
393
 *
390
 *
394
 *
391
 * CONVERSIONS:
395
 * CONVERSIONS:
392
 *
396
 *
393
 * %    Print percentage character.
397
 * %    Print percentage character itself.
394
 *
398
 *
395
 * c    Print single character.
399
 * c    Print single character.
396
 *
400
 *
397
 * s    Print zero terminated string. If a NULL value is passed as value, "(NULL)" is printed instead.
401
 * s    Print zero terminated string. If a NULL value is passed as value, "(NULL)" is printed instead.
398
 *
402
 *
399
 * P, p Print value of a pointer. Void * value is expected and it is printed in hexadecimal notation with prefix
403
 * P, p Print value of a pointer. Void * value is expected and it is printed in hexadecimal notation with prefix
400
 * ( as with %#X or %#x for 32bit or %#X / %#x for 64bit long pointers).
404
 * (as with %#X or %#x for 32bit or %#X / %#x for 64bit long pointers).
401
 *
405
 *
402
 * b    Print value as unsigned binary number. Prefix is not printed by default. (Nonstandard extension.)
406
 * b    Print value as unsigned binary number. Prefix is not printed by default. (Nonstandard extension.)
403
 *
407
 *
404
 * o    Print value as unsigned octal number. Prefix is not printed by default.
408
 * o    Print value as unsigned octal number. Prefix is not printed by default.
405
 *
409
 *
406
 * d,i  Print signed decimal number. There is no difference between d and i conversion.
410
 * d,i  Print signed decimal number. There is no difference between d and i conversion.
407
 *
411
 *
408
 * u    Print unsigned decimal number.
412
 * u    Print unsigned decimal number.
409
 *
413
 *
410
 * X, x Print hexadecimal number with upper- or lower-case. Prefix is not printed by default.
414
 * X, x Print hexadecimal number with upper- or lower-case. Prefix is not printed by default.
411
 *
415
 *
412
 * All other characters from fmt except the formatting directives
416
 * All other characters from @fmt except the formatting directives
413
 * are printed in verbatim.
417
 * are printed in verbatim.
414
 *
418
 *
415
 * @param fmt Formatting NULL terminated string.
419
 * @param fmt Formatting NULL terminated string.
416
 * @return count of printed characters or negative value on fail.
420
 * @return Number of printed characters or negative value on failure.
417
 */
421
 */
418
int printf(const char *fmt, ...)
422
int printf(const char *fmt, ...)
419
{
423
{
420
    int irqpri;
424
    int irqpri;
421
    int i = 0, j = 0; /* i is index of currently processed char from fmt, j is index to the first not printed nonformating character */
425
    int i = 0, j = 0; /* i is index of currently processed char from fmt, j is index to the first not printed nonformating character */