1 /* 2 * 3 * Copyright (c) 2019, Red Hat, Inc. 4 * Copyright (c) 2019, Masatake YAMATO 5 * 6 * Author: Masatake YAMATO <yamato@redhat.com> 7 * 8 * This source code is released for free distribution under the terms of the 9 * GNU General Public License version 2 or (at your option) any later version. 10 * 11 * Unwindable input stream 12 * 13 */ 14 #ifndef CTAGS_MAIN_UNWINDI_H 15 #define CTAGS_MAIN_UNWINDI_H 16 17 /* This header file unwindable input stream. 18 * You cannot use this API combining with functions defined 19 * in read.h: 20 * 21 * - getcFromInputFile 22 * - ungetcToInputFile 23 * - readLineFromInputFile 24 * - getInputLineNumber 25 * - getInputFilePosition 26 * - getInputLineOffset 27 * 28 * Instead, you can use 29 * - uwiGetC 30 * - uwiUngetC 31 * - uwiGetLineNumber 32 * - uwiGetFilePosition 33 * 34 * You can mark a position in the current input stream with 35 * uwiPushMarker(). 36 * Later, call uwiPopMarker() to unwind the input stream to the 37 * position where you marked. 38 * 39 * uwiPopMarker() takes COUNT as a parameter. It controls unwinding 40 * how many bytes. If -1 is passed as COUNT, unwinding to the marked 41 * position. 42 * 43 * If you find that you don't have to unwind though you called 44 * uwiPushMarker(), call uwiDropMaker(). 45 * 46 * uwiPopMarker() and uwiDropMaker() release internally allocated resources and 47 * clear the marker. 48 * 49 * If no marker is set, you can use uwiUngetC(). 50 */ 51 52 /* 53 * INCLUDE FILES 54 */ 55 #include "general.h" 56 57 /* 58 * DATA DECLARATIONS 59 */ 60 struct sUwiStats { 61 int maxLength; 62 bool overflow; 63 bool underflow; 64 }; 65 66 /* 67 * FUNCTION PROTOTYPES 68 */ 69 extern void uwiActivate (unsigned int); 70 extern void uwiDeactivate (struct sUwiStats *statsToBeUpdated); 71 72 extern void uwiStatsInit (struct sUwiStats *stats); 73 extern void uwiStatsPrint (struct sUwiStats *stats); 74 75 extern int uwiGetC (void); 76 extern void uwiUngetC (int c); 77 extern unsigned long uwiGetLineNumber (void); 78 extern MIOPos uwiGetFilePosition (void); 79 80 extern void uwiPushMarker (void); 81 extern void uwiClearMarker (const int count, const bool revertChars); 82 extern void uwiPopMarker (const int count, const bool revertChars); 83 extern void uwiDropMaker (void); 84 #endif /* CTAGS_MAIN_UNWINDI_H */ 85