subrascasse

Sub Rascasse: an iPhone dive log for Subsurface cloud storage, with a pure-Swift git client (GPL-2.0)
git clone https://git.schurger.org/subrascasse.git
Log | Files | Refs | README | LICENSE

context-private.h (2898B)


      1 /*
      2  * libdivecomputer
      3  *
      4  * Copyright (C) 2012 Jef Driesen
      5  *
      6  * This library is free software; you can redistribute it and/or
      7  * modify it under the terms of the GNU Lesser General Public
      8  * License as published by the Free Software Foundation; either
      9  * version 2.1 of the License, or (at your option) any later version.
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU Lesser General Public
     17  * License along with this library; if not, write to the Free Software
     18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
     19  * MA 02110-1301 USA
     20  */
     21 
     22 #ifndef DC_CONTEXT_PRIVATE_H
     23 #define DC_CONTEXT_PRIVATE_H
     24 
     25 #ifdef HAVE_CONFIG_H
     26 #include "config.h"
     27 #endif
     28 
     29 #include <libdivecomputer/context.h>
     30 
     31 #include "platform.h"
     32 
     33 #ifdef __cplusplus
     34 extern "C" {
     35 #endif /* __cplusplus */
     36 
     37 #define UNUSED(x) (void)sizeof(x)
     38 
     39 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
     40 #define FUNCTION __func__
     41 #else
     42 #define FUNCTION __FUNCTION__
     43 #endif
     44 
     45 #ifdef ENABLE_LOGGING
     46 #define HEXDUMP(context, loglevel, prefix, data, size) dc_context_hexdump (context, loglevel, __FILE__, __LINE__, FUNCTION, prefix, data, size)
     47 #define SYSERROR(context, errcode) dc_context_syserror (context, DC_LOGLEVEL_ERROR, __FILE__, __LINE__, FUNCTION, errcode)
     48 #define ERROR(context, ...) dc_context_log (context, DC_LOGLEVEL_ERROR, __FILE__, __LINE__, FUNCTION, __VA_ARGS__)
     49 #define WARNING(context, ...) dc_context_log (context, DC_LOGLEVEL_WARNING, __FILE__, __LINE__, FUNCTION, __VA_ARGS__)
     50 #define INFO(context, ...) dc_context_log (context, DC_LOGLEVEL_INFO, __FILE__, __LINE__, FUNCTION, __VA_ARGS__)
     51 #define DEBUG(context, ...) dc_context_log (context, DC_LOGLEVEL_DEBUG, __FILE__, __LINE__, FUNCTION, __VA_ARGS__)
     52 #else
     53 #define HEXDUMP(context, loglevel, prefix, data, size) UNUSED(context)
     54 #define SYSERROR(context, errcode) UNUSED(context)
     55 #define ERROR(context, ...) UNUSED(context)
     56 #define WARNING(context, ...) UNUSED(context)
     57 #define INFO(context, ...) UNUSED(context)
     58 #define DEBUG(context, ...) UNUSED(context)
     59 #endif
     60 
     61 dc_status_t
     62 dc_context_log (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *format, ...) DC_ATTR_FORMAT_PRINTF(6, 7);
     63 
     64 dc_status_t
     65 dc_context_syserror (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, int errcode);
     66 
     67 dc_status_t
     68 dc_context_hexdump (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *prefix, const unsigned char data[], unsigned int size);
     69 
     70 #ifdef __cplusplus
     71 }
     72 #endif /* __cplusplus */
     73 #endif /* DC_CONTEXT_PRIVATE_H */