local.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* $OpenBSD: local.h,v 1.20 2011/11/08 18:30:42 guenther Exp $ */
  2. /*-
  3. * Copyright (c) 1990, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * This code is derived from software contributed to Berkeley by
  7. * Chris Torek.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the University nor the names of its contributors
  18. * may be used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. * SUCH DAMAGE.
  32. */
  33. /*
  34. * Information local to this implementation of stdio,
  35. * in particular, macros and private variables.
  36. */
  37. #include <wchar.h>
  38. #include "wcio.h"
  39. #include "internal/arch.h" /* for SE_PAGE_SIZE */
  40. #define FLOATING_POINT 1
  41. #define PRINTF_WIDE_CHAR 1
  42. /*
  43. * NB: to fit things in six character monocase externals, the stdio
  44. * code uses the prefix `__s' for stdio objects, typically followed
  45. * by a three-character attempt at a mnemonic.
  46. */
  47. /* stdio buffers */
  48. struct __sbuf {
  49. unsigned char *_base;
  50. int _size;
  51. };
  52. /*
  53. * stdio state variables.
  54. */
  55. typedef struct __sFILE {
  56. unsigned char *_p; /* current position in (some) buffer */
  57. int _r; /* read space left for getc() */
  58. int _w; /* write space left for putc() */
  59. short _flags; /* flags, below; this FILE is free if 0 */
  60. short _file; /* fileno, if Unix descriptor, else -1 */
  61. struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
  62. /* operations */
  63. int (*_read)(void *, char *, int); /* may for sscanf */
  64. /* extension data, to avoid further ABI breakage */
  65. struct __sbuf _ext;
  66. } FILE;
  67. #define __SLBF 0x0001 /* line buffered */
  68. #define __SNBF 0x0002 /* unbuffered */
  69. #define __SRD 0x0004 /* OK to read */
  70. #define __SWR 0x0008 /* OK to write */
  71. /* RD and WR are never simultaneously asserted */
  72. #define __SRW 0x0010 /* open for reading & writing */
  73. #define __SEOF 0x0020 /* found EOF */
  74. #define __SERR 0x0040 /* found error */
  75. #define __SMBF 0x0080 /* _buf is from malloc */
  76. #define __SSTR 0x0200 /* this is an sprintf/snprintf string */
  77. #define __SALC 0x4000 /* allocate string space dynamically */
  78. #include "fileext.h"
  79. int __vfprintf(FILE *, const char *, __va_list);
  80. int __vfwprintf(FILE *, const wchar_t *, __va_list);
  81. #define __sferror(p) (((p)->_flags & __SERR) != 0)
  82. /*
  83. * Return true if the given FILE cannot be written now.
  84. */
  85. #define cantwrite(fp) 0 /* alreays writable for char array APIs */
  86. /* Disable warnings */