+ std::string filename;
+ bool got_filename = false;
+
+ for (ptr = ptr->children; ptr != 0; ptr = ptr->next) {
+ if (ptr->type != XML_ELEMENT_NODE)
+ continue;
+ if (!strcmp((const char *) ptr->name, "filename")) {
+ filename = yp2::xml::get_text(ptr);
+ got_filename = true;
+ } else {
+ throw yp2::filter::FilterException("Bad element in auth_simple: "
+ + std::string((const char *)
+ ptr->name));
+ }
+ }
+
+ if (!got_filename)
+ throw yp2::filter::FilterException("auth_simple: no user-register "
+ "filename specified");
+
+ FILE *fp = fopen(filename.c_str(), "r");
+ if (fp == 0)
+ throw yp2::filter::FilterException("can't open auth_simple "
+ "user-register '" + filename +
+ "': " + strerror(errno));
+
+ char buf[1000];
+ while (fgets(buf, sizeof buf, fp)) {
+ if (*buf == '\n' || *buf == '#')
+ continue;
+ buf[strlen(buf)-1] = 0;
+ char *cp = strchr(buf, ':');
+ if (cp == 0)
+ throw yp2::filter::FilterException("auth_simple user-register '" +
+ filename + "': bad line: " +
+ buf);
+ *cp++ = 0;
+ m_p->reg[buf] = cp;
+ //printf("Added user '%s' -> password '%s'\n", buf, cp);
+ }