Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

252 lines
8.3 KiB

  1. #ifndef __CURL_CURLRULES_H
  2. #define __CURL_CURLRULES_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at http://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. ***************************************************************************/
  24. /* ================================================================ */
  25. /* COMPILE TIME SANITY CHECKS */
  26. /* ================================================================ */
  27. /*
  28. * NOTE 1:
  29. * -------
  30. *
  31. * All checks done in this file are intentionally placed in a public
  32. * header file which is pulled by curl/curl.h when an application is
  33. * being built using an already built libcurl library. Additionally
  34. * this file is also included and used when building the library.
  35. *
  36. * If compilation fails on this file it is certainly sure that the
  37. * problem is elsewhere. It could be a problem in the curlbuild.h
  38. * header file, or simply that you are using different compilation
  39. * settings than those used to build the library.
  40. *
  41. * Nothing in this file is intended to be modified or adjusted by the
  42. * curl library user nor by the curl library builder.
  43. *
  44. * Do not deactivate any check, these are done to make sure that the
  45. * library is properly built and used.
  46. *
  47. * You can find further help on the libcurl development mailing list:
  48. * http://cool.haxx.se/mailman/listinfo/curl-library/
  49. *
  50. * NOTE 2
  51. * ------
  52. *
  53. * Some of the following compile time checks are based on the fact
  54. * that the dimension of a constant array can not be a negative one.
  55. * In this way if the compile time verification fails, the compilation
  56. * will fail issuing an error. The error description wording is compiler
  57. * dependent but it will be quite similar to one of the following:
  58. *
  59. * "negative subscript or subscript is too large"
  60. * "array must have at least one element"
  61. * "-1 is an illegal array size"
  62. * "size of array is negative"
  63. *
  64. * If you are building an application which tries to use an already
  65. * built libcurl library and you are getting this kind of errors on
  66. * this file, it is a clear indication that there is a mismatch between
  67. * how the library was built and how you are trying to use it for your
  68. * application. Your already compiled or binary library provider is the
  69. * only one who can give you the details you need to properly use it.
  70. */
  71. /*
  72. * Verify that some macros are actually defined.
  73. */
  74. #ifndef CURL_SIZEOF_LONG
  75. # error "CURL_SIZEOF_LONG definition is missing!"
  76. Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing
  77. #endif
  78. #ifndef CURL_TYPEOF_CURL_SOCKLEN_T
  79. # error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!"
  80. Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing
  81. #endif
  82. #ifndef CURL_SIZEOF_CURL_SOCKLEN_T
  83. # error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!"
  84. Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing
  85. #endif
  86. #ifndef CURL_TYPEOF_CURL_OFF_T
  87. # error "CURL_TYPEOF_CURL_OFF_T definition is missing!"
  88. Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing
  89. #endif
  90. #ifndef CURL_FORMAT_CURL_OFF_T
  91. # error "CURL_FORMAT_CURL_OFF_T definition is missing!"
  92. Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing
  93. #endif
  94. #ifndef CURL_FORMAT_CURL_OFF_TU
  95. # error "CURL_FORMAT_CURL_OFF_TU definition is missing!"
  96. Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing
  97. #endif
  98. #ifndef CURL_FORMAT_OFF_T
  99. # error "CURL_FORMAT_OFF_T definition is missing!"
  100. Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing
  101. #endif
  102. #ifndef CURL_SIZEOF_CURL_OFF_T
  103. # error "CURL_SIZEOF_CURL_OFF_T definition is missing!"
  104. Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing
  105. #endif
  106. #ifndef CURL_SUFFIX_CURL_OFF_T
  107. # error "CURL_SUFFIX_CURL_OFF_T definition is missing!"
  108. Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing
  109. #endif
  110. #ifndef CURL_SUFFIX_CURL_OFF_TU
  111. # error "CURL_SUFFIX_CURL_OFF_TU definition is missing!"
  112. Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing
  113. #endif
  114. /*
  115. * Macros private to this header file.
  116. */
  117. #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
  118. #define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
  119. /*
  120. * Verify that the size previously defined and expected for long
  121. * is the same as the one reported by sizeof() at compile time.
  122. */
  123. typedef char
  124. __curl_rule_01__
  125. [CurlchkszEQ(long, CURL_SIZEOF_LONG)];
  126. /*
  127. * Verify that the size previously defined and expected for
  128. * curl_off_t is actually the the same as the one reported
  129. * by sizeof() at compile time.
  130. */
  131. typedef char
  132. __curl_rule_02__
  133. [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
  134. /*
  135. * Verify at compile time that the size of curl_off_t as reported
  136. * by sizeof() is greater or equal than the one reported for long
  137. * for the current compilation.
  138. */
  139. typedef char
  140. __curl_rule_03__
  141. [CurlchkszGE(curl_off_t, long)];
  142. /*
  143. * Verify that the size previously defined and expected for
  144. * curl_socklen_t is actually the the same as the one reported
  145. * by sizeof() at compile time.
  146. */
  147. typedef char
  148. __curl_rule_04__
  149. [CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)];
  150. /*
  151. * Verify at compile time that the size of curl_socklen_t as reported
  152. * by sizeof() is greater or equal than the one reported for int for
  153. * the current compilation.
  154. */
  155. typedef char
  156. __curl_rule_05__
  157. [CurlchkszGE(curl_socklen_t, int)];
  158. /* ================================================================ */
  159. /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
  160. /* ================================================================ */
  161. /*
  162. * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
  163. * these to be visible and exported by the external libcurl interface API,
  164. * while also making them visible to the library internals, simply including
  165. * setup.h, without actually needing to include curl.h internally.
  166. * If some day this section would grow big enough, all this should be moved
  167. * to its own header file.
  168. */
  169. /*
  170. * Figure out if we can use the ## preprocessor operator, which is supported
  171. * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
  172. * or __cplusplus so we need to carefully check for them too.
  173. */
  174. #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
  175. defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
  176. defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
  177. defined(__ILEC400__)
  178. /* This compiler is believed to have an ISO compatible preprocessor */
  179. #define CURL_ISOCPP
  180. #else
  181. /* This compiler is believed NOT to have an ISO compatible preprocessor */
  182. #undef CURL_ISOCPP
  183. #endif
  184. /*
  185. * Macros for minimum-width signed and unsigned curl_off_t integer constants.
  186. */
  187. #ifdef CURL_ISOCPP
  188. # define __CURL_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix
  189. #else
  190. # define __CURL_OFF_T_C_HELPER2(Val,Suffix) Val/**/Suffix
  191. #endif
  192. #define __CURL_OFF_T_C_HELPER1(Val,Suffix) __CURL_OFF_T_C_HELPER2(Val,Suffix)
  193. #define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HELPER1(Val,CURL_SUFFIX_CURL_OFF_T)
  194. #define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HELPER1(Val,CURL_SUFFIX_CURL_OFF_TU)
  195. /*
  196. * Get rid of macros private to this header file.
  197. */
  198. #undef CurlchkszEQ
  199. #undef CurlchkszGE
  200. /*
  201. * Get rid of macros not intended to exist beyond this point.
  202. */
  203. #undef CURL_PULL_WS2TCPIP_H
  204. #undef CURL_PULL_SYS_TYPES_H
  205. #undef CURL_PULL_SYS_SOCKET_H
  206. #undef CURL_PULL_STDINT_H
  207. #undef CURL_PULL_INTTYPES_H
  208. #undef CURL_TYPEOF_CURL_SOCKLEN_T
  209. #undef CURL_TYPEOF_CURL_OFF_T
  210. #ifdef CURL_NO_OLDIES
  211. #undef CURL_FORMAT_OFF_T /* not required since 7.19.0 - obsoleted in 7.20.0 */
  212. #endif
  213. #endif /* __CURL_CURLRULES_H */