1
0

setup_once.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #ifndef __SETUP_ONCE_H
  2. #define __SETUP_ONCE_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2007, Daniel Stenberg, <[email protected]>, 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. * $Id$
  24. ***************************************************************************/
  25. /********************************************************************
  26. * NOTICE *
  27. * ======== *
  28. * *
  29. * Content of header files lib/setup_once.h and ares/setup_once.h *
  30. * must be kept in sync. Modify the other one if you change this. *
  31. * *
  32. ********************************************************************/
  33. /*
  34. * If we have the MSG_NOSIGNAL define, make sure we use
  35. * it as the fourth argument of function send()
  36. */
  37. #ifdef HAVE_MSG_NOSIGNAL
  38. #define SEND_4TH_ARG MSG_NOSIGNAL
  39. #else
  40. #define SEND_4TH_ARG 0
  41. #endif
  42. /*
  43. * The definitions for the return type and arguments types
  44. * of functions recv() and send() belong and come from the
  45. * configuration file. Do not define them in any other place.
  46. *
  47. * HAVE_RECV is defined if you have a function named recv()
  48. * which is used to read incoming data from sockets. If your
  49. * function has another name then don't define HAVE_RECV.
  50. *
  51. * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2,
  52. * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also
  53. * be defined.
  54. *
  55. * HAVE_SEND is defined if you have a function named send()
  56. * which is used to write outgoing data on a connected socket.
  57. * If yours has another name then don't define HAVE_SEND.
  58. *
  59. * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2,
  60. * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and
  61. * SEND_TYPE_RETV must also be defined.
  62. */
  63. #ifdef HAVE_RECV
  64. #if !defined(RECV_TYPE_ARG1) || \
  65. !defined(RECV_TYPE_ARG2) || \
  66. !defined(RECV_TYPE_ARG3) || \
  67. !defined(RECV_TYPE_ARG4) || \
  68. !defined(RECV_TYPE_RETV)
  69. /* */
  70. Error Missing_definition_of_return_and_arguments_types_of_recv
  71. /* */
  72. #else
  73. #define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
  74. (RECV_TYPE_ARG2)(y), \
  75. (RECV_TYPE_ARG3)(z), \
  76. (RECV_TYPE_ARG4)(0))
  77. #endif
  78. #else /* HAVE_RECV */
  79. #ifndef sread
  80. /* */
  81. Error Missing_definition_of_macro_sread
  82. /* */
  83. #endif
  84. #endif /* HAVE_RECV */
  85. #ifdef HAVE_SEND
  86. #if !defined(SEND_TYPE_ARG1) || \
  87. !defined(SEND_QUAL_ARG2) || \
  88. !defined(SEND_TYPE_ARG2) || \
  89. !defined(SEND_TYPE_ARG3) || \
  90. !defined(SEND_TYPE_ARG4) || \
  91. !defined(SEND_TYPE_RETV)
  92. /* */
  93. Error Missing_definition_of_return_and_arguments_types_of_send
  94. /* */
  95. #else
  96. #define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
  97. (SEND_TYPE_ARG2)(y), \
  98. (SEND_TYPE_ARG3)(z), \
  99. (SEND_TYPE_ARG4)(SEND_4TH_ARG))
  100. #endif
  101. #else /* HAVE_SEND */
  102. #ifndef swrite
  103. /* */
  104. Error Missing_definition_of_macro_swrite
  105. /* */
  106. #endif
  107. #endif /* HAVE_SEND */
  108. /*
  109. * Uppercase macro versions of ANSI/ISO is*() functions/macros which
  110. * avoid negative number inputs with argument byte codes > 127.
  111. */
  112. #define ISSPACE(x) (isspace((int) ((unsigned char)x)))
  113. #define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
  114. #define ISALNUM(x) (isalnum((int) ((unsigned char)x)))
  115. #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
  116. #define ISGRAPH(x) (isgraph((int) ((unsigned char)x)))
  117. #define ISALPHA(x) (isalpha((int) ((unsigned char)x)))
  118. #define ISPRINT(x) (isprint((int) ((unsigned char)x)))
  119. /*
  120. * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type.
  121. */
  122. #ifndef HAVE_SIG_ATOMIC_T
  123. typedef int sig_atomic_t;
  124. #define HAVE_SIG_ATOMIC_T
  125. #endif
  126. /*
  127. * Default return type for signal handlers.
  128. */
  129. #ifndef RETSIGTYPE
  130. #define RETSIGTYPE void
  131. #endif
  132. #endif /* __SETUP_ONCE_H */