| 1 | 
gregl | 
2.9 | 
/* Copyright (c) 1997 Silicon Graphics, Inc. */ | 
| 2 | 
greg | 
1.1 | 
 | 
| 3 | 
gregl | 
2.9 | 
/* SCCSid "$SunId$ SGI" */ | 
| 4 | 
greg | 
1.1 | 
 | 
| 5 | 
  | 
  | 
/* | 
| 6 | 
  | 
  | 
 *      Miscellaneous definitions required by many routines. | 
| 7 | 
  | 
  | 
 */ | 
| 8 | 
  | 
  | 
 | 
| 9 | 
  | 
  | 
#include  <stdio.h> | 
| 10 | 
  | 
  | 
 | 
| 11 | 
greg | 
2.2 | 
#include  <fcntl.h> | 
| 12 | 
  | 
  | 
 | 
| 13 | 
greg | 
1.1 | 
#include  <math.h> | 
| 14 | 
  | 
  | 
 | 
| 15 | 
  | 
  | 
#include  <errno.h> | 
| 16 | 
  | 
  | 
 | 
| 17 | 
greg | 
1.5 | 
#include  "mat4.h" | 
| 18 | 
  | 
  | 
                                /* regular transformation */ | 
| 19 | 
  | 
  | 
typedef struct { | 
| 20 | 
  | 
  | 
        MAT4  xfm;                              /* transform matrix */ | 
| 21 | 
greg | 
1.8 | 
        FLOAT  sca;                             /* scalefactor */ | 
| 22 | 
greg | 
1.5 | 
}  XF; | 
| 23 | 
  | 
  | 
                                /* complemetary tranformation */ | 
| 24 | 
  | 
  | 
typedef struct { | 
| 25 | 
  | 
  | 
        XF  f;                                  /* forward */ | 
| 26 | 
  | 
  | 
        XF  b;                                  /* backward */ | 
| 27 | 
  | 
  | 
}  FULLXF; | 
| 28 | 
greg | 
1.1 | 
 | 
| 29 | 
greg | 
2.7 | 
#ifndef  PI | 
| 30 | 
greg | 
2.2 | 
#ifdef  M_PI | 
| 31 | 
gregl | 
2.11 | 
#define  PI             ((double)M_PI) | 
| 32 | 
greg | 
1.1 | 
#else | 
| 33 | 
greg | 
2.2 | 
#define  PI             3.14159265358979323846 | 
| 34 | 
greg | 
2.7 | 
#endif | 
| 35 | 
greg | 
1.1 | 
#endif | 
| 36 | 
greg | 
1.2 | 
 | 
| 37 | 
greg | 
2.2 | 
#ifndef  F_OK                   /* mode bits for access(2) call */ | 
| 38 | 
  | 
  | 
#define  R_OK           4               /* readable */ | 
| 39 | 
  | 
  | 
#define  W_OK           2               /* writable */ | 
| 40 | 
  | 
  | 
#define  X_OK           1               /* executable */ | 
| 41 | 
  | 
  | 
#define  F_OK           0               /* exists */ | 
| 42 | 
greg | 
1.2 | 
#endif | 
| 43 | 
gregl | 
2.9 | 
 | 
| 44 | 
  | 
  | 
extern int  eputs(), wputs();   /* standard error output functions */ | 
| 45 | 
  | 
  | 
 | 
| 46 | 
greg | 
1.1 | 
                                /* error codes */ | 
| 47 | 
gregl | 
2.10 | 
#define  WARNING        0               /* non-fatal error */ | 
| 48 | 
  | 
  | 
#define  USER           1               /* fatal user-caused error */ | 
| 49 | 
  | 
  | 
#define  SYSTEM         2               /* fatal system-related error */ | 
| 50 | 
  | 
  | 
#define  INTERNAL       3               /* fatal program-related error */ | 
| 51 | 
  | 
  | 
#define  CONSISTENCY    4               /* bad consistency check, abort */ | 
| 52 | 
  | 
  | 
#define  COMMAND        5               /* interactive error */ | 
| 53 | 
  | 
  | 
#define  NERRS          6 | 
| 54 | 
gregl | 
2.9 | 
                                /* error struct */ | 
| 55 | 
  | 
  | 
extern struct erract { | 
| 56 | 
  | 
  | 
        char    pre[16];                /* prefix message */ | 
| 57 | 
  | 
  | 
        int     (*pf)();                /* put function (resettable) */ | 
| 58 | 
  | 
  | 
        int     ec;                     /* exit code (0 means non-fatal) */ | 
| 59 | 
  | 
  | 
} erract[NERRS];        /* list of error actions */ | 
| 60 | 
  | 
  | 
 | 
| 61 | 
  | 
  | 
#define  ERRACT_INIT    {       {"warning - ", wputs, 0}, \ | 
| 62 | 
  | 
  | 
                                {"fatal - ", eputs, 1}, \ | 
| 63 | 
  | 
  | 
                                {"system - ", eputs, 2}, \ | 
| 64 | 
  | 
  | 
                                {"internal - ", eputs, 1}, \ | 
| 65 | 
  | 
  | 
                                {"consistency - ", eputs, -1}, \ | 
| 66 | 
  | 
  | 
                                {"", NULL, 0}   } | 
| 67 | 
greg | 
1.1 | 
 | 
| 68 | 
  | 
  | 
extern char  errmsg[];                  /* global buffer for error messages */ | 
| 69 | 
  | 
  | 
 | 
| 70 | 
greg | 
1.3 | 
                                        /* memory operations */ | 
| 71 | 
greg | 
2.2 | 
#ifdef  NOSTRUCTASS | 
| 72 | 
  | 
  | 
#define  copystruct(d,s)        bcopy((char *)(s),(char *)(d),sizeof(*(d))) | 
| 73 | 
greg | 
1.9 | 
#else | 
| 74 | 
greg | 
2.2 | 
#define  copystruct(d,s)        (*(d) = *(s)) | 
| 75 | 
greg | 
1.3 | 
#endif | 
| 76 | 
greg | 
1.6 | 
 | 
| 77 | 
greg | 
2.2 | 
#ifndef  BSD | 
| 78 | 
  | 
  | 
#define  bcopy(s,d,n)           (void)memcpy(d,s,n) | 
| 79 | 
  | 
  | 
#define  bzero(d,n)             (void)memset(d,0,n) | 
| 80 | 
  | 
  | 
#define  bcmp(b1,b2,n)          memcmp(b1,b2,n) | 
| 81 | 
  | 
  | 
#define  index                  strchr | 
| 82 | 
  | 
  | 
#define  rindex                 strrchr | 
| 83 | 
greg | 
1.3 | 
#endif | 
| 84 | 
  | 
  | 
 | 
| 85 | 
greg | 
2.8 | 
extern char  *sskip(), *sskip2(); | 
| 86 | 
greg | 
1.4 | 
extern char  *getpath(), *getenv(); | 
| 87 | 
greg | 
2.3 | 
#ifndef malloc | 
| 88 | 
greg | 
1.1 | 
extern char  *malloc(), *calloc(), *realloc(); | 
| 89 | 
greg | 
2.3 | 
#endif | 
| 90 | 
greg | 
1.1 | 
extern char  *bmalloc(), *savestr(), *savqstr(); | 
| 91 | 
greg | 
2.2 | 
 | 
| 92 | 
greg | 
2.5 | 
#ifdef  DCL_ATOF | 
| 93 | 
  | 
  | 
extern double  atof(); | 
| 94 | 
  | 
  | 
#endif | 
| 95 | 
  | 
  | 
 | 
| 96 | 
greg | 
2.2 | 
#ifdef MSDOS | 
| 97 | 
  | 
  | 
#define NIX 1 | 
| 98 | 
  | 
  | 
#endif | 
| 99 | 
  | 
  | 
#ifdef AMIGA | 
| 100 | 
  | 
  | 
#define NIX 1 | 
| 101 | 
  | 
  | 
#endif | 
| 102 | 
  | 
  | 
 |