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
00062 typedef void (* GPLogFunc) (GPLogLevel level, const char *domain,
00063 const char *format, va_list args, void *data)
00064 #if (__GNUC__ >= 3)
00065 __attribute__((__format__(printf,3,0)))
00066 #endif
00067 ;
00068
00069 #ifndef DISABLE_DEBUGGING
00070
00071 int gp_log_add_func (GPLogLevel level, GPLogFunc func, void *data);
00072 int gp_log_remove_func (int id);
00073
00074
00075 void gp_log (GPLogLevel level, const char *domain,
00076 const char *format, ...)
00077 #ifdef __GNUC__
00078 __attribute__((__format__(printf,3,4)))
00079 #endif
00080 ;
00081 void gp_logv (GPLogLevel level, const char *domain, const char *format,
00082 va_list args)
00083 #ifdef __GNUC__
00084 __attribute__((__format__(printf,3,0)))
00085 #endif
00086 ;
00087 void gp_log_data (const char *domain, const char *data, unsigned int size);
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #ifdef _GPHOTO2_INTERNAL_CODE
00102 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00103 #define GP_DEBUG(...) \
00104 gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, __VA_ARGS__)
00105 #elif defined(__GNUC__) && __GNUC__ >= 2
00106 #define GP_DEBUG(msg, params...) \
00107 gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, msg, ##params)
00108 #else
00109 # ifdef __GNUC__
00110 # warning Disabling GP_DEBUG because variadic macros are not allowed
00111 # endif
00112 #define GP_DEBUG (void)
00113 #endif
00114 #endif
00115
00116 #else
00117
00118
00119 #define gp_log_add_func(level, func, data) (0)
00120 #define gp_log_remove_func(id) (0)
00121 #define gp_log(level, domain, format, args...)
00122 #define gp_logv(level, domain, format, args)
00123 #define gp_log_data(domain, data, size)
00124
00125 #ifdef _GPHOTO2_INTERNAL_CODE
00126 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00127 #define GP_DEBUG(...)
00128 #elif defined(__GNUC__)
00129 #define GP_DEBUG(msg, params...)
00130 #else
00131 #define GP_DEBUG (void)
00132 #endif
00133 #endif
00134
00135 #endif
00136
00137 #ifdef _GPHOTO2_INTERNAL_CODE
00138
00139 typedef struct StringFlagItem {
00140 char *str;
00141 unsigned int flag;
00142 } StringFlagItem;
00143
00144 typedef void (*string_item_func) (const char *str, void *data);
00145
00146 const char *
00147 gpi_enum_to_string(const unsigned int _enum,
00148 const StringFlagItem *map);
00149
00150 int
00151 gpi_string_to_enum(const char *str,
00152 unsigned int *result,
00153 const StringFlagItem *map);
00154
00155 void
00156 gpi_flags_to_string_list(const unsigned int flags,
00157 const StringFlagItem *map,
00158 string_item_func func, void *data);
00159
00160 int
00161 gpi_string_or_to_flags(const char *str,
00162 unsigned int *flags,
00163 const StringFlagItem *map);
00164
00165 unsigned int
00166 gpi_string_to_flag(const char *str,
00167 const StringFlagItem *map);
00168
00169 unsigned int
00170 gpi_string_list_to_flags(const char *str[],
00171 const StringFlagItem *map);
00172
00173 #endif
00174
00175
00176 #endif