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
Tommy Olofsson
LabComm
Commits
80fb199f
Commit
80fb199f
authored
Nov 08, 2011
by
Sven Robertz
Browse files
added C decoder
parent
ca5b4caf
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/simple_java/compile.sh
View file @
80fb199f
...
...
@@ -2,5 +2,7 @@ java -jar ../../labComm.jar --java=gen --c=gen/simple.c --h=gen/simple.h simple
javac
-cp
../../lib/java:. gen/
*
.java Encoder.java Decoder.java
gcc
-o
encoder
-I
.
-I
../../lib/c example_encoder.c gen/simple.c ../../lib/c/labcomm.c ../../lib/c/labcomm_fd_reader_writer.c
gcc
-o
example_encoder
-I
.
-I
../../lib/c example_encoder.c gen/simple.c ../../lib/c/labcomm.c ../../lib/c/labcomm_fd_reader_writer.c
gcc
-o
example_decoder
-I
.
-I
../../lib/c example_decoder.c gen/simple.c ../../lib/c/labcomm.c ../../lib/c/labcomm_fd_reader_writer.c
examples/simple_java/example_decoder.c
0 → 100644
View file @
80fb199f
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <labcomm_fd_reader_writer.h>
#include "gen/simple.h"
static
void
handle_simple_TwoInts
(
simple_TwoInts
*
v
,
void
*
context
)
{
printf
(
"Got TwoInts. a=%d, b=%d
\n
"
,
v
->
a
,
v
->
b
);
}
static
void
handle_simple_IntString
(
simple_IntString
*
v
,
void
*
context
)
{
printf
(
"Got IntString. x=%d, s=%s
\n
"
,
v
->
x
,
v
->
s
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
fd
;
struct
labcomm_decoder
*
decoder
;
void
*
context
=
NULL
;
int
i
,
j
;
char
*
filename
=
argv
[
1
];
printf
(
"C decoder reading from %s
\n
"
,
filename
);
fd
=
open
(
filename
,
O_RDONLY
);
decoder
=
labcomm_decoder_new
(
labcomm_fd_reader
,
&
fd
);
if
(
!
decoder
)
{
printf
(
"Failed to allocate decoder %s:%d
\n
"
,
__FUNCTION__
,
__LINE__
);
return
1
;
}
labcomm_decoder_register_simple_TwoInts
(
decoder
,
handle_simple_TwoInts
,
context
);
labcomm_decoder_register_simple_IntString
(
decoder
,
handle_simple_IntString
,
context
);
printf
(
"Decoding:
\n
"
);
labcomm_decoder_run
(
decoder
);
printf
(
"--- End Of File ---:
\n
"
);
labcomm_decoder_free
(
decoder
);
}
examples/simple_java/run.sh
View file @
80fb199f
java
-cp
.:../../lib/java:gen Encoder encoded_data
java
-cp
.:../../lib/java:gen Decoder encoded_data
./example_decoder encoded_data
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