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
29
31
32static char depr_pending[1024] = "";
33
34/********************************************************************/
38{
40
41 if (depr_pending[0] != '\0') {
43 depr_pending[0] = '\0';
44 }
45}
46
47/********************************************************************/
54
55/********************************************************************/
62
63/********************************************************************/
66void do_log_deprecation(const char *format, ...)
67{
68 va_list args;
69 char buf[1024];
70
71 va_start(args, format);
73 buf, sizeof(buf), format, args);
74 if (depr_cb != nullptr) {
75 depr_cb(buf);
76 }
77 va_end(args);
78}
79
80/********************************************************************/
85void 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
94 /* Enabled already. Log */
96 depr_pending[0] = '\0';
97 }
98}
char * incite_cost
Definition comments.c:76
void deprecation_pending(const char *format,...)
void deprecation_warn_cb_set(deprecation_warn_callback new_cb)
bool are_deprecation_warnings_enabled(void)
void do_log_deprecation(const char *format,...)
void deprecation_warnings_enable(void)
static bool depr_warns_enabled
static deprecation_warn_callback depr_cb
static char depr_pending[1024]
void(* deprecation_warn_callback)(const char *msg)
#define LOG_DEPRECATION
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
#define __FC_LINE__
Definition log.h:41
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:886
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47