libssh2_config_cmake.h.in 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
  2. *
  3. * Redistribution and use in source and binary forms,
  4. * with or without modification, are permitted provided
  5. * that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above
  8. * copyright notice, this list of conditions and the
  9. * following disclaimer.
  10. *
  11. * Redistributions in binary form must reproduce the above
  12. * copyright notice, this list of conditions and the following
  13. * disclaimer in the documentation and/or other materials
  14. * provided with the distribution.
  15. *
  16. * Neither the name of the copyright holder nor the names
  17. * of any other contributors may be used to endorse or
  18. * promote products derived from this software without
  19. * specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  22. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  23. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  26. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  29. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  31. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  33. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  34. * OF SUCH DAMAGE.
  35. */
  36. /* Headers */
  37. #cmakedefine HAVE_UNISTD_H
  38. #cmakedefine HAVE_INTTYPES_H
  39. #cmakedefine HAVE_SYS_SOCKET_H
  40. #cmakedefine HAVE_ARPA_INET_H
  41. #cmakedefine HAVE_NETINET_IN_H
  42. #cmakedefine HAVE_WINDOWS_H
  43. #cmakedefine HAVE_WINSOCK2_H
  44. #cmakedefine HAVE_SNPRINTF
  45. /* snprintf not in Visual Studio CRT and _snprintf dangerously incompatible.
  46. We provide a safe wrapper if snprintf not found */
  47. #ifndef HAVE_SNPRINTF
  48. #include <stdio.h>
  49. #include <stdarg.h>
  50. /* Want safe, 'n += snprintf(b + n ...)' like function. If cp_max_len is 1
  51. * then assume cp is pointing to a null char and do nothing. Returns number
  52. * number of chars placed in cp excluding the trailing null char. So for
  53. * cp_max_len > 0 the return value is always < cp_max_len; for cp_max_len
  54. * <= 0 the return value is 0 (and no chars are written to cp). */
  55. static int snprintf(char *cp, int cp_max_len, const char *fmt, ...)
  56. {
  57. va_list args;
  58. int n;
  59. if (cp_max_len < 2)
  60. return 0;
  61. va_start(args, fmt);
  62. n = vsnprintf(cp, cp_max_len, fmt, args);
  63. va_end(args);
  64. return (n < cp_max_len) ? n : (cp_max_len - 1);
  65. }
  66. #define HAVE_SNPRINTF
  67. #endif