| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | // InfFile.h: interface for the InfFile class. |
| 20 | // |
| 21 | ////////////////////////////////////////////////////////////////////// |
| 22 | |
| 23 | #ifndef INFFILE_H |
| 24 | #define INFFILE_Hcxx . . $ `cfile/inffile.h:24:9`! |
| 25 | |
| 26 | #if _MSC_VER >= 1000 |
| 27 | #pragma once |
| 28 | #endif // _MSC_VER >= 1000 |
| 29 | |
| 30 | #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/ |
| 31 | #include "psclass.h"cxx . . $ `<file>/lib/psclass.h`/ |
| 32 | |
| 33 | struct CFILEcxx . . $ CFILE#; |
| 34 | |
| 35 | enum InfFileErrorcxx . . $ InfFileError# { |
| 36 | INFFILE_LINELENcxx . . $ INFFILE_LINELEN. = 256, |
| 37 | INFFILE_CUSTOMcxx . . $ INFFILE_CUSTOM. = -128, |
| 38 | INFFILE_ERRORcxx . . $ INFFILE_ERROR. = -1, |
| 39 | INFFILE_COMMENTcxx . . $ INFFILE_COMMENT. = -2, |
| 40 | INFFILE_EOLcxx . . $ INFFILE_EOL. = -3, |
| 41 | INFFILE_SYMBOLcxx . . $ INFFILE_SYMBOL. = 1024, |
| 42 | }; |
| 43 | |
| 44 | class InfFilecxx . . $ InfFile# { |
| 45 | public: |
| 46 | InfFilecxx . . $ InfFile#InfFile(49f6e7a06ebc5aa8).(); |
| 47 | virtual ~cxx . . $ InfFile#`~InfFile`(ced63f7c635d850d).InfFilecxx . . $ InfFile#(); |
| 48 | |
| 49 | // opens an inf file, pass in a lexical analyzer that will return a command index. |
| 50 | // tag_check is a string that must appear at the very beginning of the file. |
| 51 | // lexfn is a function to match a command to a number. num <= 0 and num >=1024 are taken. |
| 52 | bool Opencxx . . $ InfFile#Open(a6c18f6c547e5631).(const char *filename, const char *tag_check, int (*lexfn)(const char *command)); |
| 53 | |
| 54 | // closes the file |
| 55 | void Closecxx . . $ InfFile#Close(49f6e7a06ebc5aa8).(); |
| 56 | |
| 57 | // read a command line. returns false on eof. |
| 58 | bool ReadLinecxx . . $ InfFile#ReadLine(c9857a73d68e59ba).(); |
| 59 | |
| 60 | // parses a line of 'code'. return value from the lexfn |
| 61 | // check INFFILE constants above. (any value less than 0, you should read in a new line.) |
| 62 | int ParseLinecxx . . $ InfFile#ParseLine(6abd07ddb1a912f0).(char *operand, int oprlen); |
| 63 | |
| 64 | private: |
| 65 | CFILEcxx . . $ CFILE# *m_fpcxx . . $ InfFile#m_fp.; // file object. |
| 66 | int (*m_lexfncxx . . $ InfFile#m_lexfn.)(const char *); // lexical analyzer. |
| 67 | char m_linetextcxx . . $ InfFile#m_linetext.[INFFILE_LINELENcxx . . $ INFFILE_LINELEN.]; |
| 68 | char *m_lineptrcxx . . $ InfFile#m_lineptr.; // pointer to current text line. |
| 69 | char *m_endptrcxx . . $ InfFile#m_endptr.; // pointer to last character in text line |
| 70 | int m_linecxx . . $ InfFile#m_line.; // line # |
| 71 | |
| 72 | struct sym_infocxx . . $ InfFile#sym_info# // full runtime symbol |
| 73 | { |
| 74 | char namecxx . . $ InfFile#sym_info#name.[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!]; |
| 75 | char *textcxx . . $ InfFile#sym_info#text.; |
| 76 | }; |
| 77 | |
| 78 | // inf file symbol list |
| 79 | tListcxx . . $ tList#<sym_infocxx . . $ InfFile#sym_info#> m_sym_listcxx . . $ InfFile#m_sym_list.; // symbol list. |
| 80 | |
| 81 | private: |
| 82 | void AddSymbolcxx . . $ InfFile#AddSymbol(2fa786934fe80e24).(const char *name, const char *text); |
| 83 | const char *GetSymbolTextcxx . . $ InfFile#GetSymbolText(fb58d2e09a2a1ce6).(const char *name); |
| 84 | void FreeSymbolscxx . . $ InfFile#FreeSymbols(49f6e7a06ebc5aa8).(); |
| 85 | |
| 86 | public: |
| 87 | // line number |
| 88 | int linecxx . . $ InfFile#line(455f465bc33b4cdf).() const { return m_linecxx . . $ InfFile#m_line.; }; |
| 89 | }; |
| 90 | |
| 91 | #endif |