Exemplo n.º 1
0
/*
 * Set up an include file for parsing
 */
void
fstk_RunInclude(char *tzFileName)
{
	FILE *f;

	f = fstk_FindFile(tzFileName);

	if (f == NULL) {
		err(1, "Unable to open included file '%s'",
		    tzFileName);
	}

	pushcontext();
	nLineNo = 1;
	nCurrentStatus = STAT_isInclude;
	strcpy(tzCurrentFileName, tzFileName);
	pCurrentFile = f;
	CurrentFlexHandle = yy_create_buffer(pCurrentFile);
	yy_switch_to_buffer(CurrentFlexHandle);

	//Dirty hack to give the INCLUDE directive a linefeed

	yyunput('\n');
	nLineNo -= 1;
}
Exemplo n.º 2
0
ULONG fstk_RunInclude(char *s)
{
	FILE *f;
	char tzFileName[_MAX_PATH + 1];

	//printf( "INCLUDE: %s\n", s );

	strcpy(tzFileName, s);
	fstk_FindFile(tzFileName);
	//printf( "INCLUDING: %s\n", tzFileName );

	if ((f = fopen(tzFileName, "rt")) != NULL) {
		pushcontext();
		nLineNo = 1;
		nCurrentStatus = STAT_isInclude;
		strcpy(tzCurrentFileName, tzFileName);
		pCurrentFile = f;
		CurrentFlexHandle = yy_create_buffer(pCurrentFile);
		yy_switch_to_buffer(CurrentFlexHandle);

		//      Dirty hack to give the INCLUDE directive a linefeed

		yyunput('\n');
		nLineNo -= 1;

		return (1);
	} else
		return (0);
}
Exemplo n.º 3
0
void sect_OutputBinaryFile(string* pFile)
{
	/* TODO: Handle minimum word size.
	 * Pad file if necessary.
	 * Read words and output in chosen endianness 
	 */

	FILE* f;

	if((pFile = fstk_FindFile(pFile)) != NULL
	&& (f = fopen(str_String(pFile), "rb")) != NULL)
	{
		uint32_t size;

		fseek(f, 0, SEEK_END);
		size = ftell(f);
		fseek(f, 0, SEEK_SET);

		if(sect_CheckAvailableSpace(size))
		{
			switch(sect_GetCurrentType())
			{
				case GROUP_TEXT:
				{
					size_t read;

					read = fread(&pCurrentSection->pData[pCurrentSection->UsedSpace], sizeof(uint8_t), size, f);
					pCurrentSection->FreeSpace -= size;
					pCurrentSection->UsedSpace += size;
					pCurrentSection->PC += size / g_pConfiguration->eMinimumWordSize;
					if(read != size)
					{
						prj_Fail(ERROR_READ);
					}
					break;
				}
				case GROUP_BSS:
				{
					prj_Error(ERROR_SECTION_DATA);
					break;
				}
				default:
				{
					internalerror("Unknown GROUP type");
					break;
				}
			}
		}

		fclose(f);
	}
	else
	{
		prj_Fail(ERROR_NO_FILE);
	}
	
	str_Free(pFile);
}
Exemplo n.º 4
0
ULONG fstk_Init(char *s)
{
	char tzFileName[_MAX_PATH + 1];

	sym_AddString("__FILE__", s);

	strcpy(tzFileName, s);
	fstk_FindFile(tzFileName);

	pFileStack = NULL;
	if ((pCurrentFile = fopen(tzFileName, "rt")) != NULL) {
		nMacroCount = 0;
		nCurrentStatus = STAT_isInclude;
		strcpy(tzCurrentFileName, tzFileName);
		CurrentFlexHandle = yy_create_buffer(pCurrentFile);
		yy_switch_to_buffer(CurrentFlexHandle);
		nLineNo = 1;
		return (1);
	} else
		return (0);
}
Exemplo n.º 5
0
/*
 * Set up an include file for parsing
 */
void fstk_RunInclude(char *tzFileName)
{
	char *incPathUsed = "";
	FILE *f = fstk_FindFile(tzFileName, &incPathUsed);

	if (f == NULL)
		err(1, "Unable to open included file '%s'", tzFileName);

	pushcontext();
	nLineNo = 1;
	nCurrentStatus = STAT_isInclude;
	snprintf(tzCurrentFileName, sizeof(tzCurrentFileName), "%s%s",
		 incPathUsed, tzFileName);
	pCurrentFile = f;
	CurrentFlexHandle = yy_create_buffer(pCurrentFile);
	yy_switch_to_buffer(CurrentFlexHandle);

	/* Dirty hack to give the INCLUDE directive a linefeed */

	yyunput('\n');
	nLineNo -= 1;
}