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