1 /* 2 This file is Copyright © 1994-1995 Olivier Montanuy, 3 Copyright © 1999-2005 André Majorel, 4 Copyright © 2006-2019 contributors to the DeuTex project. 5 6 DeuTex incorporates code derived from DEU 5.21 that was put in the 7 public domain in 1994 by Raphaël Quinet and Brendon Wyber. 8 9 SPDX-License-Identifier: GPL-2.0-or-later 10 */ 11 12 /* 13 ** simplified TEXT parsing 14 */ 15 struct TXTFILE { 16 FILE *fp; 17 int16_t Lines; 18 int16_t LastChar; 19 int16_t SectionStart; 20 int16_t SectionEnd; 21 char Section[8]; 22 char pathname[1]; 23 }; 24 /* A special instance of struct TXTFILE that is treated by the 25 TXT*() output functions as the equivalent of /dev/null. 26 Writing into it is a no-op. This convention is _not_ 27 supported by the input functions ! */ 28 extern struct TXTFILE TXTdummy; 29 30 /* 31 ** For any Reading of TEXT files 32 */ 33 void TXTinit(void); 34 struct TXTFILE *TXTopenR(const char *file, int silent); 35 void TXTcloseR(struct TXTFILE *TXT); 36 /* 37 ** To read entries 38 */ 39 bool TXTskipComment(struct TXTFILE *TXT); 40 bool TXTseekSection(struct TXTFILE *TXT, const char *def); 41 bool TXTentryParse(char *name, char *filenam, int16_t * x, int16_t * y, 42 bool * repeat, struct TXTFILE *TXT, bool XY); 43 /* 44 ** To read textures 45 */ 46 bool TXTreadTexDef(struct TXTFILE *TXT, char name[8], int16_t * szx, 47 int16_t * szy); 48 bool TXTreadPatchDef(struct TXTFILE *TXT, char name[8], int16_t * ofsx, 49 int16_t * ofsy); 50 /* 51 ** To read PC sounds 52 */ 53 int16_t TXTreadShort(struct TXTFILE *TXT); 54 55 /* 56 ** For any Writing of text files 57 */ 58 struct TXTFILE *TXTopenW(const char *file); /*open, and init if needed */ 59 void TXTcloseW(struct TXTFILE *TXT); 60 /* 61 ** To write entries 62 */ 63 void TXTaddSection(struct TXTFILE *TXT, const char *def); 64 void TXTaddEntry(struct TXTFILE *TXT, const char *name, const char 65 *filenam, int16_t x, int16_t y, bool repeat, bool XY); 66 void TXTaddComment(struct TXTFILE *TXT, const char *text); 67 void TXTaddEmptyLine(struct TXTFILE *TXT); 68