//
//	Common include file
//
//        Copyright (c) 2002-2003 Jim Peters <http://uazu.net/>.
//        Released under the GNU GPL version 2 as published by the
//        Free Software Foundation.  See the file COPYING for details,
//        or visit <http://www.gnu.org/copyleft/gpl.html>.
//
//	One of the target macros should be defined before this point:
//	T_LINUX, T_MINGW, or T_MSVC.
//

#define VERSION "0.9.10"
#define PROGNAME "fiview"

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <errno.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <SDL/SDL.h>
#include <math.h>

#include "fidlib/fidlib.h"

#ifndef T_MSVC
#include <unistd.h>
#include <sys/time.h>
#endif

#ifdef T_MSVC
#include <float.h>
#define NAN nan_global
#endif

#ifdef T_LINUX
#define UNIX_TIME
#endif

#ifdef T_MINGW
#define WIN_TIME
#endif

#ifdef T_MSVC
#define WIN_TIME
#endif


// I really don't know if this is portable, but it works in GCC both
// with and without optimisation (GCC precompiles it into a constant)
#ifndef NAN
#define NAN (0.0/0.0)
#endif

#ifndef M_PI
#define M_PI           3.14159265358979323846  /* pi */
#endif

#ifndef M_LN10
#define M_LN10         2.30258509299404568402  /* log_e 10 */
#endif

#ifdef T_MINGW
//#define isnan(val) _isnan(val)
#define vsnprintf _vsnprintf
#define snprintf _snprintf
#endif

#ifdef T_MSVC
#define isnan(val) _isnan(val)
#define vsnprintf _vsnprintf
#define snprintf _snprintf
#endif

#ifdef UNIX_TIME
 #include <sys/ioctl.h>
 #include <sys/times.h>
#endif

#ifdef WIN_TIME
 #include <windows.h>
 #include <mmsystem.h>
#endif


// With HEADER defined, these C files just give their header info
// (mainly structure-definitions).  Perhaps this is bit unusual --
// people normally seem to use separate header files -- but at least
// it keeps the structures together with their related functions.

#define HEADER 1
#include "filter.c"
#include "display.c"
#include "scratch.c"
#undef HEADER

#include "proto.h"

#define M301DB (0.707106781186548)
#define M602DB (0.50)

#ifndef DEBUG_ON
#define DEBUG_ON 0
#endif

#define DEBUG if (DEBUG_ON) warn
#define ALLOC(type) ((type*)Alloc(sizeof(type)))
#define ALLOC_ARR(cnt, type) ((type*)Alloc((cnt) * sizeof(type)))

// END //

