static void do_help(struct Client *source_p, char *topic) { char h_index[] = "index"; struct stat sb; if (EmptyString(topic)) topic = h_index; else for (char *p = topic; *p; ++p) *p = ToLower(*p); if (strpbrk(topic, "/\\")) { sendto_one_numeric(source_p, &me, ERR_HELPNOTFOUND, topic); return; } char path[sizeof(HPATH) + strlen(topic) + 1]; /* +1 for / */ snprintf(path, sizeof(path), "%s/%s", HPATH, topic); if (stat(path, &sb) < 0) { sendto_one_numeric(source_p, &me, ERR_HELPNOTFOUND, topic); return; } if (!S_ISREG(sb.st_mode)) { sendto_one_numeric(source_p, &me, ERR_HELPNOTFOUND, topic); return; } sendhelpfile(source_p, path, topic); }
static void dohelp(struct Client *source_p, const char *hpath, char *topic) { char h_index[] = "index"; char path[PATH_MAX + 1]; struct stat sb; int i; if (topic != NULL) { if (*topic == '\0') topic = h_index; else { /* convert to lower case */ for (i = 0; topic[i] != '\0'; ++i) topic[i] = ToLower(topic[i]); } } else topic = h_index; /* list available help topics */ if (strpbrk(topic, "/\\")) { sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, source_p->name, topic); return; } if (strlen(hpath) + strlen(topic) + 1 > PATH_MAX) { sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, source_p->name, topic); return; } snprintf(path, sizeof(path), "%s/%s", hpath, topic); if (stat(path, &sb) < 0) { ilog(L_NOTICE, "help file %s not found", path); sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, source_p->name, topic); return; } #ifndef _WIN32 if (!S_ISREG(sb.st_mode)) { ilog(L_NOTICE, "help file %s not found", path); sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, source_p->name, topic); return; } #endif sendhelpfile(source_p, path, topic); }
static void dohelp(struct Client *source_p, const char *hpath, char *topic, const char *nick) { char path[MAXPATHLEN + 1]; struct stat sb; unsigned int i; static char ind[] = "index"; if(topic != NULL && !EmptyString(topic)) { /* convert to lower case */ for (i = 0; topic[i] != '\0'; i++) { topic[i] = ToLower(topic[i]); } } else topic = ind; /* list available help topics */ if(strchr(topic, '/')) { sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, nick, topic); return; } if(strlen(hpath) + strlen(topic) + 1 > MAXPATHLEN) { sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, nick, topic); return; } sprintf(path, "%s/%s", hpath, topic); if(stat(path, &sb) < 0) { ilog(L_NOTICE, "help file %s not found", path); sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, nick, topic); return; } if(!S_ISREG(sb.st_mode)) { ilog(L_NOTICE, "help file %s not found", path); sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, nick, topic); return; } sendhelpfile(source_p, path, topic, nick); return; }
static void dohelp(struct Client *source_p, char *topic) { char *p = topic; char h_index[] = "index"; char path[HYB_PATH_MAX + 1]; struct stat sb; if (EmptyString(topic)) topic = h_index; else for (; *p; ++p) *p = ToLower(*p); if (strpbrk(topic, "/\\")) { sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, source_p->name, topic); return; } if (strlen(HPATH) + strlen(topic) + 1 > HYB_PATH_MAX) { sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, source_p->name, topic); return; } snprintf(path, sizeof(path), "%s/%s", HPATH, topic); if (stat(path, &sb) < 0) { sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, source_p->name, topic); return; } if (!S_ISREG(sb.st_mode)) { sendto_one(source_p, form_str(ERR_HELPNOTFOUND), me.name, source_p->name, topic); return; } sendhelpfile(source_p, path, topic); }