Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!decwrl!ucbvax!pasteur!ames!hc!lll-winken!uunet!tektronix!tekgen!tekred!games From: games@tekred.CNA.TEK.COM Newsgroups: comp.sources.games Subject: v06i071: connect4 - connect four opponent (you vs the computer), patch1 Message-ID: <3926@tekred.CNA.TEK.COM> Date: 1 May 89 19:00:51 GMT Sender: billr@tekred.CNA.TEK.COM Lines: 242 Approved: billr@saab.CNA.TEK.COM Submitted-by: Tim Ramsey Posting-number: Volume 6, Issue 71 Archive-name: connect4.pch1 [[Here's the patches for Connect 4 to get it to compile under SysV Rel3.1. If you find any bugs in the patches please let me know. Tim]] #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh c4.c.diff <<'END_OF_c4.c.diff' X*** Orig/c4.c Thu Apr 27 07:35:24 1989 X--- c4.c Thu Apr 27 07:37:56 1989 X*************** X*** 11,16 **** X--- 11,18 ---- X * BITNET: tcjones@WATER.bitnet X * Canadian domain: tcjones@dragon.uwaterloo.ca X * X+ * Patched for SysV Rel3.1 by Tim Ramsey on 27 April 89. X+ * ..!rutgers!ksuvax1!tar, tar@ksuvax1.cis.ksu.edu X */ X X #include X*************** X*** 17,25 **** X #include X #include X #include X! #include X! #include X! #include X #include "c4.h" X #include "types.h" X #include "tables.h" X--- 19,44 ---- X #include X #include X #include X! X! #define SYSV /* TAR: could do this in Makefile but screen.c would complain */ X! X! #ifdef SYSV /* TAR */ X! # include /* For lockf() */ X! # include /* For uname() */ X! X! # define index strchr X! # define u_char unchar X! # define u_short ushort X! X! struct passwd *getpwuid(), *getpwnam(); X! X! #else /* !SYSV */ X! X! # include X! # include X! # include X! #endif /* SYSV */ X! X #include "c4.h" X #include "types.h" X #include "tables.h" X*************** X*** 43,49 **** X char *release_date = "8pm, January 1st, 1988"; X int turn = GAME_OVER; X int first; X! char *wizard = "tcjones"; X X main(argc, argv, envp) X int argc; X--- 62,68 ---- X char *release_date = "8pm, January 1st, 1988"; X int turn = GAME_OVER; X int first; X! char wizard[] = "tcjones"; /* TAR: added "[]" */ X X main(argc, argv, envp) X int argc; X*************** X*** 259,264 **** X--- 278,287 ---- X char *win_str = "won"; X extern char *date(); X X+ #ifdef SYSV /* TAR */ X+ struct utsname sysname; X+ #endif X+ X bell(); X switch (winner){ X case OURS:{ X*************** X*** 285,296 **** X--- 308,330 ---- X } X } X X+ #ifdef SYSV /* TAR */ X+ if (uname(&sysname) != -1){ X+ strcpy(host, sysname.nodename); X+ } X+ else{ X+ #else X if (gethostname(host, sizeof(host)) == -1){ X+ #endif X host[0] = '\0'; X strcat(host, "Unknown"); X } X X+ #ifdef SYSV /* TAR */ X+ if (lockf(fileno(scorefile), F_LOCK, 0) == -1){ X+ #else X if (flock(fileno(scorefile), LOCK_EX) == -1){ X+ #endif X fprintf(stderr, "Could not lock scorefile!\n"); X return; X } X*************** X*** 297,303 **** X--- 331,341 ---- X X if (fseek(scorefile, 0L, 2) == -1){ X fprintf(stderr, "Could not unlock scorefile!\n"); X+ #ifdef SYSV /* TAR */ X+ if (lockf(fileno(scorefile), F_ULOCK, 0) == -1){ X+ #else X if (flock(fileno(scorefile), LOCK_UN) == -1){ X+ #endif X fprintf(stderr, "Could not unlock scorefile!\n"); X } X return; X*************** X*** 320,326 **** X--- 358,368 ---- X } X fprintf(scorefile, "\n\n"); X X+ #ifdef SYSV /* TAR */ X+ if (lockf(fileno(scorefile), F_ULOCK, 0) == -1){ X+ #else X if (flock(fileno(scorefile), LOCK_UN) == -1){ X+ #endif X fprintf(stderr, "Could not unlock scorefile!\n"); X return; X } X*************** X*** 683,703 **** X /* return pointer to NULL terminated date string */ X X extern char *index(); X! static char time[26]; X struct timeval v; X struct timezone z; X- char *nl; X X gettimeofday(&v, &z); X! sprintf(time,"%s", ctime(&v.tv_sec)); X X! if ((nl = index(time, '\n')) == NULL){ X fprintf(stderr,"date: ctime returned non-newline terminated string.\n"); X exit(1); X } X X *nl = '\0'; X! return time; X } X X void X--- 725,753 ---- X /* return pointer to NULL terminated date string */ X X extern char *index(); X! static char timestr[26]; /* TAR */ X! char *nl; X! X! #ifdef SYSV /* TAR */ X! long secs; X! X! secs = time((long *) 0); X! sprintf(timestr,"%s", ctime(&secs)); X! #else X struct timeval v; X struct timezone z; X X gettimeofday(&v, &z); X! sprintf(timestr,"%s", ctime(&v.tv_sec)); X! #endif X X! if ((nl = index(timestr, '\n')) == NULL){ X fprintf(stderr,"date: ctime returned non-newline terminated string.\n"); X exit(1); X } X X *nl = '\0'; X! return timestr; X } X X void END_OF_c4.c.diff if test 4222 -ne `wc -c screen.c.diff <<'END_OF_screen.c.diff' X*** Orig/screen.c Thu Apr 27 07:35:27 1989 X--- screen.c Thu Apr 27 07:37:09 1989 X*************** X*** 116,121 **** X--- 116,122 ---- X refresh(); X nocrmode(); X echo(); X+ endwin(); /* TAR */ X } X X END_OF_screen.c.diff if test 217 -ne `wc -c