You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

debug.h 2.7 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $
  3. *
  4. * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  5. * Michael Clark <michael@metaparadigm.com>
  6. * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
  7. *
  8. * This library is free software; you can redistribute it and/or modify
  9. * it under the terms of the MIT license. See COPYING for details.
  10. *
  11. */
  12. /**
  13. * @file
  14. * @brief Do not use, json-c internal, may be changed or removed at any time.
  15. */
  16. #ifndef _JSON_C_DEBUG_H_
  17. #define _JSON_C_DEBUG_H_
  18. #include <stdlib.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #ifndef JSON_EXPORT
  23. #if defined(_MSC_VER) && defined(JSON_C_DLL)
  24. #define JSON_EXPORT __declspec(dllexport)
  25. #else
  26. #define JSON_EXPORT extern
  27. #endif
  28. #endif
  29. JSON_EXPORT void mc_set_debug(int debug);
  30. JSON_EXPORT int mc_get_debug(void);
  31. JSON_EXPORT void mc_set_syslog(int syslog);
  32. JSON_EXPORT void mc_debug(const char *msg, ...);
  33. JSON_EXPORT void mc_error(const char *msg, ...);
  34. JSON_EXPORT void mc_info(const char *msg, ...);
  35. #ifndef __STRING
  36. #define __STRING(x) #x
  37. #endif
  38. #ifndef PARSER_BROKEN_FIXED
  39. #define JASSERT(cond) \
  40. do \
  41. { \
  42. } while (0)
  43. #else
  44. #define JASSERT(cond) \
  45. do \
  46. { \
  47. if (!(cond)) \
  48. { \
  49. mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", \
  50. __FILE__, __LINE__); \
  51. *(int *)0 = 1; \
  52. abort(); \
  53. } \
  54. } while (0)
  55. #endif
  56. #define MC_ERROR(x, ...) mc_error(x, ##__VA_ARGS__)
  57. #ifdef MC_MAINTAINER_MODE
  58. #define MC_SET_DEBUG(x) mc_set_debug(x)
  59. #define MC_GET_DEBUG() mc_get_debug()
  60. #define MC_SET_SYSLOG(x) mc_set_syslog(x)
  61. #define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__)
  62. #define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__)
  63. #else
  64. #define MC_SET_DEBUG(x) \
  65. if (0) \
  66. mc_set_debug(x)
  67. #define MC_GET_DEBUG() (0)
  68. #define MC_SET_SYSLOG(x) \
  69. if (0) \
  70. mc_set_syslog(x)
  71. #define MC_DEBUG(x, ...) \
  72. if (0) \
  73. mc_debug(x, ##__VA_ARGS__)
  74. #define MC_INFO(x, ...) \
  75. if (0) \
  76. mc_info(x, ##__VA_ARGS__)
  77. #endif
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif