Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton Klarén
LabComm
Commits
02d82d5d
Commit
02d82d5d
authored
10 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
skeleton decoder
parent
91219636
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/c/labcomm_decoder.c
+22
-16
22 additions, 16 deletions
lib/c/labcomm_decoder.c
lib/c/labcomm_encoder.c
+1
-1
1 addition, 1 deletion
lib/c/labcomm_encoder.c
lib/c/labcomm_private.h
+6
-4
6 additions, 4 deletions
lib/c/labcomm_private.h
with
29 additions
and
21 deletions
lib/c/labcomm_decoder.c
+
22
−
16
View file @
02d82d5d
...
...
@@ -86,7 +86,7 @@ void labcomm_decoder_free(struct labcomm_decoder* d)
labcomm_memory_free
(
memory
,
0
,
d
);
}
static
int
decode_sample
(
struct
labcomm_decoder
*
d
,
int
kind
)
static
int
decode_sample
_def
(
struct
labcomm_decoder
*
d
,
int
kind
)
{
int
result
;
struct
labcomm_signature
signature
,
*
local_signature
;
...
...
@@ -189,7 +189,24 @@ static void reader_alloc(struct labcomm_decoder *d)
labcomm_reader_alloc
(
d
->
reader
,
d
->
reader
->
action_context
);
}
}
static
int
decode_version
(
struct
labcomm_decoder
*
d
,
int
remote_index
)
{
int
result
;
char
*
version
=
labcomm_read_string
(
d
->
reader
);
if
(
d
->
reader
->
error
<
0
)
{
result
=
d
->
reader
->
error
;
goto
out
;
}
if
(
strcmp
(
version
,
CURRENT_VERSION
)
==
0
)
{
result
=
LABCOMM_VERSION
;
d
->
version_ok
=
1
;
}
else
{
result
=
-
ECONNRESET
;
}
labcomm_memory_free
(
d
->
memory
,
1
,
version
);
out:
return
result
;
}
int
labcomm_decoder_decode_one
(
struct
labcomm_decoder
*
d
)
{
int
result
,
remote_index
,
length
;
...
...
@@ -206,23 +223,12 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
goto
out
;
}
if
(
remote_index
==
LABCOMM_VERSION
)
{
char
*
version
=
labcomm_read_string
(
d
->
reader
);
if
(
d
->
reader
->
error
<
0
)
{
result
=
d
->
reader
->
error
;
goto
out
;
}
if
(
strcmp
(
version
,
CURRENT_VERSION
)
==
0
)
{
result
=
LABCOMM_VERSION
;
d
->
version_ok
=
1
;
}
else
{
result
=
-
ECONNRESET
;
}
labcomm_memory_free
(
d
->
memory
,
1
,
version
);
result
=
decode_version
(
d
,
remote_index
);
}
else
if
(
!
d
->
version_ok
)
{
fprintf
(
stderr
,
"No VERSION %d %d
\n
"
,
remote_index
,
length
);
result
=
-
ECONNRESET
;
}
else
if
(
remote_index
==
LABCOMM_SAMPLE
)
{
result
=
decode_sample
(
d
,
remote_index
);
}
else
if
(
remote_index
==
LABCOMM_SAMPLE
_DEF
)
{
result
=
decode_sample
_def
(
d
,
remote_index
);
}
else
if
(
remote_index
==
LABCOMM_PRAGMA
&&
0
/* d->pragma_handler*/
)
{
/* d->prama_handler(...); */
}
else
if
(
remote_index
<
LABCOMM_USER
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/c/labcomm_encoder.c
+
1
−
1
View file @
02d82d5d
...
...
@@ -222,7 +222,7 @@ int labcomm_internal_encoder_register(
index
,
signature
,
NULL
);
if
(
err
==
-
EALREADY
)
{
result
=
0
;
goto
out
;
}
if
(
err
!=
0
)
{
result
=
err
;
goto
out
;
}
labcomm_write_packed32
(
e
->
writer
,
LABCOMM_SAMPLE
);
labcomm_write_packed32
(
e
->
writer
,
LABCOMM_SAMPLE
_DEF
);
length
=
(
labcomm_size_packed32
(
index
)
+
labcomm_size_string
(
signature
->
name
)
+
labcomm_size_packed32
(
signature
->
size
)
+
...
...
This diff is collapsed.
Click to expand it.
lib/c/labcomm_private.h
+
6
−
4
View file @
02d82d5d
...
...
@@ -40,7 +40,9 @@
* Allowed packet tags
*/
#define LABCOMM_VERSION 0x01
#define LABCOMM_SAMPLE 0x02
#define LABCOMM_SAMPLE_DEF 0x02
#define LABCOMM_TYPE_DEF 0x03
#define LABCOMM_TYPE_BINDING 0x04
#define LABCOMM_PRAGMA 0x3f
#define LABCOMM_USER 0x40
/* ..0xffffffff */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment