blob: c43e8ecd5ec1f7b0463a9f8b3ffe096537de3a6c (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// (C) 2017 <>< C. N. Lohr, Under MIT/x11 License.
//
// See notice in survive_driverman.h
//
#include "survive_internal.h"
#include <stdio.h>
#include <string.h>
static void *Drivers[MAX_DRIVERS];
static const char *DriverNames[MAX_DRIVERS];
static int NrDrivers;
void RegisterDriver(const char *element, void *data) {
Drivers[NrDrivers] = data;
DriverNames[NrDrivers] = element;
NrDrivers++;
}
void *GetDriver(const char *element) {
int i;
for (i = 0; i < NrDrivers; i++) {
if (strcmp(element, DriverNames[i]) == 0)
return Drivers[i];
}
return 0;
}
const char *GetDriverNameMatching(const char *prefix, int place) {
int i;
int prefixlen = (int)strlen(prefix);
for (i = 0; i < NrDrivers; i++) {
if (strncmp(prefix, DriverNames[i], prefixlen) == 0)
if (0 == (place--))
return DriverNames[i];
}
return 0;
}
void ListDrivers() {
int i;
printf("Drivers (%d/%d):\n", NrDrivers, MAX_DRIVERS);
for (i = 0; i < NrDrivers; i++) {
printf(" %s\n", DriverNames[i]);
}
}
|