home *** CD-ROM | disk | FTP | other *** search
- /*
- *
- * miscellaneous definitions
- *
- */
-
- /*
- * This software is property of the U.S. Government and may be freely
- * distributed under the following conditions:
- * 1. It is distributed in its current form, without alterations.
- * 2. No monetary profit is made, under any circumstances.
- *
- * Marc A. Murison
- * Smithsonian Astrophysical Observatory
- * 60 Garden Street, MS 63
- * Cambridge, MA 02138
- *
- * (617) 495-7079 murison@cfacx2.harvard.edu
- */
-
-
- #ifndef MYDEFS_H
- #define MYDEFS_H
-
- /* constants */
- #define PI 3.14159265358979323846264
- #define TWOPI 6.28318530717958647692528
- #define PI2 1.57079632679489661923132
- #define PI4 PI / 4.0
-
-
- /* enums */
- typedef enum { BINARY_RADIX=2, OCTAL_RADIX=8,
- DECIMAL_RADIX=10, HEX_RADIX=16 } Radix;
- typedef enum { FALSE=0, TRUE=1, OFF=0, ON=1, NO=0, YES=1 } Boolean;
-
-
- /* characters */
- #define BELL '\a'
- #define BEEP '\a'
- #define BLANK ' '
- #define SPACE ' '
- #define ESCAPE '\x1b'
- #define CR '\r'
- #define LF '\x0a'
- #define FORMFEED '\x0c'
- #define NEWLINE '\n'
- #define TAB '\t'
- #define BACKSPACE '\b'
- #define DOT '.'
- #define PERIOD '.'
- #define PLUS '+'
- #define MINUS '-'
- #define HYPHEN '-'
- #define ASTERISK '*'
- #define STAR '*'
- #define SQUOTE '\''
- #define DQUOTE '\"'
- #define SLASH '/'
- #define BSLASH '\\'
-
-
- /* type definitions */
- typedef Boolean Flag;
- typedef short int sint;
- typedef unsigned int counter;
- typedef unsigned int uint;
- typedef unsigned short ushort;
- typedef unsigned long ulong;
- typedef unsigned char uchar;
-
-
- /* file stuff */
- #ifdef FILES
-
- #ifndef STDIO_H
- #define STDIO_H
- #include <stdio.h>
- #endif
-
- #define MAX_FNAME 32
- typedef struct { FILE *fp; char name[MAX_FNAME+1]; } File_Def;
- typedef enum { FTEXT, FBINARY } File_Type;
- typedef enum { FREAD, FWRITE, FAPPEND } File_Mode;
-
- #endif
-
-
-
-
-
- /* macros */
-
- #define IS_ODD( x ) ( (x) & 1 )
-
- #define IS_EVEN( x ) ( !((x) & 1) )
-
- #define SWAP( a, b ) ( (a) ^= (b), (b) ^= (a), (a) ^= (b) )
-
- #define CINDEX( c ) ( (int)(c) )
-
- #define STREQ( a , b ) ( strcmp( (a), (b) ) == 0 )
-
- #define UPPER( c ) ( ((c) >= 'a' && (c) <= 'z') ? ((c)-'a'+'A'): (c) )
-
- #define LOWER( c ) ( ((c) >= 'A' && (c) <= 'Z') ? ((c)-'A'+'a'): (c) )
-
- #define IABS( x ) ( ((x) < 0) ? (-(x)) : (x) )
-
- #define FABS( x ) ( ((x) < 0.0) ? (-(x)) : (x) )
-
- #define RANGE( x, xmin, xmax ) ( ((x) < (xmin)) ? \
- (xmin) : \
- ( ((x) > (xmax)) ? (xmax) : (x) ) )
-
- #define INRANGE( x, xmin, xmax ) ( ((x) < (xmin)) ? \
- 0 : ( ((x) > (xmax)) ? 0 : 1 ) )
-
- #define NINT( x ) ( ((x) > 0) ? ((int)(0.5+(x))) : (-(int)(0.5-(x))) )
-
- #define FLOOR( x ) ( ((x) > 0) ? (int)(x) : -(int)(-(x)) )
-
- #define CEILING( x ) ( ((x) > 0) ? (1+(int)(x)) : (-(1+(int)(-(x)))) )
-
- #define MAX( a , b ) ( ((a) > (b)) ? (a) : (b) )
-
- #define MIN( a , b ) ( ((a) < (b)) ? (a) : (b) )
-
- #define SQR( x ) ( (x) * (x) )
-
- /* x modulo y (floating point) */
- #define FMOD( x, y ) ( \
- (FABS(x) < (y)) ? \
- (x) : \
- ( (x) - (double)((ulong)((x)/(y))) * (y) ) \
- )
-
- /* if ax = fabs(x) is within eps of zero, return zero; if ax > 1.0,
- return 1.0 or -1.0, depending on sign of x (x = sin or cos) */
- #define TRIGFIX( x, ax, eps ) ( ((ax) < (eps)) ? 0.0 : \
- ( \
- (1.0 - (ax) > 0.0) ? \
- (x) : \
- ( ((x) > 0) ? 1.0 : -1.0 ) \
- ) \
- )
-
-
-
- /* generic function prototyping */
- #if defined(__STDC__) || defined(__MSDOS__)
- #define PROTO( arglist ) arglist
- #else
- #define PROTO( arglist ) ()
- #endif
-
-
-
- /* key scan codes (for not-extended keys, the ascii code is given) */
- #ifdef KEY_CODES
- typedef enum {
- KEY_ESCAPE=27,
-
- KEY_ENTER=13, KEY_CR=13, KEY_TAB=9, KEY_SP=32,
- KEY_LF=10, KEY_FF=12,
-
- KEY_PRTSC=42, KEY_UP=72, KEY_DN=80, KEY_LEFT=75,
- KEY_RIGHT=77, KEY_PGUP=73, KEY_PGDN=81, KEY_HOME=71,
- KEY_END=79, KEY_INS=82, KEY_DEL=83,
-
- KEY_F1=59, KEY_F2=60, KEY_F3=61, KEY_F4=62, KEY_F5=63,
- KEY_F6=64, KEY_F7=65, KEY_F8=66, KEY_F9=67, KEY_F10=68,
-
- KEY_0=48, KEY_1=49, KEY_2=50, KEY_3=51, KEY_4=52,
- KEY_5=53, KEY_6=54, KEY_7=55, KEY_8=56, KEY_9=57,
-
- KEY_A=65, KEY_B=66, KEY_C=67, KEY_D=68, KEY_E=69,
- KEY_F=70, KEY_G=71, KEY_H=72, KEY_I=73, KEY_J=74,
- KEY_K=75, KEY_L=76, KEY_M=77, KEY_N=78, KEY_O=79,
- KEY_P=80, KEY_Q=81, KEY_R=82, KEY_S=83, KEY_T=84,
- KEY_U=85, KEY_V=86, KEY_W=87, KEY_X=88, KEY_Y=89,
- KEY_Z=90,
-
- KEY_a= 97, KEY_b= 98, KEY_c= 99, KEY_d=100, KEY_e=101,
- KEY_f=102, KEY_g=103, KEY_h=104, KEY_i=105, KEY_j=106,
- KEY_k=107, KEY_l=108, KEY_m=109, KEY_n=110, KEY_o=111,
- KEY_p=112, KEY_q=113, KEY_r=114, KEY_s=115, KEY_t=116,
- KEY_u=117, KEY_v=118, KEY_w=119, KEY_x=120, KEY_y=121,
- KEY_z=122
-
- } Key_Code;
- #endif
-
-
-
- /*
- *
- * generic error output routine
- *
- */
-
- /*
- void errout( Boolean bell, FILE *device, char *errstring );
-
- #ifdef ERROUT
- void errout( Boolean bell, FILE *device, char *errstring )
- {
- if( bell ) putc( BELL, device );
- fprintf( device, "%s", errstring );
- return;
- }
- #endif
- */
-
-
- #endif
-
-