Freeciv-3.2
Loading...
Searching...
No Matches
utility
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
=
NULL
;
29
30
static
bool
depr_warns_enabled
=
FALSE
;
31
32
static
char
depr_pending
[1024] =
""
;
33
34
/********************************************************************/
37
void
deprecation_warnings_enable
(
void
)
38
{
39
depr_warns_enabled
=
TRUE
;
40
41
if
(
depr_pending
[0] !=
'\0'
) {
42
do_log_deprecation
(
"%s"
,
depr_pending
);
43
depr_pending
[0] =
'\0'
;
44
}
45
}
46
47
/********************************************************************/
50
bool
are_deprecation_warnings_enabled
(
void
)
51
{
52
return
depr_warns_enabled
;
53
}
54
55
/********************************************************************/
58
void
deprecation_warn_cb_set
(
deprecation_warn_callback
new_cb
)
59
{
60
depr_cb
=
new_cb
;
61
}
62
63
/********************************************************************/
66
void
do_log_deprecation
(
const
char
*format, ...)
67
{
68
va_list
args;
69
char
buf
[1024];
70
71
va_start
(args, format);
72
vdo_log
(
__FILE__
,
__FUNCTION__
,
__FC_LINE__
,
FALSE
,
LOG_DEPRECATION
,
73
buf
,
sizeof
(
buf
), format, args);
74
if
(
depr_cb
!=
NULL
) {
75
depr_cb
(
buf
);
76
}
77
va_end
(args);
78
}
79
80
/********************************************************************/
85
void
deprecation_pending
(
const
char
*format, ...)
86
{
87
va_list
args;
88
89
va_start
(args, format);
90
fc_vsnprintf
(
depr_pending
,
sizeof
(
depr_pending
), format, args);
91
va_end
(args);
92
93
if
(
depr_warns_enabled
) {
94
/* Enabled already. Log */
95
do_log_deprecation
(
"%s"
,
depr_pending
);
96
depr_pending
[0] =
'\0'
;
97
}
98
}
incite_cost
char * incite_cost
Definition
comments.c:75
deprecation_pending
void deprecation_pending(const char *format,...)
Definition
deprecations.c:85
deprecation_warn_cb_set
void deprecation_warn_cb_set(deprecation_warn_callback new_cb)
Definition
deprecations.c:58
are_deprecation_warnings_enabled
bool are_deprecation_warnings_enabled(void)
Definition
deprecations.c:50
do_log_deprecation
void do_log_deprecation(const char *format,...)
Definition
deprecations.c:66
deprecation_warnings_enable
void deprecation_warnings_enable(void)
Definition
deprecations.c:37
depr_warns_enabled
static bool depr_warns_enabled
Definition
deprecations.c:30
depr_cb
static deprecation_warn_callback depr_cb
Definition
deprecations.c:28
depr_pending
static char depr_pending[1024]
Definition
deprecations.c:32
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
fc_vsnprintf
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition
support.c:900
TRUE
#define TRUE
Definition
support.h:46
FALSE
#define FALSE
Definition
support.h:47
Generated on Sun Dec 22 2024 23:00:34 for Freeciv-3.2 by
1.9.8