/* sole.h -- encoding methods for the SOLE encoding * */ #ifndef SOLE_H #define SOLE_H 1 #include BEGIN_C_DECLS #define SOLE_OK 0 #define SOLE_NO_BUF_SPC 1 #define SOLE_DECODE_FINISH (2) #define SOLE_ERRNO (-1) #define SOLE_MEM_ERROR (-2) /** * The stream type. * * Holds the current state of the encoding/decoding. */ typedef struct sole_stream_s { byte flags; uint offset; size_t total_in; /* Total number of bytes read */ size_t total_out; /* Total number of bytes written */ blk128_t *i3; /* Current value of 3*i */ blk128_t *b3i; /* Current (B - 3i) */ blk128_t *r; /* Current remainder */ blk256_t *q; /* Current spill */ blk128_t *b1; /* First block */ blk128_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 */ } sole_stream; /* Initialise a sole_stream */ DPT_EXTERN(int) sole_stream_init(sole_stream *strm); /** * Encode 64 bits in SOLE */ DPT_EXTERN(int) sole_encode_u64(sole_stream *strm, uint64_t x); /** * Encode available input */ DPT_EXTERN(int) sole_encode(sole_stream *strm); /** * Decode available input * * Returns SOLE_DECODE_END when encoded EOF is encountered */ DPT_EXTERN(int) sole_decode(sole_stream *strm); /** * Encode the data to be extracted from the given file descriptor. */ DPT_EXTERN(void) sole_encode_fd(sole_stream *strm, int fd); /** * 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) sole_encode_end(sole_stream *strm); /** * Drop and release all resources associated with the given SOLE stream */ DPT_EXTERN(void) sole_stream_free(sole_stream *strm); END_C_DECLS #endif /* SOLE_H */