Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/console.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
console.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#ifndef FC__CONSOLE_H
14#define FC__CONSOLE_H
15
16/* utility */
17#include "support.h" /* bool type and fc__attribute */
18
19#define MAX_LEN_CONSOLE_LINE 1024 /* closing '\0' included */
20
21/*
22 * A note on "rfc-style":
23 *
24 * This style of server output, started with the /rfcstyle server
25 * command, prefixes all output with a status number. This is similar
26 * to how some common ascii based internet protocols like FTP and SMTP
27 * work. A parser can check these numbers to determine whether an
28 * action was successful or not, instead of attempting to parse the
29 * text (which can be translated into various languages and easily
30 * change between versions). This status number is given to the output
31 * functions below as their first parameter, or to cmd_reply* as their
32 * third parameter.
33 */
34
35 enum rfc_status {
36 C_IGNORE = -1, /* never print RFC-style number prefix */
37 C_COMMENT = 0, /* for human eyes only */
38 C_VERSION = 1, /* version info */
39 C_DEBUG = 2, /* debug info */
40 C_LOG_BASE = 10, /* 10, 11, 12 depending on log level */
41 C_OK = 100, /* success of requested operation */
42 C_CONNECTION = 101, /* new client */
43 C_DISCONNECTED = 102, /* client gone */
44 C_REJECTED = 103, /* client rejected */
45 C_FAIL = 200, /* failure of requested operation */
46 C_METAERROR = 201, /* failure of meta server */
47 C_SYNTAX = 300, /* syntax error or value out of range */
48 C_BOUNCE = 301, /* option no longer available */
49 C_GENFAIL = 400, /* failure not caused by a requested operation */
50 C_WARNING = 500, /* something may be wrong */
51 C_READY = 999 /* waiting for input */
52};
53
54/* initialize logging via console */
55void con_log_init(const char *log_filename, enum log_level level,
56 int fatal_assertions);
57void con_log_close(void);
58
59/* write to console and add line-break, and show prompt if required. */
60 void con_write(enum rfc_status rfc_status, const char *message, ...)
61 fc__attribute((__format__ (__printf__, 2, 3)));
62
63/* write to console and add line-break, and show prompt if required.
64 ie, same as con_write, but without the format string stuff. */
65void con_puts(enum rfc_status rfc_status, const char *str);
66
67/* ensure timely update */
68void con_flush(void);
69
70/* initialize prompt; display initial message */
71void con_prompt_init(void);
72
73/* make sure a prompt is printed, and re-printed after every message */
74void con_prompt_on(void);
75
76/* do not print a prompt after every message */
77void con_prompt_off(void);
78
79/* user pressed enter: will need a new prompt */
80void con_prompt_enter(void);
81
82/* clear "user pressed enter" state (used in special cases) */
83void con_prompt_enter_clear(void);
84
85/* set server output style */
86void con_set_style(bool i);
87
88/* return server output style */
89bool con_get_style(void);
90
91#endif /* FC__CONSOLE_H */
str
#define str
Definition astring.c:76
con_get_style
bool con_get_style(void)
Definition console.c:264
con_log_init
void con_log_init(const char *log_filename, enum log_level level, int fatal_assertions)
Definition console.c:150
con_prompt_enter_clear
void con_prompt_enter_clear(void)
Definition console.c:314
con_puts
void void con_puts(enum rfc_status rfc_status, const char *str)
Definition console.c:226
con_set_style
void con_set_style(bool i)
Definition console.c:251
con_flush
void con_flush(void)
Definition console.c:243
rfc_status
rfc_status
Definition console.h:35
C_DISCONNECTED
@ C_DISCONNECTED
Definition console.h:43
C_BOUNCE
@ C_BOUNCE
Definition console.h:48
C_CONNECTION
@ C_CONNECTION
Definition console.h:42
C_FAIL
@ C_FAIL
Definition console.h:45
C_SYNTAX
@ C_SYNTAX
Definition console.h:47
C_DEBUG
@ C_DEBUG
Definition console.h:39
C_OK
@ C_OK
Definition console.h:41
C_METAERROR
@ C_METAERROR
Definition console.h:46
C_GENFAIL
@ C_GENFAIL
Definition console.h:49
C_REJECTED
@ C_REJECTED
Definition console.h:44
C_READY
@ C_READY
Definition console.h:51
C_LOG_BASE
@ C_LOG_BASE
Definition console.h:40
C_COMMENT
@ C_COMMENT
Definition console.h:37
C_VERSION
@ C_VERSION
Definition console.h:38
C_WARNING
@ C_WARNING
Definition console.h:50
C_IGNORE
@ C_IGNORE
Definition console.h:36
con_write
void con_write(enum rfc_status rfc_status, const char *message,...) fc__attribute((__format__(__printf__
con_prompt_init
void con_prompt_init(void)
Definition console.c:272
con_prompt_enter
void con_prompt_enter(void)
Definition console.c:303
con_prompt_off
void con_prompt_off(void)
Definition console.c:295
con_prompt_on
void con_prompt_on(void)
Definition console.c:286
con_log_close
void con_log_close(void)
Definition console.c:167
log_filename
static char * log_filename
Definition log.c:39
log_level
log_level
Definition log.h:28
fatal_assertions
static int fatal_assertions
Definition ruledit.cpp:58
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
message
Definition messagewin_common.h:29
support.h
fc__attribute
#define fc__attribute(x)
Definition support.h:89