Freeciv-3.3: /fast/freeciv/nightly/main/tools/manual/manual_commands.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
manual_commands.c
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#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "fcintl.h"
20
21/* server */
22#include "commands.h"
23
24/* tools/manual */
25#include "fc_manual.h"
26
27/**********************************************************************/
33 bool manual_commands(struct tag_types *tag_info)
34{
35 FILE *doc;
36 int i;
37
38 doc = manual_start(tag_info, MANUAL_COMMANDS);
39
40 if (doc == NULL) {
41 return FALSE;
42 }
43
44 /* TRANS: markup ... Freeciv version ... markup */
45 fprintf(doc, _("%sFreeciv %s server commands%s\n\n"), tag_info->title_begin,
46 VERSION_STRING, tag_info->title_end);
47 for (i = 0; i < CMD_NUM; i++) {
48 const struct command *cmd = command_by_number(i);
49
50 fprintf(doc, tag_info->item_begin, "cmd", i);
51 fprintf(doc, "%s%s - %s%s\n\n", tag_info->sect_title_begin,
52 command_name(cmd), command_short_help(cmd),
53 tag_info->sect_title_end);
54 if (command_synopsis(cmd)) {
55 char *cmdstr = fc_strdup(command_synopsis(cmd));
56 size_t cmdstr_len = strlen(cmdstr) + 1;
57
58 cmdstr = html_special_chars(cmdstr, &cmdstr_len);
59 fprintf(doc, _("<table>\n<tr>\n<td valign=\"top\">"
60 "<pre>Synopsis:</pre></td>\n<td>"));
61 fprintf(doc, "<pre>%s</pre></td></tr></table>", cmdstr);
62 free(cmdstr);
63 }
64 fprintf(doc, _("<p class=\"level\">Level: %s</p>\n"),
65 cmdlevel_name(command_level(cmd)));
66 {
67 char *help = command_extra_help(cmd);
68
69 if (help) {
70 size_t help_len = strlen(help) + 1;
71
72 fc_break_lines(help, LINE_BREAK);
73 help = html_special_chars(help, &help_len);
74 fprintf(doc, "\n");
75 fprintf(doc, _("<p>Description:</p>\n\n"));
76 fprintf(doc, "<pre>%s</pre>\n", help);
77 free(help);
78 }
79 }
80
81 fprintf(doc, "%s", tag_info->item_end);
82 }
83
84 manual_finalize(tag_info, doc, MANUAL_COMMANDS);
85
86 return TRUE;
87}
command_name
const char * command_name(const struct command *pcommand)
Definition commands.c:743
command_by_number
const struct command * command_by_number(int i)
Definition commands.c:734
command_short_help
const char * command_short_help(const struct command *pcommand)
Definition commands.c:767
command_extra_help
char * command_extra_help(const struct command *pcommand)
Definition commands.c:776
command_level
enum cmdlevel command_level(const struct command *pcommand)
Definition commands.c:791
command_synopsis
const char * command_synopsis(const struct command *pcommand)
Definition commands.c:759
commands.h
CMD_NUM
@ CMD_NUM
Definition commands.h:109
incite_cost
char * incite_cost
Definition comments.c:74
manual_finalize
void manual_finalize(struct tag_types *tag_info, FILE *doc, enum manuals manual)
Definition fc_manual.c:316
html_special_chars
char * html_special_chars(char *str, size_t *len)
Definition fc_manual.c:164
manual_start
FILE * manual_start(struct tag_types *tag_info, int manual_number)
Definition fc_manual.c:287
fc_manual.h
LINE_BREAK
#define LINE_BREAK
Definition fc_types.h:77
fcintl.h
_
#define _(String)
Definition fcintl.h:67
manual_commands
bool manual_commands(struct tag_types *tag_info)
Definition manual_commands.c:33
fc_strdup
#define fc_strdup(str)
Definition mem.h:43
command
Definition commands.c:37
tag_types
Definition fc_manual.h:28
fc_break_lines
int fc_break_lines(char *str, size_t desired_len)
Definition support.c:1135
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47