/****
 * Fisher's standard macros.  Use them if you like.
 */

#ifndef std_macros_included
#define std_macros_included

/*
 * Very frequently used libraries.
 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/*
 * Boolean helpers.
 */
#define bool unsigned char
#define true 1
#define false 0
#define and &&
#define or ||
#define not !

/*
 * Null.
 */
#define null 0

/*
 * Exception handling.
 */
#define catch setjmp
#define throw longjmp
#define exception jmp_buf

/*
 * General allocators.
 */
#define new(t) (t*) malloc(sizeof(t))
#define newblock(t, size) (t*) malloc(sizeof(t) * size)
#define newc(t) (t*) calloc(1, sizeof(t))

/*
 * String helpers.
 */
#define newstr(s) strcpy((char*) malloc(strlen(s)+1), s)
#define newstrcat(s1,s2) \
    strcat(strcpy(newblock(char, strlen(s1)+strlen(s2)+1), s1), s2)
#define streq(s1,s2) strcmp(s1,s2) == 0

#endif