Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  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. ANSI_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. _DEFUN(_diprintf_r, (ptr, fd, format),
  53.        struct _reent *ptr _AND
  54.        int fd _AND
  55.        const char *format _DOTS)
  56. {
  57.   va_list ap;
  58.   int n;
  59.  
  60.   va_start (ap, format);
  61.   n = _vdiprintf_r (ptr, fd, format, ap);
  62.   va_end (ap);
  63.   return n;
  64. }
  65.  
  66. #ifndef _REENT_ONLY
  67.  
  68. int
  69. _DEFUN(diprintf, (fd, format),
  70.        int fd _AND
  71.        const char *format _DOTS)
  72. {
  73.   va_list ap;
  74.   int n;
  75.  
  76.   va_start (ap, format);
  77.   n = _vdiprintf_r (_REENT, fd, format, ap);
  78.   va_end (ap);
  79.   return n;
  80. }
  81.  
  82. #endif /* ! _REENT_ONLY */
  83.