6 #include "device-handler.h"
8 struct discover_context;
15 * Each parser is responsible for creating discover_boot_options from config
16 * files found on new devices. The boot items discovered during parse will have
17 * 'resources' attached (see @discover_boot_option), which may already be
18 * resolved (in the case of a device-local filename, or a URL), or unresolved
19 * (in the case of a filename on another device).
21 * If the boot option contains references to unresolved resources, the
22 * device handler will not inform clients about the boot options, as
23 * they're not properly "available" at this stage. The handler will attempt to
24 * resolve them whenever new devices are discovered, by calling the parser's
25 * resolve_resource function. Once a boot option's resources are full resolved,
26 * the option can be sent to clients.
30 int (*parse)(struct discover_context *ctx);
31 bool (*resolve_resource)(
32 struct device_handler *handler,
33 struct resource *res);
36 enum generic_icon_type {
44 #define streq(a,b) (!strcasecmp((a),(b)))
46 void parser_init(void);
48 void iterate_parsers(struct discover_context *ctx);
49 int parse_user_event(struct discover_context *ctx, struct event *event);
51 /* File IO functions for parsers; these should be the only interface that
52 * parsers use to access a device's filesystem.
54 * These are intended for small amounts of data, typically text configuration
57 int parser_request_file(struct discover_context *ctx,
58 struct discover_device *dev, const char *filename,
59 char **buf, int *len);
60 int parser_replace_file(struct discover_context *ctx,
61 struct discover_device *dev, const char *filename,
63 int parser_request_url(struct discover_context *ctx, struct pb_url *url,
64 char **buf, int *len);
65 int parser_check_dir(struct discover_context *ctx,
66 struct discover_device *dev, const char *dirname);
68 #endif /* _PARSER_H */