home *** CD-ROM | disk | FTP | other *** search
- #define pi 3.14159265
- #include <math.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include <assert.h>
- #ifndef unix
- #include <stdarg.h>
- #endif
- #ifdef __TURBOC__
- #include <alloc.h>
- #else
- #define farcalloc calloc
- #endif
- polar_xy(double r, double angle, double *dx, double *dy)
- {
- *dx = r*cos(angle*3.14159265/180);
- *dy = r*sin(angle*3.14159265/180);
- }
- xy_polar(double dx,double dy,double *radius,double *angle)
- {
- if (dx==0 && dy==0) {
- printf("Cannot work out angle of zero length vector\n");
- return;
- }
- if (dx==0) {
- *angle = 90;
- if (dy<0) *angle = -90;
- } else {
- *angle = atan2(dy,dx)*180/pi;
- }
- *radius = sqrt(pow(dx,2)+pow(dy,2));
- }
- ncpy(char *d, char *s, int n)
- {
- strncpy(d,s,n);
- *(d+n) = 0;
- }
- ncat(char *d, char *s, int n)
- {
- int i;
- i = strlen(d);
- strncat(d,s,n);
- *(d+i+n) = 0;
- }
- #ifdef __TURBOC__
- #else
- char *strdup(char *s)
- {
- char *v;
- v = malloc(strlen(s)+1);
- strcpy(v,s);
- return v;
- }
- #endif
- char *sdup(char *s)
- {
- char *v;
- v = malloc(strlen(s)+1);
- strcpy(v,s);
- return v;
- }
- /*
- var_getstr(int varnum,char *s){}
- sub_clear(void){}
- int sub_def(char *s){}
- sub_call(int idx,double *pval,char **pstr,int *npm){}
- sub_find(char *s,int *idx,int *zret, int *np, int **plist){*idx = 0;}
- sub_get_startend(int idx, int *ss, int *ee){}
- sub_param(int idx,char *s){}
- sub_set_return(double d){}
- sub_set_startend(int idx, int ss, int ee){}
- var_add(char *name,int *idx,int *type){}
- var_find(char *name,int *idx,int *type){*idx = 0;}
- var_findadd(char *name,int *idx,int *type){}
- var_get(int jj, double *v){}
- var_nlocal(int *l){}
- var_set(int jj, double v){}
- var_setstr(int jj, char *s){}
- */
-
- void *myallocz(long size)
- {
- static void *p;
- static long *l;
- p = farcalloc(1,size);
- return p;
- }
- mystrcpy(char **d,char *s)
- {
- if (*d!=0) free(*d);
- *d = 0;
- *d = malloc(strlen(s)+1);
- if (d==NULL) gle_abort("Memory gone\n");
- strcpy(*d,s);
- }
- do_pcode()
- {}
- int gpcode;
- int gplen;
-