Removed mention of gtk3x-client from README.msys2
[freeciv.git] / utility / section_file.h
blob00b53f53824acf57c358eb945819b6ff291e5ee1
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.
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 #ifndef FC__SECTION_FILE_H
14 #define FC__SECTION_FILE_H
16 /* This header contains internals of section_file that its users should
17 * not care about. This header should be included by soruce files implementing
18 * registry itself. */
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
24 /* Section structure. */
25 struct section {
26 struct section_file *secfile; /* Parent structure. */
27 bool include;
28 char *name; /* Name of the section. */
29 struct entry_list *entries; /* The list of the children. */
32 /* The section file struct itself. */
33 struct section_file {
34 char *name; /* Can be NULL. */
35 size_t num_entries;
36 /* num_includes should be size_t, but as there's no truly portable
37 * printf format for size_t and we need to construct string containing
38 * num_includes with fc_snprintf(), we set for unsigned int. */
39 unsigned int num_includes;
40 struct section_list *sections;
41 bool allow_duplicates;
42 bool allow_digital_boolean;
43 struct {
44 struct section_hash *sections;
45 struct entry_hash *entries;
46 } hash;
49 void secfile_log(const struct section_file *secfile,
50 const struct section *psection,
51 const char *file, const char *function, int line,
52 const char *format, ...)
53 fc__attribute((__format__(__printf__, 6, 7)));
55 #define SECFILE_LOG(secfile, psection, format, ...) \
56 secfile_log(secfile, psection, __FILE__, __FUNCTION__, __FC_LINE__, \
57 format, ## __VA_ARGS__)
58 #define SECFILE_RETURN_IF_FAIL(secfile, psection, condition) \
59 if (!(condition)) { \
60 SECFILE_LOG(secfile, psection, "Assertion '%s' failed.", #condition); \
61 return; \
63 #define SECFILE_RETURN_VAL_IF_FAIL(secfile, psection, condition, value) \
64 if (!(condition)) { \
65 SECFILE_LOG(secfile, psection, "Assertion '%s' failed.", #condition); \
66 return value; \
69 #define SPECHASH_TAG section
70 #define SPECHASH_CSTR_KEY_TYPE
71 #define SPECHASH_IDATA_TYPE struct section *
72 #include "spechash.h"
74 #define SPECHASH_TAG entry
75 #define SPECHASH_ASTR_KEY_TYPE
76 #define SPECHASH_IDATA_TYPE struct entry *
77 #include "spechash.h"
79 bool entry_from_token(struct section *psection, const char *name,
80 const char *tok);
82 #ifdef __cplusplus
84 #endif /* __cplusplus */
86 #endif /* FC__SECTION_FILE_H */