-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.c
57 lines (48 loc) · 1.18 KB
/
map.c
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
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#ifndef NEED_RUNLEVELS_DEF
#define NEED_RUNLEVELS_DEF
#endif
#include "listing.h"
int map_has_runlevels(void)
{
return RUNLEVELS;
}
char map_runlevel_to_key(const int runlevel)
{
if (runlevel >= RUNLEVELS) {
error("Wrong runlevel %d\n", runlevel);
}
return runlevel_locations[runlevel].key;
}
ushort map_key_to_lvl(const char key)
{
int runlevel;
const char uckey = toupper(key);
for (runlevel = 0; runlevel < RUNLEVELS; runlevel++) {
if (uckey == runlevel_locations[runlevel].key)
return runlevel_locations[runlevel].lvl;
}
error("Wrong runlevel key '%c'\n", uckey);
return 0;
}
const char *map_runlevel_to_location(const int runlevel)
{
if (runlevel >= RUNLEVELS) {
error("Wrong runlevel %d\n", runlevel);
}
return runlevel_locations[runlevel].location;
}
ushort map_runlevel_to_lvl(const int runlevel)
{
if (runlevel >= RUNLEVELS) {
error("Wrong runlevel %d\n", runlevel);
}
return runlevel_locations[runlevel].lvl;
}
ushort map_runlevel_to_seek(const int runlevel)
{
return runlevel_locations[runlevel].seek;
}