2 Copyright (C) Andrew Tridgell 2002
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 support for the 'help' and 'ahelp' commands
24 const char *help_dir[NUM_LANGS] = {HELP_DIR, HELP_SPANISH,
25 HELP_FRENCH, HELP_DANISH};
32 static int help_page(int p, const char *dir, const char *cmd)
35 char *filenames[1000];
37 /* try for help dir exact match */
38 if (psend_file(p, dir, cmd) == 0) {
42 /* search help dir for a partial match */
43 count = search_directory(dir, cmd, filenames, 1000);
45 psend_file(p, dir, filenames[0]);
51 pprintf(p,"-- Matches: %u help topics --", count);
52 display_directory(p, filenames, count);
56 /* allow admins to use 'help' for admin pages */
57 if (dir != ADHELP_DIR && check_admin(p, ADMIN_ADMIN)) {
58 return help_page(p, ADHELP_DIR, cmd);
61 pprintf(p,"No help found for topic '%s'\n", cmd);
69 int com_help(int p, param_list param)
71 struct player *pp = &player_globals.parray[p];
74 const struct alias_type *list;
76 if (param[0].type == TYPE_STRING) {
77 cmd = param[0].val.string;
82 /* see if its a global alias */
83 list = alias_list_global();
84 for (i=0;list && list[i].comm_name;i++) {
85 if (strcasecmp(cmd, list[i].comm_name) == 0) {
86 pprintf(p,"'%s' is a global alias for '%s'\n",
92 /* or a personal alias */
93 list = alias_list_personal(p, &n);
95 if (strcasecmp(cmd, list[i].comm_name) == 0) {
96 pprintf(p,"'%s' is a personal alias for '%s'\n",
102 return help_page(p, help_dir[pp->language], cmd);
108 int com_ahelp(int p, param_list param)
112 if (param[0].type == TYPE_STRING) {
113 cmd = param[0].val.string;
118 return help_page(p, ADHELP_DIR, cmd);