2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* input.h */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Input file handling */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2010-04-22 19:40:50 +00:00
|
|
|
/* (C) 2000-2010, Ullrich von Bassewitz */
|
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-06-14 21:01:37 +00:00
|
|
|
#ifndef INPUT_H
|
|
|
|
#define INPUT_H
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-22 09:32:24 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-09-16 12:42:41 +00:00
|
|
|
/* common */
|
2022-10-12 07:28:14 +00:00
|
|
|
#include "coll.h"
|
2004-09-16 12:42:41 +00:00
|
|
|
#include "strbuf.h"
|
|
|
|
|
2001-05-22 09:32:24 +00:00
|
|
|
|
|
|
|
|
2000-06-15 19:03:01 +00:00
|
|
|
/*****************************************************************************/
|
2022-07-26 13:10:26 +00:00
|
|
|
/* Data */
|
2000-06-15 19:03:01 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-09 20:50:42 +00:00
|
|
|
/* Forwards */
|
|
|
|
struct IFile;
|
|
|
|
struct LineInfo;
|
|
|
|
|
2010-05-09 10:54:15 +00:00
|
|
|
/* An enum that describes different types of input files. The members are
|
2014-06-30 09:10:35 +00:00
|
|
|
** choosen so that it is possible to combine them to bitsets
|
|
|
|
*/
|
2010-05-09 10:54:15 +00:00
|
|
|
typedef enum {
|
2014-03-04 00:11:19 +00:00
|
|
|
IT_MAIN = 0x01, /* Main input file */
|
|
|
|
IT_SYSINC = 0x02, /* System include file (using <>) */
|
|
|
|
IT_USRINC = 0x04, /* User include file (using "") */
|
2010-05-09 10:54:15 +00:00
|
|
|
} InputType;
|
|
|
|
|
2004-09-16 12:42:41 +00:00
|
|
|
/* The current input line */
|
|
|
|
extern StrBuf* Line;
|
2000-06-21 21:02:44 +00:00
|
|
|
|
|
|
|
/* Current and next input character */
|
|
|
|
extern char CurC;
|
|
|
|
extern char NextC;
|
2000-06-15 19:03:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Code */
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-06-14 21:01:37 +00:00
|
|
|
void OpenMainFile (const char* Name);
|
|
|
|
/* Open the main file. Will call Fatal() in case of failures. */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2010-05-09 10:54:15 +00:00
|
|
|
void OpenIncludeFile (const char* Name, InputType IT);
|
2000-06-14 21:01:37 +00:00
|
|
|
/* Open an include file and insert it into the tables. */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2022-07-26 13:10:26 +00:00
|
|
|
void CloseIncludeFile (void);
|
|
|
|
/* Close an include file and switch to the higher level file. Set Input to
|
|
|
|
** NULL if this was the main file.
|
|
|
|
*/
|
|
|
|
|
2000-06-21 21:02:44 +00:00
|
|
|
void NextChar (void);
|
|
|
|
/* Read the next character from the input stream and make CurC and NextC
|
2014-06-30 09:10:35 +00:00
|
|
|
** valid. If end of line is reached, both are set to NUL, no more lines
|
|
|
|
** are read by this function.
|
|
|
|
*/
|
2000-06-15 19:03:01 +00:00
|
|
|
|
2022-08-22 06:34:50 +00:00
|
|
|
Collection* UseInputStack (Collection* InputStack);
|
|
|
|
/* Use the provided input stack for incoming input. Return the previously used
|
|
|
|
** InputStack.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void PushLine (StrBuf* L);
|
|
|
|
/* Save the current input line and use a new one */
|
|
|
|
|
2022-09-01 04:58:52 +00:00
|
|
|
void ReuseInputLine (void);
|
|
|
|
/* Save and reuse the current line as the next line */
|
|
|
|
|
2004-09-16 12:42:41 +00:00
|
|
|
void ClearLine (void);
|
|
|
|
/* Clear the current input line */
|
|
|
|
|
|
|
|
StrBuf* InitLine (StrBuf* Buf);
|
|
|
|
/* Initialize Line from Buf and read CurC and NextC from the new input line.
|
2014-06-30 09:10:35 +00:00
|
|
|
** The function returns the old input line.
|
|
|
|
*/
|
2004-09-16 12:42:41 +00:00
|
|
|
|
2000-06-21 21:02:44 +00:00
|
|
|
int NextLine (void);
|
2022-07-26 13:10:26 +00:00
|
|
|
/* Get a line from the current input. Returns 0 on end of file with no new
|
|
|
|
** input bytes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int PreprocessNextLine (void);
|
|
|
|
/* Get a line from opened input files and do preprocess. Returns 0 on end of
|
|
|
|
** main file.
|
|
|
|
*/
|
2000-06-15 19:03:01 +00:00
|
|
|
|
2024-01-09 20:50:42 +00:00
|
|
|
void GetFileInclusionInfo (struct LineInfo* LI);
|
|
|
|
/* Get info about source file inclusion for LineInfo struct */
|
|
|
|
|
|
|
|
void FreeFileInclusionInfo (struct LineInfo* LI);
|
|
|
|
/* Free info about source file inclusion for LineInfo struct */
|
|
|
|
|
|
|
|
int HasFileInclusionChanged (const struct LineInfo* LI);
|
|
|
|
/* Return true if file inclusion has changed from last time */
|
|
|
|
|
|
|
|
const char* GetInputFileName (const struct IFile* IF);
|
|
|
|
/* Return the name of the file from an IFile struct */
|
2010-05-01 09:42:12 +00:00
|
|
|
|
2024-01-09 20:50:42 +00:00
|
|
|
const char* GetCurrentFileName (void);
|
2000-06-21 21:02:44 +00:00
|
|
|
/* Return the name of the current input file */
|
2000-06-15 19:03:01 +00:00
|
|
|
|
2022-11-02 06:16:15 +00:00
|
|
|
unsigned GetCurrentLineNum (void);
|
2000-06-21 21:02:44 +00:00
|
|
|
/* Return the line number in the current input file */
|
2000-06-15 19:03:01 +00:00
|
|
|
|
2022-11-02 06:16:15 +00:00
|
|
|
void SetCurrentLineNum (unsigned LineNum);
|
2022-07-24 15:19:05 +00:00
|
|
|
/* Set the line number in the current input file */
|
|
|
|
|
2024-01-09 20:50:42 +00:00
|
|
|
void SetCurrentFileName (const char* Name);
|
2022-07-24 15:19:05 +00:00
|
|
|
/* Set the presumed name of the current input file */
|
|
|
|
|
2022-07-24 15:19:05 +00:00
|
|
|
unsigned GetCurrentCounter (void);
|
|
|
|
/* Return the counter number in the current input file */
|
|
|
|
|
2010-05-01 09:42:12 +00:00
|
|
|
void CreateDependencies (void);
|
|
|
|
/* Create dependency files requested by the user */
|
2000-09-01 19:20:32 +00:00
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
2000-06-14 21:01:37 +00:00
|
|
|
/* End of input.h */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2014-03-04 00:11:19 +00:00
|
|
|
#endif
|