From 47c03b4e192acc14bdd5c130568fbe443e9f290e Mon Sep 17 00:00:00 2001 From: Sven Gestegard Robertz <sven.robertz@cs.lth.se> Date: Mon, 27 Oct 2014 12:43:56 +0100 Subject: [PATCH] started moving pragma declarations t pragma.h --- lib/c/labcomm.h | 22 ++----------------- lib/c/labcomm_decoder.c | 2 -- lib/c/labcomm_pragma.h | 48 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 22 deletions(-) create mode 100644 lib/c/labcomm_pragma.h diff --git a/lib/c/labcomm.h b/lib/c/labcomm.h index d67bb2a..bc68f09 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 1a6536d..37679ce 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 0000000..a9097c3 --- /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 -- GitLab