Skip to content
Snippets Groups Projects
Select Git revision
  • labcomm2014
  • labcomm2006
  • master default
  • python_sig_hash
  • typedefs
  • anders.blomdell
  • typeref
  • pragma
  • compiler-refactoring
  • labcomm2013
  • v2014.6
  • v2015.0
  • v2014.5
  • v2014.4
  • v2006.0
  • v2014.3
  • v2014.2
  • v2014.1
  • v2014.0
  • v2013.0
20 results

example_encoder.c

Blame
  • example_encoder.c 839 B
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <labcomm_fd_reader_writer.h>
    #include "gen/simple.h"
    
    int main(int argc, char *argv[]) {
      int fd;
      struct labcomm_encoder *encoder;
      int i, j;
    
      char *filename = argv[1];
      printf("C encoder writing to %s\n", filename);
      fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
      encoder = labcomm_encoder_new(labcomm_fd_writer, &fd);
      labcomm_encoder_register_simple_TwoInts(encoder);
      labcomm_encoder_register_simple_IntString(encoder);
      simple_IntString is;
      is.x = 24;
      is.s = "Hello, LabComm!";
      printf("Encoding IntString, x=%d, s=%s\n", is.x, is.s);
      labcomm_encode_simple_IntString(encoder, &is);
    
      simple_TwoInts ti;
      ti.a = 13;
      ti.b = 37;
      printf("Encoding TwoInts, a=%d, b=%d\n", ti.a, ti.b);
      labcomm_encode_simple_TwoInts(encoder, &ti);
    }