#include #include #include #include "tennis.h" #define TRUE 1 #define FALSE 0 extern char *opointer, *ipointer; char *upointer; #if defined(VAX) int f_put_set(short *keyp) #else int f_put_set_(short *keyp) #endif { short key; key = *keyp; upointer = put_set(key); return (upointer == NULL ? FALSE : TRUE); } /* * This routine is written to take into account the way Brownlee Gauld * envisions that the underlying C routines will work. It is subject * to future modifications. */ #if defined(VAX) short f_get_key(short *keyp) #else short f_get_key_(short *keyp) #endif { short key, kp; key = *keyp; kp = get_key(key); if (kp == key) /* if key returned is the same as requested, set upointer */ upointer=ipointer; return kp; /* return key got */ } /* * This routine returns the key, whatever that may be, of the next set in * the input buffer and sets the user pointer, upointer, to its start. */ #if defined(VAX) short f_get_set(void) #else short f_get_set_(void) #endif { short kp; kp = get_set(); upointer = ipointer; return kp; } /* * This routine passes a pointer to a file name to the set_init routine. * The routine can be called either as * * call f_set_init('filename') * * or by * character*50 name * name = '....' * . . . * call f_set_init(name) * * Brownlee is going to change the C set_init routine to save the value of * name in an internal buffer so that if the caller happens to reuse this * character variable again it won't mess up the C routines. The call here * is for Fortran running under Ultrix or on a Sun. It will be slightly * different for VMS. * * This routine checks to see if the byte at filename[len] is NULL or not. If * it isn't, then it assumes that the variable filename is a Fortran character * variable which will not be NULL terminated. It searches backward in the * string to the first nonblank character and puts a NULL byte at this point * before calling the C set_init routine. If it is NULL terminated, then it * was probably called as in the first example above. */ #if defined(VAX) void f_set_init(void *p) { char *filename, *cp, l, savch; int i = -1, m; short len; filename = (char *)p; if (filename[2] == 14 && filename[3] == 1) { len = *(short *) filename; cp = (char *) &m; for(l=0; l= 0) i--; i++; savch = filename[i]; if(savch) filename[i] = '\0'; /* put in the NULL terminator for C */ } set_init(filename); if (i >= 0 && savch) filename[i] = savch;/* restore character made NULL */ } /* * Added interfaces to two new routines: set_reinit(short *key) and * set_bufsize(int inputsiz, int outputsiz) * These were added for a single Tennis library */ #if defined(VAX) void f_set_reinit(short *key) #else void f_set_reinit_(short *key) #endif { set_reinit(*key); } #if defined(VAX) void f_set_bufsize(int *inputsiz, int *outputsiz) #else void f_set_bufsize_(int *inputsiz, int *outputsiz) #endif { set_bufsize(*inputsiz, *outputsiz); } /* * Routine sets the user pointer (upointer) to point to the * beginning of game N * * This routine needs to have access to the pointer ipointer and the * struct setdscr[]. */ #if defined(VAX) void f_get_game(int *N) #else void f_get_game_(int *N) #endif { short p; char *ip; ip = (char *) &p; ip[0] = ipointer[0]; /* get the key pointed to by ipointer one char */ ip[1] = ipointer[1]; /* at a time to avoid alignment problems */ upointer = ipointer + setdscr[t_keymap(p)].gamepnt[*N-1]; } /* * Routine sets the user pointer (upointer) to point to the * beginning of game N * * This routine needs to have access to the pointer opointer and the * struct setdscr[]. */ #if defined(VAX) void f_put_game(int *N) #else void f_put_game_(int *N) #endif { short p; char *op; op = (char *) &p; op[0] = opointer[0]; /* get the key pointed to by opointer one char */ op[1] = opointer[1]; /* at a time to avoid alignment problems */ upointer = opointer + setdscr[t_keymap(p)].gamepnt[*N-1]; } /* * Get a byte value from the most recently called game whose pointer * has been set by a call to f_get_game(N) which is located offset bytes * from the beginning of the game. */ #if defined(VAX) char f_getbyte(int *offset) #else char f_getbyte_(int *offset) #endif { char *ch; ch = upointer + *offset; return *ch; } /* * Put a byte value into the most recently set game whose pointer * has been set by a call to f_put_game(N) which is located offset bytes * from the beginning of the game. */ #if defined(VAX) void f_putbyte(int *offset, char *c) #else void f_putbyte_(int *offset, char *c) #endif { *(upointer + *offset) = *c; } #if defined(VAX) short f_getwrd(int *offset) #else short f_getwrd_(int *offset) #endif { short j; char *jch, *cp, l; /* because of alignment problems, get values */ cp = upointer + *offset; /* one byte at a time */ jch = (char *) &j; for(l=0; l= 0) i--; i++; msav = mainp[i]; if(msav) mainp[i] = '\0'; } if (olen) { j = olen-1; while (otherp[j] == ' ' && j >= 0) j--; j++; osav = otherp[j]; if(osav) otherp[j] = '\0'; } setnmsav(mainp, otherp); /* Call the Tennis C Library routine */ if (i>=0 && msav) mainp[i] = msav; /* restore the previously zeroed chars */ if (j>=0 && osav) otherp[j] = osav; } #if defined(VAX) void f_setsrcsav(void *p) { char *src, *cp, l, savch; int i = -1, m; short srclen; src = (char *)p; if (src[2] == 14 && src[3] == 1) { srclen = *(short *) src; cp = (char *) &m; for(l=0; l= 0) i--; i++; savch = src[i]; if(savch) src[i] = '\0'; } setsrcsav(src); /* Call the Tennis C Library routine */ if (i>=0 && savch) src[i] = savch; /* Restore character set to NULL */ } #define NAMLEN 64 #if defined(VAX) void f_set_outfile(void *o, void *t) { char *outfile, *trnynm, *cp, l, osav, tsav; int i = -1,j = -1, m; short olen, tlen; cp = (char *) &m; outfile = (char *)o; if (outfile[2] == 14 && outfile[3] == 1) { olen = *(short *) outfile; for(l=0; l= 0) i--; i++; osav = outfile[i]; if(osav) outfile[i] = '\0'; if ( i > NAMLEN ) { fprintf(stderr, "f_set_outfile error: Output file name > %d characters.\n", NAMLEN); if (osav) outfile[i] = osav; exit (EXIT_FAILURE); } } if (tlen) { j = tlen-1; while (trnynm[j] == ' ' && j >= 0) j--; j++; tsav = trnynm[j]; if(tsav) trnynm[j] = '\0'; if ( j > 80 ) { fprintf(stderr, "f_set_outfile error: Tourney name > 80 characters.\n"); if (tsav) trnynm[j] = tsav; exit (EXIT_FAILURE); } } set_outfile(outfile, trnynm); if (i>=0 && osav) outfile[i] = osav; /* restore the previously zeroed chars */ if (j>=0 && tsav) trnynm[j] = tsav; } #if defined(VAX) void f_set_infile(void *p) { char *in, ch, *cp, l; int i = -1,m; short len; in = (char *)p; if (in[2] == 14 && in[3] == 1) { len = *(short *) in; cp = (char *) &m; for(l=0; l= 0) i--; i++; ch = in[i]; if(ch) in[i] = '\0'; if ( i > NAMLEN ) { fprintf(stderr, "f_set_infile error: Input file name > %d characters.\n", NAMLEN); if (ch) in[i] = ch; exit (EXIT_FAILURE); } } set_infile(in); if (i>=0 && ch) in[i] = ch; /* Restore character set to NULL */ } /********************************************************************** * * The next two routines get and put a byte array that begins at * offset from the start of the game. The number of elements in * array is denoted by count. * *********************************************************************/ #if defined(VAX) void f_getbyte_ary(int *offset, char array[], int *count) #else void f_getbyte_ary_(int *offset, char array[], int *count) #endif { int i; char *ch; ch = upointer + *offset; /* setup the access pointer */ for(i=0; i < *count; ++i) array[i] = ch[i]; /* get the values */ } #if defined(VAX) void f_putbyte_ary(int *offset, char array[], int *count) #else void f_putbyte_ary_(int *offset, char array[], int *count) #endif { int i; char *ch; ch = upointer + *offset; /* setup the access pointer */ for(i=0; i < *count; ++i) ch[i] = array[i]; /* put the values */ } /********************************************************************** * * The next two routines get and put an integer*2 array that begins at * offset from the start of the game. The number of elements in * array is denoted by count. * *********************************************************************/ #if defined(VAX) void f_getwrd_ary(int *offset, short array[], int *count) #else void f_getwrd_ary_(int *offset, short array[], int *count) #endif { int i; char *ch, *p; ch = upointer + *offset; /* setup the access pointer */ p = (char *) array; /* point to start of array */ for(i=0; i < *count * sizeof(short); ++i) p[i] = ch[i]; /* get the values */ } #if defined(VAX) void f_putwrd_ary(int *offset, short array[], int *count) #else void f_putwrd_ary_(int *offset, short array[], int *count) #endif { int i; char *ch, *p; ch = upointer + *offset; /* setup the access pointer */ p = (char *) array; /* point to start of array */ for(i=0; i < *count * sizeof(short); ++i) ch[i] = p[i]; /* put the values */ } /********************************************************************** * * The next two routines get and put an integer*4 array that begins at * offset from the start of the game. The number of elements in * array is denoted by count. * *********************************************************************/ #if defined(VAX) void f_getdblwrd_ary(int *offset, int array[], int *count) #else void f_getdblwrd_ary_(int *offset, int array[], int *count) #endif { int i; char *ch, *p; ch = upointer + *offset; /* setup the access pointer */ p = (char *) array; /* point to start of array */ for(i=0; i < *count * sizeof(int); ++i) p[i] = ch[i]; /* get the values */ } #if defined(VAX) void f_putdblwrd_ary(int *offset, int array[], int *count) #else void f_putdblwrd_ary_(int *offset, int array[], int *count) #endif { int i; char *ch, *p; ch = upointer + *offset; /* setup the access pointer */ p = (char *) array; /* point to start of array */ for(i=0; i < *count * sizeof(int); ++i) ch[i] = p[i]; /* put the values */ } /********************************************************************** * * The next two routines get and put a float array that begins at * offset from the start of the game. The number of elements in * array is denoted by count. * *********************************************************************/ #if defined(VAX) void f_getfloat_ary(int *offset, float array[], int *count) #else void f_getfloat_ary_(int *offset, float array[], int *count) #endif { int i; char *ch, *p; ch = upointer + *offset; /* setup the access pointer */ p = (char *) array; /* point to start of array */ for(i=0; i < *count * sizeof(float); ++i) p[i] = ch[i]; /* get the values */ } #if defined(VAX) void f_putfloat_ary(int *offset, float array[], int *count) #else void f_putfloat_ary_(int *offset, float array[], int *count) #endif { int i; char *ch, *p; ch = upointer + *offset; /* setup the access pointer */ p = (char *) array; /* point to start of array */ for(i=0; i < *count * sizeof(float); ++i) ch[i] = p[i]; /* put the values */ } /********************************************************************** * * The next two routines get and put a double precision real array that * begins at offset from the start of the game. The number of elements * in array is denoted by count. * *********************************************************************/ #if defined(VAX) void f_getdblfloat_ary(int *offset, double array[], int *count) #else void f_getdblfloat_ary_(int *offset, double array[], int *count) #endif { int i; char *ch, *p; ch = upointer + *offset; /* setup the access pointer */ p = (char *) array; /* point to start of array */ for(i=0; i < *count * sizeof(double); ++i) p[i] = ch[i]; /* get the values */ } #if defined(VAX) void f_putdblfloat_ary(int *offset, double array[], int *count) #else void f_putdblfloat_ary_(int *offset, double array[], int *count) #endif { int i; char *ch, *p; ch = upointer + *offset; /* setup the access pointer */ p = (char *) array; /* point to start of array */ for(i=0; i < *count * sizeof(double); ++i) ch[i] = p[i]; /* put the values */ }