diff --git a/.gitignore b/.gitignore index b6bd49f..0e268a8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.swp *.o hkd* +tests/parse +tests/ioctl +tests/evtest diff --git a/template.conf b/template.conf new file mode 100644 index 0000000..d8ee747 --- /dev/null +++ b/template.conf @@ -0,0 +1,13 @@ +# This is a comment + +# these are valid entries +keymap = it +layout = qwerty + +I dont care about whitespaces = true +# will be translated to Idontcareaboutwhitespaces=true +or tabs = true +# is: ortabs=true + +# I can define strings +identifier = "keyboard 0" diff --git a/tests/makefile b/tests/makefile new file mode 100644 index 0000000..cdaecf1 --- /dev/null +++ b/tests/makefile @@ -0,0 +1,11 @@ +CC = gcc +CFLAGS = -Wall -Werror -pedantic -O2 + +parse: parse.c + +ioctl: ioctl.c + +evtest: evtest.c + +clean: + rm *.o parse ioctl 2> /dev/null diff --git a/tests/parse.c b/tests/parse.c new file mode 100644 index 0000000..09296fe --- /dev/null +++ b/tests/parse.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include + +int main(int argc, char const *argv[]) +{ + if (argc < 2) + return 1; + FILE *fd; + fd = fopen(argv[1], "r"); + if (!fd) + return -1; + for (;;) { + char *line = NULL; + size_t linelen = 0; + if (getline(&line, &linelen, fd) == -1) + break; + if (linelen < 2) + continue; + + printf("%s\n", line); + // remove white spaces + for (size_t i = 0; i < linelen; i++) { + if (isblank(line[i])) + memmove(&line[i], &line[i + 1], linelen - i); + } + if (line[0] == '#') + continue; + printf("%s\n", line); + + char *token = NULL; + token = strtok(line, "="); + if (token) + printf("%s\n", token); + token = strtok(NULL, "="); + if (token) + printf("%s\n", token); + free(line); + } + return 0; +}