1 | /*****************************************************************************/ |
2 | /* */ |
3 | /* input.h */ |
4 | /* */ |
5 | /* Input file handling */ |
6 | /* */ |
7 | /* */ |
8 | /* */ |
9 | /* (C) 2000-2010, Ullrich von Bassewitz */ |
10 | /* Roemerstrasse 52 */ |
11 | /* D-70794 Filderstadt */ |
12 | /* EMail: uz@cc65.org */ |
13 | /* */ |
14 | /* */ |
15 | /* This software is provided 'as-is', without any expressed or implied */ |
16 | /* warranty. In no event will the authors be held liable for any damages */ |
17 | /* arising from the use of this software. */ |
18 | /* */ |
19 | /* Permission is granted to anyone to use this software for any purpose, */ |
20 | /* including commercial applications, and to alter it and redistribute it */ |
21 | /* freely, subject to the following restrictions: */ |
22 | /* */ |
23 | /* 1. The origin of this software must not be misrepresented; you must not */ |
24 | /* claim that you wrote the original software. If you use this software */ |
25 | /* in a product, an acknowledgment in the product documentation would be */ |
26 | /* appreciated but is not required. */ |
27 | /* 2. Altered source versions must be plainly marked as such, and must not */ |
28 | /* be misrepresented as being the original software. */ |
29 | /* 3. This notice may not be removed or altered from any source */ |
30 | /* distribution. */ |
31 | /* */ |
32 | /*****************************************************************************/ |
33 | |
34 | |
35 | |
36 | #ifndef INPUT_H |
37 | #define INPUT_H |
38 | |
39 | |
40 | |
41 | #include <stdio.h> |
42 | |
43 | /* common */ |
44 | #include "strbuf.h" |
45 | |
46 | |
47 | |
48 | /*****************************************************************************/ |
49 | /* data */ |
50 | /*****************************************************************************/ |
51 | |
52 | |
53 | |
54 | /* An enum that describes different types of input files. The members are |
55 | ** choosen so that it is possible to combine them to bitsets |
56 | */ |
57 | typedef enum { |
58 | IT_MAIN = 0x01, /* Main input file */ |
59 | IT_SYSINC = 0x02, /* System include file (using <>) */ |
60 | IT_USRINC = 0x04, /* User include file (using "") */ |
61 | } InputType; |
62 | |
63 | /* Forward for an IFile structure */ |
64 | struct IFile; |
65 | |
66 | /* The current input line */ |
67 | extern StrBuf* Line; |
68 | |
69 | /* Current and next input character */ |
70 | extern char CurC; |
71 | extern char NextC; |
72 | |
73 | |
74 | |
75 | /*****************************************************************************/ |
76 | /* Code */ |
77 | /*****************************************************************************/ |
78 | |
79 | |
80 | |
81 | void OpenMainFile (const char* Name); |
82 | /* Open the main file. Will call Fatal() in case of failures. */ |
83 | |
84 | void OpenIncludeFile (const char* Name, InputType IT); |
85 | /* Open an include file and insert it into the tables. */ |
86 | |
87 | void NextChar (void); |
88 | /* Read the next character from the input stream and make CurC and NextC |
89 | ** valid. If end of line is reached, both are set to NUL, no more lines |
90 | ** are read by this function. |
91 | */ |
92 | |
93 | void ClearLine (void); |
94 | /* Clear the current input line */ |
95 | |
96 | StrBuf* InitLine (StrBuf* Buf); |
97 | /* Initialize Line from Buf and read CurC and NextC from the new input line. |
98 | ** The function returns the old input line. |
99 | */ |
100 | |
101 | int NextLine (void); |
102 | /* Get a line from the current input. Returns 0 on end of file. */ |
103 | |
104 | const char* GetInputFile (const struct IFile* IF); |
105 | /* Return a filename from an IFile struct */ |
106 | |
107 | const char* GetCurrentFile (void); |
108 | /* Return the name of the current input file */ |
109 | |
110 | unsigned GetCurrentLine (void); |
111 | /* Return the line number in the current input file */ |
112 | |
113 | void CreateDependencies (void); |
114 | /* Create dependency files requested by the user */ |
115 | |
116 | |
117 | |
118 | /* End of input.h */ |
119 | |
120 | #endif |
121 | |