2 * ircd-ratbox: A slightly useful ircd.
3 * m_help.c: Provides help information to a user/operator.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
37 #include "rb_dictionary.h"
39 static const char help_desc
[] =
40 "Provides the help facility for commands, modes, and server concepts";
42 static void m_help(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
43 static void mo_help(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
44 static void mo_uhelp(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
45 static void dohelp(struct Client
*, int, const char *);
47 struct Message help_msgtab
= {
49 {mg_unreg
, {m_help
, 0}, mg_ignore
, mg_ignore
, mg_ignore
, {mo_help
, 0}}
51 struct Message uhelp_msgtab
= {
53 {mg_unreg
, {m_help
, 0}, mg_ignore
, mg_ignore
, mg_ignore
, {mo_uhelp
, 0}}
56 mapi_clist_av1 help_clist
[] = { &help_msgtab
, &uhelp_msgtab
, NULL
};
58 DECLARE_MODULE_AV2(help
, NULL
, NULL
, help_clist
, NULL
, NULL
, NULL
, NULL
, help_desc
);
61 * m_help - HELP message handler
64 m_help(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
66 dohelp(source_p
, HELP_USER
, parc
> 1 ? parv
[1] : NULL
);
70 * mo_help - HELP message handler
73 mo_help(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
75 dohelp(source_p
, HELP_OPER
, parc
> 1 ? parv
[1] : NULL
);
79 * mo_uhelp - HELP message handler
80 * This is used so that opers can view the user help file without deopering
83 mo_uhelp(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
85 dohelp(source_p
, HELP_USER
, parc
> 1 ? parv
[1] : NULL
);
89 dohelp(struct Client
*source_p
, int flags
, const char *topic
)
91 static const char ntopic
[] = "index";
92 struct cachefile
*hptr
;
93 struct cacheline
*lineptr
;
97 if(EmptyString(topic
))
100 hptr
= rb_dictionary_retrieve(flags
& HELP_OPER
? help_dict_oper
: help_dict_user
, topic
);
102 if(hptr
== NULL
|| !(hptr
->flags
& flags
))
104 sendto_one(source_p
, form_str(ERR_HELPNOTFOUND
),
105 me
.name
, source_p
->name
, topic
);
109 fptr
= hptr
->contents
.head
;
110 lineptr
= fptr
->data
;
112 /* first line cant be empty */
113 sendto_one(source_p
, form_str(RPL_HELPSTART
),
114 me
.name
, source_p
->name
, topic
, lineptr
->data
);
116 RB_DLINK_FOREACH(ptr
, fptr
->next
)
120 sendto_one(source_p
, form_str(RPL_HELPTXT
),
121 me
.name
, source_p
->name
, topic
, lineptr
->data
);
124 sendto_one(source_p
, form_str(RPL_ENDOFHELP
),
125 me
.name
, source_p
->name
, topic
);