Freeciv-3.3: /fast/freeciv/nightly/main/utility/deprecations.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
deprecations.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif /* HAVE_CONFIG_H */
17
18#include "fc_prehdrs.h"
19
20#include <stdarg.h>
21
22/* utility */
23#include "log.h"
24#include "shared.h"
25
26#include "deprecations.h"
27
28 static deprecation_warn_callback depr_cb = nullptr;
29
30 static bool depr_warns_enabled = FALSE;
31
32/********************************************************************/
35 void deprecation_warnings_enable(void)
36{
37 depr_warns_enabled = TRUE;
38}
39
40/********************************************************************/
43 bool are_deprecation_warnings_enabled(void)
44{
45 return depr_warns_enabled;
46}
47
48/********************************************************************/
51 void deprecation_warn_cb_set(deprecation_warn_callback new_cb)
52{
53 depr_cb = new_cb;
54}
55
56/********************************************************************/
59 void do_log_deprecation(const char *format, ...)
60{
61 va_list args;
62 char buf[1024];
63
64 va_start(args, format);
65 vdo_log(__FILE__, __FUNCTION__, __FC_LINE__, FALSE, LOG_DEPRECATION,
66 buf, sizeof(buf), format, args);
67 if (depr_cb != nullptr) {
68 depr_cb(buf);
69 }
70 va_end(args);
71}
incite_cost
char * incite_cost
Definition comments.c:74
deprecation_warn_cb_set
void deprecation_warn_cb_set(deprecation_warn_callback new_cb)
Definition deprecations.c:51
are_deprecation_warnings_enabled
bool are_deprecation_warnings_enabled(void)
Definition deprecations.c:43
do_log_deprecation
void do_log_deprecation(const char *format,...)
Definition deprecations.c:59
deprecation_warnings_enable
void deprecation_warnings_enable(void)
Definition deprecations.c:35
depr_warns_enabled
static bool depr_warns_enabled
Definition deprecations.c:30
depr_cb
static deprecation_warn_callback depr_cb
Definition deprecations.c:28
deprecations.h
deprecation_warn_callback
void(* deprecation_warn_callback)(const char *msg)
Definition deprecations.h:24
LOG_DEPRECATION
#define LOG_DEPRECATION
Definition deprecations.h:26
fc_prehdrs.h
vdo_log
void vdo_log(const char *file, const char *function, int line, bool print_from_where, enum log_level level, char *buf, int buflen, const char *message, va_list args)
Definition log.c:403
log.h
__FC_LINE__
#define __FC_LINE__
Definition log.h:40
shared.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47