util.c File Reference

Implementations of various utility functions. More...

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <ctime>
#include "util.h"
#include "gabbie.h"

Defines

#define MAX_LINE_SIZE   256
#define EXCHANGE(a, b)

Functions

void PrintNumber (double d)
 Print a number, in a nice format.
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)
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 '-'.


Detailed Description

Implementations of various utility functions.

Author:
Bryan Jacobson, 2006.

Define Documentation

#define EXCHANGE a,
 ) 
 

Value:

{ temp_p = array[a]; array[a] = array[b]; \
                         array[b] = temp_p; }

#define MAX_LINE_SIZE   256
 


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.


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