+STATIC_LIST(parsers);
+
+static char *local_path(struct discover_context *ctx,
+ const char *filename)
+{
+ return join_paths(ctx, ctx->device->mount_path, filename);
+}
+
+static int download_config(struct discover_context *ctx, char **buf, int *len)
+{
+ unsigned tempfile;
+ const char *file;
+ int rc;
+
+ file = load_url(ctx, ctx->conf_url, &tempfile);
+ if (!file)
+ return -1;
+
+ rc = read_file(ctx, file, buf, len);
+ if (rc)
+ goto out_clean;
+
+ return 0;
+
+out_clean:
+ if (tempfile)
+ unlink(file);
+ return -1;
+}
+
+static void iterate_parser_files(struct discover_context *ctx,
+ const struct parser *parser)
+{
+ const char * const *filename;
+ const char *path;
+
+ if (!parser->filenames)
+ return;
+
+ for (filename = parser->filenames; *filename; filename++) {
+ int rc, len;
+ char *buf;
+
+ path = local_path(ctx, *filename);
+ if (!path)
+ continue;
+
+ rc = read_file(ctx, path, &buf, &len);
+ if (!rc) {
+ pb_log("Running parser %s on file %s\n",
+ parser->name, *filename);
+ parser->parse(ctx, buf, len);
+ talloc_free(buf);
+ }
+ }
+}
+
+void iterate_parsers(struct discover_context *ctx, enum conf_method method)