23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
– |
#include "handlers.h" |
26 |
|
#include "client.h" |
27 |
|
#include "ircd.h" |
29 |
– |
#include "ircd_handler.h" |
30 |
– |
#include "msg.h" |
28 |
|
#include "numeric.h" |
29 |
|
#include "send.h" |
30 |
|
#include "s_conf.h" |
33 |
|
#include "modules.h" |
34 |
|
#include "irc_string.h" |
35 |
|
|
39 |
– |
#define HPATH IRCD_PREFIX "/help/opers" |
40 |
– |
#define UHPATH IRCD_PREFIX "/help/users" |
36 |
|
#define HELPLEN 400 |
37 |
|
|
43 |
– |
static void m_help(struct Client *, struct Client *, int, char *[]); |
44 |
– |
static void mo_help(struct Client *, struct Client *, int, char *[]); |
45 |
– |
static void mo_uhelp(struct Client *, struct Client *, int, char *[]); |
38 |
|
static void dohelp(struct Client *, const char *, char *); |
39 |
|
static void sendhelpfile(struct Client *, const char *, const char *); |
40 |
|
|
49 |
– |
struct Message help_msgtab = { |
50 |
– |
"HELP", 0, 0, 0, 0, MFLG_SLOW, 0, |
51 |
– |
{m_unregistered, m_help, m_ignore, m_ignore, mo_help, m_ignore} |
52 |
– |
}; |
53 |
– |
|
54 |
– |
struct Message uhelp_msgtab = { |
55 |
– |
"UHELP", 0, 0, 0, 0, MFLG_SLOW, 0, |
56 |
– |
{m_unregistered, m_help, m_ignore, m_ignore, mo_uhelp, m_ignore} |
57 |
– |
}; |
58 |
– |
|
59 |
– |
#ifndef STATIC_MODULES |
60 |
– |
void |
61 |
– |
_modinit(void) |
62 |
– |
{ |
63 |
– |
mod_add_cmd(&help_msgtab); |
64 |
– |
mod_add_cmd(&uhelp_msgtab); |
65 |
– |
} |
66 |
– |
|
67 |
– |
void |
68 |
– |
_moddeinit(void) |
69 |
– |
{ |
70 |
– |
mod_del_cmd(&help_msgtab); |
71 |
– |
mod_del_cmd(&uhelp_msgtab); |
72 |
– |
} |
73 |
– |
|
74 |
– |
const char *_version = "$Revision$"; |
75 |
– |
#endif |
41 |
|
|
42 |
|
/* |
43 |
|
* m_help - HELP message handler |
89 |
|
static void |
90 |
|
dohelp(struct Client *source_p, const char *hpath, char *topic) |
91 |
|
{ |
92 |
+ |
char h_index[] = "index"; |
93 |
|
char path[PATH_MAX + 1]; |
94 |
|
struct stat sb; |
95 |
|
int i; |
97 |
|
if (topic != NULL) |
98 |
|
{ |
99 |
|
if (*topic == '\0') |
100 |
< |
topic = "index"; |
100 |
> |
topic = h_index; |
101 |
|
else |
102 |
|
{ |
103 |
|
/* convert to lower case */ |
104 |
< |
for (i = 0; topic[i] != '\0'; i++) |
104 |
> |
for (i = 0; topic[i] != '\0'; ++i) |
105 |
|
topic[i] = ToLower(topic[i]); |
106 |
|
} |
107 |
|
} |
108 |
|
else |
109 |
< |
topic = "index"; /* list available help topics */ |
109 |
> |
topic = h_index; /* list available help topics */ |
110 |
|
|
111 |
|
if (strpbrk(topic, "/\\")) |
112 |
|
{ |
126 |
|
|
127 |
|
if (stat(path, &sb) < 0) |
128 |
|
{ |
163 |
– |
ilog(L_NOTICE, "help file %s not found", path); |
129 |
|
sendto_one(source_p, form_str(ERR_HELPNOTFOUND), |
130 |
|
me.name, source_p->name, topic); |
131 |
|
return; |
132 |
|
} |
133 |
|
|
169 |
– |
#ifndef _WIN32 |
134 |
|
if (!S_ISREG(sb.st_mode)) |
135 |
|
{ |
172 |
– |
ilog(L_NOTICE, "help file %s not found", path); |
136 |
|
sendto_one(source_p, form_str(ERR_HELPNOTFOUND), |
137 |
|
me.name, source_p->name, topic); |
138 |
|
return; |
139 |
|
} |
177 |
– |
#endif |
140 |
|
|
141 |
|
sendhelpfile(source_p, path, topic); |
142 |
|
} |
174 |
|
while (fbgets(line, sizeof(line), file)) |
175 |
|
{ |
176 |
|
line[strlen(line) - 1] = '\0'; |
177 |
< |
if(line[0] != '#') |
177 |
> |
if (line[0] != '#') |
178 |
|
{ |
179 |
|
if (!started) |
180 |
|
{ |
181 |
|
type = RPL_HELPSTART; |
182 |
< |
started = 1; |
182 |
> |
started = 1; |
183 |
|
} |
184 |
|
else |
185 |
|
type = RPL_HELPTXT; |
195 |
|
sendto_one(source_p, form_str(RPL_ENDOFHELP), |
196 |
|
me.name, source_p->name, topic); |
197 |
|
} |
198 |
+ |
|
199 |
+ |
static struct Message help_msgtab = { |
200 |
+ |
"HELP", 0, 0, 0, 0, MFLG_SLOW, 0, |
201 |
+ |
{m_unregistered, m_help, m_ignore, m_ignore, mo_help, m_ignore} |
202 |
+ |
}; |
203 |
+ |
|
204 |
+ |
static struct Message uhelp_msgtab = { |
205 |
+ |
"UHELP", 0, 0, 0, 0, MFLG_SLOW, 0, |
206 |
+ |
{m_unregistered, m_help, m_ignore, m_ignore, mo_uhelp, m_ignore} |
207 |
+ |
}; |
208 |
+ |
|
209 |
+ |
static void |
210 |
+ |
module_init(void) |
211 |
+ |
{ |
212 |
+ |
mod_add_cmd(&help_msgtab); |
213 |
+ |
mod_add_cmd(&uhelp_msgtab); |
214 |
+ |
} |
215 |
+ |
|
216 |
+ |
static void |
217 |
+ |
module_exit(void) |
218 |
+ |
{ |
219 |
+ |
mod_del_cmd(&help_msgtab); |
220 |
+ |
mod_del_cmd(&uhelp_msgtab); |
221 |
+ |
} |
222 |
+ |
|
223 |
+ |
struct module module_entry = { |
224 |
+ |
.node = { NULL, NULL, NULL }, |
225 |
+ |
.name = NULL, |
226 |
+ |
.version = "$Revision$", |
227 |
+ |
.handle = NULL, |
228 |
+ |
.modinit = module_init, |
229 |
+ |
.modexit = module_exit, |
230 |
+ |
.flags = 0 |
231 |
+ |
}; |