summaryrefslogtreecommitdiffstats
path: root/src/device.h
blob: 33acfbb03ec0f1644dda1c6d5415f2784b822ab1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#include "config-ini.h"

#include <libubox/avl.h>

extern struct avl_tree device_types;

typedef struct _device_type device_type_t;

typedef struct _device {
	struct avl_node node;
	const device_type_t *type;
} device_t;

struct _device_type {
	struct avl_node node;
	device_t * (*process_config)(const char *name, const ini_file_t *config);
	void (*free)(device_t *device);

	void (*init)(device_t *device);
	void (*update)(device_t *device);
	void (*release)(device_t *device);
};

void register_device_type(const char *name, device_type_t *device_type);
const device_type_t * get_device_type(const char *name);