91 |
|
char h_index[] = "index"; |
92 |
|
char path[PATH_MAX + 1]; |
93 |
|
struct stat sb; |
94 |
< |
int i; |
94 |
> |
unsigned int i; |
95 |
|
|
96 |
< |
if (topic != NULL) |
97 |
< |
{ |
98 |
< |
if (*topic == '\0') |
99 |
< |
topic = h_index; |
100 |
< |
else |
101 |
< |
{ |
102 |
< |
/* convert to lower case */ |
103 |
< |
for (i = 0; topic[i] != '\0'; ++i) |
104 |
< |
topic[i] = ToLower(topic[i]); |
105 |
< |
} |
106 |
< |
} |
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 |
|
{ |
137 |
|
{ |
138 |
|
FILE *file; |
139 |
|
char line[HELPLEN]; |
148 |
– |
char started = 0; |
149 |
– |
int type; |
140 |
|
|
141 |
|
if ((file = fopen(path, "r")) == NULL) |
142 |
|
{ |
152 |
|
return; |
153 |
|
} |
154 |
|
|
155 |
< |
else if (line[0] != '#') |
156 |
< |
{ |
167 |
< |
line[strlen(line) - 1] = '\0'; |
168 |
< |
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); |
170 |
– |
started = 1; |
171 |
– |
} |
158 |
|
|
159 |
|
while (fgets(line, sizeof(line), file)) |
160 |
|
{ |
161 |
|
line[strlen(line) - 1] = '\0'; |
162 |
< |
if (line[0] != '#') |
163 |
< |
{ |
164 |
< |
if (!started) |
179 |
< |
{ |
180 |
< |
type = RPL_HELPSTART; |
181 |
< |
started = 1; |
182 |
< |
} |
183 |
< |
else |
184 |
< |
type = RPL_HELPTXT; |
185 |
< |
|
186 |
< |
sendto_one(source_p, form_str(RPL_HELPTXT), |
187 |
< |
me.name, source_p->name, topic, line); |
188 |
< |
} |
162 |
> |
|
163 |
> |
sendto_one(source_p, form_str(RPL_HELPTXT), |
164 |
> |
me.name, source_p->name, topic, line); |
165 |
|
} |
166 |
|
|
167 |
|
fclose(file); |
192 |
– |
sendto_one(source_p, form_str(RPL_HELPTXT), |
193 |
– |
me.name, source_p->name, topic, ""); |
168 |
|
sendto_one(source_p, form_str(RPL_ENDOFHELP), |
169 |
|
me.name, source_p->name, topic); |
170 |
|
} |