summaryrefslogtreecommitdiff
path: root/rcm-server-keymap.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2015-07-18 10:59:50 +0200
committerDavid Härdeman <david@hardeman.nu>2015-07-18 10:59:50 +0200
commit48bd20a7b4d183edf2e19e17a3b7dc1d307ea8c1 (patch)
treea882729fc41a09c92e7641b6fbd33889bbdb1bad /rcm-server-keymap.c
parentf9bfa7645d2301fbf9de5510ad9cf4c98d8cfcea (diff)
Move rows and cols in keymap files to the description section
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;