sprintf.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* $Id$
  2. *
  3. * Copyright 2001-2003, Meiosys (www.meiosys.com). All rights reserved.
  4. *
  5. * See the COPYING file for the terms of usage and distribution.
  6. */
  7. #ifndef __sd_sprintf_h
  8. #define __sd_sprintf_h
  9. /**
  10. * @file sprintf.h
  11. *
  12. * @brief Formatted output conversion
  13. *
  14. * These functions write the output under the control of a format
  15. * string that specifies how subsequent arguments (or arguments
  16. * accessed via the variable-length argument facilities of stdarg(2))
  17. * are converted for output.
  18. *
  19. * They do not write more than \a size bytes, including the trailing
  20. * \c '\0'.
  21. *
  22. * These functions return the number of characters printed (not
  23. * including the trailing \c `\0' used to end output to strings). They
  24. * return -1 if the output was truncated due to the @a size limit.
  25. *
  26. */
  27. #include <stdarg.h>
  28. #include <stddef.h>
  29. #include <sd/defs.h>
  30. __SD_BEGIN_DECLS
  31. /**
  32. * Same as fprintf(3) with auto-allocation of the resulting buffer,
  33. * and output directly in a file, not a stream.
  34. */
  35. extern int sd_fprintf(int fd, const char *fmt, ...);
  36. /**
  37. * Same as sprintf(3) with auto-allocation of the resulting buffer.
  38. */
  39. extern char* sd_sprintf(const char* a_fmt, ...);
  40. /**
  41. * Same as vsprintf(3) with auto-allocation of the resulting buffer.
  42. */
  43. extern char* sd_vsprintf(const char* a_fmt, va_list a_arg);
  44. #if defined(__osf__)
  45. extern int snprintf(char* str, size_t size, const char* fmt, ...);
  46. extern int vsnprintf(char* str, size_t size, const char* fmt, va_list arg);
  47. #endif
  48. __SD_END_DECLS
  49. #endif