config.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Visual Studio configuration file for Mini-XML, a small XML file parsing
  3. * library.
  4. *
  5. * Copyright 2003-2021 by Michael R Sweet.
  6. *
  7. * These coded instructions, statements, and computer programs are the
  8. * property of Michael R Sweet and are protected by Federal copyright
  9. * law. Distribution and use rights are outlined in the file "COPYING"
  10. * which should have been included with this file. If this file is
  11. * missing or damaged, see the license at:
  12. *
  13. * https://michaelrsweet.github.io/mxml
  14. */
  15. /*
  16. * Beginning with VC2005, Microsoft breaks ISO C and POSIX conformance
  17. * by deprecating a number of functions in the name of security, even
  18. * when many of the affected functions are otherwise completely secure.
  19. * The _CRT_SECURE_NO_DEPRECATE definition ensures that we won't get
  20. * warnings from their use...
  21. *
  22. * Then Microsoft decided that they should ignore this in VC2008 and use
  23. * yet another define (_CRT_SECURE_NO_WARNINGS) instead...
  24. */
  25. #define _CRT_SECURE_NO_DEPRECATE
  26. #define _CRT_SECURE_NO_WARNINGS
  27. /*
  28. * Include necessary headers...
  29. */
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <stdarg.h>
  34. #include <ctype.h>
  35. #include <io.h>
  36. /*
  37. * Microsoft also renames the POSIX functions to _name, and introduces
  38. * a broken compatibility layer using the original names. As a result,
  39. * random crashes can occur when, for example, strdup() allocates memory
  40. * from a different heap than used by malloc() and free().
  41. *
  42. * To avoid moronic problems like this, we #define the POSIX function
  43. * names to the corresponding non-standard Microsoft names.
  44. */
  45. #define close _close
  46. #define open _open
  47. #define read _read
  48. #define snprintf _snprintf
  49. #define strdup _strdup
  50. #define vsnprintf _vsnprintf
  51. #define write _write
  52. /*
  53. * Version number...
  54. */
  55. #define MXML_VERSION "Mini-XML v3.3.1"
  56. /*
  57. * Inline function support...
  58. */
  59. #define inline _inline
  60. /*
  61. * Long long support...
  62. */
  63. #define HAVE_LONG_LONG_INT 1
  64. /*
  65. * Do we have the *printf() functions?
  66. */
  67. #define HAVE_SNPRINTF 1
  68. /* #undef HAVE_VASPRINTF */
  69. #define HAVE_VSNPRINTF 1
  70. /*
  71. * Do we have the strXXX() functions?
  72. */
  73. #define HAVE_STRDUP 1
  74. /* #undef HAVE_STRLCPY */
  75. /*
  76. * Do we have threading support?
  77. */
  78. /* #undef HAVE_PTHREAD_H */
  79. /*
  80. * Define prototypes for string functions as needed...
  81. */
  82. # ifndef HAVE_STRDUP
  83. extern char *_mxml_strdup(const char *);
  84. # define strdup _mxml_strdup
  85. # endif /* !HAVE_STRDUP */
  86. # ifndef HAVE_STRLCAT
  87. extern size_t _mxml_strlcat(char *, const char *, size_t);
  88. # define strlcat _mxml_strlcat
  89. # endif /* !HAVE_STRLCAT */
  90. # ifndef HAVE_STRLCPY
  91. extern size_t _mxml_strlcpy(char *, const char *, size_t);
  92. # define strlcpy _mxml_strlcpy
  93. # endif /* !HAVE_STRLCPY */
  94. extern char *_mxml_strdupf(const char *, ...);
  95. extern char *_mxml_vstrdupf(const char *, va_list);
  96. # ifndef HAVE_SNPRINTF
  97. extern int _mxml_snprintf(char *, size_t, const char *, ...);
  98. # define snprintf _mxml_snprintf
  99. # endif /* !HAVE_SNPRINTF */
  100. # ifndef HAVE_VSNPRINTF
  101. extern int _mxml_vsnprintf(char *, size_t, const char *, va_list);
  102. # define vsnprintf _mxml_vsnprintf
  103. # endif /* !HAVE_VSNPRINTF */