1 /* 2 Copyright (C) 2015-2021, Dirk Krause 3 SPDX-License-Identifier: BSD-3-Clause 4 */ 5 6 /* 7 WARNING: This file was generated by the dkct program (see 8 http://dktools.sourceforge.net/ for details). 9 Changes you make here will be lost if dkct is run again! 10 You should modify the original source and run dkct on it. 11 Original source: dk4c32.ctr 12 */ 13 14 #ifndef DK4C32_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4C32_H_INCLUDED 1 17 18 19 /** @file 20 32 bit character decoding. 21 22 CRT on Windows: Not used. 23 */ 24 25 #ifndef DK4CONF_H_INCLUDED 26 #if DK4_BUILDING_DKTOOLS4 27 #include "dk4conf.h" 28 #else 29 #include <dktools-4/dk4conf.h> 30 #endif 31 #endif 32 33 #ifndef DK4TYPES_H_INCLUDED 34 #if DK4_BUILDING_DKTOOLS4 35 #include <libdk4base/dk4types.h> 36 #else 37 #include <dktools-4/dk4types.h> 38 #endif 39 #endif 40 41 42 /** Decoder structure to build a 32 bit character from 4 4 4 4 bytes. 43 */ 44 typedef struct { 45 dk4_c32_t val; /**< Value constructed from the bytes. */ 46 int msb; /**< Flag: First byte is MSB. */ 47 int nb; /**< Number of next byte. */ 48 } dk4_c32_byte_decoder_t; 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 /** Initialize the decoder. 55 @param ptr Decoder to initialize. 56 @param msb Flag: Most significant byte first. 57 */ 58 void 59 60 dk4c32_decoder_init(dk4_c32_byte_decoder_t *ptr, int msb); 61 62 /** Add one byte to the decoder. 63 @param ptr 64 @param inbyte 65 @return DK4_EDSTM_ACCEPT if the byte was added to the internal 66 decoder state (no action necessary) or 67 DK4_EDSTM_FINISHED if one output was finished (use 68 dk4c32_decoder_get() to obtain the value). 69 */ 70 int 71 72 dk4c32_decoder_add(dk4_c32_byte_decoder_t *ptr, unsigned char inbyte); 73 74 /** Retrieve output value. 75 @param ptr Decoder to retrieve value from. 76 @return Output produced by the decoder. 77 */ 78 dk4_c32_t 79 80 dk4c32_decoder_get(dk4_c32_byte_decoder_t const *ptr); 81 82 /** Check whether the decoder is empty (nothing is stored in the 83 internal state). 84 @param ptr Decoder to check. 85 @return 1 on success (decoder empty), 0 otherwise. 86 */ 87 int 88 89 dk4c32_decoder_is_empty(dk4_c32_byte_decoder_t const *ptr); 90 91 #ifdef __cplusplus 92 } 93 #endif 94 95 96 97 98 #endif 99