home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #3
/
amigamamagazinepolishissue1998.iso
/
szachy
/
gnu
/
amyboard-3.2.pl2
/
amyboard.patch
< prev
next >
Wrap
Text File
|
1995-05-25
|
41KB
|
1,502 lines
diff -c -b -r xboard-3.2.pl2/backend.c AmyBoard-3.2.pl2/backend.c
*** xboard-3.2.pl2/backend.c Thu Mar 09 02:02:43 1995
--- AmyBoard-3.2.pl2/backend.c Tue May 23 19:30:30 1995
***************
*** 1,6 ****
/*
* backend.c -- Common back end for X and Windows NT versions of
! * XBoard $Id: backend.c,v 1.50 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* backend.c -- Common back end for X and Windows NT versions of
! * XBoard $Id: backend.c,v 1.1 1995/04/12 21:19:29 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
***************
*** 165,175 ****
void StopClocks P((void));
void ResetClocks P((void));
char *PGNDate P((void));
- char *PGNResult P((ChessMove result));
- char *PGNTags P((void));
- void PrintPGNTags P((FILE *f));
- void ParsePGNTag P((char *tag));
- void ClearGameInfo P((void));
void SetGameInfo P((void));
char *PositionToFEN P((int move));
Boolean ParseFEN P((Board board, int *blackPlaysFirst, char *fen));
--- 165,170 ----
***************
*** 182,188 ****
char *SavePart P((char *));
int SaveGameOldStyle P((FILE *));
int SaveGamePGN P((FILE *));
- char *PGNTagsStatic P((void));
char *StrSave P((char *));
void GetTimeMark P((TimeMark *));
long SubtractTimeMarks P((TimeMark *, TimeMark *));
--- 177,182 ----
***************
*** 189,196 ****
void CheckFlags(void);
long NextTickLength P((long));
void CheckTimeControl P((void));
-
/* States for ics_getting_history */
#define H_FALSE 0
#define H_REQUESTED 1
--- 183,190 ----
void CheckFlags(void);
long NextTickLength P((long));
void CheckTimeControl P((void));
+ void show_bytes P((FILE *, char *, int));
/* States for ics_getting_history */
#define H_FALSE 0
#define H_REQUESTED 1
***************
*** 284,289 ****
--- 278,289 ----
int matched, min, sec;
/*
+ * Initialize game list
+ */
+ ListNew(&gameList);
+
+
+ /*
* Internet chess server status
*/
if (appData.icsActive) {
***************
*** 484,490 ****
int count;
{
while (count--) {
! if (*buf < 040 || *buf > 0177) {
fprintf(fp, "\\%03o", *buf & 0xff);
} else {
putc(*buf, fp);
--- 484,490 ----
int count;
{
while (count--) {
! if (*buf < 040 || ((unsigned char) *buf) > 0177) {
fprintf(fp, "\\%03o", *buf & 0xff);
} else {
putc(*buf, fp);
***************
*** 642,647 ****
--- 642,648 ----
i = 0;
while (i < buf_len) {
+
#define TN_WILL '\373'
#define TN_WONT '\374'
#define TN_DO '\375'
***************
*** 666,672 ****
oldi = i;
reply[0] = TN_IAC;
reply[3] = NULLCHAR;
! switch (buf[++i]) {
case TN_WILL:
if (appData.debugMode)
fprintf(debugFP, "\n<WILL ");
--- 667,673 ----
oldi = i;
reply[0] = TN_IAC;
reply[3] = NULLCHAR;
! switch (((unsigned char) buf[++i])) {
case TN_WILL:
if (appData.debugMode)
fprintf(debugFP, "\n<WILL ");
***************
*** 1050,1056 ****
int gamenum = atoi(star_match[0]);
char *why = star_match[3];
char *endtoken = star_match[4];
! ChessMove endtype;
if (gameMode == IcsIdle || gameMode == BeginningOfGame ||
ics_gamenum != gamenum) {
--- 1051,1058 ----
int gamenum = atoi(star_match[0]);
char *why = star_match[3];
char *endtoken = star_match[4];
! ChessMove endtype = (ChessMove) 0;
! /* Suppress warnings on uninitialized variables */
if (gameMode == IcsIdle || gameMode == BeginningOfGame ||
ics_gamenum != gamenum) {
***************
*** 1385,1390 ****
--- 1387,1393 ----
black or if the ICS flip flag is set, but let the user change
it with the Flip View button. */
flipView = (newGameMode == IcsPlayingBlack) || ics_flip;
+ DrawPosition(FALSE, NULL);
/* Done with values from previous mode; copy in new ones */
gameMode = newGameMode;
***************
*** 1876,1881 ****
--- 1879,1885 ----
FILE *lastLoadGameFP = NULL;
int lastLoadGameNumber = 0;
+ int lastLoadGameUseList = FALSE;
char lastLoadGameTitle[MSG_SIZ];
void UserMoveEvent(fromX, fromY, toX, toY, promoChar)
***************
*** 2778,2784 ****
whiteFlag = blackFlag = FALSE;
maybePondering = FALSE;
thinkOutput[0] = NULLCHAR;
! ClearGameInfo();
ics_user_moved = FALSE;
ics_getting_history = H_FALSE;
ics_gamenum = -1;
--- 2782,2788 ----
whiteFlag = blackFlag = FALSE;
maybePondering = FALSE;
thinkOutput[0] = NULLCHAR;
! ClearGameInfo(&gameInfo);
ics_user_moved = FALSE;
ics_getting_history = H_FALSE;
ics_gamenum = -1;
***************
*** 2907,2912 ****
--- 2911,2917 ----
appData.flipView = flipView;
if (appData.debugMode)
fprintf(debugFP, "Setting flipView to %d\n", flipView) ;
+ DrawPosition(FALSE, NULL);
}
break;
***************
*** 3035,3041 ****
char buf[MSG_SIZ];
if (strcmp(filename, "-") == 0) {
! return LoadGame(stdin, n, "stdin");
} else {
f = fopen(filename, "r");
if (f == NULL) {
--- 3040,3046 ----
char buf[MSG_SIZ];
if (strcmp(filename, "-") == 0) {
! return LoadGame(stdin, n, "stdin", FALSE);
} else {
f = fopen(filename, "r");
if (f == NULL) {
***************
*** 3043,3049 ****
DisplayError(buf, errno);
return FALSE;
} else {
! return LoadGame(f, n, title);
}
}
}
--- 3048,3054 ----
DisplayError(buf, errno);
return FALSE;
} else {
! return LoadGame(f, n, title, FALSE);
}
}
}
***************
*** 3148,3156 ****
}
}
rewind(lastLoadGameFP);
retVal = LoadGame(lastLoadGameFP, lastLoadGameNumber + offset,
! lastLoadGameTitle);
if ((cmailMsgLoaded) && (offset != 0)) {
/* Make move registered during previous look at this game */
--- 3153,3163 ----
}
}
+ if (!lastLoadGameUseList) {
rewind(lastLoadGameFP);
+ }
retVal = LoadGame(lastLoadGameFP, lastLoadGameNumber + offset,
! lastLoadGameTitle, lastLoadGameUseList);
if ((cmailMsgLoaded) && (offset != 0)) {
/* Make move registered during previous look at this game */
***************
*** 3168,3180 ****
/* Load the nth game from open file f, and cache the open file handle
for possible later use by ReloadGame */
! int LoadGame(f, gameNumber, title)
FILE *f;
int gameNumber;
char *title;
{
ChessMove cm, lastStart;
char buf[MSG_SIZ];
if (gameMode != BeginningOfGame) {
Reset(FALSE);
--- 3175,3189 ----
/* Load the nth game from open file f, and cache the open file handle
for possible later use by ReloadGame */
! int LoadGame(f, gameNumber, title, useList)
FILE *f;
int gameNumber;
char *title;
+ int useList;
{
ChessMove cm, lastStart;
char buf[MSG_SIZ];
+ int seekPos;
if (gameMode != BeginningOfGame) {
Reset(FALSE);
***************
*** 3185,3206 ****
fclose(lastLoadGameFP);
}
lastLoadGameFP = f;
- if (gameNumber > 0)
- lastLoadGameNumber = gameNumber;
- else
- lastLoadGameNumber = 1;
- strcpy(lastLoadGameTitle, title);
/* Negative game number means to seek to that byte position
and load the next game found. */
! if (gameNumber < 0) {
! fseek(f, -gameNumber, 0);
! gameNumber = 1; /* do look for start marker, e.g. PGN tags */
}
yynewfile(f);
! if (gameNumber > 1) {
! sprintf(buf, "%s %d", title, gameNumber);
DisplayTitle(buf);
} else {
DisplayTitle(title);
--- 3194,3230 ----
fclose(lastLoadGameFP);
}
lastLoadGameFP = f;
/* Negative game number means to seek to that byte position
and load the next game found. */
! if (gameNumber > 0) {
! lastLoadGameNumber = gameNumber;
! seekPos = -1;
! if (useList) {
! ListGame *lg = (ListGame *) ListElem(&gameList, gameNumber-1);
!
! if (lg) {
! seekPos = lg->offset;
! gameNumber = 1;
! }
! else {
! seekPos = 0;
! }
! }
! } else {
! seekPos = -gameNumber;
! lastLoadGameNumber = gameNumber = 1;
}
+ lastLoadGameUseList = useList;
+ strcpy(lastLoadGameTitle, title);
+
+ if (seekPos >= 0) {
+ fseek(f, seekPos, 0);
+ }
yynewfile(f);
! if (lastLoadGameNumber > 1) {
! sprintf(buf, "%s %d", title, lastLoadGameNumber);
DisplayTitle(buf);
} else {
DisplayTitle(title);
***************
*** 3340,3346 ****
while (cm == PGNTag) {
if (appData.debugMode)
fprintf(debugFP, "Parsed PGNTag: %s\n", yy_text);
! ParsePGNTag(yy_text);
yyboardindex = forwardMostMove;
cm = (ChessMove) yylex();
/* Handle comments interspersed among the tags */
--- 3364,3370 ----
while (cm == PGNTag) {
if (appData.debugMode)
fprintf(debugFP, "Parsed PGNTag: %s\n", yy_text);
! ParsePGNTag(yy_text, &gameInfo);
yyboardindex = forwardMostMove;
cm = (ChessMove) yylex();
/* Handle comments interspersed among the tags */
***************
*** 3361,3367 ****
}
if (gameInfo.event != NULL) {
! char *tags = PGNTags();
if (cmailMsgLoaded) {
tags = AppendCmailMsg(tags);
}
--- 3385,3391 ----
}
if (gameInfo.event != NULL) {
! char *tags = PGNTags(&gameInfo);
if (cmailMsgLoaded) {
tags = AppendCmailMsg(tags);
}
***************
*** 3530,3536 ****
char buf[MSG_SIZ];
if (strcmp(filename, "-") == 0) {
! return LoadPosition(stdin, n, "stdin");
} else {
f = fopen(filename, "r");
if (f == NULL) {
--- 3554,3560 ----
char buf[MSG_SIZ];
if (strcmp(filename, "-") == 0) {
! return LoadPosition(stdin, n, "stdin", FALSE);
} else {
f = fopen(filename, "r");
if (f == NULL) {
***************
*** 3538,3553 ****
DisplayError(buf, errno);
return FALSE;
} else {
! return LoadPosition(f, n, title);
}
}
}
/* Load the nth position from the given open file, and close it */
! int LoadPosition(fp, positionNumber, title)
FILE *fp;
int positionNumber;
char *title;
{
char *p, line[MSG_SIZ];
Board initial_position;
--- 3562,3578 ----
DisplayError(buf, errno);
return FALSE;
} else {
! return LoadPosition(f, n, title, FALSE);
}
}
}
/* Load the nth position from the given open file, and close it */
! int LoadPosition(fp, positionNumber, title, dummy)
FILE *fp;
int positionNumber;
char *title;
+ int dummy;
{
char *p, line[MSG_SIZ];
Board initial_position;
***************
*** 3703,3709 ****
char buf[MSG_SIZ];
if (strcmp(filename, "-") == 0) {
! return SaveGame(toUserFP, 0, NULL);
} else {
f = fopen(filename, "a");
if (f == NULL) {
--- 3728,3734 ----
char buf[MSG_SIZ];
if (strcmp(filename, "-") == 0) {
! return SaveGame(toUserFP, 0, NULL, FALSE);
} else {
f = fopen(filename, "a");
if (f == NULL) {
***************
*** 3711,3717 ****
DisplayError(buf, errno);
return FALSE;
} else {
! return SaveGame(f, 0, NULL);
}
}
}
--- 3736,3742 ----
DisplayError(buf, errno);
return FALSE;
} else {
! return SaveGame(f, 0, NULL, FALSE);
}
}
}
***************
*** 3742,3748 ****
tm = time((time_t *) NULL);
! PrintPGNTags(f);
if (backwardMostMove > 0 || startedFromSetupPosition) {
fprintf(f, "[FEN \"%s\"]\n[SetUp \"1\"]\n",
--- 3767,3773 ----
tm = time((time_t *) NULL);
! PrintPGNTags(f, &gameInfo);
if (backwardMostMove > 0 || startedFromSetupPosition) {
fprintf(f, "[FEN \"%s\"]\n[SetUp \"1\"]\n",
***************
*** 3902,3911 ****
}
/* Save the current game to open file f and close the file */
! int SaveGame(f, dummy, dummy2)
FILE *f;
int dummy;
char *dummy2;
{
if (appData.oldSaveStyle)
return SaveGameOldStyle(f);
--- 3927,3937 ----
}
/* Save the current game to open file f and close the file */
! int SaveGame(f, dummy, dummy2, dummy3)
FILE *f;
int dummy;
char *dummy2;
+ int dummy3;
{
if (appData.oldSaveStyle)
return SaveGameOldStyle(f);
***************
*** 3921,3927 ****
char buf[MSG_SIZ];
if (strcmp(filename, "-") == 0) {
! return SavePosition(toUserFP, 0, NULL);
} else {
f = fopen(filename, "a");
if (f == NULL) {
--- 3947,3953 ----
char buf[MSG_SIZ];
if (strcmp(filename, "-") == 0) {
! return SavePosition(toUserFP, 0, NULL, FALSE);
} else {
f = fopen(filename, "a");
if (f == NULL) {
***************
*** 3929,3935 ****
DisplayError(buf, errno);
return FALSE;
} else {
! SavePosition(f, 0, NULL);
return TRUE;
}
}
--- 3955,3961 ----
DisplayError(buf, errno);
return FALSE;
} else {
! SavePosition(f, 0, NULL, FALSE);
return TRUE;
}
}
***************
*** 3936,3945 ****
}
/* Save the current position to the given open file and close the file */
! int SavePosition(f, dummy, dummy2)
FILE *f;
int dummy;
char *dummy2;
{
time_t tm;
extern char *programName;
--- 3962,3972 ----
}
/* Save the current position to the given open file and close the file */
! int SavePosition(f, dummy, dummy2, dummy3)
FILE *f;
int dummy;
char *dummy2;
+ int dummy3;
{
time_t tm;
extern char *programName;
***************
*** 4095,4101 ****
sprintf(string, "%s.pos.out", appData.cmailGameName);
f = fopen(string, "w");
! SavePosition(f, 0, NULL);
fclose(f);
} else {
fprintf(f, "{--------------\n");
--- 4122,4128 ----
sprintf(string, "%s.pos.out", appData.cmailGameName);
f = fopen(string, "w");
! SavePosition(f, 0, NULL, FALSE);
fclose(f);
} else {
fprintf(f, "{--------------\n");
***************
*** 4102,4108 ****
PrintPosition(f, currentMove);
fprintf(f, "--------------}\n\n");
! SaveGame(f, 0, NULL);
fclose(f);
}
--- 4129,4135 ----
PrintPosition(f, currentMove);
fprintf(f, "--------------}\n\n");
! SaveGame(f, 0, NULL, FALSE);
fclose(f);
}
***************
*** 4121,4127 ****
static char *partCommandString = "cmail -xv%s -remail -game %s 2>&1";
FILE *commandOutput;
char buffer[MSG_SIZ], msg[MSG_SIZ], string[MSG_SIZ];
! int nBytes;
int nBuffers;
int i;
int archived;
--- 4148,4154 ----
static char *partCommandString = "cmail -xv%s -remail -game %s 2>&1";
FILE *commandOutput;
char buffer[MSG_SIZ], msg[MSG_SIZ], string[MSG_SIZ];
! int nBytes = 0; /* Suppress warnings on uninitialized variables */
int nBuffers;
int i;
int archived;
***************
*** 5180,5186 ****
void AboutGameEvent()
{
if (gameInfo.event != NULL) {
! char *tags = PGNTags();
if (cmailMsgLoaded) {
tags = AppendCmailMsg(tags);
}
--- 5207,5213 ----
void AboutGameEvent()
{
if (gameInfo.event != NULL) {
! char *tags = PGNTags(&gameInfo);
if (cmailMsgLoaded) {
tags = AppendCmailMsg(tags);
}
***************
*** 5221,5259 ****
}
}
- void ClearGameInfo()
- {
- if (gameInfo.event != NULL) free(gameInfo.event);
- gameInfo.event = NULL;
- if (gameInfo.site != NULL) free(gameInfo.site);
- gameInfo.site = NULL;
- if (gameInfo.date != NULL) free(gameInfo.date);
- gameInfo.date = NULL;
- if (gameInfo.round != NULL) free(gameInfo.round);
- gameInfo.round = NULL;
- if (gameInfo.white != NULL) free(gameInfo.white);
- gameInfo.white = NULL;
- if (gameInfo.black != NULL) free(gameInfo.black);
- gameInfo.black = NULL;
- gameInfo.result = GameUnfinished;
- if (gameInfo.resultDetails != NULL) {
- free(gameInfo.resultDetails);
- gameInfo.resultDetails = NULL;
- }
- if (gameInfo.fen != NULL) free(gameInfo.fen);
- gameInfo.fen = NULL;
- if (gameInfo.timeControl != NULL) free(gameInfo.timeControl);
- gameInfo.timeControl = NULL;
- if (gameInfo.extraTags != NULL) free(gameInfo.extraTags);
- gameInfo.extraTags = NULL;
- }
-
void SetGameInfo()
{
char buf[MSG_SIZ];
/* This routine is used only for certain modes */
! ClearGameInfo();
switch (gameMode) {
case MachinePlaysWhite:
gameInfo.event = StrSave("GNU Chess game");
--- 5248,5259 ----
}
}
void SetGameInfo()
{
char buf[MSG_SIZ];
/* This routine is used only for certain modes */
! ClearGameInfo(&gameInfo);
switch (gameMode) {
case MachinePlaysWhite:
gameInfo.event = StrSave("GNU Chess game");
***************
*** 5344,5458 ****
}
}
- void ParsePGNTag(tag)
- char *tag;
- {
- char *name, *value, *p, *oldTags;
- int len;
-
- name = tag;
- while (!isalpha(*name) && !isdigit(*name)) name++;
- p = name;
- while (*p != ' ' && *p != '\t' && *p != '\n') p++;
- *p = NULLCHAR;
- value = strchr(p + 1, '"') + 1;
- p = strrchr(value, '"');
- *p = NULLCHAR;
-
- if (strcmp(name, "Event") == 0) {
- gameInfo.event = StrSave(value);
- } else if (strcmp(name, "Site") == 0) {
- gameInfo.site = StrSave(value);
- } else if (strcmp(name, "Date") == 0) {
- gameInfo.date = StrSave(value);
- } else if (strcmp(name, "Round") == 0) {
- gameInfo.round = StrSave(value);
- } else if (strcmp(name, "White") == 0) {
- gameInfo.white = StrSave(value);
- } else if (strcmp(name, "Black") == 0) {
- gameInfo.black = StrSave(value);
- } else if (strcmp(name, "Result") == 0) {
- if (strcmp(value, "1-0") == 0)
- gameInfo.result = WhiteWins;
- else if (strcmp(value, "0-1") == 0)
- gameInfo.result = BlackWins;
- else if (strcmp(value, "1/2-1/2") == 0)
- gameInfo.result = GameIsDrawn;
- else
- gameInfo.result = GameUnfinished;
- } else if (strcmp(name, "FEN") == 0) {
- gameInfo.fen = StrSave(value);
- } else if (strcmp(name, "SetUp") == 0) {
- /* ignore on input; presence of FEN governs */
- } else {
- if (gameInfo.extraTags == NULL)
- oldTags = "";
- else
- oldTags = gameInfo.extraTags;
- /* Buffer size includes 7 bytes of space for [ ""]\n\0 */
- len = strlen(oldTags) + strlen(value) + strlen(name) + 7;
- p = (char *) malloc(len);
- sprintf(p, "%s[%s \"%s\"]\n", oldTags, name, value);
- if (gameInfo.extraTags != NULL) free(gameInfo.extraTags);
- gameInfo.extraTags = p;
- }
- }
-
- char *PGNTagsStatic()
- {
- static char buf[8192];
- char buf1[MSG_SIZ];
-
- buf[0] = NULLCHAR;
-
- if (gameInfo.event != NULL) {
- sprintf(buf1, "[Event \"%s\"]\n", gameInfo.event);
- strcat(buf, buf1);
- }
- if (gameInfo.site != NULL) {
- sprintf(buf1, "[Site \"%s\"]\n", gameInfo.site);
- strcat(buf, buf1);
- }
- if (gameInfo.date != NULL) {
- sprintf(buf1, "[Date \"%s\"]\n", gameInfo.date);
- strcat(buf, buf1);
- }
- if (gameInfo.round != NULL) {
- sprintf(buf1, "[Round \"%s\"]\n", gameInfo.round);
- strcat(buf, buf1);
- }
- if (gameInfo.white != NULL) {
- sprintf(buf1, "[White \"%s\"]\n", gameInfo.white);
- strcat(buf, buf1);
- }
- if (gameInfo.black != NULL) {
- sprintf(buf1, "[Black \"%s\"]\n", gameInfo.black);
- strcat(buf, buf1);
- }
- sprintf(buf1, "[Result \"%s\"]\n", PGNResult(gameInfo.result));
- strcat(buf, buf1);
- if (gameInfo.timeControl != NULL) {
- sprintf(buf1, "[TimeControl \"%s\"]\n", gameInfo.timeControl);
- strcat(buf, buf1);
- }
- if (gameInfo.extraTags != NULL) {
- strcat(buf, gameInfo.extraTags);
- }
- return buf;
- }
-
-
- void PrintPGNTags(fp)
- FILE *fp;
- {
- fprintf(fp, "%s", PGNTagsStatic());
- }
-
- char *PGNTags()
- {
- return StrSave(PGNTagsStatic());
- }
-
void ReplaceComment(index, text)
int index;
char *text;
--- 5344,5349 ----
***************
*** 6092,6102 ****
{
char *ret;
! ret = (char *) malloc(strlen(s) + 1);
strcpy(ret, s);
return ret;
}
char *PGNDate()
{
time_t clock;
--- 5983,6007 ----
{
char *ret;
! if ((ret = (char *) malloc(strlen(s) + 1))) {
strcpy(ret, s);
+ }
return ret;
}
+ char *StrSavePtr(s, savePtr)
+ char *s, **savePtr;
+ {
+ if (*savePtr) {
+ free(*savePtr);
+ }
+ if ((*savePtr = (char *) malloc(strlen(s) + 1))) {
+ strcpy(*savePtr, s);
+ }
+ return(*savePtr);
+ }
+
+
char *PGNDate()
{
time_t clock;
***************
*** 6110,6130 ****
return StrSave(buf);
}
- char *PGNResult(result)
- ChessMove result;
- {
- switch (result) {
- case GameUnfinished:
- default:
- return "*";
- case WhiteWins:
- return "1-0";
- case BlackWins:
- return "0-1";
- case GameIsDrawn:
- return "1/2-1/2";
- }
- }
char *PositionToFEN(move)
int move;
--- 6015,6020 ----
diff -c -b -r xboard-3.2.pl2/backend.h AmyBoard-3.2.pl2/backend.h
*** xboard-3.2.pl2/backend.h Thu Mar 09 02:02:43 1995
--- AmyBoard-3.2.pl2/backend.h Tue May 23 19:30:30 1995
***************
*** 1,6 ****
/*
* backend.h -- Interface exported by XBoard back end
! * $Id: backend.h,v 1.19 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* backend.h -- Interface exported by XBoard back end
! * $Id: backend.h,v 1.1 1995/04/12 21:19:14 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
***************
*** 45,50 ****
--- 45,52 ----
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* ------------------------------------------------------------------------
*/
+ #include "lists.h"
+
extern GameMode gameMode;
extern int pausing, cmailMsgLoaded, flipView;
extern FILE *fromUserFP, *toUserFP, *debugFP;
***************
*** 57,67 ****
int OKToStartUserMove P((int x, int y));
void Reset P((int redraw));
void ResetGameEvent P((void));
! int LoadGame P((FILE *f, int n, char *title));
int ReloadGame P((int offset));
! int SaveGame P((FILE *f, int dummy, char *dummy2));
! int LoadPosition P((FILE *f, int n, char *title));
! int SavePosition P((FILE *f, int dummy, char *dummy2));
void EditPositionEvent P((void));
void FlipViewEvent P((void));
void MachineWhiteEvent P((void));
--- 59,69 ----
int OKToStartUserMove P((int x, int y));
void Reset P((int redraw));
void ResetGameEvent P((void));
! int LoadGame P((FILE *f, int n, char *title, int useList));
int ReloadGame P((int offset));
! int SaveGame P((FILE *f, int dummy, char *dummy2, int dummy3));
! int LoadPosition P((FILE *f, int n, char *title, int dummy));
! int SavePosition P((FILE *f, int dummy, char *dummy2, int dummy3));
void EditPositionEvent P((void));
void FlipViewEvent P((void));
void MachineWhiteEvent P((void));
***************
*** 107,114 ****
void ReloadCmailGameEvent P((int unregister));
void MailMoveEvent P((void));
- int StrCaseCmp P((char *s1, char *s2));
char *StrStr P((char *string, char *match));
int ToLower P((int c));
int ToUpper P((int c));
! char *StrSave P((char *s));
--- 109,153 ----
void ReloadCmailGameEvent P((int unregister));
void MailMoveEvent P((void));
char *StrStr P((char *string, char *match));
+ char *StrSave P((char *s));
+ char *StrSavePtr P((char *s, char **savePtr));
+
+ #ifndef _amigados
+ int StrCaseCmp P((char *s1, char *s2));
int ToLower P((int c));
int ToUpper P((int c));
! #else
! #define StrCaseCmp Stricmp /* Use utility.library functions */
! #include <proto/utility.h>
! #endif
!
! extern GameInfo gameInfo;
!
!
!
! /* pgntags.c prototypes
! */
! char *PGNTags P((GameInfo *));
! void PrintPGNTags P((FILE *f, GameInfo *));
! int ParsePGNTag P((char *, GameInfo *));
! char *PGNResult P((ChessMove result));
!
!
! /* gamelist.c prototypes
! */
! /* A game node in the double linked list of games.
! */
! typedef struct _ListGame {
! ListNode node;
! int number;
! unsigned long offset; /* Byte offset of game within file. */
! GameInfo gameInfo; /* Note, that some entries may be NULL, */
! /* except for event, black and white, */
! /* which are initialized to "Unknown". */
! } ListGame;
!
! extern List gameList;
! void ClearGameInfo P((GameInfo *));
! int GameListBuild P((FILE *));
! void GameListInitGameInfo P((GameInfo *));
diff -c -b -r xboard-3.2.pl2/bitmaps.h AmyBoard-3.2.pl2/bitmaps.h
*** xboard-3.2.pl2/bitmaps.h Thu Mar 09 02:02:46 1995
--- AmyBoard-3.2.pl2/bitmaps.h Tue May 23 19:30:30 1995
***************
*** 1,6 ****
/*
* bitmaps.h - Include bitmap files for pieces and icons
! * $Id: bitmaps.h,v 1.2 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* bitmaps.h - Include bitmap files for pieces and icons
! * $Id: bitmaps.h,v 1.1 1995/04/12 21:18:57 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
diff -c -b -r xboard-3.2.pl2/childio.h AmyBoard-3.2.pl2/childio.h
*** xboard-3.2.pl2/childio.h Thu Mar 09 02:02:50 1995
--- AmyBoard-3.2.pl2/childio.h Tue May 23 19:30:30 1995
***************
*** 1,6 ****
/*
* childio.h -- set up communication with child processes
! * $Id: childio.h,v 1.3 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* childio.h -- set up communication with child processes
! * $Id: childio.h,v 1.1 1995/04/12 21:18:13 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
diff -c -b -r xboard-3.2.pl2/common.h AmyBoard-3.2.pl2/common.h
*** xboard-3.2.pl2/common.h Thu Mar 09 02:02:51 1995
--- AmyBoard-3.2.pl2/common.h Tue May 23 19:30:30 1995
***************
*** 1,6 ****
/*
* common.h -- Common definitions for X and Windows NT versions of XBoard
! * $Id: common.h,v 1.24 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* common.h -- Common definitions for X and Windows NT versions of XBoard
! * $Id: common.h,v 1.1 1995/04/12 21:17:58 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
***************
*** 48,54 ****
/* Begin compatibility grunge */
! #if defined(__STDC__) || defined(WIN32)
#define P(args) args
typedef void *VOIDSTAR;
#else
--- 48,54 ----
/* Begin compatibility grunge */
! #if defined(__STDC__) || defined(WIN32) || defined(_amigados)
#define P(args) args
typedef void *VOIDSTAR;
#else
***************
*** 61,70 ****
--- 61,82 ----
typedef char *String;
#define popen _popen
#define pclose _pclose
+
+ #else
+ #ifdef _amigados /* It is important, that these types have */
+ typedef int Boolean; /* a length of 4 bytes each, as we are */
+ typedef char *String; /* using ReadArgs() for argument parsing. */
+ #ifdef _DCC
+ FILE *popen(const char *, const char *);
+ int pclose(FILE *);
+ #endif
+
#else
#include <X11/Intrinsic.h>
#endif
+ #endif
+
#ifndef TRUE
#define TRUE 1
#define FALSE 0
***************
*** 142,151 ****
--- 154,170 ----
} ChessMove;
typedef struct {
+ #if !defined(_amigados)
char *whitePieceColor;
char *blackPieceColor;
char *lightSquareColor;
char *darkSquareColor;
+ #else
+ int whitePieceColor;
+ int blackPieceColor;
+ int lightSquareColor;
+ int darkSquareColor;
+ #endif
int movesPerSession;
char *initString;
char *whiteString;
***************
*** 206,211 ****
--- 225,234 ----
/********************************************/
Boolean zippyTalk;
Boolean zippyPlay;
+ /********************************************/
+ /**** Currently used only by AmyBoard: ******/
+ Boolean useGameList;
+ /********************************************/
} AppData, *AppDataPtr;
extern AppData appData;
diff -c -b -r xboard-3.2.pl2/frontend.h AmyBoard-3.2.pl2/frontend.h
*** xboard-3.2.pl2/frontend.h Thu Mar 09 02:02:51 1995
--- AmyBoard-3.2.pl2/frontend.h Tue May 23 19:30:32 1995
***************
*** 1,6 ****
/*
* frontend.h -- Interface exported by all XBoard front ends
! * $Id: frontend.h,v 1.12 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* frontend.h -- Interface exported by all XBoard front ends
! * $Id: frontend.h,v 1.1 1995/04/12 21:16:21 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
***************
*** 53,59 ****
void SetNCPMode P((void));
void SetCmailMode P((void));
void DisplayTitle P((String title));
! void DisplayMessage P((String message1, String message2));
void DisplayError P((String message, int error));
void DisplayFatalError P((String message, int error, int status));
void DisplayInformation P((String message));
--- 53,59 ----
void SetNCPMode P((void));
void SetCmailMode P((void));
void DisplayTitle P((String title));
! void DisplayMessage P((String message, String extMessage));
void DisplayError P((String message, int error));
void DisplayFatalError P((String message, int error, int status));
void DisplayInformation P((String message));
***************
*** 102,106 ****
--- 102,109 ----
int OutputToProcess P((ProcRef pr, char *message, int count, int *outError));
void CmailSigHandlerCallBack P((InputSourceRef isr, char *buf, int count, int error));
+
+ void EditPositionPopUp P((void));
+ void EditPositionPopDown P((void));
extern ProcRef cmailPR;
diff -c -b -r xboard-3.2.pl2/moves.c AmyBoard-3.2.pl2/moves.c
*** xboard-3.2.pl2/moves.c Thu Mar 09 02:02:52 1995
--- AmyBoard-3.2.pl2/moves.c Tue May 23 19:30:32 1995
***************
*** 1,6 ****
/*
* moves.c - Move generation and checking
! * $Id: moves.c,v 1.6 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* moves.c - Move generation and checking
! * $Id: moves.c,v 1.1 1995/04/12 21:16:02 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
***************
*** 57,62 ****
--- 57,67 ----
#include "moves.h"
#include "parser.h"
+ int WhitePiece P((ChessSquare));
+ int BlackPiece P((ChessSquare));
+ int SameColor P((ChessSquare, ChessSquare));
+
+
int WhitePiece(piece)
ChessSquare piece;
{
***************
*** 514,520 ****
{
CheckTestClosure cl;
ChessSquare king = flags & F_WHITE_ON_MOVE ? WhiteKing : BlackKing;
! ChessSquare captured;
if (rf >= 0) {
if (enPassant) {
--- 519,526 ----
{
CheckTestClosure cl;
ChessSquare king = flags & F_WHITE_ON_MOVE ? WhiteKing : BlackKing;
! ChessSquare captured = EmptySquare;
! /* Suppress warnings on uninitialized variables */
if (rf >= 0) {
if (enPassant) {
diff -c -b -r xboard-3.2.pl2/moves.h AmyBoard-3.2.pl2/moves.h
*** xboard-3.2.pl2/moves.h Thu Mar 09 02:02:52 1995
--- AmyBoard-3.2.pl2/moves.h Tue May 23 19:30:32 1995
***************
*** 1,6 ****
/*
* moves.h - Move generation and checking
! * $Id: moves.h,v 1.4 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* moves.h - Move generation and checking
! * $Id: moves.h,v 1.1 1995/04/12 21:15:29 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
diff -c -b -r xboard-3.2.pl2/parser.c AmyBoard-3.2.pl2/parser.c
*** xboard-3.2.pl2/parser.c Thu Mar 09 02:02:53 1995
--- AmyBoard-3.2.pl2/parser.c Tue May 23 19:30:32 1995
***************
*** 27,33 ****
extern struct yysvf yysvec[], *yybgin;
/*
* parser.l -- lex parser of algebraic chess moves for XBoard
! * $Id: parser.l,v 1.21 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 27,33 ----
extern struct yysvf yysvec[], *yybgin;
/*
* parser.l -- lex parser of algebraic chess moves for XBoard
! * $Id: parser.c,v 1.1 1995/04/12 21:14:04 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
***************
*** 131,136 ****
--- 131,138 ----
static int input P((void));
static void output P((int ch));
static void unput P((int ch));
+ int yylook P((void));
+ int yyback P((int *, int));
#endif
#undef yywrap
int yywrap P((void));
***************
*** 782,787 ****
--- 784,799 ----
return ret;
}
+ int yyoffset()
+ {
+ int offset = ftell(lexFP) - unputCount;
+
+ if (offset < 0) {
+ offset = 0;
+ }
+ return(offset);
+ }
+
static void output(ch)
int ch;
{
diff -c -b -r xboard-3.2.pl2/parser.h AmyBoard-3.2.pl2/parser.h
*** xboard-3.2.pl2/parser.h Thu Mar 09 02:02:52 1995
--- AmyBoard-3.2.pl2/parser.h Tue May 23 19:30:32 1995
***************
*** 1,6 ****
/*
* parser.h -- Interface to XBoard move parser
! * $Id: parser.h,v 1.4 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* parser.h -- Interface to XBoard move parser
! * $Id: parser.h,v 1.1 1995/04/12 21:14:47 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
***************
*** 54,56 ****
--- 54,57 ----
extern int yyboardindex;
extern char *yy_text; /* needed because yytext is a char[] in lex
but a char* in flex */
+ extern int yyoffset P((void));
diff -c -b -r xboard-3.2.pl2/parser.l AmyBoard-3.2.pl2/parser.l
*** xboard-3.2.pl2/parser.l Thu Mar 09 02:02:52 1995
--- AmyBoard-3.2.pl2/parser.l Tue May 23 19:30:32 1995
***************
*** 67,72 ****
--- 67,83 ----
/* This is flex */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) my_yy_input(buf, &result, max_size)
+ #ifdef _amigados /* AmigaDOS flex modifies yytext. Don't other? */
+ #define YY_DECL \
+ int _yylex YY_PROTO((void)); \
+ int yylex YY_PROTO((void)) \
+ { \
+ int result = _yylex(); \
+ yy_text = yytext; \
+ return(result); \
+ } \
+ int _yylex YY_PROTO((void))
+ #endif
#else
/* This is lex */
#undef input
***************
*** 88,95 ****
--- 99,114 ----
# include <unistd.h>
#endif
+ #if defined(_amigados)
+ # include <errno.h>
+ # if HAVE_FCNTL_H
+ # include <fcntl.h> /* isatty() prototype */
+ # endif /* HAVE_FCNTL_H */
+ #endif /* defined(_amigados) */
+
#include "common.h"
#include "backend.h"
+ #include "frontend.h"
#include "parser.h"
#include "moves.h"
***************
*** 111,116 ****
--- 130,137 ----
static int input P((void));
static void output P((int ch));
static void unput P((int ch));
+ int yylook P((void));
+ int yyback P((int *, int));
#endif
#undef yywrap
int yywrap P((void));
***************
*** 709,714 ****
--- 730,748 ----
return ret;
}
+ /*
+ Return offset of next pattern within current file.
+ */
+ int yyoffset()
+ {
+ int offset = ftell(lexFP) - unputCount;
+
+ if (offset < 0) {
+ offset = 0;
+ }
+ return(offset);
+ }
+
static void output(ch)
int ch;
{
***************
*** 785,812 ****
}
}
static YY_BUFFER_STATE my_file_buffer = NULL;
void yynewstr(s)
char *s;
{
- yy_text = (char *) yytext;
if (my_file_buffer != NULL)
yy_delete_buffer(my_file_buffer);
StringToLex = s;
my_file_buffer = yy_create_buffer(stdin, YY_BUF_SIZE);
yy_switch_to_buffer(my_file_buffer);
}
void yynewfile(f)
FILE *f;
{
- yy_text = (char *) yytext;
if (my_file_buffer != NULL)
yy_delete_buffer(my_file_buffer);
StringToLex = NULL;
my_file_buffer = yy_create_buffer(f, YY_BUF_SIZE);
yy_switch_to_buffer(my_file_buffer);
}
#endif /*FLEX_SCANNER*/
--- 819,857 ----
}
}
+ /*
+ Return offset of next pattern in the current file.
+ */
+ int yyoffset()
+ {
+ int pos = yy_c_buf_p - yy_current_buffer->yy_ch_buf;
+
+ return(ftell(yy_current_buffer->yy_input_file) -
+ yy_n_chars + pos);
+ }
+
static YY_BUFFER_STATE my_file_buffer = NULL;
void yynewstr(s)
char *s;
{
if (my_file_buffer != NULL)
yy_delete_buffer(my_file_buffer);
StringToLex = s;
my_file_buffer = yy_create_buffer(stdin, YY_BUF_SIZE);
yy_switch_to_buffer(my_file_buffer);
+ yy_text = (char *) yytext;
}
void yynewfile(f)
FILE *f;
{
if (my_file_buffer != NULL)
yy_delete_buffer(my_file_buffer);
StringToLex = NULL;
my_file_buffer = yy_create_buffer(f, YY_BUF_SIZE);
yy_switch_to_buffer(my_file_buffer);
+ yy_text = (char *) yytext;
}
#endif /*FLEX_SCANNER*/
diff -c -b -r xboard-3.2.pl2/xboard.c AmyBoard-3.2.pl2/xboard.c
*** xboard-3.2.pl2/xboard.c Thu Mar 09 02:02:52 1995
--- AmyBoard-3.2.pl2/xboard.c Tue May 23 19:30:34 1995
***************
*** 1,6 ****
/*
* xboard.c -- X front end for XBoard
! * $Id: xboard.c,v 1.42 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* xboard.c -- X front end for XBoard
! * $Id: xboard.c,v 1.1 1995/04/12 21:13:30 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
***************
*** 2895,2901 ****
char *title;
{
cmailMsgLoaded = FALSE;
! return LoadGame(f, gameNumber, title);
}
void LoadGameProc(w, event, prms, nprms)
--- 2895,2901 ----
char *title;
{
cmailMsgLoaded = FALSE;
! return LoadGame(f, gameNumber, title, FALSE);
}
void LoadGameProc(w, event, prms, nprms)
***************
*** 3489,3495 ****
Arg arg;
if (extMessage) {
! if (message) {
sprintf(buf, "%s %s", message, extMessage);
message = buf;
} else {
--- 3489,3495 ----
Arg arg;
if (extMessage) {
! if (*message) {
sprintf(buf, "%s %s", message, extMessage);
message = buf;
} else {
diff -c -b -r xboard-3.2.pl2/xboard.h AmyBoard-3.2.pl2/xboard.h
*** xboard-3.2.pl2/xboard.h Thu Mar 09 02:02:53 1995
--- AmyBoard-3.2.pl2/xboard.h Tue May 23 19:30:34 1995
***************
*** 1,6 ****
/*
* xboard.h -- Parameter definitions for X front end
! * $Id: xboard.h,v 1.10 1995/03/09 00:43:28 mann Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.
--- 1,6 ----
/*
* xboard.h -- Parameter definitions for X front end
! * $Id: xboard.h,v 1.1 1995/04/12 21:13:03 Joe Exp $
*
* Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
* Enhancements Copyright 1992-95 Free Software Foundation, Inc.