Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.2 6/6/85; site csee-vax.unlv.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!hplabs!parcvax!unlv!ray From: ray@unlv.UUCP (Ray Tripamer) Newsgroups: net.sources Subject: Craps diffs Message-ID: <168@csee-vax.unlv.UUCP> Date: Sun, 2-Mar-86 16:44:03 EST Article-I.D.: csee-vax.168 Posted: Sun Mar 2 16:44:03 1986 Date-Received: Fri, 7-Mar-86 07:04:07 EST Reply-To: ray@unlv.UUCP (Ray Tripamer) Organization: Unversity of Nevada, Las Vegas Lines: 221 Thanks to Joe Flake from NCR for the diffs for SYSV machines. I've put them into my source, and here are the diffs for the Makefile, random.c, and final.c. Note: I found a small bug in final.c. It seems that if you compile w/o the #define SCORES, the compiler blows up because the variable "sfile" (note the variable name change) is undefined in myexit(). This is fixed. Also, as stated above, I've changed the variable *file to *sfile. It seems there was a clash in the include file on SysV. --Ray Tripamer University of Nevada, Las Vegas !seismo!unrvax!unlv!ray ------------------------- diffs for Makefile ----------------------------- *** Makefile Sun Mar 2 13:10:55 1986 --- Makefile.old Sun Mar 2 13:23:02 1986 *************** *** 7,13 **** # # -DBSD42 for Berkeley Unix 4.2 # -DBSD29 for Berkeley Unix 2.9 - # -DSYSV for System V machines # CFLAGS = -O -DBSD42 --- 7,12 ---- ------------------------ diffs for random.c ------------------------------- *** random.c Sun Mar 2 13:10:22 1986 --- random.c.old Sun Mar 2 13:23:30 1986 *************** *** 13,33 **** #ifdef BSD42 struct timeval tp; struct timezone tpz; gettimeofday(&tp,&tpz); srandom((int)tp.tv_sec); ! #endif ! #ifdef BSD29 randomize(); #endif - #ifdef SYSV - long seed; - long time(); - void srand48(); - - time(&seed); - srand48(seed); - #endif } /* --- 13,26 ---- #ifdef BSD42 struct timeval tp; struct timezone tpz; + #endif + #ifdef BSD42 gettimeofday(&tp,&tpz); srandom((int)tp.tv_sec); ! #else randomize(); #endif } /* *************** *** 38,51 **** { #ifdef BSD42 long random(); ! return( (int) random() % 6 + 1); ! #endif ! #ifdef BSD29 double ranm(); - return( (int) (ranm() * 6.0) + 1.0); #endif ! #ifdef SYSV ! double drand48(); ! return( (int) (drand48() * 6.0) + 1.0); #endif } --- 31,43 ---- { #ifdef BSD42 long random(); ! #else double ranm(); #endif ! ! #ifdef BSD42 ! return( (int) random() % 6 + 1); ! #else ! return( (int) (ranm() * 6.0) + 1.0); #endif } -------------------------- diffs for final.c -------------------------------- *** final.c Sun Mar 2 13:20:08 1986 --- nfinal.c Sun Mar 2 13:18:18 1986 *************** *** 10,20 **** * */ ! #ifdef SCORES ! char *file="/users/intern/ray/craps.list"; ! char *reclock="/users/intern/ray/craps.lock"; ! typedef struct node { struct node *next; int uid; --- 10,19 ---- * */ ! char *sfile="/usr/games/lib/craps.list"; ! char *reclock="/usr/games/lib/craps.lock"; ! #ifdef SCORES typedef struct node { struct node *next; int uid; *************** *** 39,45 **** clear(); refresh(); signal(SIGHUP,SIG_IGN); signal(SIGINT,SIG_IGN); ! while(link(file, reclock) == -1) { perror(reclock); if(!sleepct--) { puts("I give up. Sorry."); --- 38,44 ---- clear(); refresh(); signal(SIGHUP,SIG_IGN); signal(SIGINT,SIG_IGN); ! while(link(sfile, reclock) == -1) { perror(reclock); if(!sleepct--) { puts("I give up. Sorry."); *************** *** 51,68 **** fflush(stdout); sleep(1); } ! if((list=fopen(file,"r"))==NULL) { ! fprintf(stderr,"can't open %s\n",file); myexit(); return(0); } while((fscanf(list,"%d %f %ld %s",&i,&x,&l,s))!=EOF) n++; rewind(list); score=(scores *)malloc((n+1)*sizeof(scores)); cuid=getuid(); i=0; while(1) { if((fscanf(list,"%d %f %ld %s", &score[i].uid, &score[i].amt, &score[i].ngames, --- 50,75 ---- fflush(stdout); sleep(1); } ! if((list=fopen(sfile,"r"))==NULL) { ! fprintf(stderr,"can't open %s\n",sfile); myexit(); return(0); } + #ifdef SYSV + while((fscanf(list,"%d %lf %ld %s",&i,&x,&l,s))!=EOF) n++; + #else while((fscanf(list,"%d %f %ld %s",&i,&x,&l,s))!=EOF) n++; + #endif rewind(list); score=(scores *)malloc((n+1)*sizeof(scores)); cuid=getuid(); i=0; while(1) { + #ifdef SYSV + if((fscanf(list,"%d %lf %ld %s", + #else if((fscanf(list,"%d %f %ld %s", + #endif &score[i].uid, &score[i].amt, &score[i].ngames, *************** *** 81,92 **** score[n].amt = (wins-loss); score[n].ngames = 1; if(getenv("CRAPSNAME")==NULL) strcpy(score[n].name,getenv("USER")); else strcpy(score[n].name,getenv("CRAPSNAME")); n++; } qsort(score,n,sizeof(scores),comp); ! list=fopen(file,"w"); for(i=0;i