Remove hard limitation that AI wonder cities never build settlers
[freeciv.git] / server / console.h
blobc736b978a6af61bf08480704f2a90027d8d87794
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__CONSOLE_H
14 #define FC__CONSOLE_H
16 /* utility */
17 #include "support.h" /* bool type and fc__attribute */
19 #define MAX_LEN_CONSOLE_LINE 1024 /* closing '\0' included */
21 /*
22 * A note on "rfc-style":
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.
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 */
54 /* initialize logging via console */
55 void con_log_init(const char *log_filename, enum log_level level,
56 int fatal_assertions);
57 void con_log_close(void);
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)));
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. */
65 void con_puts(enum rfc_status rfc_status, const char *str);
67 /* ensure timely update */
68 void con_flush(void);
70 /* initialize prompt; display initial message */
71 void con_prompt_init(void);
73 /* make sure a prompt is printed, and re-printed after every message */
74 void con_prompt_on(void);
76 /* do not print a prompt after every message */
77 void con_prompt_off(void);
79 /* user pressed enter: will need a new prompt */
80 void con_prompt_enter(void);
82 /* clear "user pressed enter" state (used in special cases) */
83 void con_prompt_enter_clear(void);
85 /* set server output style */
86 void con_set_style(bool i);
88 /* return server output style */
89 bool con_get_style(void);
91 #endif /* FC__CONSOLE_H */