| 1 |
greg |
1.1 |
/* Copyright (c) 1988 Regents of the University of California */ |
| 2 |
|
|
|
| 3 |
|
|
/* SCCSid "$SunId$ LBL" */ |
| 4 |
|
|
|
| 5 |
|
|
/* |
| 6 |
|
|
* Miscellaneous definitions required by many routines. |
| 7 |
|
|
*/ |
| 8 |
|
|
|
| 9 |
|
|
#include <stdio.h> |
| 10 |
|
|
|
| 11 |
|
|
#include <math.h> |
| 12 |
|
|
|
| 13 |
|
|
#include <errno.h> |
| 14 |
|
|
|
| 15 |
|
|
#include "fvect.h" |
| 16 |
|
|
|
| 17 |
|
|
#define FHUGE (1e10) /* large real number */ |
| 18 |
|
|
#define FTINY (1e-6) /* small real number */ |
| 19 |
|
|
|
| 20 |
|
|
#ifdef M_PI |
| 21 |
|
|
#define PI M_PI |
| 22 |
|
|
#else |
| 23 |
|
|
#define PI 3.14159265358979323846 |
| 24 |
|
|
#endif |
| 25 |
greg |
1.2 |
|
| 26 |
|
|
#ifndef F_OK /* mode bits for access(2) call */ |
| 27 |
|
|
#define R_OK 4 /* readable */ |
| 28 |
|
|
#define W_OK 2 /* writable */ |
| 29 |
|
|
#define X_OK 1 /* executable */ |
| 30 |
|
|
#define F_OK 0 /* exists */ |
| 31 |
|
|
#endif |
| 32 |
greg |
1.1 |
/* error codes */ |
| 33 |
|
|
#define WARNING 1 /* non-fatal error */ |
| 34 |
|
|
#define USER 2 /* fatal user-caused error */ |
| 35 |
|
|
#define SYSTEM 3 /* fatal system-related error */ |
| 36 |
|
|
#define INTERNAL 4 /* fatal program-related error */ |
| 37 |
|
|
#define CONSISTENCY 5 /* bad consistency check, abort */ |
| 38 |
|
|
#define COMMAND 6 /* interactive error */ |
| 39 |
|
|
|
| 40 |
|
|
extern char errmsg[]; /* global buffer for error messages */ |
| 41 |
|
|
|
| 42 |
|
|
extern int errno; /* system error number */ |
| 43 |
|
|
|
| 44 |
greg |
1.3 |
/* memory operations */ |
| 45 |
|
|
#ifdef STRUCTASSIGN |
| 46 |
|
|
#define copystruct(d,s) (*(d) = *(s)) |
| 47 |
|
|
#else |
| 48 |
|
|
#define copystruct(d,s) bcopy((char *)(s),(char *)(d),sizeof(*(d))) |
| 49 |
|
|
#endif |
| 50 |
|
|
#ifndef BSD |
| 51 |
|
|
#define bcopy(s,d,n) (void)memcpy(d,s,n) |
| 52 |
|
|
#define bzero(d,n) (void)memset(d,0,n) |
| 53 |
|
|
#define bcmp(b1,b2,n) memcmp(b1,b2,n) |
| 54 |
|
|
extern char *memcpy(), *memset(); |
| 55 |
|
|
#endif |
| 56 |
|
|
|
| 57 |
greg |
1.1 |
extern char *sskip(); |
| 58 |
|
|
extern char *getpath(); |
| 59 |
|
|
extern char *malloc(), *calloc(), *realloc(); |
| 60 |
|
|
extern char *bmalloc(), *savestr(), *savqstr(); |