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" |
34 |
< |
#include "s_log.h" |
30 |
> |
#include "conf.h" |
31 |
|
#include "parse.h" |
32 |
|
#include "modules.h" |
33 |
|
#include "irc_string.h" |
34 |
|
|
35 |
|
#define HELPLEN 400 |
36 |
|
|
41 |
– |
static void m_help(struct Client *, struct Client *, int, char *[]); |
42 |
– |
static void mo_help(struct Client *, struct Client *, int, char *[]); |
43 |
– |
static void mo_uhelp(struct Client *, struct Client *, int, char *[]); |
37 |
|
static void dohelp(struct Client *, const char *, char *); |
38 |
|
static void sendhelpfile(struct Client *, const char *, const char *); |
39 |
|
|
47 |
– |
struct Message help_msgtab = { |
48 |
– |
"HELP", 0, 0, 0, 0, MFLG_SLOW, 0, |
49 |
– |
{m_unregistered, m_help, m_ignore, m_ignore, mo_help, m_ignore} |
50 |
– |
}; |
51 |
– |
|
52 |
– |
struct Message uhelp_msgtab = { |
53 |
– |
"UHELP", 0, 0, 0, 0, MFLG_SLOW, 0, |
54 |
– |
{m_unregistered, m_help, m_ignore, m_ignore, mo_uhelp, m_ignore} |
55 |
– |
}; |
56 |
– |
|
57 |
– |
void |
58 |
– |
_modinit(void) |
59 |
– |
{ |
60 |
– |
mod_add_cmd(&help_msgtab); |
61 |
– |
mod_add_cmd(&uhelp_msgtab); |
62 |
– |
} |
63 |
– |
|
64 |
– |
void |
65 |
– |
_moddeinit(void) |
66 |
– |
{ |
67 |
– |
mod_del_cmd(&help_msgtab); |
68 |
– |
mod_del_cmd(&uhelp_msgtab); |
69 |
– |
} |
70 |
– |
|
71 |
– |
const char *_version = "$Revision$"; |
40 |
|
|
41 |
|
/* |
42 |
|
* m_help - HELP message handler |
89 |
|
dohelp(struct Client *source_p, const char *hpath, char *topic) |
90 |
|
{ |
91 |
|
char h_index[] = "index"; |
92 |
< |
char path[PATH_MAX + 1]; |
92 |
> |
char path[HYB_PATH_MAX + 1]; |
93 |
|
struct stat sb; |
94 |
< |
int i; |
94 |
> |
unsigned int i; |
95 |
|
|
96 |
< |
if (topic != NULL) |
97 |
< |
{ |
130 |
< |
if (*topic == '\0') |
131 |
< |
topic = h_index; |
132 |
< |
else |
133 |
< |
{ |
134 |
< |
/* convert to lower case */ |
135 |
< |
for (i = 0; topic[i] != '\0'; ++i) |
136 |
< |
topic[i] = ToLower(topic[i]); |
137 |
< |
} |
138 |
< |
} |
96 |
> |
if (EmptyString(topic)) |
97 |
> |
topic = h_index; |
98 |
|
else |
99 |
< |
topic = h_index; /* list available help topics */ |
99 |
> |
for (i = 0; topic[i] != '\0'; ++i) |
100 |
> |
topic[i] = ToLower(topic[i]); |
101 |
|
|
102 |
|
if (strpbrk(topic, "/\\")) |
103 |
|
{ |
106 |
|
return; |
107 |
|
} |
108 |
|
|
109 |
< |
if (strlen(hpath) + strlen(topic) + 1 > PATH_MAX) |
109 |
> |
if (strlen(hpath) + strlen(topic) + 1 > HYB_PATH_MAX) |
110 |
|
{ |
111 |
|
sendto_one(source_p, form_str(ERR_HELPNOTFOUND), |
112 |
|
me.name, source_p->name, topic); |
135 |
|
static void |
136 |
|
sendhelpfile(struct Client *source_p, const char *path, const char *topic) |
137 |
|
{ |
138 |
< |
FBFILE *file; |
138 |
> |
FILE *file; |
139 |
|
char line[HELPLEN]; |
180 |
– |
char started = 0; |
181 |
– |
int type; |
140 |
|
|
141 |
< |
if ((file = fbopen(path, "r")) == NULL) |
141 |
> |
if ((file = fopen(path, "r")) == NULL) |
142 |
|
{ |
143 |
|
sendto_one(source_p, form_str(ERR_HELPNOTFOUND), |
144 |
|
me.name, source_p->name, topic); |
145 |
|
return; |
146 |
|
} |
147 |
|
|
148 |
< |
if (fbgets(line, sizeof(line), file) == NULL) |
148 |
> |
if (fgets(line, sizeof(line), file) == NULL) |
149 |
|
{ |
150 |
|
sendto_one(source_p, form_str(ERR_HELPNOTFOUND), |
151 |
|
me.name, source_p->name, topic); |
152 |
|
return; |
153 |
|
} |
154 |
|
|
155 |
< |
else if (line[0] != '#') |
156 |
< |
{ |
199 |
< |
line[strlen(line) - 1] = '\0'; |
200 |
< |
sendto_one(source_p, form_str(RPL_HELPSTART), |
155 |
> |
line[strlen(line) - 1] = '\0'; |
156 |
> |
sendto_one(source_p, form_str(RPL_HELPSTART), |
157 |
|
me.name, source_p->name, topic, line); |
202 |
– |
started = 1; |
203 |
– |
} |
158 |
|
|
159 |
< |
while (fbgets(line, sizeof(line), file)) |
159 |
> |
while (fgets(line, sizeof(line), file)) |
160 |
|
{ |
161 |
|
line[strlen(line) - 1] = '\0'; |
162 |
< |
if (line[0] != '#') |
163 |
< |
{ |
164 |
< |
if (!started) |
165 |
< |
{ |
166 |
< |
type = RPL_HELPSTART; |
167 |
< |
started = 1; |
214 |
< |
} |
215 |
< |
else |
216 |
< |
type = RPL_HELPTXT; |
217 |
< |
|
218 |
< |
sendto_one(source_p, form_str(RPL_HELPTXT), |
219 |
< |
me.name, source_p->name, topic, line); |
220 |
< |
} |
221 |
< |
} |
222 |
< |
|
223 |
< |
fbclose(file); |
224 |
< |
sendto_one(source_p, form_str(RPL_HELPTXT), |
225 |
< |
me.name, source_p->name, topic, ""); |
162 |
> |
|
163 |
> |
sendto_one(source_p, form_str(RPL_HELPTXT), |
164 |
> |
me.name, source_p->name, topic, line); |
165 |
> |
} |
166 |
> |
|
167 |
> |
fclose(file); |
168 |
|
sendto_one(source_p, form_str(RPL_ENDOFHELP), |
169 |
|
me.name, source_p->name, topic); |
170 |
|
} |
171 |
+ |
|
172 |
+ |
static struct Message help_msgtab = { |
173 |
+ |
"HELP", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
174 |
+ |
{m_unregistered, m_help, m_ignore, m_ignore, mo_help, m_ignore} |
175 |
+ |
}; |
176 |
+ |
|
177 |
+ |
static struct Message uhelp_msgtab = { |
178 |
+ |
"UHELP", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
179 |
+ |
{m_unregistered, m_help, m_ignore, m_ignore, mo_uhelp, m_ignore} |
180 |
+ |
}; |
181 |
+ |
|
182 |
+ |
static void |
183 |
+ |
module_init(void) |
184 |
+ |
{ |
185 |
+ |
mod_add_cmd(&help_msgtab); |
186 |
+ |
mod_add_cmd(&uhelp_msgtab); |
187 |
+ |
} |
188 |
+ |
|
189 |
+ |
static void |
190 |
+ |
module_exit(void) |
191 |
+ |
{ |
192 |
+ |
mod_del_cmd(&help_msgtab); |
193 |
+ |
mod_del_cmd(&uhelp_msgtab); |
194 |
+ |
} |
195 |
+ |
|
196 |
+ |
struct module module_entry = { |
197 |
+ |
.node = { NULL, NULL, NULL }, |
198 |
+ |
.name = NULL, |
199 |
+ |
.version = "$Revision$", |
200 |
+ |
.handle = NULL, |
201 |
+ |
.modinit = module_init, |
202 |
+ |
.modexit = module_exit, |
203 |
+ |
.flags = 0 |
204 |
+ |
}; |