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
Anders Blomdell
LabComm
Commits
011d940d
Commit
011d940d
authored
May 21, 2015
by
Sven Gestegård Robertz
Browse files
WiP: temporary fix in C lib, incompatible with other libs
parent
52e78cef
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/c/2014/labcomm2014_decoder.c
View file @
011d940d
...
...
@@ -157,6 +157,17 @@ static int decode_sample_def_or_ref(struct labcomm2014_decoder *d, int kind)
result
=
d
->
reader
->
error
;
goto
out
;
}
int
numInts
=
labcomm2014_read_byte
(
d
->
reader
);
if
(
numInts
!=
1
)
{
printf
(
"WARNING! #intentions != 1, this will probably crash
\n
"
);
}
//XXX temporary kludge for intentions
//assume only one intention: the name
labcomm2014_read_packed32
(
d
->
reader
);
// assume the empty key (i.e., name)
signature
.
name
=
labcomm2014_read_string
(
d
->
reader
);
if
(
d
->
reader
->
error
<
0
)
{
result
=
d
->
reader
->
error
;
...
...
lib/c/2014/labcomm2014_encoder.c
View file @
011d940d
...
...
@@ -36,6 +36,25 @@ struct encoder {
LABCOMM_SIGNATURE_ARRAY_DEF
(
typedefs
,
int
);
};
/* XXX: TEMPORARY PLACEHOLDERS FOR INTENTIONS */
static
int
TODO_sizeof_intentions
(
const
struct
labcomm2014_signature
*
signature
)
{
return
labcomm2014_size_string
(
signature
->
name
)
+
2
;
}
static
int
TODO_encode_intentions
(
struct
labcomm2014_encoder
*
e
,
const
struct
labcomm2014_signature
*
signature
)
{
int
result
=
-
EINVAL
;
labcomm2014_write_packed32
(
e
->
writer
,
1
);
// one intention: the name
labcomm2014_write_packed32
(
e
->
writer
,
0
);
// key: the empty string
labcomm2014_write_string
(
e
->
writer
,
signature
->
name
);
result
=
e
->
writer
->
error
;
return
result
;
}
static
int
do_sample_register
(
struct
labcomm2014_encoder
*
e
,
const
struct
labcomm2014_signature
*
signature
,
...
...
@@ -58,12 +77,12 @@ static int do_sample_register(
if
(
err
!=
0
)
{
result
=
err
;
goto
out
;
}
labcomm2014_write_packed32
(
e
->
writer
,
LABCOMM_SAMPLE_DEF
);
length
=
(
labcomm2014_size_packed32
(
index
)
+
labcomm2014_size_string
(
signature
->
name
)
+
TODO_sizeof_intentions
(
signature
)
+
labcomm2014_size_packed32
(
signature
->
size
)
+
signature
->
size
);
labcomm2014_write_packed32
(
e
->
writer
,
length
);
labcomm2014_write_packed32
(
e
->
writer
,
index
);
labcomm2014_write_string
(
e
->
writer
,
signature
->
name
);
TODO_encode_intentions
(
e
,
signature
);
labcomm2014_write_packed32
(
e
->
writer
,
signature
->
size
);
for
(
i
=
0
;
i
<
signature
->
size
;
i
++
)
{
if
(
e
->
writer
->
pos
>=
e
->
writer
->
count
)
{
...
...
@@ -138,12 +157,12 @@ static int do_ref_register(
if
(
err
!=
0
)
{
result
=
err
;
goto
out
;
}
labcomm2014_write_packed32
(
e
->
writer
,
LABCOMM_SAMPLE_REF
);
length
=
(
labcomm2014_size_packed32
(
index
)
+
labcomm2014_size_string
(
signature
->
name
)
+
TODO_sizeof_intentions
(
signature
)
+
labcomm2014_size_packed32
(
signature
->
size
)
+
signature
->
size
);
labcomm2014_write_packed32
(
e
->
writer
,
length
);
labcomm2014_write_packed32
(
e
->
writer
,
index
);
labcomm2014_write_string
(
e
->
writer
,
signature
->
name
);
TODO_encode_intentions
(
e
,
signature
);
labcomm2014_write_packed32
(
e
->
writer
,
signature
->
size
);
for
(
i
=
0
;
i
<
signature
->
size
;
i
++
)
{
if
(
e
->
writer
->
pos
>=
e
->
writer
->
count
)
{
...
...
lib/c/2014/test/test_labcomm_generated_encoding.c
View file @
011d940d
...
...
@@ -213,7 +213,7 @@ int main(void)
/* Register twice to make sure that only one registration gets encoded */
labcomm2014_encoder_register_generated_encoding_V
(
encoder
);
labcomm2014_encoder_register_generated_encoding_V
(
encoder
);
EXPECT
({
0x02
,
0x0
7
,
VARIABLE
(
0
),
0x01
,
'V'
,
0x0
3
,
0x0
0
,
0x11
,
0x00
,
EXPECT
({
0x02
,
0x0
8
,
VARIABLE
(
0
),
0x01
,
0x00
,
0x0
1
,
'V'
,
0x0
2
,
0x11
,
0x00
,
0x04
,
0x08
,
VARIABLE
(
1
),
0x03
,
'v'
,
'_'
,
't'
,
0x02
,
0x11
,
0x00
,
0x04
,
0x05
,
VARIABLE
(
2
),
0x01
,
'V'
,
0x01
,
VARIABLE
(
1
),
0x05
,
0x02
,
VARIABLE
(
0
),
VARIABLE
(
2
)
});
...
...
@@ -222,14 +222,14 @@ int main(void)
/* Register twice to make sure that only one registration gets encoded */
labcomm2014_encoder_register_generated_encoding_B
(
encoder
);
labcomm2014_encoder_register_generated_encoding_B
(
encoder
);
EXPECT
({
0x02
,
0x0
6
,
VARIABLE
(
3
),
0x01
,
'B'
,
0x0
2
,
0x0
0
,
0x21
,
EXPECT
({
0x02
,
0x0
7
,
VARIABLE
(
3
),
0x01
,
0x00
,
0x0
1
,
'B'
,
0x0
1
,
0x21
,
0x05
,
0x02
,
VARIABLE
(
3
),
LABCOMM_BIND_SELF
});
labcomm2014_encoder_ioctl
(
encoder
,
IOCTL_WRITER_RESET
);
/* Register twice to make sure that only one registration gets encoded */
labcomm2014_encoder_register_generated_encoding_R
(
encoder
);
labcomm2014_encoder_register_generated_encoding_R
(
encoder
);
EXPECT
({
0x02
,
0x0
9
,
VARIABLE
(
4
),
0x01
,
'R'
,
0x0
5
,
0x0
0
,
0x10
,
0x01
,
0x04
,
0x28
,
EXPECT
({
0x02
,
0x0
a
,
VARIABLE
(
4
),
0x01
,
0x00
,
0x0
1
,
'R'
,
0x0
4
,
0x10
,
0x01
,
0x04
,
0x28
,
0x05
,
0x02
,
VARIABLE
(
4
),
LABCOMM_BIND_SELF
});
labcomm2014_encoder_ioctl
(
encoder
,
IOCTL_WRITER_RESET
);
...
...
@@ -238,7 +238,7 @@ int main(void)
labcomm2014_signature_generated_encoding_V
);
labcomm2014_encoder_sample_ref_register
(
encoder
,
labcomm2014_signature_generated_encoding_V
);
EXPECT
({
0x03
,
0x0
7
,
VARIABLE
(
5
),
0x01
,
'V'
,
0x0
3
,
0x0
0
,
0x11
,
0x00
});
EXPECT
({
0x03
,
0x0
8
,
VARIABLE
(
5
),
0x01
,
0x00
,
0x0
1
,
'V'
,
0x0
2
,
0x11
,
0x00
});
labcomm2014_encoder_ioctl
(
encoder
,
IOCTL_WRITER_RESET
);
/* Register twice to make sure that only one registration gets encoded */
...
...
@@ -246,7 +246,7 @@ int main(void)
labcomm2014_signature_generated_encoding_B
);
labcomm2014_encoder_sample_ref_register
(
encoder
,
labcomm2014_signature_generated_encoding_B
);
EXPECT
({
0x03
,
0x0
6
,
VARIABLE
(
6
),
0x01
,
'B'
,
0x0
2
,
0x0
0
,
0x21
});
EXPECT
({
0x03
,
0x0
7
,
VARIABLE
(
6
),
0x01
,
0x00
,
0x0
1
,
'B'
,
0x0
1
,
0x21
});
labcomm2014_encoder_ioctl
(
encoder
,
IOCTL_WRITER_RESET
);
/* Register twice to make sure that only one registration gets encoded */
...
...
@@ -254,7 +254,7 @@ int main(void)
labcomm2014_signature_generated_encoding_R
);
labcomm2014_encoder_sample_ref_register
(
encoder
,
labcomm2014_signature_generated_encoding_R
);
EXPECT
({
0x03
,
0x0
9
,
VARIABLE
(
7
),
0x01
,
'R'
,
0x0
5
,
0x0
0
,
0x10
,
0x01
,
0x04
,
0x28
});
EXPECT
({
0x03
,
0x0
a
,
VARIABLE
(
7
),
0x01
,
0x00
,
0x0
1
,
'R'
,
0x0
4
,
0x10
,
0x01
,
0x04
,
0x28
});
labcomm2014_encoder_ioctl
(
encoder
,
IOCTL_WRITER_RESET
);
// was: labcomm2014_encode_generated_encoding_V(encoder, &V);
...
...
Write
Preview
Supports
Markdown
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