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 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 _DEBUG_H_
  17. #define _DEBUG_H_
  18. #include <stdlib.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #ifndef JSON_EXPORT
  23. #if defined(_MSC_VER)
  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) do {} while(0)
  40. #else
  41. #define JASSERT(cond) do { \
  42. if (!(cond)) { \
  43. mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", __FILE__, __LINE__); \
  44. *(int *)0 = 1;\
  45. abort(); \
  46. }\
  47. } while(0)
  48. #endif
  49. #define MC_ERROR(x, ...) mc_error(x, ##__VA_ARGS__)
  50. #ifdef MC_MAINTAINER_MODE
  51. #define MC_SET_DEBUG(x) mc_set_debug(x)
  52. #define MC_GET_DEBUG() mc_get_debug()
  53. #define MC_SET_SYSLOG(x) mc_set_syslog(x)
  54. #define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__)
  55. #define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__)
  56. #else
  57. #define MC_SET_DEBUG(x) if (0) mc_set_debug(x)
  58. #define MC_GET_DEBUG() (0)
  59. #define MC_SET_SYSLOG(x) if (0) mc_set_syslog(x)
  60. #define MC_DEBUG(x, ...) if (0) mc_debug(x, ##__VA_ARGS__)
  61. #define MC_INFO(x, ...) if (0) mc_info(x, ##__VA_ARGS__)
  62. #endif
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif