/* sole.h -- encoding methods for the SOLE encoding * */ #ifndef SOLEG_H #define SOLEG_H 1 #include #include BEGIN_C_DECLS #define SOLEG_OK 0 #define SOLEG_NO_BUF_SPC 1 #define SOLEG_DECODE_FINISH (2) #define SOLEG_ERRNO (-1) #define SOLEG_MEM_ERROR (-2) /** * The stream type. * * Holds the current state of the encoding/decoding. */ typedef struct soleg_stream_s { byte flags; uint offset; size_t total_in; /* Total number of bytes read */ size_t total_out; /* Total number of bytes written */ mpz_t i3; /* Current value of 3*i */ mpz_t b3i; /* Current (B - 3i) */ mpz_t r; /* Current remainder */ mpz_t q; /* Current spill */ mpz_t b1; /* First block */ mpz_t b2; /* Second block */ size_t avail_in; /* Number of bytes available */ byte *inp; /* Next input bytes */ size_t avail_out; /* Remaining free space at outp */ byte *outp; /* Pointer to next output slot */ byte buf[64]; /* Buffer, used for alignment */ } soleg_stream; /* Initialise a soleg_stream */ DPT_EXTERN(int) soleg_stream_init(soleg_stream *strm); /** * Encode available input */ DPT_EXTERN(int) soleg_encode(soleg_stream *strm); /** * Instruct the given stream that it is finished. This takes care of finalising * the output, encoding EOF and free()'ing the associated resources */ DPT_EXTERN(void) soleg_encode_end(soleg_stream *strm); /** * Drop and release all resources associated with the given SOLE stream */ DPT_EXTERN(void) soleg_stream_free(soleg_stream *strm); END_C_DECLS #endif /* SOLE_H */