GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > XLX / V10-0-2

Constituent: parser     Tag: linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

util.c File Reference

General character/conversion utilities. More...

#include "XLX_p.h"
#include "EXPAT/expat.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "ctype.h"

Include dependency graph for util.c:


Functions

static int strtobin (int optns, const char *string, unsigned int len, void *value)
 Convert a string to binary.
int XLX_isEnabled (const char **attribute, int *enabled)
 Reads the attribute list and sets enabled accordingly.
int XLX_getAttribute (const char **attribute, const char *name, int *value)
 Find a named attribute in an attribute list.
int XLX_strtoi (const char *string, unsigned int len, int *value)
 Convert a string to a signed 32-bit integer.
int XLX_strtou (const char *string, unsigned int len, unsigned int *value)
 Convert a string to an unsigned 32-bit integer.
int XLX_strtoll (const char *string, unsigned int len, long long *value)
 Convert a string to a signed 64-bit integer.
int XLX_strtoull (const char *string, unsigned int len, unsigned long long *value)
 Convert a string to an unsigned 64-bit integer.
int XLX_getLineNum (XLX_state *state)
 Get the current line number.
void XLX_valError (XLX_state *state, const char *func, const char *string, unsigned int len)
 Report value string to be in error.
void XLX_attrError (XLX_state *state, const char *func, const char *name)
 Report missing attribute error.
void XLX_attrValError (XLX_state *state, const char *func, const char *name)
 Report invalid attribute value error.
void XLX_dispFileName (XLX_state *state, const char *func)
 Display the name of the current file being parsed.
int XLX_ischar (const char *string, unsigned int len)
 Test a string for valid characters.

Detailed Description

General character/conversion utilities.

Author:
James Swain & Owen Saxton
Id
util.c,v 1.16 2007/10/29 18:07:31 saxton Exp

Function Documentation

int strtobin int  optns,
const char *  string,
unsigned int  len,
void *  value
[static]
 

Convert a string to binary.

This routine converts a decimal or hexadecimal string to an integer. By default the string must be unsigned and the integer is 32-bit. Options allow the string to be signed, and the integer to be 64-bit.

Parameters:
optns Bit mask of conversion options: 1 = signed, 2 = 64-bit
string String to convert
len Maximum length of the string (including whitespace)
value Address of the converted value
Return values:
0 If the string represents a valid integer
-1 If the string contains invalid characters

void XLX_attrError XLX_state state,
const char *  func,
const char *  name
 

Report missing attribute error.

This routine displays the name of the missing attribute, along with the line number in and the name of the file being parsed.

Parameters:
state Current parse state
func Name of function reporting the error
name Attribute name

void XLX_attrValError XLX_state state,
const char *  func,
const char *  name
 

Report invalid attribute value error.

This routine displays the name of the attribute, along with the line number in and the name of the file being parsed.

Parameters:
state Current parse state
func Name of function reporting the error
name Attribute name

void XLX_dispFileName XLX_state state,
const char *  func
 

Display the name of the current file being parsed.

This routine is used when reporting errors during the parsing.

Parameters:
state Current parse state
func Name of function reporting the error

int XLX_getAttribute const char **  attribute,
const char *  name,
int *  value
 

Find a named attribute in an attribute list.

This routine looks for the attribute in the attribute list and returns its associated value (signed decimal or hexadecimal string) converted to an integer.

Parameters:
attribute Attribute list from the start tag of the element
name Attribute to find and return
value Location to put value of attribute
Return values:
0 If the name is found and its value is valid
-1 If the value is not a valid number
-2 If the name is missing from the attribute list

int XLX_getLineNum XLX_state state  ) 
 

Get the current line number.

This routine obtains the current line number in the file being parsed.

Parameters:
state Current parse state
Returns:
The current line number

int XLX_ischar const char *  string,
unsigned int  len
 

Test a string for valid characters.

Checks that the string has valid graphic characters after any leading whitespace and before the start of the next tag.

Parameters:
string Address of string to test
len Max length of the string (including whitespace)
Return values:
1 If the string has valid characters before the start of the next tag
0 If the string does not have valid characters before the start of the next tag

int XLX_isEnabled const char **  attribute,
int *  enabled
 

Reads the attribute list and sets enabled accordingly.

Parameters:
attribute Attribute list from the start tag of the element
enabled Location to write 0 (FALSE) or 1 (TRUE)
Return values:
0 If the attribute list was read correctly
-1 If there was a bad value for the 'enabled' attribute
-2 If there was no 'enabled' attribute

int XLX_strtoi const char *  string,
unsigned int  len,
int *  value
 

Convert a string to a signed 32-bit integer.

Parameters:
string String to convert
len Maximum length of the string (including whitespace)
value Address of the converted value
Return values:
0 If the string represents a valid integer
-1 If the string contains invalid characters

int XLX_strtoll const char *  string,
unsigned int  len,
long long *  value
 

Convert a string to a signed 64-bit integer.

Parameters:
string String to convert
len Maximum length of the string (including whitespace)
value Address of the converted value
Return values:
0 If the string represents a valid integer
-1 If the string contains invalid characters

int XLX_strtou const char *  string,
unsigned int  len,
unsigned int *  value
 

Convert a string to an unsigned 32-bit integer.

Parameters:
string String to convert
len Maximum length of the string (including whitespace)
value Address of the converted value
Return values:
0 If the string represents a valid integer
-1 If the string contains invalid characters

int XLX_strtoull const char *  string,
unsigned int  len,
unsigned long long *  value
 

Convert a string to an unsigned 64-bit integer.

Parameters:
string String to convert
len Maximum length of the string (including whitespace)
value Address of the converted value
Return values:
0 If the string represents a valid integer
-1 If the string contains invalid characters

void XLX_valError XLX_state state,
const char *  func,
const char *  string,
unsigned int  len
 

Report value string to be in error.

This routine displays the contents of the string, along with the line number in and the name of the file being parsed.

Parameters:
state Current parse state
func Name of function reporting the error
string String to report
len Max length of the string (including whitespace)


Generated on Sun Jun 14 02:44:47 2009 by  doxygen 1.4.4