#ifndef NAIVE_H #define NAIVE_H 1 #include #include #include #include #include typedef unsigned char byte; #ifndef lo #define lo(x) ((uint32_t)x) #endif #ifndef hi #define hi(x) ((uint32_t)(x>>32)) #endif #ifndef u64 #define u64(x) ((uint64_t)x) #endif #define NAIVE_OK 0 #define NAIVE_NO_BUF_SPC 1 #define NAIVE_DECODE_FINISH (2) #define NAIVE_ERRNO (-1) #define NAIVE_MEM_ERROR (-2) typedef struct __blk_t { uint64_t x[4]; } blk; #define BLKSIZ sizeof(blk) typedef struct naive_stream_s { size_t total_in; size_t total_out; size_t avail_in; byte *inp; size_t avail_out; byte *outp; byte buf_avail; /* How much encoded data is available to output? */ byte buf[64]; } naive_stream; int naive_stream_init(naive_stream *); int naive_encode(naive_stream *s); int naive_encode_end(naive_stream *s); #define strm_buf_have_data(strm) (strm->buf_avail) #define strm_set_buf(strm, size) (strm->buf_avail = size) #define strm_clear_buf(strm) (strm->buf_avail = 0) #endif