summaryrefslogtreecommitdiff
path: root/rcm-server-keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'rcm-server-keymap.c')
-rw-r--r--rcm-server-keymap.c72
1 files changed, 38 insertions, 34 deletions
diff --git a/rcm-server-keymap.c b/rcm-server-keymap.c
index d2a01c8..b33e262 100644
--- a/rcm-server-keymap.c
+++ b/rcm-server-keymap.c
@@ -155,19 +155,46 @@ keymap_parse(FILE *fp, char **line, size_t *buf_size, struct keymap *keymap,
/* FIXME: eat RHS whitespace for p */
switch (current_section) {
case INI_SECTION_DESCRIPTION:
- if (!keymap)
- continue;
+ if (!strcasecmp(p, "Rows")) {
+ if (rows >= 0) {
+ fprintf(stderr, "Multiple rows specifications\n");
+ return -EINVAL;
+ }
+
+ r = strtol_strict(tmp, &rows);
+ if (r < 0) {
+ fprintf(stderr, "Invalid rows specification\n");
+ return -EINVAL;
+ }
+
+ } else if (!strcasecmp(p, "Cols")) {
+ if (cols >= 0) {
+ fprintf(stderr, "Multiple cols specifications\n");
+ return -EINVAL;
+ }
+
+ r = strtol_strict(tmp, &cols);
+ if (r < 0) {
+ fprintf(stderr, "Invalid cols specification\n");
+ return -EINVAL;
+ }
+
+ } else if (!strcasecmp(p, "Name")) {
+ if (keymap) {
+ keymap->name = strdup(tmp);
+ if (!keymap->name)
+ return -ENOMEM;
+ }
- if (!strcasecmp(p, "Name")) {
- keymap->name = strdup(tmp);
- if (!keymap->name)
- return -ENOMEM;
} else if (!strcasecmp(p, "Description")) {
- keymap->description = strdup(tmp);
- if (!keymap->description)
- return -ENOMEM;
+ if (keymap) {
+ keymap->description = strdup(tmp);
+ if (!keymap->description)
+ return -ENOMEM;
+ }
}
break;
+
case INI_SECTION_KEYMAP:
if (!strcasecmp(p, "Map")) {
char *protocol;
@@ -214,32 +241,9 @@ keymap_parse(FILE *fp, char **line, size_t *buf_size, struct keymap *keymap,
}
break;
- case INI_SECTION_LAYOUT:
- if (!strcasecmp(p, "Rows")) {
- if (rows >= 0) {
- fprintf(stderr, "Multiple rows specifications\n");
- return -EINVAL;
- }
-
- r = strtol_strict(tmp, &rows);
- if (r < 0) {
- fprintf(stderr, "Invalid rows specification\n");
- return -EINVAL;
- }
-
- } else if (!strcasecmp(p, "Cols")) {
- if (cols >= 0) {
- fprintf(stderr, "Multiple cols specifications\n");
- return -EINVAL;
- }
- r = strtol_strict(tmp, &cols);
- if (r < 0) {
- fprintf(stderr, "Invalid cols specification\n");
- return -EINVAL;
- }
-
- } else if (!strcasecmp(p, "Button")) {
+ case INI_SECTION_LAYOUT:
+ if (!strcasecmp(p, "Button")) {
if (keymap) {
if (!strcasecmp(tmp, "Blank"))
keymap->layout[layout_count] = NULL;