home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Panoráma
/
computer_panorama_1997-12-hibas.iso
/
SHARE
/
GRAPH
/
PTC051.ZIP
/
SRC
/
MISC.H
< prev
next >
Wrap
C/C++ Source or Header
|
1997-09-20
|
2KB
|
150 lines
/////////////////////////
// miscellaneous stuff //
/////////////////////////
#ifndef __MISC_H
#define __MISC_H
#include "lang.h"
#include <time.h>
#include <math.h>
#include <stdlib.h>
#ifndef __LINUX__
#include <conio.h>
#else
#include <iostream.h>
#endif
// nice types
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
// NULL if needed
#ifndef NULL
#define NULL 0
#endif
// randomize
#ifndef randomize
#define randomize() srand((uint)time(NULL))
#endif
// randoms
#ifndef random
inline int random(int max)
{
float n=(float)rand()/((float)(RAND_MAX));
int val=(int)floor(n*max);
if (val>=max) val=max-1;
return val;
}
#endif
// inp | outp for VC++
#ifdef __VISUALC__
#define outp _outp
#define inp _inp
#endif
// inp | outp for djgpp
#ifdef __DJGPP__
#include <pc.h>
#endif
// include memory routines
#if defined(__VISUALC__) || defined(__POSIX__)
#include <memory.h>
#include <string.h>
#endif
#ifdef __WATCOMC__
#include <mem.h>
#include <string.h>
#endif
// fixup icky kbhit #defines in DJGPP - replace with inline wrapper
#ifdef __DJGPP__
#if kbhit == _conio_kbhit
#undef kbhit
inline int kbhit() { return _conio_kbhit(); }
#endif
#endif
// define "PACKED"
#if defined (__DJGPP__)
#define PACKED __attribute__ ((packed))
#else
#define PACKED
#endif
// linux stricmp
#ifdef __LINUX__
#define stricmp strcasecmp
#endif
// undefine "ABSOLUTE"
#undef ABSOLUTE
// HWINDOW
#ifdef __WIN32__
// win32 HWND
#define HWINDOW HWND
#elif __X11__
// X11 Window
#define HWINDOW (*Window)
#else
// dummy window
typedef struct STUPIDWINDOW
{
int bah;
} * HWINDOW;
#endif
#endif