+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
/* Including standard libraries */
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <math.h>
+#include <assert.h>
+#include <errno.h>
+#include <getopt.h>
-/* Define a shorthand for unsigned int */
-#define uint unsigned int
-
-/* Define a boolean type */
-#define bool char
-#define TRUE 1
-#define FALSE 0
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+typedef long long llong;
+typedef char boolean;
-/* Macro for resetting a pointer to all \0's. */
-#define ZERO( pt ) ( memset( pt, '\0', sizeof( *pt ) ) )
+#ifndef bool
+#define bool boolean
+#endif
-/* Macro for dynamic allocation of memory. */
-#define MEM_GET( pt ) ( pt = mem_get( sizeof( *pt ) ) )
+#ifndef TRUE
+#define TRUE 1
+#endif
-/* Macro for cloning a structure in memroy. */
-#define MEM_CLONE( pt ) mem_clone( pt, sizeof( ( pt )[ 0 ] ) )
+#ifndef FALSE
+#define FALSE 0
+#endif
/* Macros for determining min or max of two given values. */
#define MAX( a, b ) a < b ? b : a
#define ABS( x ) ( ( x ) < 0 ) ? -( x ) : ( x )
#define INT( x ) ( int ) x
+/* Neat debug macro. */
+#define DEBUG_EXIT 0
-/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> STRUCTURE DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
-
-
-/* Singly linked list with a pointer to the next element and a pointer to a value. */
-struct list
-{
- struct list *next;
- void *val;
-};
-
-/* Singly linked list with a pointer to the next element and an integer value. */
-struct list_int
-{
- struct list *next;
- int val;
-};
-
-
-/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ERROR HANDLING <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
-
-
-/* Print error message to stderr and exit. */
-void die( char *error_msg );
-
-/* Print warning message to stderr. */
-void warn( char *warn_msg );
-
-
-/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MEMORY HANDLING <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
-
-
-/* Get a pointer with a given size of allocated memory. */
-void *mem_get( size_t size );
-
-/* Get a pointer with a given size of allocated and zero'ed memory. */
-void *mem_get_zero( size_t size );
-
-/* Resize allocated memory for a given pointer. */
-void *mem_resize( void* pt, size_t size );
-
-/* Resize allocated memory for a given pointer with extra memory zero'ed. */
-void *mem_resize_zero( void* pt, size_t old_size, size_t new_size );
-
-/* Clone a structure in memory and return a pointer to the clone. */
-void *mem_clone( void *old_pt, size_t size );
-
-/* Free memory from a given pointer. */
-void mem_free( void *pt );
-
-
-/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ARRAYS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
-
-
-/* Binary search an array of integers for an integer value. */
-bool binary_search_array( int *array, int array_size, int val );
+#ifndef die
+#define die assert( DEBUG_EXIT )
+#endif
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MISC <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
-/* Remove the last char from a string. */
-void chop( char *string );
-
-/* Remove the last char from a string if the char is a newline (safer than chop). */
-void chomp( char *string );
-
-/* Split a given line and a delimiter return the split result as a list. */
-void split( char *string, char delimit, struct list **fields );
-
-/* Mockup version of Perl substr. */
-char *substr( char *string, int offset, int len );
+/* Function that prints "pong" to stderr. */
+void maasha_ping();
/* Return a binary number as a string of 1's and 0's. */
char *bits2string( uint bin );