/*******************************************/
/* INCLUDES */

#ifndef __UTIL_H__
#define __UTIL_H__
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/time.h>
#include <assert.h>


/*******************************************/
/* DEFINES AND ENUM */

enum { STRA, STRB, STRR };


/*******************************************/
/* PROTOTYPES */

void display_error(char *str);
void display_warning(char *str);
void *my_malloc(unsigned int count);
void *my_calloc(unsigned int count);
void *my_realloc(void *ptr, unsigned int count);
void timeval_subtract(struct timeval *result, struct timeval *x,
		      struct timeval *y);
void timeval_add(struct timeval *result, struct timeval *x,
		 struct timeval *y);
void print_time(struct timeval *tv);
int timeval_cmp(struct timeval *first, struct timeval *second);
void get_current_time(timeval * tv_ptr);
void get_elapsed_time(timeval * start_ptr, timeval * result_ptr);


/*******************************************/
/* CLASSES */

class my_str {
    /* A small string class. */
  public:

    char *str_ptr;
    int buf_size;

     my_str();
     my_str(char *init_str);
    ~my_str();
    void clean_up();
    void my_str::grow(int size);
     my_str(my_str & other);
     my_str & operator=(my_str & other);
    char *str();
    char *re(char *replace_str);
    char *af(char *after_str);
    char *bf(char *before_str);
    char *sf(int where, char *format, ...);
};


/*******************************************/
/* GLOBALS. */

// The MSG string is a global string that you can use for temporary string
// manipulation.
extern my_str MSG;


#endif
