Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Erik Jansson
LabComm
Commits
d4d7a74e
Commit
d4d7a74e
authored
Feb 14, 2014
by
Sven Gestegård Robertz
Browse files
moved version to labcomm.h and added check (sketch) in reader and writer
parent
2b1728f7
Changes
6
Hide whitespace changes
Inline
Side-by-side
lib/c/2006/labcomm2006.c
View file @
d4d7a74e
...
...
@@ -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, ...) \
...
...
lib/c/2006/labcomm2006.h
View file @
d4d7a74e
...
...
@@ -23,6 +23,8 @@
#ifndef _LABCOMM_H_
#define _LABCOMM_H_
#define LABCOMM_VERSION "LabComm2006"
#include <stdarg.h>
#include <stdint.h>
#include <unistd.h>
...
...
lib/c/2006/labcomm2006_decoder.c
View file @
d4d7a74e
...
...
@@ -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"
...
...
lib/c/2006/labcomm2006_encoder.c
View file @
d4d7a74e
...
...
@@ -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"
...
...
lib/c/2006/labcomm2006_fd_reader.c
View file @
d4d7a74e
...
...
@@ -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
;
}
...
...
lib/c/2006/labcomm2006_fd_writer.c
View file @
d4d7a74e
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment