Пример #1
0
static long
ParseTagData( char * buffer, TagPtr * tag )
{
    int actuallen = 0;
    long   length;
    TagPtr tmpTag;

    length = FixDataMatchingTag(buffer, kXMLTagData);
    if (length == -1) return -1;
    
    tmpTag = NewTag();
    if (tmpTag == 0) return -1;
    
	//printf("ParseTagData unimplimented\n");
	//printf("Data: %s\n", buffer);
	//	getchar();

	char* string = BASE64Decode(buffer, strlen(buffer), &actuallen);
    tmpTag->type = kTagTypeData;
    tmpTag->string = string;
    tmpTag->tag = 0;
	tmpTag->offset = actuallen; // buffer_start ? buffer - buffer_start: 0;
    tmpTag->tagNext = 0;
    
    *tag = tmpTag;
    
    return length;
}
Пример #2
0
static long
ParseTagDate( char * buffer, TagPtr * tag )
{
    long   length;
    TagPtr tmpTag;
    
    length = FixDataMatchingTag(buffer, kXMLTagDate);
    if (length == -1) return -1;
    
    tmpTag = NewTag();
    if (tmpTag == 0) return -1;
    
	printf("ParseTagDate unimplimented\n");
	getchar();
	
    tmpTag->type = kTagTypeDate;
    tmpTag->string = 0;
    tmpTag->tag = 0;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
    tmpTag->tagNext = 0;
    
    *tag = tmpTag;
    
    return length;
}
Пример #3
0
static long
ParseTagString( char * buffer, TagPtr * tag )
{
    long   length;
    char * string;
  
    length = FixDataMatchingTag(buffer, kXMLTagString);
    if (length == -1) return -1;
  
	TagPtr tmpTag = NewTag();
    if (tmpTag == 0) return -1;
  
    string = NewSymbol(buffer);
    if (string == 0)
    {
        XMLFreeTag(tmpTag);
        return -1;
    }
  
    tmpTag->type = kTagTypeString;
    tmpTag->string = string;
    tmpTag->tag = 0;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
    tmpTag->tagNext = 0;
  
    *tag = tmpTag;
    return length;
}
Пример #4
0
EFI_STATUS ParseTagData(CHAR8* buffer, TagPtr * tag,UINT32* lenPtr)
{
	EFI_STATUS	Status;
	UINT32		length;
	TagPtr		tmpTag;

	Status = FixDataMatchingTag(buffer, kXMLTagData,&length);
	if (EFI_ERROR(Status))
		return Status;

	tmpTag = NewTag();
	if (tmpTag == 0) 
		return EFI_UNSUPPORTED;
//Slice - correction as Apple 2003
	CHAR8* string = NewSymbol(buffer);
	tmpTag->type = kTagTypeData;
	tmpTag->string = string;
	tmpTag->tag = NULL;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
	tmpTag->tagNext = NULL;

	*tag = tmpTag;
	*lenPtr=length;

	return EFI_SUCCESS;
}
Пример #5
0
static long ParseTagInteger(char *buffer, TagPtr * tag)
{
    long length = FixDataMatchingTag(buffer, kXMLTagInteger);

    if (length == -1) {
        return -1;
    }

    TagPtr tmpTag = NewTag();

    if (tmpTag == 0) {
        return -1;
    }

    long integer = 0;

    tmpTag->type = kTagTypeInteger;
    tmpTag->string = (char *)integer;
    tmpTag->tag = 0;
    tmpTag->tagNext = 0;

    *tag = tmpTag;

    return length;
}
Пример #6
0
static long
ParseTagData( char * buffer, TagPtr * tag )
{
    long   length;
    TagPtr tmpTag;

    length = FixDataMatchingTag(buffer, kXMLTagData);
    if (length == -1) return -1;
    
    tmpTag = NewTag();
    if (tmpTag == 0) return -1;
    
	//printf("ParseTagData unimplimented\n");
	//printf("Data: %s\n", buffer);
	//	getchar();
	
	// TODO: base64 decode
	
	char* string = NewSymbol(buffer);
    tmpTag->type = kTagTypeData;
    tmpTag->string = string;
    tmpTag->tag = 0;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
    tmpTag->tagNext = 0;
    
    *tag = tmpTag;
    
    return length;
}
Пример #7
0
static long ParseTagInteger(char *buffer, TagPtr *tag)
{
  long   length;
  char   *intString;
  TagPtr tmpTag;
  
  length = FixDataMatchingTag(buffer, kXMLTagInteger);
  if (length == -1) return -1;
  
  tmpTag = NewTag();
  if (tmpTag == 0) return -1;
  
  intString = NewSymbol(buffer);
  if (intString == 0) {
    FreeTag(tmpTag);
    return -1;
  }
  
  tmpTag->type = kTagTypeInteger;
  tmpTag->string = intString;
  tmpTag->tag = 0;
  tmpTag->tagNext = 0;
  
  *tag = tmpTag;
  
  return length;
}
Пример #8
0
EFI_STATUS ParseTagString(CHAR8* buffer, TagPtr * tag,UINT32* lenPtr)
{
	EFI_STATUS	Status;
	UINT32		length;
	CHAR8*		string;
	TagPtr		tmpTag;

	Status = FixDataMatchingTag(buffer, kXMLTagString,&length);
	if (EFI_ERROR(Status))
		return Status;

	tmpTag = NewTag();
	if (tmpTag == NULL) 
		return EFI_UNSUPPORTED;

	string = NewSymbol(buffer);
	if (string == NULL)
	{
		FreeTag(tmpTag);
		return EFI_UNSUPPORTED;
	}

	tmpTag->type = kTagTypeString;
	tmpTag->string = string;
	tmpTag->tag = NULL;
	tmpTag->tagNext = NULL;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
	*tag = tmpTag;
	*lenPtr=length;

	return EFI_SUCCESS;
}
Пример #9
0
EFI_STATUS ParseTagKey( char * buffer, TagPtr * tag,UINT32* lenPtr)
{
	EFI_STATUS	Status;
	UINT32		length;
	UINT32		length2;
	CHAR8*		string;
	TagPtr		tmpTag;
	TagPtr		subTag;

	Status = FixDataMatchingTag(buffer, kXMLTagKey,&length);
	if (EFI_ERROR(Status)) 
		return Status;

	Status = XMLParseNextTag(buffer + length, &subTag,&length2);
	if (EFI_ERROR(Status)) 
		return Status;

	tmpTag = NewTag();
	if (tmpTag == NULL)
	{
		FreeTag(subTag);
		return EFI_UNSUPPORTED;
	}

	string = NewSymbol(buffer);
	if (string == NULL)
	{
		FreeTag(subTag);
		FreeTag(tmpTag);
		return EFI_UNSUPPORTED;
	}

	tmpTag->type = kTagTypeKey;
	tmpTag->string = string;
	tmpTag->tag = subTag;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
	tmpTag->tagNext = 0;

	*tag = tmpTag;
	*lenPtr=length + length2;

	return EFI_SUCCESS;
}
Пример #10
0
static long ParseTagKey(char *buffer, TagPtr * tag)
{
    long length = FixDataMatchingTag(buffer, kXMLTagKey);

    if (length == -1) {
        return -1;
    }

    TagPtr subTag;

    long length2 = XMLParseNextTag(buffer + length, &subTag);

    if (length2 == -1) {
        return -1;
    }

    TagPtr tmpTag = NewTag();

    if (tmpTag == 0) {
        XMLFreeTag(subTag);

        return -1;
    }

    char *string = NewSymbol(buffer);

    if (string == 0) {
        XMLFreeTag(subTag);
        XMLFreeTag(tmpTag);

        return -1;
    }

    tmpTag->type = kTagTypeKey;
    tmpTag->string = string;
    tmpTag->tag = subTag;
    tmpTag->tagNext = 0;

    *tag = tmpTag;

    return length + length2;
}
Пример #11
0
static long ParseTagDate(char *buffer, TagPtr *tag)
{
  long   length;
  TagPtr tmpTag;
  
  length = FixDataMatchingTag(buffer, kXMLTagDate);
  if (length == -1) return -1;
  
  tmpTag = NewTag();
  if (tmpTag == 0) return -1;
  
  tmpTag->type = kTagTypeDate;
  tmpTag->string = 0;
  tmpTag->tag = 0;
  tmpTag->tagNext = 0;
  
  *tag = tmpTag;
  
  return length;
}
Пример #12
0
static long ParseTagKey(char *buffer, TagPtr *tag)
{
  long   length, length2;
  char   *string;
  TagPtr tmpTag, subTag = (TagPtr)-1;  // eliminate possible stale tag
  
  length = FixDataMatchingTag(buffer, kXMLTagKey);
  if (length == -1) return -1;
  
  length2 = ParseNextTag(buffer + length, &subTag);
  if (length2 == -1) return -1;

  // XXXX revisit 4063982 if FreeTag becomes real
  if(subTag == (TagPtr)-1)
    subTag = NULL;
  
  tmpTag = NewTag();
  if (tmpTag == 0) {
    FreeTag(subTag);
    return -1;
  }
  
  string = NewSymbol(buffer);
  if (string == 0) {
    FreeTag(subTag);
    FreeTag(tmpTag);
    return -1;
  }
  
  tmpTag->type = kTagTypeKey;
  tmpTag->string = string;
  tmpTag->tag = subTag;
  tmpTag->tagNext = 0;
  
  *tag = tmpTag;
  
  return length + length2;
}
Пример #13
0
EFI_STATUS ParseTagDate(CHAR8* buffer, TagPtr * tag,UINT32* lenPtr)
{
	EFI_STATUS	Status;
	UINT32		length;
	TagPtr		tmpTag;
	
	Status = FixDataMatchingTag(buffer, kXMLTagDate,&length);
	if (EFI_ERROR(Status))
		return Status;


	tmpTag = NewTag();
	if (tmpTag == 0) return EFI_UNSUPPORTED;

	tmpTag->type = kTagTypeDate;
	tmpTag->string = NULL;
	tmpTag->tag = NULL;
	tmpTag->tagNext = NULL;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;

	*tag = tmpTag;

	return length;
}
Пример #14
0
static long
ParseTagInteger( char * buffer, TagPtr * tag )
{
    long   length, integer;
	bool negative = false;
    TagPtr tmpTag;
	char* val = buffer;
    int size;
	
	if(buffer[0] == '<')
	{
		printf("Warning integer is non existant\n");
		getchar();
		tmpTag = NewTag();
		tmpTag->type = kTagTypeInteger;
		tmpTag->string = 0;
		tmpTag->tag = 0;
		tmpTag->offset =  0;
		tmpTag->tagNext = 0;
		
		*tag = tmpTag;
		
		return 0;
	}
	
    size = length = FixDataMatchingTag(buffer, kXMLTagInteger);
    if (length == -1) return -1;
    
    tmpTag = NewTag();
    if (tmpTag == 0) return -1;
    
    integer = 0;

	if(size > 1 && (val[1] == 'x' || val[1] == 'X'))	// Hex value
	{
		val += 2;
		while(*val)
		{
			if ((*val >= '0' && *val <= '9'))	// 0 - 9
			{
				integer = (integer * 16) + (*val++ - '0');
			}
			else if ((*val >= 'a' && *val <= 'f'))	// a - f
			{
				integer = (integer * 16) + (*val++ - 'a' + 10);
			}
			else if ((*val >= 'A' && *val <= 'F'))	// A - F
			{
				integer = (integer * 16) + (*val++ - 'A' + 10);
			}
			else
			{
				printf("ParseTagInteger hex error (0x%x) in buffer %s\n", *val, buffer);
				getchar();
                XMLFreeTag(tmpTag);
				return -1;
			}
		}
	}
	else if ( size )	// Decimal value
	{
		if (*val == '-')
		{
			negative = true;
			val++;
			size--;
		}
		
		for (integer = 0; size > 0; size--)
		{
			if(*val) // UGLY HACK, fix me.
			{
				if (*val < '0' || *val > '9')
				{
					printf("ParseTagInteger decimal error (0x%x) in buffer %s\n", *val, buffer);
					getchar();
					return -1;
				}
				
				integer = (integer * 10) + (*val++ - '0');
			}
		}
		
		if (negative)
			integer = -integer;
	}
		
    tmpTag->type = kTagTypeInteger;
	tmpTag->string = (char *)integer;
	tmpTag->tag = 0;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
    tmpTag->tagNext = 0;
    
    *tag = tmpTag;
    
    return length;
}
Пример #15
0
EFI_STATUS ParseTagInteger(CHAR8* buffer, TagPtr * tag,UINT32* lenPtr)
{
	EFI_STATUS	Status;
	UINT32		length; 
	UINT32		integer;
	UINT32		size;
	BOOLEAN		negative = FALSE;
	CHAR8*		val = buffer;
	TagPtr tmpTag;
	
	Status = FixDataMatchingTag(buffer, kXMLTagInteger,&length);
	if (EFI_ERROR(Status))
		return Status;

	tmpTag = NewTag();
	if (tmpTag == NULL) 
		return EFI_UNSUPPORTED;
	size = length;
	
	integer = 0;
	if(buffer[0] == '<')
	{
		tmpTag->type = kTagTypeInteger;
		tmpTag->string = 0;
		tmpTag->tag = 0;
		tmpTag->offset =  0;
		tmpTag->tagNext = 0;
		
		*tag = tmpTag;
		length = 0;
		return EFI_SUCCESS;
	}
	if(size > 1 && (val[1] == 'x' || val[1] == 'X'))	// Hex value
	{
		val += 2;
		while(*val)
		{
			if ((*val >= '0' && *val <= '9'))	// 0 - 9
			{
				integer = (integer * 16) + (*val++ - '0');
			}
			else if ((*val >= 'a' && *val <= 'f'))	// a - f
			{
				integer = (integer * 16) + (*val++ - 'a' + 10);
			}
			else if ((*val >= 'A' && *val <= 'F'))	// A - F
			{
				integer = (integer * 16) + (*val++ - 'a' + 10);
			}
			else
			{
//				getchar();
				return EFI_UNSUPPORTED;
			}
		}
	}
	else if ( size )	// Decimal value
	{
		if (*val == '-')
		{
			negative = TRUE;
			val++;
			size--;
		}
		
		for (integer = 0; size > 0; size--)
		{
			if(*val) // UGLY HACK, fix me.
			{
				if (*val < '0' || *val > '9')
				{
//					getchar();
					return EFI_UNSUPPORTED;
				}				
				integer = (integer * 10) + (*val++ - '0');
			}
		}
		
		if (negative)
			integer = -integer;
	}

	
	tmpTag->type = kTagTypeInteger;
	tmpTag->string = (CHAR8*)(UINTN)integer;
	tmpTag->tag = NULL;
	tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
	tmpTag->tagNext = NULL;

	*tag = tmpTag;
	*lenPtr=length;
	return EFI_SUCCESS;
}