libgphoto2 photo camera library (libgphoto2) API
2.5.2
|
00001 00021 #ifndef __GPHOTO2_PORT_LOG_H__ 00022 #define __GPHOTO2_PORT_LOG_H__ 00023 00024 #include <stdarg.h> 00025 00030 typedef enum { 00031 GP_LOG_ERROR = 0, 00032 GP_LOG_VERBOSE = 1, 00033 GP_LOG_DEBUG = 2, 00034 GP_LOG_DATA = 3 00035 } GPLogLevel; 00036 00046 #define GP_LOG_ALL GP_LOG_DATA 00047 00061 typedef void (* GPLogFunc) (GPLogLevel level, const char *domain, const char *str, void *data); 00062 00063 #ifndef DISABLE_DEBUGGING 00064 00065 int gp_log_add_func (GPLogLevel level, GPLogFunc func, void *data); 00066 int gp_log_remove_func (int id); 00067 00068 /* Logging */ 00069 void gp_log (GPLogLevel level, const char *domain, 00070 const char *format, ...) 00071 #ifdef __GNUC__ 00072 __attribute__((__format__(printf,3,4))) 00073 #endif 00074 ; 00075 void gp_logv (GPLogLevel level, const char *domain, const char *format, 00076 va_list args) 00077 #ifdef __GNUC__ 00078 __attribute__((__format__(printf,3,0))) 00079 #endif 00080 ; 00081 void gp_log_data (const char *domain, const char *data, unsigned int size); 00082 00083 00084 /* 00085 * GP_DEBUG: 00086 * msg: message to log 00087 * params: params to message 00088 * 00089 * Logs message at log level #GP_LOG_DEBUG by calling #gp_log() with 00090 * an automatically generated domain 00091 * You have to define GP_MODULE as "mymod" for your module 00092 * mymod before using #GP_DEBUG(). 00093 */ 00094 00095 #ifdef _GPHOTO2_INTERNAL_CODE 00096 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 00097 #define GP_DEBUG(...) \ 00098 gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, __VA_ARGS__) 00099 #elif defined(__GNUC__) && __GNUC__ >= 2 00100 #define GP_DEBUG(msg, params...) \ 00101 gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, msg, ##params) 00102 #else 00103 # ifdef __GNUC__ 00104 # warning Disabling GP_DEBUG because variadic macros are not allowed 00105 # endif 00106 #define GP_DEBUG (void) 00107 #endif 00108 #endif /* _GPHOTO2_INTERNAL_CODE */ 00109 00110 #else /* DISABLE_DEBUGGING */ 00111 00112 /* Stub these functions out if debugging is disabled */ 00113 #define gp_log_add_func(level, func, data) (0) 00114 #define gp_log_remove_func(id) (0) 00115 #define gp_log(level, domain, format, args...) 00116 #define gp_logv(level, domain, format, args) 00117 #define gp_log_data(domain, data, size) 00118 00119 #ifdef _GPHOTO2_INTERNAL_CODE 00120 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 00121 #define GP_DEBUG(...) /* no-op */ 00122 #elif defined(__GNUC__) 00123 #define GP_DEBUG(msg, params...) /* no-op */ 00124 #else 00125 #define GP_DEBUG (void) 00126 #endif 00127 #endif /* _GPHOTO2_INTERNAL_CODE */ 00128 00129 #endif /* DISABLE_DEBUGGING */ 00130 00131 #ifdef _GPHOTO2_INTERNAL_CODE 00132 00133 typedef struct StringFlagItem { 00134 char *str; 00135 unsigned int flag; 00136 } StringFlagItem; 00137 00138 typedef void (*string_item_func) (const char *str, void *data); 00139 00140 const char * 00141 gpi_enum_to_string(const unsigned int _enum, 00142 const StringFlagItem *map); 00143 00144 int 00145 gpi_string_to_enum(const char *str, 00146 unsigned int *result, 00147 const StringFlagItem *map); 00148 00149 void 00150 gpi_flags_to_string_list(const unsigned int flags, 00151 const StringFlagItem *map, 00152 string_item_func func, void *data); 00153 00154 int 00155 gpi_string_or_to_flags(const char *str, 00156 unsigned int *flags, 00157 const StringFlagItem *map); 00158 00159 unsigned int 00160 gpi_string_to_flag(const char *str, 00161 const StringFlagItem *map); 00162 00163 unsigned int 00164 gpi_string_list_to_flags(const char *str[], 00165 const StringFlagItem *map); 00166 00167 #endif /* _GPHOTO2_INTERNAL_CODE */ 00168 00169 00170 #endif /* __GPHOTO2_PORT_LOG_H__ */