Esempio n. 1
0
int STR_Find(char *name)
{
    int i;

    for(i = 0; i < str_StringCount; i++)
    {
        if(strcmp(StringInfo[i].name, name) == 0)
        {
            return i;
        }
    }
    // Add to list
    if(str_StringCount == MAX_STRINGS)
    {
        ERR_Exit(ERR_TOO_MANY_STRINGS, YES, "Current maximum: %d",
                 MAX_STRINGS);
    }
    MS_Message(MSG_DEBUG, "Adding string %d:\n  \"%s\"\n",
               str_StringCount, name);
    StringInfo[str_StringCount].name = MS_Alloc(strlen(name)+1,
                                       ERR_OUT_OF_MEMORY);
    strcpy(StringInfo[str_StringCount].name, name);
    str_StringCount++;
    return str_StringCount-1;
}
Esempio n. 2
0
static char *AddFileName(const char *name)
{
	size_t len = strlen(name) + 1;
	char *namespot;

	if (FileNamesLen + len > FileNamesMax)
	{
		FileNames = MS_Alloc(FileNamesMax, ERR_OUT_OF_MEMORY);
		FileNamesLen = 0;
	}
	namespot = FileNames + FileNamesLen;
	memcpy(namespot, name, len);
	FileNamesLen += len;
	return namespot;
}
Esempio n. 3
0
void TK_Init(void)
{
	int i;

	for(i = 0; i < 256; i++)
	{
		ASCIIToChrCode[i] = CHR_SPECIAL;
		ASCIIToHexDigit[i] = NON_HEX_DIGIT;
	}
	for(i = '0'; i <= '9'; i++)
	{
		ASCIIToChrCode[i] = CHR_NUMBER;
		ASCIIToHexDigit[i] = i-'0';
	}
	for(i = 'A'; i <= 'F'; i++)
	{
		ASCIIToHexDigit[i] = 10+(i-'A');
	}
	for(i = 'a'; i <= 'f'; i++)
	{
		ASCIIToHexDigit[i] = 10+(i-'a');
	}
	for(i = 'A'; i <= 'Z'; i++)
	{
		ASCIIToChrCode[i] = CHR_LETTER;
	}
	for(i = 'a'; i <= 'z'; i++)
	{
		ASCIIToChrCode[i] = CHR_LETTER;
	}
	ASCIIToChrCode[ASCII_QUOTE] = CHR_QUOTE;
	ASCIIToChrCode[ASCII_UNDERSCORE] = CHR_LETTER;
	ASCIIToChrCode[EOF_CHARACTER] = CHR_EOF;
	tk_String = TokenStringBuffer;
	IncLineNumber = FALSE;
	tk_IncludedLines = 0;
	NumIncludePaths = 1;	// the first path is always the parsed file path - Pascal 12/11/08
	SourceOpen = FALSE;
	*MasterSourceLine = '\0'; // master line - Ty 07jan2000
	MasterSourcePos = 0;      // master position - Ty 07jan2000
	ClearMasterSourceLine = TRUE; // clear the line to start
	qsort (Keywords, NUM_KEYWORDS, sizeof(Keywords[0]), SortKeywords);
	FileNames = MS_Alloc(4096, ERR_OUT_OF_MEMORY);
	FileNamesLen = 0;
	FileNamesMax = 4096;
}
Esempio n. 4
0
void PC_OpenObject(char *name, size_t size, int flags)
{
	if(ObjectOpened == YES)
	{
		PC_CloseObject();
	}
	if(strlen(name) >= MAX_FILE_NAME_LENGTH)
	{
		ERR_Exit(ERR_FILE_NAME_TOO_LONG, NO, "File: \"%s\".", name);
	}
	strcpy(ObjectName, name);
	pc_Buffer = MS_Alloc(size, ERR_ALLOC_PCODE_BUFFER);
	pc_BufferPtr = pc_Buffer;
	pc_Address = 0;
	ObjectFlags = flags;
	BufferSize = size;
	pc_ScriptCount = 0;
	ObjectOpened = YES;
	PC_AppendString("ACS");
	PC_SkipLong(); // Script table offset
}