diff --git a/lib/c/2006/labcomm2006.c b/lib/c/2006/labcomm2006.c index 34c5b06956fdd9e4e9d5ac0050fcaa80529afc40..34a13ec11ca428da1eac5db458e8e388362b8d56 100644 --- a/lib/c/2006/labcomm2006.c +++ b/lib/c/2006/labcomm2006.c @@ -37,8 +37,6 @@ #include "labcomm2006_ioctl.h" #include "labcomm2006_dynamic_buffer_writer.h" -#define LABCOMM_VERSION "LabComm2006" - /* Unwrapping reader/writer functions */ #define UNWRAP_ac(rw, ac, ...) ac #define UNWRAP(func, ...) \ diff --git a/lib/c/2006/labcomm2006.h b/lib/c/2006/labcomm2006.h index eb7ad2c8bdb1a79de95470f7e2c15f201de0ec31..20db98efe70e1f379b4f36975940276216e4715e 100644 --- a/lib/c/2006/labcomm2006.h +++ b/lib/c/2006/labcomm2006.h @@ -23,6 +23,8 @@ #ifndef _LABCOMM_H_ #define _LABCOMM_H_ +#define LABCOMM_VERSION "LabComm2006" + #include <stdarg.h> #include <stdint.h> #include <unistd.h> diff --git a/lib/c/2006/labcomm2006_decoder.c b/lib/c/2006/labcomm2006_decoder.c index 3ee2f3ca53fba244d44d155e8b8854ba761e5d1f..a936f3e1bfd3d1eb0cdf77f0836026aabe55d8e5 100644 --- a/lib/c/2006/labcomm2006_decoder.c +++ b/lib/c/2006/labcomm2006_decoder.c @@ -18,8 +18,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define LABCOMM_VERSION "LabComm2006" - #include <errno.h> #include "labcomm2006.h" #include "labcomm2006_private.h" diff --git a/lib/c/2006/labcomm2006_encoder.c b/lib/c/2006/labcomm2006_encoder.c index a84f82a5681fc5d1d6d58ca1aafb76576faf3a95..06eb4dca403a0a43d44544cfe3a939963bc3d63d 100644 --- a/lib/c/2006/labcomm2006_encoder.c +++ b/lib/c/2006/labcomm2006_encoder.c @@ -18,8 +18,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define LABCOMM_VERSION "LabComm2006" - #include <errno.h> #include "labcomm2006.h" #include "labcomm2006_private.h" diff --git a/lib/c/2006/labcomm2006_fd_reader.c b/lib/c/2006/labcomm2006_fd_reader.c index a8100ffbbc59b67fae55003b8cd7a2ecf4e56097..7c0596094eba5dbd067f4debd05e049ea5ac98f5 100644 --- a/lib/c/2006/labcomm2006_fd_reader.c +++ b/lib/c/2006/labcomm2006_fd_reader.c @@ -40,6 +40,15 @@ static int fd_alloc(struct labcomm2006_reader *r, char *version) { int result = 0; +// in-band version is not included in version 2006. +// This may be a place for version checking and/or printing +// a warning message + if (version && version[0]) { + if (strcmp(LABCOMM_VERSION, version) != 0) { + fprintf(stderr, "ERROR: version mismatch: %s != %s\n", version, LABCOMM_VERSION); + return -EINVAL; + } + } r->count = 0; r->pos = 0; @@ -51,22 +60,6 @@ static int fd_alloc(struct labcomm2006_reader *r, r->data_size = BUFFER_SIZE; result = r->data_size; -#if 0 -// in-band version is not included in version 2006. -// This may be a place for version checking and/or printing -// a warning message - if (version && version[0]) { - char *tmp; - - tmp = labcomm2006_read_string(r); - if (strcmp(tmp, version) != 0) { - result = -EINVAL; - } else { - result = r->data_size; - } - labcomm2006_memory_free(r->memory, 1, tmp); - } -#endif } return result; } diff --git a/lib/c/2006/labcomm2006_fd_writer.c b/lib/c/2006/labcomm2006_fd_writer.c index 0b1d47440505102baa009e2841e450925a0e0e14..d93c63b6c9821e1f92c95193b0a9b51c00cda518 100644 --- a/lib/c/2006/labcomm2006_fd_writer.c +++ b/lib/c/2006/labcomm2006_fd_writer.c @@ -43,6 +43,16 @@ static int fd_alloc(struct labcomm2006_writer *w, struct labcomm2006_writer_action_context *action_context, char *version) { +// in-band version is not included in version 2006. +// This may be a place for version checking and/or printing +// a warning message + if (version && version[0]) { + if (strcmp(LABCOMM_VERSION, version) != 0) { + fprintf(stderr, "ERROR: version mismatch: %s != %s\n", version, LABCOMM_VERSION); + return -EINVAL; + } + } + w->data = labcomm2006_memory_alloc(w->memory, 0, BUFFER_SIZE); if (! w->data) { w->error = -ENOMEM; @@ -53,12 +63,6 @@ static int fd_alloc(struct labcomm2006_writer *w, w->data_size = BUFFER_SIZE; w->count = BUFFER_SIZE; w->pos = 0; - if (version && version[0]) { -#if 0 - labcomm2006_write_string(w, version); - fd_flush(w, action_context); -#endif - } } return w->error;