diff --git a/lib/c/labcomm.h b/lib/c/labcomm.h index d67bb2a3977afb73d202c3cc912874f09a9d28c7..bc68f098101dca46ff57a327d758c206d13c187d 100644 --- a/lib/c/labcomm.h +++ b/lib/c/labcomm.h @@ -39,6 +39,8 @@ struct labcomm_encoder; struct labcomm_decoder; +#include "labcomm_pragma.h" + /* * Signature entry */ @@ -125,26 +127,6 @@ int labcomm_decoder_ioctl(struct labcomm_decoder *decoder, uint32_t ioctl_action, ...); -/* pragma */ -struct labcomm_encoder *labcomm_pragma_builder_new( - struct labcomm_encoder *e, - char * pragma_type) ; -int labcomm_pragma_send(struct labcomm_encoder* e); -struct labcomm_pragma_handler { - //struct labcomm_decoder_registry *registry; - //TODO: implement map (char * pragma_type) --> decoder_registry * - //to allow having different sets of handlers for different pragma types - int foo; -}; - -typedef int (*labcomm_pragma_handler_callback)( - struct labcomm_decoder *decoder, - struct labcomm_decoder *registry, - char *pragma_type); - -void labcomm_decoder_register_pragma_handler(struct labcomm_decoder *d, - labcomm_pragma_handler_callback pragma_dispatcher); - /* * Encoder */ diff --git a/lib/c/labcomm_decoder.c b/lib/c/labcomm_decoder.c index 1a6536d88df98bed85c44466fef1c6641c0e68f2..37679ceb5566e6892f2704e9cb5711a8efdee8b0 100644 --- a/lib/c/labcomm_decoder.c +++ b/lib/c/labcomm_decoder.c @@ -39,8 +39,6 @@ static int internal_decoder_run(struct labcomm_decoder *d, struct labcomm_decoder *registry); static int internal_decode_one(struct labcomm_decoder *d, struct labcomm_decoder *registry); -//XXX move to pragma.ch -//int default_pragma_handler(struct labcomm_decoder *d, char *pragma_type); int default_pragma_handler(struct labcomm_decoder *d, struct labcomm_decoder *registry, char *pragma_type) diff --git a/lib/c/labcomm_pragma.h b/lib/c/labcomm_pragma.h new file mode 100644 index 0000000000000000000000000000000000000000..a9097c37bcc4ce7d8c84178125d22b0550a19fb9 --- /dev/null +++ b/lib/c/labcomm_pragma.h @@ -0,0 +1,48 @@ +/* + labcomm_pragma.h -- user interface for handling labcomm pragma packets. + + Copyright 2014 Sven GestegÄrd Robertz <sven.robertz@cs.lth.se> + + This file is part of LabComm. + + LabComm is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LabComm is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _LABCOMM_PRAGMA_H +#define _LABCOMM_PRAGMA_H + +typedef int (*labcomm_pragma_handler_callback)( + struct labcomm_decoder *decoder, + struct labcomm_decoder *registry, + char *pragma_type); + +void labcomm_decoder_register_pragma_handler(struct labcomm_decoder *d, + labcomm_pragma_handler_callback pragma_dispatcher); + +int default_pragma_handler(struct labcomm_decoder *d, + struct labcomm_decoder *registry, + char *pragma_type); + +struct labcomm_encoder *labcomm_pragma_builder_new( + struct labcomm_encoder *e, + char * pragma_type) ; +int labcomm_pragma_send(struct labcomm_encoder* e); +struct labcomm_pragma_handler { + //struct labcomm_decoder_registry *registry; + //TODO: implement map (char * pragma_type) --> decoder_registry * + //to allow having different sets of handlers for different pragma types + int foo; +}; + +#endif