Jef Driesen 0f6d23757f Add a new library context object.
With the introduction of a context object, library initialization and
shutdown can be performed without requiring any global state. A single
process can use multiple independent contexts without any problems. The
lack of a global state also improves the thread-safety of the library.

At the moment, the new context object is primary used to implement an
improved logging system.
2012-08-27 23:02:44 +02:00

55 lines
1.4 KiB
C

/*
* libdivecomputer
*
* Copyright (C) 2012 Jef Driesen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
#ifndef DC_CONTEXT_H
#define DC_CONTEXT_H
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct dc_context_t dc_context_t;
typedef enum dc_loglevel_t {
DC_LOGLEVEL_NONE,
DC_LOGLEVEL_ERROR,
DC_LOGLEVEL_WARNING,
DC_LOGLEVEL_INFO,
DC_LOGLEVEL_DEBUG,
DC_LOGLEVEL_ALL
} dc_loglevel_t;
dc_status_t
dc_context_new (dc_context_t **context);
dc_status_t
dc_context_free (dc_context_t *context);
dc_status_t
dc_context_set_loglevel (dc_context_t *context, dc_loglevel_t loglevel);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DC_CONTEXT_H */