diff options
author | Michał Cichoń <michcic@gmail.com> | 2015-08-25 19:56:24 +0200 |
---|---|---|
committer | Michał Cichoń <michcic@gmail.com> | 2015-08-25 19:56:24 +0200 |
commit | 682f23e7bb4a52bedf46eff5c4859e1308eda124 (patch) | |
tree | 30ad4f37b434ecdfb5edc36dfbaf7fc924e53c0e /vtparse/src/vtparse_test.c | |
parent | 8b41fc907bcd27d24c895062ae8a61b305fc2d46 (diff) | |
download | pianobar-windows-build-682f23e7bb4a52bedf46eff5c4859e1308eda124.tar.gz pianobar-windows-build-682f23e7bb4a52bedf46eff5c4859e1308eda124.tar.bz2 pianobar-windows-build-682f23e7bb4a52bedf46eff5c4859e1308eda124.zip |
Update build ref
Diffstat (limited to 'vtparse/src/vtparse_test.c')
-rw-r--r-- | vtparse/src/vtparse_test.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vtparse/src/vtparse_test.c b/vtparse/src/vtparse_test.c new file mode 100644 index 0000000..4082655 --- /dev/null +++ b/vtparse/src/vtparse_test.c @@ -0,0 +1,37 @@ +/* + * VTParse - an implementation of Paul Williams' DEC compatible state machine parser + * + * Author: Joshua Haberman <joshua@reverberate.org> + * + * This code is in the public domain. + */ + +#include <stdio.h> +#include "vtparse.h" + +void parser_callback(vtparse_t *parser, vtparse_action_t action, unsigned char ch) +{ + int i; + + printf("Received action %s, char=0x%02x\n", ACTION_NAMES[action]); + printf("Intermediate chars: '%s'\n", parser->intermediate_chars); + printf("%d Parameters:\n", parser->num_params); + for(i = 0; i < parser->num_params; i++) + printf("\t%d\n", parser->params[i]); + printf("\n"); +} + +int main() +{ + unsigned char buf[1024]; + int bytes; + vtparse_t parser; + + vtparse_init(&parser, parser_callback); + + while(1) { + bytes = read(0, buf, 1024); + vtparse(&parser, buf, bytes); + } +} + |