[444] | 1 | /* Copyright (C) 2005, 2007 Shaun Jackman |
---|
| 2 | * Permission to use, copy, modify, and distribute this software |
---|
| 3 | * is freely granted, provided that this notice is preserved. |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | /* |
---|
| 7 | FUNCTION |
---|
| 8 | <<diprintf>>, <<vdiprintf>>---print to a file descriptor (integer only) |
---|
| 9 | |
---|
| 10 | INDEX |
---|
| 11 | diprintf |
---|
| 12 | INDEX |
---|
| 13 | _diprintf_r |
---|
| 14 | INDEX |
---|
| 15 | vdiprintf |
---|
| 16 | INDEX |
---|
| 17 | _vdiprintf_r |
---|
| 18 | |
---|
| 19 | SYNOPSIS |
---|
| 20 | #include <stdio.h> |
---|
| 21 | #include <stdarg.h> |
---|
| 22 | int diprintf(int <[fd]>, const char *<[format]>, ...); |
---|
| 23 | int vdiprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>); |
---|
| 24 | int _diprintf_r(struct _reent *<[ptr]>, int <[fd]>, |
---|
| 25 | const char *<[format]>, ...); |
---|
| 26 | int _vdiprintf_r(struct _reent *<[ptr]>, int <[fd]>, |
---|
| 27 | const char *<[format]>, va_list <[ap]>); |
---|
| 28 | |
---|
| 29 | DESCRIPTION |
---|
| 30 | <<diprintf>> and <<vdiprintf>> are similar to <<dprintf>> and <<vdprintf>>, |
---|
| 31 | except that only integer format specifiers are processed. |
---|
| 32 | |
---|
| 33 | The functions <<_diprintf_r>> and <<_vdiprintf_r>> are simply |
---|
| 34 | reentrant versions of the functions above. |
---|
| 35 | |
---|
| 36 | RETURNS |
---|
| 37 | Similar to <<dprintf>> and <<vdprintf>>. |
---|
| 38 | |
---|
| 39 | PORTABILITY |
---|
| 40 | This set of functions is an integer-only extension, and is not portable. |
---|
| 41 | |
---|
| 42 | Supporting OS subroutines required: <<sbrk>>, <<write>>. |
---|
| 43 | */ |
---|
| 44 | |
---|
| 45 | #include <_ansi.h> |
---|
| 46 | #include <reent.h> |
---|
| 47 | #include <stdio.h> |
---|
| 48 | #include <unistd.h> |
---|
| 49 | #include <stdarg.h> |
---|
| 50 | |
---|
| 51 | int |
---|
| 52 | _diprintf_r (struct _reent *ptr, |
---|
| 53 | int fd, |
---|
| 54 | const char *format, ...) |
---|
| 55 | { |
---|
| 56 | va_list ap; |
---|
| 57 | int n; |
---|
| 58 | |
---|
| 59 | va_start (ap, format); |
---|
| 60 | n = _vdiprintf_r (ptr, fd, format, ap); |
---|
| 61 | va_end (ap); |
---|
| 62 | return n; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | #ifndef _REENT_ONLY |
---|
| 66 | |
---|
| 67 | int |
---|
| 68 | diprintf (int fd, |
---|
| 69 | const char *format, ...) |
---|
| 70 | { |
---|
| 71 | va_list ap; |
---|
| 72 | int n; |
---|
| 73 | |
---|
| 74 | va_start (ap, format); |
---|
| 75 | n = _vdiprintf_r (_REENT, fd, format, ap); |
---|
| 76 | va_end (ap); |
---|
| 77 | return n; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | #endif /* ! _REENT_ONLY */ |
---|