Freeciv-3.1: /fast/freeciv/nightly/S3_1/utility/inputfile.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
inputfile.h
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/**********************************************************************
15 A low-level object for reading a registry-format file.
16 See comments in inputfile.c
17***********************************************************************/
18
19#ifndef FC__INPUTFILE_H
20#define FC__INPUTFILE_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif /* __cplusplus */
25
26/* utility */
27#include "ioz.h"
28#include "log.h" /* enum log_level */
29#include "support.h" /* bool type and fc__attribute */
30
31struct inputfile; /* opaque */
32
33 typedef const char *(*datafilename_fn_t)(const char *filename);
34
35struct inputfile *inf_from_file(const char *filename,
36 datafilename_fn_t datafn);
37struct inputfile *inf_from_stream(fz_FILE * stream,
38 datafilename_fn_t datafn);
39void inf_close(struct inputfile *inf);
40bool inf_at_eof(struct inputfile *inf);
41
42 enum inf_token_type {
43 INF_TOK_SECTION_NAME,
44 INF_TOK_ENTRY_NAME,
45 INF_TOK_EOL,
46 INF_TOK_TABLE_START,
47 INF_TOK_TABLE_END,
48 INF_TOK_COMMA,
49 INF_TOK_VALUE,
50 INF_TOK_LAST
51};
52#define INF_TOK_FIRST INF_TOK_SECTION_NAME
53
54const char *inf_token(struct inputfile *inf, enum inf_token_type type);
55int inf_discard_tokens(struct inputfile *inf, enum inf_token_type type);
56
57 char *inf_log_str(struct inputfile *inf, const char *message, ...)
58 fc__attribute((__format__ (__printf__, 2, 3)));
59
60#ifdef __cplusplus
61}
62#endif /* __cplusplus */
63
64#endif /* FC__INPUTFILE_H */
type
GType type
Definition repodlgs.c:1312
inf_token_type
inf_token_type
Definition inputfile.h:42
INF_TOK_EOL
@ INF_TOK_EOL
Definition inputfile.h:45
INF_TOK_COMMA
@ INF_TOK_COMMA
Definition inputfile.h:48
INF_TOK_TABLE_END
@ INF_TOK_TABLE_END
Definition inputfile.h:47
INF_TOK_VALUE
@ INF_TOK_VALUE
Definition inputfile.h:49
INF_TOK_TABLE_START
@ INF_TOK_TABLE_START
Definition inputfile.h:46
INF_TOK_ENTRY_NAME
@ INF_TOK_ENTRY_NAME
Definition inputfile.h:44
INF_TOK_LAST
@ INF_TOK_LAST
Definition inputfile.h:50
INF_TOK_SECTION_NAME
@ INF_TOK_SECTION_NAME
Definition inputfile.h:43
datafilename_fn_t
const char *(* datafilename_fn_t)(const char *filename)
Definition inputfile.h:33
inf_at_eof
bool inf_at_eof(struct inputfile *inf)
Definition inputfile.c:346
inf_from_file
struct inputfile * inf_from_file(const char *filename, datafilename_fn_t datafn)
Definition inputfile.c:219
inf_log_str
char * inf_log_str(struct inputfile *inf, const char *message,...) fc__attribute((__format__(__printf__
inf_from_stream
struct inputfile * inf_from_stream(fz_FILE *stream, datafilename_fn_t datafn)
Definition inputfile.c:241
inf_close
void inf_close(struct inputfile *inf)
Definition inputfile.c:300
inf_discard_tokens
int inf_discard_tokens(struct inputfile *inf, enum inf_token_type type)
Definition inputfile.c:645
inf_token
const char * inf_token(struct inputfile *inf, enum inf_token_type type)
Definition inputfile.c:607
ioz.h
log.h
fz_FILE_s
Definition ioz.c:149
inputfile
Definition inputfile.c:90
inputfile::filename
char * filename
Definition inputfile.c:92
inputfile::datafn
datafilename_fn_t datafn
Definition inputfile.c:102
message
Definition messagewin_common.h:29
support.h
fc__attribute
#define fc__attribute(x)
Definition support.h:89