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