1 /* 2 Copyright 2020, Dirk Krause. All rights reserved. 3 SPDX-License-Identifier: BSD-3-Clause 4 */ 5 6 #ifndef DK4TSP_H_INCLUDED 7 #define DK4TSP_H_INCLUDED 1 8 9 /** @file dk4tsp.h Text stream processing. 10 */ 11 12 #ifndef DK4CONF_H_INCLUDED 13 #if DK4_BUILDING_DKTOOLS4 14 #include "dk4conf.h" 15 #else 16 #include <dktools-4/dk4conf.h> 17 #endif 18 #endif 19 20 #ifndef DK4TYPES_H_INCLUDED 21 #if DK4_BUILDING_DKTOOLS4 22 #include <libdk4base/dk4types.h> 23 #else 24 #include <dktools-4/dk4types.h> 25 #endif 26 #endif 27 28 /** Position in a data stream. 29 */ 30 typedef struct { 31 dk4_um_t bytes; /**< Number of bytes successfully processed. */ 32 dk4_um_t chars; /**< Number of current character. */ 33 dk4_um_t lineno; /**< Current line number. */ 34 dk4_um_t charil; /**< Number of current character in line. */ 35 } dk4_text_stream_position_t; 36 37 /** Results from processing a text character or a line. 38 */ 39 enum { 40 /** Text processing succeeded. 41 */ 42 DK4_TSP_RES_OK = 1, 43 44 /** There was an error while applying 45 the information, but we can continue. 46 */ 47 DK4_TSP_RES_ERROR = 0, 48 49 /** Fatal error while applying information, 50 abort processing. 51 */ 52 DK4_TSP_RES_FATAL = -1 53 }; 54 55 #endif 56 57