Untility functions


Functions

void nextLine (FILE *fp)
 Read from file until a newline.
void nextInput (FILE *fp)
 Read from file until next input line is ready (i.e. next line not starting with a comment sign '#').
char * getNextToken (char *ptr)
 Read until a new token.
char * terminateToken (char *ptr)
 Terminate the current token with a null byte.
long long getLong (char **buf)
 Get a long value.
double getDouble (char **buf)
 Get a double value.
char * getString (char **buf)
 Get a string value.
void stringCopy (const char *source, char *dest, int n)
 Copies a string.
int stringCmpQ (const char *s1, const char *s2)
 Compares two strings, but at maximum until one string ends.
void removeTrailingNewline (char *s)
 removes a trailing newline from a string, if there is one
void minMaxD (double *arr, size_t size, double *mini, double *maxi)
 return the minimum and maximum from an array of double's
void minMaxT (time_t *arr, size_t size, time_t *mini, time_t *maxi)
 return the minimum and maximum from an array of time_t's
char * findChr (char *str, size_t len, char chr)
 Find the character chr in the string str.

Function Documentation

void nextLine ( FILE *  fp  ) 

Read from file until a newline.

Parameters:
fp Pointer to the FILE structure

void nextInput ( FILE *  fp  ) 

Read from file until next input line is ready (i.e. next line not starting with a comment sign '#').

Parameters:
fp Pointer to the FILE structure

char* getNextToken ( char *  ptr  ) 

Read until a new token.

A token is a word, a number or a string, seperated by spaces or tabs. This function is intended for parsing data files, etc.

Parameters:
ptr Pointer to a string
Returns:
Pointer to the start of a new token

char* terminateToken ( char *  ptr  ) 

Terminate the current token with a null byte.

Parameters:
ptr Pointer to a string, pointing to the start of a token
Returns:
A pointer to the end of the token. It points to the next character after the current token, or, if the whole string ends after the current token, it will point to a null character ('\0').

long long getLong ( char **  buf  ) 

Get a long value.

Searches for the next token in a string, converts it to a long long and returns its value. The parameter buf will be changed so that (*buf) points to the end of the returned token.

Parameters:
buf Pointer to a pointer to a string
Returns:
The converted value

double getDouble ( char **  buf  ) 

Get a double value.

Searches for the next token in a string, converts it to a double and returns its value. The parameter buf will be changed so that (*buf) points to the end of the returned token.

Parameters:
buf Pointer to a pointer to a string
Returns:
The converted value

char* getString ( char **  buf  ) 

Get a string value.

Searches for the next token in a string, and returns its value. The parameter buf will be changed so that (*buf) points to the end of the returned token.

Parameters:
buf Pointer to a pointer to a string
Returns:
The string

void stringCopy ( const char *  source,
char *  dest,
int  n 
)

Copies a string.

Copy a string, but copy n bytes maximum Terminate dest string with null byte

Parameters:
source Source string
dest Destination string
n maximum number of bytes to copy

int stringCmpQ ( const char *  s1,
const char *  s2 
)

Compares two strings, but at maximum until one string ends.

Parameters:
s1 The first string
s2 The second string
Returns:
0 if the strings match, or the difference of the first non-matching character

void removeTrailingNewline ( char *  s  ) 

removes a trailing newline from a string, if there is one

Parameters:
s The string

void minMaxD ( double *  arr,
size_t  size,
double *  mini,
double *  maxi 
)

return the minimum and maximum from an array of double's

Parameters:
arr An array of double
size The size of the array
mini Returns the minimal value of arr
maxi Returns the maximal value of arr

void minMaxT ( time_t *  arr,
size_t  size,
time_t *  mini,
time_t *  maxi 
)

return the minimum and maximum from an array of time_t's

Parameters:
arr An array of unsigned long
size The size of the array
mini Returns the minimal value of arr
maxi Returns the maximal value of arr

char* findChr ( char *  str,
size_t  len,
char  chr 
)

Find the character chr in the string str.

Parameters:
str An array of char
len The size of the array
chr The character which is to be found
Returns:
A pointer to the location where the character has been found, or NULL if it hasn't been found.


Generated by
doxygen
SourceForge.net Logo