stdio2-decl.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Checking macros for stdio functions. Declarations only.
  17. Copyright (C) 2004-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _BITS_STDIO2_DEC_H
  31. #define _BITS_STDIO2_DEC_H 1
  32. #ifndef _STDIO_H
  33. # error "Never include <bits/stdio2-decl.h> directly; use <stdio.h> instead."
  34. #endif
  35. extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen,
  36. const char *__restrict __format, ...) __THROW
  37. __attr_access ((__write_only__, 1, 3));
  38. extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
  39. const char *__restrict __format,
  40. __gnuc_va_list __ap) __THROW
  41. __attr_access ((__write_only__, 1, 3));
  42. #if defined __USE_ISOC99 || defined __USE_UNIX98
  43. extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag,
  44. size_t __slen, const char *__restrict __format,
  45. ...) __THROW
  46. __attr_access ((__write_only__, 1, 2));
  47. extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag,
  48. size_t __slen, const char *__restrict __format,
  49. __gnuc_va_list __ap) __THROW
  50. __attr_access ((__write_only__, 1, 2));
  51. #endif
  52. #if __USE_FORTIFY_LEVEL > 1
  53. extern int __fprintf_chk (FILE *__restrict __stream, int __flag,
  54. const char *__restrict __format, ...)
  55. __nonnull ((1));
  56. extern int __printf_chk (int __flag, const char *__restrict __format, ...);
  57. extern int __vfprintf_chk (FILE *__restrict __stream, int __flag,
  58. const char *__restrict __format,
  59. __gnuc_va_list __ap) __nonnull ((1));
  60. extern int __vprintf_chk (int __flag, const char *__restrict __format,
  61. __gnuc_va_list __ap);
  62. # ifdef __USE_XOPEN2K8
  63. extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt,
  64. ...) __attribute__ ((__format__ (__printf__, 3, 4)));
  65. extern int __vdprintf_chk (int __fd, int __flag,
  66. const char *__restrict __fmt, __gnuc_va_list __arg)
  67. __attribute__ ((__format__ (__printf__, 3, 0)));
  68. # endif
  69. # ifdef __USE_GNU
  70. extern int __asprintf_chk (char **__restrict __ptr, int __flag,
  71. const char *__restrict __fmt, ...)
  72. __THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur;
  73. extern int __vasprintf_chk (char **__restrict __ptr, int __flag,
  74. const char *__restrict __fmt, __gnuc_va_list __arg)
  75. __THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur;
  76. extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
  77. int __flag, const char *__restrict __format,
  78. ...)
  79. __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
  80. extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
  81. int __flag,
  82. const char *__restrict __format,
  83. __gnuc_va_list __args)
  84. __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
  85. # endif
  86. #endif
  87. #if __GLIBC_USE (DEPRECATED_GETS)
  88. extern char *__REDIRECT (__gets_warn, (char *__str), gets)
  89. __wur __warnattr ("please use fgets or getline instead, gets can't "
  90. "specify buffer size");
  91. extern char *__gets_chk (char *__str, size_t) __wur;
  92. #endif
  93. extern char *__REDIRECT (__fgets_alias,
  94. (char *__restrict __s, int __n,
  95. FILE *__restrict __stream), fgets)
  96. __wur __attr_access ((__write_only__, 1, 2));
  97. extern char *__REDIRECT (__fgets_chk_warn,
  98. (char *__restrict __s, size_t __size, int __n,
  99. FILE *__restrict __stream), __fgets_chk)
  100. __wur __warnattr ("fgets called with bigger size than length "
  101. "of destination buffer");
  102. extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n,
  103. FILE *__restrict __stream)
  104. __wur __attr_access ((__write_only__, 1, 3)) __nonnull ((4));
  105. extern size_t __REDIRECT (__fread_alias,
  106. (void *__restrict __ptr, size_t __size,
  107. size_t __n, FILE *__restrict __stream),
  108. fread) __wur;
  109. extern size_t __REDIRECT (__fread_chk_warn,
  110. (void *__restrict __ptr, size_t __ptrlen,
  111. size_t __size, size_t __n,
  112. FILE *__restrict __stream),
  113. __fread_chk)
  114. __wur __warnattr ("fread called with bigger size * nmemb than length "
  115. "of destination buffer");
  116. extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen,
  117. size_t __size, size_t __n,
  118. FILE *__restrict __stream) __wur __nonnull ((5));
  119. #ifdef __USE_GNU
  120. extern char *__REDIRECT_FORTIFY (__fgets_unlocked_alias,
  121. (char *__restrict __s, int __n,
  122. FILE *__restrict __stream), fgets_unlocked)
  123. __wur __attr_access ((__write_only__, 1, 2));
  124. extern char *__REDIRECT (__fgets_unlocked_chk_warn,
  125. (char *__restrict __s, size_t __size, int __n,
  126. FILE *__restrict __stream), __fgets_unlocked_chk)
  127. __wur __warnattr ("fgets_unlocked called with bigger size than length "
  128. "of destination buffer");
  129. extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size,
  130. int __n, FILE *__restrict __stream)
  131. __wur __attr_access ((__write_only__, 1, 3)) __nonnull ((4));
  132. #endif
  133. #ifdef __USE_MISC
  134. # undef fread_unlocked
  135. extern size_t __REDIRECT (__fread_unlocked_alias,
  136. (void *__restrict __ptr, size_t __size,
  137. size_t __n, FILE *__restrict __stream),
  138. fread_unlocked) __wur;
  139. extern size_t __REDIRECT (__fread_unlocked_chk_warn,
  140. (void *__restrict __ptr, size_t __ptrlen,
  141. size_t __size, size_t __n,
  142. FILE *__restrict __stream),
  143. __fread_unlocked_chk)
  144. __wur __warnattr ("fread_unlocked called with bigger size * nmemb than "
  145. "length of destination buffer");
  146. extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen,
  147. size_t __size, size_t __n,
  148. FILE *__restrict __stream)
  149. __wur __nonnull ((5));
  150. #endif
  151. #endif /* bits/stdio2-decl.h. */