]> git.sur5r.net Git - cc65/blob - src/cc65/input.h
Change the OptStackOps function so that it adjusts the instruction pointer
[cc65] / src / cc65 / input.h
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 */
55 typedef enum {
56     IT_MAIN,                    /* Main input file */
57     IT_SYSINC,                  /* System include file (using <>) */
58     IT_USERINC,                 /* User include file (using "") */
59 } InputType;
60
61 /* The current input line */
62 extern StrBuf* Line;
63
64 /* Current and next input character */
65 extern char CurC;
66 extern char NextC;
67
68 /* Struct that describes an input file */
69 typedef struct IFile IFile;
70 struct IFile {
71     unsigned        Index;      /* File index */
72     unsigned        Usage;      /* Usage counter */
73     unsigned long   Size;       /* File size */
74     unsigned long   MTime;      /* Time of last modification */
75     InputType       Type;       /* Type of input file */
76     char            Name[1];    /* Name of file (dynamically allocated) */
77 };
78
79
80
81 /*****************************************************************************/
82 /*                                   Code                                    */
83 /*****************************************************************************/
84
85
86
87 void OpenMainFile (const char* Name);
88 /* Open the main file. Will call Fatal() in case of failures. */
89
90 void OpenIncludeFile (const char* Name, unsigned DirSpec);
91 /* Open an include file and insert it into the tables. */
92
93 void NextChar (void);
94 /* Read the next character from the input stream and make CurC and NextC
95  * valid. If end of line is reached, both are set to NUL, no more lines
96  * are read by this function.
97  */
98
99 void ClearLine (void);
100 /* Clear the current input line */
101
102 StrBuf* InitLine (StrBuf* Buf);
103 /* Initialize Line from Buf and read CurC and NextC from the new input line.
104  * The function returns the old input line.
105  */
106
107 int NextLine (void);
108 /* Get a line from the current input. Returns 0 on end of file. */
109
110 const char* GetCurrentFile (void);
111 /* Return the name of the current input file */
112
113 unsigned GetCurrentLine (void);
114 /* Return the line number in the current input file */
115
116 void WriteDependencies (FILE* F, const char* OutputFile);
117 /* Write a makefile dependency list to the given file */
118
119
120
121 /* End of input.h */
122 #endif
123
124
125