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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Sven Gestegård Robertz
LabComm
Commits
979cef40
Commit
979cef40
authored
Oct 26, 2014
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
refactored, preparing for wrapped decoders a.k.a shared registries
parent
b88ba88e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/c/labcomm.h
+1
-0
1 addition, 0 deletions
lib/c/labcomm.h
lib/c/labcomm_decoder.c
+34
-11
34 additions, 11 deletions
lib/c/labcomm_decoder.c
with
35 additions
and
11 deletions
lib/c/labcomm.h
+
1
−
0
View file @
979cef40
...
@@ -139,6 +139,7 @@ struct labcomm_pragma_handler {
...
@@ -139,6 +139,7 @@ struct labcomm_pragma_handler {
typedef
int
(
*
labcomm_pragma_handler_callback
)(
typedef
int
(
*
labcomm_pragma_handler_callback
)(
struct
labcomm_decoder
*
decoder
,
struct
labcomm_decoder
*
decoder
,
struct
labcomm_decoder
*
registry
,
char
*
pragma_type
);
char
*
pragma_type
);
void
labcomm_decoder_register_pragma_handler
(
struct
labcomm_decoder
*
d
,
void
labcomm_decoder_register_pragma_handler
(
struct
labcomm_decoder
*
d
,
...
...
This diff is collapsed.
Click to expand it.
lib/c/labcomm_decoder.c
+
34
−
11
View file @
979cef40
...
@@ -35,12 +35,18 @@ struct sample_entry {
...
@@ -35,12 +35,18 @@ struct sample_entry {
void
*
context
;
void
*
context
;
};
};
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
//XXX move to pragma.ch
//int default_pragma_handler(struct labcomm_decoder *d, char *pragma_type);
//int default_pragma_handler(struct labcomm_decoder *d, char *pragma_type);
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
)
{
{
printf
(
"Default pragma handler got pragma: %s
\n
"
,
pragma_type
);
printf
(
"Default pragma handler got pragma: %s
\n
"
,
pragma_type
);
int
res
=
labcomm
_decoder_run
(
d
);
int
res
=
internal
_decoder_run
(
d
,
registry
);
printf
(
"... %d:%s
\n
"
,
res
,
strerror
(
-
res
));
printf
(
"... %d:%s
\n
"
,
res
,
strerror
(
-
res
));
return
LABCOMM_PRAGMA
;
return
LABCOMM_PRAGMA
;
}
}
...
@@ -121,7 +127,9 @@ void labcomm_decoder_free(struct labcomm_decoder* d)
...
@@ -121,7 +127,9 @@ void labcomm_decoder_free(struct labcomm_decoder* d)
}
}
#endif
#endif
static
int
decode_sample_def
(
struct
labcomm_decoder
*
d
,
int
kind
)
static
int
decode_sample_def
(
struct
labcomm_decoder
*
d
,
struct
labcomm_decoder
*
registry
,
int
kind
)
{
{
int
result
;
int
result
;
struct
labcomm_signature
signature
,
*
local_signature
;
struct
labcomm_signature
signature
,
*
local_signature
;
...
@@ -224,7 +232,8 @@ static void reader_alloc(struct labcomm_decoder *d)
...
@@ -224,7 +232,8 @@ static void reader_alloc(struct labcomm_decoder *d)
labcomm_reader_alloc
(
d
->
reader
,
d
->
reader
->
action_context
);
labcomm_reader_alloc
(
d
->
reader
,
d
->
reader
->
action_context
);
}
}
}
}
static
int
decode_version
(
struct
labcomm_decoder
*
d
,
int
remote_index
)
static
int
decode_version
(
struct
labcomm_decoder
*
d
,
int
remote_index
)
{
{
int
result
;
int
result
;
char
*
version
=
labcomm_read_string
(
d
->
reader
);
char
*
version
=
labcomm_read_string
(
d
->
reader
);
...
@@ -255,7 +264,9 @@ static int decoder_skip(struct labcomm_decoder *d, int len, int tag)
...
@@ -255,7 +264,9 @@ static int decoder_skip(struct labcomm_decoder *d, int len, int tag)
}
}
return
tag
;
return
tag
;
}
}
static
int
decode_pragma
(
struct
labcomm_decoder
*
d
,
int
len
)
static
int
decode_pragma
(
struct
labcomm_decoder
*
d
,
struct
labcomm_decoder
*
registry
,
int
len
)
{
{
char
*
pragma_type
;
char
*
pragma_type
;
int
result
;
int
result
;
...
@@ -290,7 +301,7 @@ static int decode_pragma(struct labcomm_decoder *d, int len)
...
@@ -290,7 +301,7 @@ static int decode_pragma(struct labcomm_decoder *d, int len)
pr
,
d
->
error
,
d
->
memory
,
d
->
scheduler
);
pr
,
d
->
error
,
d
->
memory
,
d
->
scheduler
);
pd
->
version_ok
=
1
;
pd
->
version_ok
=
1
;
printf
(
"calling pragma_handler
\n
"
);
printf
(
"calling pragma_handler
\n
"
);
result
=
d
->
pragma_handler
(
pd
,
pragma_type
);
result
=
d
->
pragma_handler
(
pd
,
pd
,
pragma_type
);
printf
(
"returned from pragma_handler
\n
"
);
printf
(
"returned from pragma_handler
\n
"
);
internal_labcomm_decoder_free
(
pd
);
internal_labcomm_decoder_free
(
pd
);
...
@@ -326,7 +337,9 @@ static labcomm_decoder_function lookup_h(struct labcomm_decoder *d,
...
@@ -326,7 +337,9 @@ static labcomm_decoder_function lookup_h(struct labcomm_decoder *d,
labcomm_scheduler_data_unlock
(
d
->
scheduler
);
labcomm_scheduler_data_unlock
(
d
->
scheduler
);
return
do_decode
;
return
do_decode
;
}
}
static
int
decode_and_handle
(
struct
labcomm_decoder
*
d
,
int
remote_index
)
static
int
decode_and_handle
(
struct
labcomm_decoder
*
d
,
struct
labcomm_decoder
*
registry
,
int
remote_index
)
{
{
int
result
;
int
result
;
int
*
local_index
;
int
*
local_index
;
...
@@ -350,6 +363,11 @@ static int decode_and_handle(struct labcomm_decoder *d, int remote_index)
...
@@ -350,6 +363,11 @@ static int decode_and_handle(struct labcomm_decoder *d, int remote_index)
return
result
;
return
result
;
}
}
int
labcomm_decoder_decode_one
(
struct
labcomm_decoder
*
d
)
int
labcomm_decoder_decode_one
(
struct
labcomm_decoder
*
d
)
{
return
internal_decode_one
(
d
,
d
);
}
int
internal_decode_one
(
struct
labcomm_decoder
*
d
,
struct
labcomm_decoder
*
registry
)
{
{
int
result
,
remote_index
,
length
;
int
result
,
remote_index
,
length
;
...
@@ -370,21 +388,26 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
...
@@ -370,21 +388,26 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
fprintf
(
stderr
,
"No VERSION %d %d
\n
"
,
remote_index
,
length
);
fprintf
(
stderr
,
"No VERSION %d %d
\n
"
,
remote_index
,
length
);
result
=
-
ECONNRESET
;
result
=
-
ECONNRESET
;
}
else
if
(
remote_index
==
LABCOMM_SAMPLE_DEF
)
{
}
else
if
(
remote_index
==
LABCOMM_SAMPLE_DEF
)
{
result
=
decode_sample_def
(
d
,
remote_index
);
result
=
decode_sample_def
(
d
,
d
,
remote_index
);
}
else
if
(
remote_index
==
LABCOMM_PRAGMA
){
}
else
if
(
remote_index
==
LABCOMM_PRAGMA
){
result
=
decode_pragma
(
d
,
length
);
result
=
decode_pragma
(
d
,
d
,
length
);
}
else
if
(
remote_index
<
LABCOMM_USER
)
{
}
else
if
(
remote_index
<
LABCOMM_USER
)
{
//fprintf(stderr, "SKIP %d %d\n", remote_index, length);
//fprintf(stderr, "SKIP %d %d\n", remote_index, length);
//result = remote_index;
//result = remote_index;
result
=
decoder_skip
(
d
,
length
,
remote_index
);
result
=
decoder_skip
(
d
,
length
,
remote_index
);
}
else
{
}
else
{
result
=
decode_and_handle
(
d
,
remote_index
);
result
=
decode_and_handle
(
d
,
d
,
remote_index
);
}
}
out:
out:
return
result
;
return
result
;
}
}
int
labcomm_decoder_run
(
struct
labcomm_decoder
*
d
)
int
labcomm_decoder_run
(
struct
labcomm_decoder
*
d
)
{
return
internal_decoder_run
(
d
,
d
);
}
int
internal_decoder_run
(
struct
labcomm_decoder
*
d
,
struct
labcomm_decoder
*
registry
)
{
{
int
res
;
int
res
;
while
(
(
res
=
labcomm_decoder_decode_one
(
d
))
>
0
)
{
while
(
(
res
=
labcomm_decoder_decode_one
(
d
))
>
0
)
{
...
...
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