2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2000-06-14 21:01:37 +00:00
|
|
|
/* input.h */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
2000-06-14 21:01:37 +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 */
|
|
|
|
#include "strbuf.h"
|
|
|
|
|
2001-05-22 09:32:24 +00:00
|
|
|
|
|
|
|
|
2000-06-15 19:03:01 +00:00
|
|
|
/*****************************************************************************/
|
2010-04-22 19:40:50 +00:00
|
|
|
/* data */
|
2000-06-15 19:03:01 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-22 19:40:50 +00:00
|
|
|
/* An enum that describes different types of input files */
|
|
|
|
typedef enum {
|
|
|
|
IT_MAIN, /* Main input file */
|
|
|
|
IT_SYSINC, /* System include file (using <>) */
|
|
|
|
IT_USERINC, /* User include file (using "") */
|
|
|
|
} 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
|
|
|
|
2001-05-22 09:32:24 +00:00
|
|
|
/* Struct that describes an input file */
|
|
|
|
typedef struct IFile IFile;
|
|
|
|
struct IFile {
|
2001-05-22 20:03:26 +00:00
|
|
|
unsigned Index; /* File index */
|
2004-09-16 12:42:41 +00:00
|
|
|
unsigned Usage; /* Usage counter */
|
2001-05-22 20:03:26 +00:00
|
|
|
unsigned long Size; /* File size */
|
|
|
|
unsigned long MTime; /* Time of last modification */
|
2010-04-22 19:40:50 +00:00
|
|
|
InputType Type; /* Type of input file */
|
2001-05-22 20:03:26 +00:00
|
|
|
char Name[1]; /* Name of file (dynamically allocated) */
|
2001-05-22 09:32:24 +00:00
|
|
|
};
|
|
|
|
|
2000-06-15 19:03:01 +00:00
|
|
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-16 12:42:41 +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
|
|
|
|
2000-06-14 21:01:37 +00:00
|
|
|
void OpenIncludeFile (const char* Name, unsigned DirSpec);
|
|
|
|
/* Open an include file and insert it into the tables. */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2000-06-21 21:02:44 +00:00
|
|
|
void NextChar (void);
|
|
|
|
/* Read the next character from the input stream and make CurC and NextC
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
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.
|
|
|
|
* The function returns the old input line.
|
|
|
|
*/
|
|
|
|
|
2000-06-21 21:02:44 +00:00
|
|
|
int NextLine (void);
|
|
|
|
/* Get a line from the current input. Returns 0 on end of file. */
|
2000-06-15 19:03:01 +00:00
|
|
|
|
2000-06-21 21:02:44 +00:00
|
|
|
const char* GetCurrentFile (void);
|
|
|
|
/* Return the name of the current input file */
|
2000-06-15 19:03:01 +00:00
|
|
|
|
2000-06-21 21:02:44 +00:00
|
|
|
unsigned GetCurrentLine (void);
|
|
|
|
/* Return the line number in the current input file */
|
2000-06-15 19:03:01 +00:00
|
|
|
|
2000-09-01 19:20:32 +00:00
|
|
|
void WriteDependencies (FILE* F, const char* OutputFile);
|
|
|
|
/* Write a makefile dependency list to the given file */
|
|
|
|
|
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
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|