util.h File Reference

Various utility functions. More...

#include <cstdio>

Go to the source code of this file.

Functions

void Error (bool condition, char *message)
 If condition is true, print message and exit.
void Error (bool condition, char *message, char *a1)
void Mesg (char *message)
 Print a message to stderr.
void Mesg (char *message, char *a1)
void Mesg (char *message, int a1)
void PrintNumber (double d)
 Print a number, in a nice format.
FILE * FileOpen (char *fileName, char *mode)
 Open a file, print an advisory message if the open fails.
char * GetLine (FILE *fp)
bool HasDigits (char *s)
 Return true if this string has any digits.
void Sort (void *array[], int size, int(*compare)(void *, void *))
 In-place quicksort of an array of pointers.
void StrLower (char *p)
 Force all chars in string to lower case.
bool IsNormalChar (char c)
 True if char is alpha, numeric, or '-'.

Variables

const int MAX_LINE = 40000
 Maximum length of a line of input.


Detailed Description

Various utility functions.

Author:
Bryan Jacobson, 2006.

Function Documentation

void Error bool  condition,
char *  message,
char *  a1
 

void Error bool  condition,
char *  message
 

If condition is true, print message and exit.

FILE* FileOpen char *  fileName,
char *  mode
 

Open a file, print an advisory message if the open fails.

char* GetLine FILE *  fp  ) 
 

Read line from a file, return a pointer to the contents of the line. Notes: 1. Returns pointer to a static buffer that is overwritten when the function is called again, or when GetTreeLine is called. 2. Reads up to MAX_LINE chars. 3. Returns NULL pointer at end-of-file.

bool HasDigits char *  s  ) 
 

Return true if this string has any digits.

bool IsNormalChar char  c  ) 
 

True if char is alpha, numeric, or '-'.

void Mesg char *  message,
int  a1
 

void Mesg char *  message,
char *  a1
 

void Mesg char *  message  ) 
 

Print a message to stderr.

void PrintNumber double  d  ) 
 

Print a number, in a nice format.

void Sort void *  array[],
int  size,
int(*)(void *, void *)  compare
 

In-place quicksort of an array of pointers.

Sort() performs an in-place quicksort. compare must be a pointer to a function that takes 2 void * arguments, and returns 0 if they are equal, >0 if the first arg is greater, and <0 if first arg is less.

void StrLower char *  p  ) 
 

Force all chars in string to lower case.


Variable Documentation

const int MAX_LINE = 40000
 

Maximum length of a line of input.


Generated on Sun Oct 8 09:32:10 2006 for gabbie by  doxygen 1.4.6