sfio.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #pragma once
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /* Public header file for the sfio library
  15. **
  16. ** Written by Kiem-Phong Vo
  17. */
  18. #include "config.h"
  19. #include <limits.h>
  20. #include <stdio.h>
  21. #include <sys/types.h>
  22. /* formatting environment */
  23. typedef struct _sffmt_s Sffmt_t;
  24. typedef int (*Sffmtext_f)(void *, Sffmt_t *);
  25. struct _sffmt_s {
  26. Sffmtext_f extf; /* function to process arguments */
  27. char *form; /* format string to stack */
  28. int fmt; /* format character */
  29. ssize_t size; /* object size */
  30. int flags; /* formatting flags */
  31. int width; /* width of field */
  32. int precis; /* precision required */
  33. int base; /* conversion base */
  34. const char *t_str; /* type string */
  35. ssize_t n_str; /* length of t_str */
  36. };
  37. #define SFFMT_SSHORT 00000010 /* 'hh' flag, char */
  38. #define SFFMT_TFLAG 00000020 /* 't' flag, ptrdiff_t */
  39. #define SFFMT_ZFLAG 00000040 /* 'z' flag, size_t */
  40. #define SFFMT_LEFT 00000100 /* left-justification */
  41. #define SFFMT_SIGN 00000200 /* must have a sign */
  42. #define SFFMT_BLANK 00000400 /* if not signed, prepend a blank */
  43. #define SFFMT_ZERO 00001000 /* zero-padding on the left */
  44. #define SFFMT_ALTER 00002000 /* alternate formatting */
  45. #define SFFMT_THOUSAND 00004000 /* thousand grouping */
  46. #define SFFMT_SKIP 00010000 /* skip assignment in scanf() */
  47. #define SFFMT_SHORT 00020000 /* 'h' flag */
  48. #define SFFMT_LONG 00040000 /* 'l' flag */
  49. #define SFFMT_LLONG 00100000 /* 'll' flag */
  50. #define SFFMT_LDOUBLE 00200000 /* 'L' flag */
  51. #define SFFMT_VALUE 00400000 /* value is returned */
  52. #define SFFMT_ARGPOS 01000000 /* getting arg for $ patterns */
  53. #define SFFMT_IFLAG 02000000 /* 'I' flag */
  54. #define SFFMT_JFLAG 04000000 /* 'j' flag, intmax_t */
  55. #define SFFMT_SET 07777770 /* flags settable on calling extf */
  56. extern ssize_t _Sfi;
  57. extern int sfprint(FILE*, Sffmt_t *format);
  58. extern int sfvscanf(FILE *, Sffmt_t *format);
  59. /* miscellaneous function analogues of fast in-line functions */
  60. extern ssize_t sfslen(void);
  61. #ifdef __cplusplus
  62. }
  63. #endif