Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:19:15

0001 /*
0002  * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $
0003  *
0004  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
0005  * Michael Clark <michael@metaparadigm.com>
0006  * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
0007  *
0008  * This library is free software; you can redistribute it and/or modify
0009  * it under the terms of the MIT license. See COPYING for details.
0010  *
0011  */
0012 
0013 /**
0014  * @file
0015  * @brief Do not use, json-c internal, may be changed or removed at any time.
0016  */
0017 #ifndef _JSON_C_DEBUG_H_
0018 #define _JSON_C_DEBUG_H_
0019 
0020 #include <stdlib.h>
0021 
0022 #ifdef __cplusplus
0023 extern "C" {
0024 #endif
0025 
0026 #ifndef JSON_EXPORT
0027 #if defined(_MSC_VER) && defined(JSON_C_DLL)
0028 #define JSON_EXPORT __declspec(dllexport)
0029 #else
0030 #define JSON_EXPORT extern
0031 #endif
0032 #endif
0033 
0034 JSON_EXPORT void mc_set_debug(int debug);
0035 JSON_EXPORT int mc_get_debug(void);
0036 
0037 JSON_EXPORT void mc_set_syslog(int syslog);
0038 
0039 JSON_EXPORT void mc_debug(const char *msg, ...);
0040 JSON_EXPORT void mc_error(const char *msg, ...);
0041 JSON_EXPORT void mc_info(const char *msg, ...);
0042 
0043 #ifndef __STRING
0044 #define __STRING(x) #x
0045 #endif
0046 
0047 #ifndef PARSER_BROKEN_FIXED
0048 
0049 #define JASSERT(cond) \
0050     do            \
0051     {             \
0052     } while (0)
0053 
0054 #else
0055 
0056 #define JASSERT(cond)                                                                              \
0057     do                                                                                         \
0058     {                                                                                          \
0059         if (!(cond))                                                                       \
0060         {                                                                                  \
0061             mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", \
0062                      __FILE__, __LINE__);                                              \
0063             *(int *)0 = 1;                                                             \
0064             abort();                                                                   \
0065         }                                                                                  \
0066     } while (0)
0067 
0068 #endif
0069 
0070 #define MC_ERROR(x, ...) mc_error(x, ##__VA_ARGS__)
0071 
0072 #ifdef MC_MAINTAINER_MODE
0073 #define MC_SET_DEBUG(x) mc_set_debug(x)
0074 #define MC_GET_DEBUG() mc_get_debug()
0075 #define MC_SET_SYSLOG(x) mc_set_syslog(x)
0076 #define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__)
0077 #define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__)
0078 #else
0079 #define MC_SET_DEBUG(x) \
0080     if (0)          \
0081     mc_set_debug(x)
0082 #define MC_GET_DEBUG() (0)
0083 #define MC_SET_SYSLOG(x) \
0084     if (0)           \
0085     mc_set_syslog(x)
0086 #define MC_DEBUG(x, ...) \
0087     if (0)           \
0088     mc_debug(x, ##__VA_ARGS__)
0089 #define MC_INFO(x, ...) \
0090     if (0)          \
0091     mc_info(x, ##__VA_ARGS__)
0092 #endif
0093 
0094 #ifdef __cplusplus
0095 }
0096 #endif
0097 
0098 #endif