Window xBoardWindow;
Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor,
jailSquareColor, highlightSquareColor, premoveHighlightColor;
+Pixel lowTimeWarningColor;
GC lightSquareGC, darkSquareGC, jailSquareGC, lineGC, wdPieceGC, wlPieceGC,
bdPieceGC, blPieceGC, wbPieceGC, bwPieceGC, coordGC, highlineGC,
wjPieceGC, bjPieceGC, prelineGC, countGC;
{ "zippyReplayTimeout", "zippyReplayTimeout", XtRInt, sizeof(int),
XtOffset(AppDataPtr, zippyReplayTimeout), XtRImmediate,
(XtPointer) ZIPPY_REPLAY_TIMEOUT },
+ { "zippyShortGame", "zippyShortGame", XtRInt, sizeof(int),
+ XtOffset(AppDataPtr, zippyShortGame), XtRImmediate,
+ (XtPointer) 0 },
#endif
{ "flashCount", "flashCount", XtRInt, sizeof(int),
XtOffset(AppDataPtr, flashCount), XtRImmediate,
{ "showButtonBar", "showButtonBar", XtRBoolean,
sizeof(Boolean), XtOffset(AppDataPtr, showButtonBar),
XtRImmediate, (XtPointer) True },
+ { "lowTimeWarningColor", "lowTimeWarningColor", XtRString,
+ sizeof(String), XtOffset(AppDataPtr, lowTimeWarningColor),
+ XtRString, COLOR_LOWTIMEWARNING },
+ { "lowTimeWarning", "lowTimeWarning", XtRBoolean,
+ sizeof(Boolean), XtOffset(AppDataPtr, lowTimeWarning),
+ XtRImmediate, (XtPointer) False },
{"icsEngineAnalyze", "icsEngineAnalyze", XtRBoolean, /* [DM] icsEngineAnalyze */
sizeof(Boolean), XtOffset(AppDataPtr, icsEngineAnalyze),
XtRImmediate, (XtPointer) False },
{ "secondOptions", "secondOptions", XtRString,
sizeof(String), XtOffset(AppDataPtr, secondOptions),
XtRImmediate, (XtPointer) "" },
+ { "firstNeedsNoncompliantFEN", "firstNeedsNoncompliantFEN", XtRString,
+ sizeof(String), XtOffset(AppDataPtr, fenOverride1),
+ XtRImmediate, (XtPointer) 0 },
+ { "secondNeedsNoncompliantFEN", "secondNeedsNoncompliantFEN", XtRString,
+ sizeof(String), XtOffset(AppDataPtr, fenOverride2),
+ XtRImmediate, (XtPointer) 0 },
// [HGM] Winboard_x UCI options
{ "firstIsUCI", "firstIsUCI", XtRBoolean,
{ "-zippyVariants", "zippyVariants", XrmoptionSepArg, NULL },
{ "-zippyMaxGames", "zippyMaxGames", XrmoptionSepArg, NULL },
{ "-zippyReplayTimeout", "zippyReplayTimeout", XrmoptionSepArg, NULL },
+ { "-zippyShortGame", "zippyShortGame", XrmoptionSepArg, NULL },
#endif
{ "-flashCount", "flashCount", XrmoptionSepArg, NULL },
{ "-flash", "flashCount", XrmoptionNoArg, "3" },
{ "-showButtonBar", "showButtonBar", XrmoptionSepArg, NULL },
{ "-buttons", "showButtonBar", XrmoptionNoArg, "True" },
{ "-xbuttons", "showButtonBar", XrmoptionNoArg, "False" },
+ { "-lowTimeWarningColor", "lowTimeWarningColor", XrmoptionSepArg, NULL },
+ { "-lowTimeWarning", "lowTimeWarning", XrmoptionSepArg, NULL },
/* [AS,HR] New features */
{ "-firstScoreAbs", "firstScoreAbs", XrmoptionSepArg, NULL },
{ "-secondScoreAbs", "secondScoreAbs", XrmoptionSepArg, NULL },
{ "-noGUI", "noGUI", XrmoptionNoArg, "True" },
{ "-firstOptions", "firstOptions", XrmoptionSepArg, NULL },
{ "-secondOptions", "secondOptions", XrmoptionSepArg, NULL },
+ { "-firstNeedsNoncompliantFEN", "firstNeedsNoncompliantFEN", XrmoptionSepArg, NULL },
+ { "-secondNeedsNoncompliantFEN", "secondNeedsNoncompliantFEN", XrmoptionSepArg, NULL },
};
{
char buf[MSG_SIZ];
XSetWMProtocols(xDisplay, XtWindow(w), &wm_delete_window, 1);
- sprintf(buf, "<Message>WM_PROTOCOLS: %s() \n", procname);
+ snprintf(buf, sizeof(buf), "<Message>WM_PROTOCOLS: %s() \n", procname);
XtAugmentTranslations(w, XtParseTranslationTable(buf));
}
if (argc > 1) {
fprintf(stderr, _("%s: unrecognized argument %s\n"),
programName, argv[1]);
+ fprintf(stderr, "Recognized options:\n");
+ for(i = 0; i < XtNumber(shellOptions); i++) {
+ j = fprintf(stderr, " %s%s", shellOptions[i].option,
+ (shellOptions[i].argKind == XrmoptionSepArg
+ ? " ARG" : ""));
+ if (i++ < XtNumber(shellOptions)) {
+ fprintf(stderr, "%*c%s%s\n", 40 - j, ' ',
+ shellOptions[i].option,
+ (shellOptions[i].argKind == XrmoptionSepArg
+ ? " ARG" : ""));
+ } else {
+ fprintf(stderr, "\n");
+ }
+ }
exit(2);
}
i = strlen(p) + strlen("/.xboardXXXXXx.pgn") + 1;
gameCopyFilename = (char*) malloc(i);
gamePasteFilename = (char*) malloc(i);
- sprintf(gameCopyFilename, "%s/.xboard%05uc.pgn", p, getpid());
- sprintf(gamePasteFilename, "%s/.xboard%05up.pgn", p, getpid());
+ snprintf(gameCopyFilename,i, "%s/.xboard%05uc.pgn", p, getpid());
+ snprintf(gamePasteFilename,i, "%s/.xboard%05up.pgn", p, getpid());
XtGetApplicationResources(shellWidget, (XtPointer) &appData,
clientResources, XtNumber(clientResources),
if (forceMono) {
fprintf(stderr, _("%s: too few colors available; trying monochrome mode\n"),
programName);
+
+ if (appData.bitmapDirectory == NULL ||
+ appData.bitmapDirectory[0] == NULLCHAR)
+ appData.bitmapDirectory = DEF_BITMAP_DIR;
+ }
+
+ if (appData.lowTimeWarning && !appData.monoMode) {
+ vFrom.addr = (caddr_t) appData.lowTimeWarningColor;
+ vFrom.size = strlen(appData.lowTimeWarningColor);
+ XtConvert(shellWidget, XtRString, &vFrom, XtRPixel, &vTo);
+ if (vTo.addr == NULL)
+ appData.monoMode = True;
+ else
+ lowTimeWarningColor = *(Pixel *) vTo.addr;
}
if (appData.monoMode && appData.debugMode) {
fprintf(stderr, "%d", piece+1);
for (kind=0; kind<4; kind++) {
fprintf(stderr, ".");
- sprintf(buf, "%s/%c%s%u.xim",
+ snprintf(buf, sizeof(buf), "%s/%c%s%u.xim",
ExpandPathName(appData.pixmapDirectory),
ToLower(PieceToChar((ChessSquare)piece)),
ximkind[kind], ss);
/* Load light and dark squares */
/* If the LSQ and DSQ pieces don't exist, we will
draw them with solid squares. */
- sprintf(buf, "%s/lsq%u.xim", ExpandPathName(appData.pixmapDirectory), ss);
+ snprintf(buf,sizeof(buf), "%s/lsq%u.xim", ExpandPathName(appData.pixmapDirectory), ss);
if (access(buf, 0) != 0) {
useImageSqs = 0;
} else {
loadXIM(ximLightSquare, NULL, buf, &xpmLightSquare, NULL);
fprintf(stderr, _("dark square "));
- sprintf(buf, "%s/dsq%u.xim",
+ snprintf(buf,sizeof(buf), "%s/dsq%u.xim",
ExpandPathName(appData.pixmapDirectory), ss);
if (appData.debugMode)
fprintf(stderr, _("(File:%s:) "), buf);
XSynchronize(xDisplay, False); /* Work-around for xlib/xt buffering bug */
}
+char pieceBitmapNames[] = "pnbrqfeacwmohijgdvlsuk";
+
#if HAVE_LIBXPM
void CreateXPMPieces()
{
for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) {
fprintf(stderr, "%d ", piece+1);
for (kind=0; kind<4; kind++) {
- sprintf(buf, "%s/%c%s%u.xpm",
+ snprintf(buf, sizeof(buf), "%s/%c%s%u.xpm",
ExpandPathName(appData.pixmapDirectory),
- ToLower(PieceToChar((ChessSquare)piece)),
+ pieceBitmapNames[piece],
xpmkind[kind], ss);
if (appData.debugMode) {
fprintf(stderr, _("(File:%s:) "), buf);
/* If the LSQ and DSQ pieces don't exist, we will
draw them with solid squares. */
fprintf(stderr, _("light square "));
- sprintf(buf, "%s/lsq%u.xpm", ExpandPathName(appData.pixmapDirectory), ss);
+ snprintf(buf, sizeof(buf), "%s/lsq%u.xpm", ExpandPathName(appData.pixmapDirectory), ss);
if (access(buf, 0) != 0) {
useImageSqs = 0;
} else {
exit(1);
}
fprintf(stderr, _("dark square "));
- sprintf(buf, "%s/dsq%u.xpm",
+ snprintf(buf, sizeof(buf), "%s/dsq%u.xpm",
ExpandPathName(appData.pixmapDirectory), ss);
if (appData.debugMode) {
fprintf(stderr, _("(File:%s:) "), buf);
for (kind = SOLID; kind <= (appData.monoMode ? OUTLINE : SOLID); kind++) {
for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) {
- sprintf(buf, "%c%u%c.bm", ToLower(PieceToChar((ChessSquare)piece)),
+ sprintf(buf, "%c%u%c.bm", pieceBitmapNames[piece],
ss, kind == SOLID ? 's' : 'o');
ReadBitmap(&pieceBitmap[kind][piece], buf, NULL, ss, ss);
}
for (kind = SOLID; kind <= (appData.monoMode ? OUTLINE : SOLID); kind++) {
for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) {
- sprintf(buf, "%c%u%c.bm", ToLower(PieceToChar((ChessSquare)piece)),
+ sprintf(buf, "%c%u%c.bm", pieceBitmapNames[piece],
ss, kind == SOLID ? 's' : 'o');
ReadBitmap(&pieceBitmap[kind][piece], buf,
bib->bits[kind][piece], ss, ss);
strcat(fullname, name);
errcode = XReadBitmapFile(xDisplay, xBoardWindow, fullname,
&w, &h, pm, &x_hot, &y_hot);
+ fprintf(stderr, "load %s\n", name);
if (errcode != BitmapSuccess) {
switch (errcode) {
case BitmapOpenFailed:
- sprintf(msg, _("Can't open bitmap file %s"), fullname);
+ snprintf(msg, sizeof(msg), _("Can't open bitmap file %s"), fullname);
break;
case BitmapFileInvalid:
- sprintf(msg, _("Invalid bitmap in file %s"), fullname);
+ snprintf(msg, sizeof(msg), _("Invalid bitmap in file %s"), fullname);
break;
case BitmapNoMemory:
- sprintf(msg, _("Ran out of memory reading bitmap file %s"),
+ snprintf(msg, sizeof(msg), _("Ran out of memory reading bitmap file %s"),
fullname);
break;
default:
- sprintf(msg, _("Unknown XReadBitmapFile error %d on file %s"),
+ snprintf(msg, sizeof(msg), _("Unknown XReadBitmapFile error %d on file %s"),
errcode, fullname);
break;
}
&& !appData.icsActive));
count = 0;
while (p && *p++ == dmEnables[i].piece) count++;
- sprintf(label, "%s %d", dmEnables[i].widget, count);
+ snprintf(label, sizeof(label), "%s %d", dmEnables[i].widget, count);
j = 0;
XtSetArg(args[j], XtNlabel, label); j++;
XtSetValues(entry, args, j);
int ret;
if (selected_fen_position) free(selected_fen_position);
- selected_fen_position = (char *)PositionToFEN(currentMove,1);
+ selected_fen_position = (char *)PositionToFEN(currentMove, NULL);
if (!selected_fen_position) return;
ret = XtOwnSelection(menuBarWidget, XA_PRIMARY,
CurrentTime,
char buf[MSG_SIZ];
if (!first.analysisSupport) {
- sprintf(buf, _("%s does not support analysis"), first.tidy);
+ snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
DisplayError(buf, 0);
return;
}
{
if (!first.analysisSupport) {
char buf[MSG_SIZ];
- sprintf(buf, _("%s does not support analysis"), first.tidy);
+ snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
DisplayError(buf, 0);
return;
}
Cardinal *nprms;
{
char buf[MSG_SIZ];
- sprintf(buf, "xterm -e info --directory %s --directory . -f %s &",
+ snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
INFODIR, INFOFILE);
system(buf);
}
name = prms[0];
else
name = "xboard";
- sprintf(buf, "xterm -e man %s &", name);
+ snprintf(buf, sizeof(buf), "xterm -e man %s &", name);
system(buf);
}
#else
char *zippy = "";
#endif
- sprintf(buf, "%s%s\n\n%s\n%s\n%s\n%s\n\n%s%s\n%s",
+ snprintf(buf, sizeof(buf), "%s%s\n\n%s\n%s\n%s\n\n%s%s\n%s",
programVersion, zippy,
"Copyright 1991 Digital Equipment Corporation",
- "Enhancements Copyright 1992-2001 Free Software Foundation",
+ "Enhancements Copyright 1992-2009 Free Software Foundation",
"Enhancements Copyright 2005 Alessandro Scotti",
- "Enhancements Copyright 2007-2008 H.G.Muller",
PRODUCT, " is free software and carries NO WARRANTY;",
"see the file COPYING for more information.");
ErrorPopUp(_("About XBoard"), buf, FALSE);
if (extMessage) {
if (*message) {
- sprintf(buf, "%s %s", message, extMessage);
+ snprintf(buf, sizeof(buf), "%s %s", message, extMessage);
message = buf;
} else {
message = extMessage;
strcpy(icon, text);
strcpy(title, text);
} else if (appData.icsActive) {
- sprintf(icon, "%s", appData.icsHost);
- sprintf(title, "%s: %s", programName, appData.icsHost);
+ snprintf(icon, sizeof(icon), "%s", appData.icsHost);
+ snprintf(title, sizeof(title),"%s: %s", programName, appData.icsHost);
} else if (appData.cmailGameName[0] != NULLCHAR) {
- sprintf(icon, "%s", "CMail");
- sprintf(title, "%s: %s", programName, "CMail");
+ snprintf(icon, sizeof(icon), "%s", "CMail");
+ snprintf(title,sizeof(title), "%s: %s", programName, "CMail");
#ifdef GOTHIC
// [HGM] license: This stuff should really be done in back-end, but WinBoard already had a pop-up for it
} else if (gameInfo.variant == VariantGothic) {
strcpy(title, programName);
} else {
strcpy(icon, first.tidy);
- sprintf(title, "%s: %s", programName, first.tidy);
+ snprintf(title,sizeof(title), "%s: %s", programName, first.tidy);
}
i = 0;
XtSetArg(args[i], XtNiconName, (XtArgVal) icon); i++;
fprintf(stderr, "%s: %s: %s\n",
programName, message, strerror(error));
}
- sprintf(buf, "%s: %s", message, strerror(error));
+ snprintf(buf, sizeof(buf), "%s: %s", message, strerror(error));
message = buf;
}
ErrorPopUp(_("Error"), message, FALSE);
} else {
fprintf(stderr, "%s: %s: %s\n",
programName, message, strerror(error));
- sprintf(buf, "%s: %s", message, strerror(error));
+ snprintf(buf, sizeof(buf), "%s: %s", message, strerror(error));
message = buf;
}
if (appData.popupExitMessage && boardWidget && XtIsRealized(boardWidget)) {
putc(BELLCHAR, stderr);
} else {
char buf[2048];
- sprintf(buf, "%s '%s' &", appData.soundProgram, name);
+ snprintf(buf, sizeof(buf), "%s '%s' &", appData.soundProgram, name);
system(buf);
}
}
char buf[MSG_SIZ];
Arg args[16];
+ Pixel foregroundOrWarningColor = timerForegroundPixel;
+
+ if (timer > 0
+ && appData.lowTimeWarning
+ && (timer / 1000) < appData.icsAlarmTime)
+
+ foregroundOrWarningColor = lowTimeWarningColor;
+
if (appData.clockMode) {
sprintf(buf, "%s: %s", color, TimeString(timer));
XtSetArg(args[0], XtNlabel, buf);
}
if (highlight) {
- XtSetArg(args[1], XtNbackground, timerForegroundPixel);
+
+ XtSetArg(args[1], XtNbackground, foregroundOrWarningColor);
XtSetArg(args[2], XtNforeground, timerBackgroundPixel);
} else {
XtSetArg(args[1], XtNbackground, timerBackgroundPixel);
- XtSetArg(args[2], XtNforeground, timerForegroundPixel);
+ XtSetArg(args[2], XtNforeground, foregroundOrWarningColor);
}
XtSetValues(w, args, 3);
char cmdLine[MSG_SIZ];
if (port[0] == NULLCHAR) {
- sprintf(cmdLine, "%s %s", appData.telnetProgram, host);
+ snprintf(cmdLine, sizeof(cmdLine), "%s %s", appData.telnetProgram, host);
} else {
- sprintf(cmdLine, "%s %s %s", appData.telnetProgram, host, port);
+ snprintf(cmdLine,sizeof(cmdLine), "%s %s %s", appData.telnetProgram, host, port);
}
return StartChildProcess(cmdLine, "", pr);
}