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
24 * $Id: m_help.c 254 2005-09-21 23:35:12Z nenolod $
40 static int m_help(struct Client
*, struct Client
*, int, const char **);
41 static int mo_help(struct Client
*, struct Client
*, int, const char **);
42 static int mo_uhelp(struct Client
*, struct Client
*, int, const char **);
43 static void dohelp(struct Client
*, int, const char *);
45 struct Message help_msgtab
= {
46 "HELP", 0, 0, 0, MFLG_SLOW
,
47 {mg_unreg
, {m_help
, 0}, mg_ignore
, mg_ignore
, mg_ignore
, {mo_help
, 0}}
49 struct Message uhelp_msgtab
= {
50 "UHELP", 0, 0, 0, MFLG_SLOW
,
51 {mg_unreg
, {m_help
, 0}, mg_ignore
, mg_ignore
, mg_ignore
, {mo_uhelp
, 0}}
54 mapi_clist_av1 help_clist
[] = { &help_msgtab
, &uhelp_msgtab
, NULL
};
55 DECLARE_MODULE_AV1(help
, NULL
, NULL
, help_clist
, NULL
, NULL
, "$Revision: 254 $");
58 * m_help - HELP message handler
59 * parv[0] = sender prefix
62 m_help(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
64 static time_t last_used
= 0;
66 /* HELP is always local */
67 if((last_used
+ ConfigFileEntry
.pace_wait_simple
) > CurrentTime
)
69 /* safe enough to give this on a local connect only */
70 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
71 me
.name
, source_p
->name
, "HELP");
72 sendto_one(source_p
, form_str(RPL_ENDOFHELP
),
73 me
.name
, source_p
->name
,
74 (parc
> 1 && !EmptyString(parv
[1])) ? parv
[1] : "index");
79 last_used
= CurrentTime
;
82 dohelp(source_p
, HELP_USER
, parc
> 1 ? parv
[1] : NULL
);
88 * mo_help - HELP message handler
89 * parv[0] = sender prefix
92 mo_help(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
94 dohelp(source_p
, HELP_OPER
, parc
> 1 ? parv
[1] : NULL
);
99 * mo_uhelp - HELP message handler
100 * This is used so that opers can view the user help file without deopering
101 * parv[0] = sender prefix
104 mo_uhelp(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
106 dohelp(source_p
, HELP_USER
, parc
> 1 ? parv
[1] : NULL
);
111 dohelp(struct Client
*source_p
, int flags
, const char *topic
)
113 static const char ntopic
[] = "index";
114 struct cachefile
*hptr
;
115 struct cacheline
*lineptr
;
119 if(EmptyString(topic
))
122 hptr
= hash_find_help(topic
, flags
);
126 sendto_one(source_p
, form_str(ERR_HELPNOTFOUND
),
127 me
.name
, source_p
->name
, topic
);
131 fptr
= hptr
->contents
.head
;
132 lineptr
= fptr
->data
;
134 /* first line cant be empty */
135 sendto_one(source_p
, form_str(RPL_HELPSTART
),
136 me
.name
, source_p
->name
, topic
, lineptr
->data
);
138 DLINK_FOREACH(ptr
, fptr
->next
)
142 sendto_one(source_p
, form_str(RPL_HELPTXT
),
143 me
.name
, source_p
->name
, topic
, lineptr
->data
);
146 sendto_one(source_p
, form_str(RPL_ENDOFHELP
),
147 me
.name
, source_p
->name
, topic
);