X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=args.h;h=2bc0211236218c84e057345910aacc90c9eecb94;hb=38d1b8471964ebf9d4da576d74a452dc3a12b057;hp=c7b2a83266678531db00a7c31907194c69b57d93;hpb=90f9791afa04690fdd044946c7369ae5c085f9b9;p=xboard.git diff --git a/args.h b/args.h index c7b2a83..2bc0211 100644 --- a/args.h +++ b/args.h @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -60,7 +60,7 @@ typedef enum { ArgString, ArgInt, ArgFloat, ArgBoolean, ArgTrue, ArgFalse, ArgNone, ArgColor, ArgAttribs, ArgFilename, ArgBoardSize, ArgFont, ArgCommSettings, - ArgSettingsFilename, ArgBackupSettingsFile, ArgTwo, + ArgSettingsFilename, ArgBackupSettingsFile, ArgTwo, ArgInstall, ArgMaster, ArgX, ArgY, ArgZ // [HGM] placement: for window-placement options stored relative to main window } ArgType; @@ -102,7 +102,10 @@ typedef struct { IcsTextMenuEntry icsTextMenuEntry[ICS_TEXT_MENU_SIZE]; int junk; +unsigned int saveDate; +unsigned int dateStamp; Boolean singleList; +Boolean autoClose; char *homeDir; char *firstEngineLine; char *secondEngineLine; @@ -149,6 +152,9 @@ ArgDescriptor argDescriptors[] = { { "loadGameFile", ArgFilename, (void *) &appData.loadGameFile, FALSE, INVALID }, { "", ArgNone, NULL, FALSE, INVALID }, /* keyword arguments */ + { "saveDate", ArgInt, (void *) &saveDate, TRUE, 0 }, + { "date", ArgInt, (void *) &dateStamp, FALSE, 0 }, + { "autoClose", ArgTrue, (void *) &autoClose, FALSE, FALSE }, JAWS_ARGS { "whitePieceColor", ArgColor, (void *) 0, TRUE, (ArgIniType) WHITE_PIECE_COLOR }, { "wpc", ArgColor, (void *) 0, FALSE, INVALID }, @@ -468,6 +474,7 @@ ArgDescriptor argDescriptors[] = { { "soundSeek", ArgFilename, (void *) &appData.soundSeek, TRUE, (ArgIniType) "" }, { "soundMove", ArgFilename, (void *) &appData.soundMove, TRUE, (ArgIniType) "" }, { "soundBell", ArgFilename, (void *) &appData.soundBell, TRUE, (ArgIniType) SOUND_BELL }, + { "soundRoar", ArgFilename, (void *) &appData.soundRoar, TRUE, (ArgIniType) "" }, { "soundIcsWin", ArgFilename, (void *) &appData.soundIcsWin, TRUE, (ArgIniType) "" }, { "soundIcsLoss", ArgFilename, (void *) &appData.soundIcsLoss, TRUE, (ArgIniType) "" }, { "soundIcsDraw", ArgFilename, (void *) &appData.soundIcsDraw, TRUE, (ArgIniType) "" }, @@ -506,6 +513,8 @@ ArgDescriptor argDescriptors[] = { { "secondChessProgramNames", ArgString, (void *) &secondChessProgramNames, !XBOARD, (ArgIniType) SCP_NAMES }, { "themeNames", ArgString, (void *) &appData.themeNames, !XBOARD, (ArgIniType) "native -upf false -ub false -ubt false -pid \"\"\n" }, + { "addMasterOption", ArgMaster, NULL, FALSE, INVALID }, + { "installEngine", ArgInstall, (void *) &firstChessProgramNames, FALSE, (ArgIniType) "" }, { "initialMode", ArgString, (void *) &appData.initialMode, FALSE, (ArgIniType) "" }, { "mode", ArgString, (void *) &appData.initialMode, FALSE, INVALID }, { "variant", ArgString, (void *) &appData.variant, FALSE, (ArgIniType) "normal" }, @@ -597,6 +606,7 @@ ArgDescriptor argDescriptors[] = { { "useBorder", ArgBoolean, (void *) &appData.useBorder, TRUE, (ArgIniType) FALSE }, { "ub", ArgBoolean, (void *) &appData.useBorder, FALSE, INVALID }, { "border", ArgFilename, (void *) &appData.border, TRUE, (ArgIniType) "" }, + { "finger", ArgFilename, (void *) &appData.finger, FALSE, (ArgIniType) "" }, // [HGM] tournament options { "tourneyFile", ArgFilename, (void *) &appData.tourneyFile, FALSE, (ArgIniType) "" }, @@ -687,6 +697,9 @@ ArgDescriptor argDescriptors[] = { { "topLevel", ArgBoolean, (void *) &appData.topLevel, XBOARD, (ArgIniType) TOPLEVEL }, { "dialogColor", ArgString, (void *) &appData.dialogColor, XBOARD, (ArgIniType) "" }, { "buttonColor", ArgString, (void *) &appData.buttonColor, XBOARD, (ArgIniType) "" }, + { "firstDrawDepth", ArgInt, (void *) &appData.drawDepth[0], FALSE, (ArgIniType) 0 }, + { "secondDrawDepth", ArgInt, (void *) &appData.drawDepth[1], FALSE, (ArgIniType) 0 }, + { "memoHeaders", ArgBoolean, (void *) &appData.headers, TRUE, (ArgIniType) FALSE }, #if ZIPPY { "zippyTalk", ArgBoolean, (void *) &appData.zippyTalk, FALSE, (ArgIniType) ZIPPY_TALK }, @@ -822,6 +835,30 @@ ExitArgError(char *msg, char *badArg, Boolean quit) exit(2); } +void +AppendToSettingsFile (char *line) +{ + char buf[MSG_SIZ]; + FILE *f; + int c; + if(f = fopen(SETTINGS_FILE, "r")) { + do { + int i = 0; + while((buf[i] = c = fgetc(f)) != '\n' && c != EOF) if(i < MSG_SIZ-1) i++; + buf[i] = NULLCHAR; + if(!strcmp(line, buf)) return; // line occurs + } while(c != EOF); + // line did not occur; add it + fclose(f); + if(f = fopen(SETTINGS_FILE, "a")) { + TimeMark now; + GetTimeMark(&now); + fprintf(f, "-date %10lu\n%s\n", now.sec, line); + fclose(f); + } + } +} + int ValidateInt(char *s) { @@ -873,6 +910,14 @@ ParseSettingsFile(char *name, char **addr) } if (ok) { f = fopen(fullname, "r"); +#ifdef DATADIR + if(f == NULL && *fullname != '/') { // when a relative name did not work + char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, "%s/themes/conf", DATADIR); + MySearchPath(buf, name, fullname); // also look in standard place + f = fopen(fullname, "r"); + } +#endif if (f != NULL) { if (addr != NULL) { ASSIGN(*addr, fullname); @@ -1105,6 +1150,12 @@ ParseArgs(GetFunc get, void *cl) case ArgString: case ArgFilename: + if(argValue[0] == '~' && argValue[1] == '~') { + char buf[4*MSG_SIZ]; // expand ~~ + snprintf(buf, 4*MSG_SIZ, "%s%s", DATADIR, argValue+2); + ASSIGN(*(char **) ad->argLoc, buf); + break; + } ASSIGN(*(char **) ad->argLoc, argValue); break; @@ -1160,6 +1211,20 @@ ParseArgs(GetFunc get, void *cl) ParseCommPortSettings(argValue); break; + case ArgMaster: + AppendToSettingsFile(argValue); + break; + + case ArgInstall: + q = *(char **) ad->argLoc; + if((saveDate == 0 || saveDate - dateStamp < 0) && !strstr(q, argValue) ) { + int l = strlen(q) + strlen(argValue); + *(char **) ad->argLoc = malloc(l+2); + snprintf(*(char **) ad->argLoc, l+2, "%s%s\n", q, argValue); + free(q); + } + break; + case ArgNone: ExitArgError(_("Unrecognized argument %s"), argValue, TRUE); break; @@ -1395,6 +1460,11 @@ InitAppData(char *lpCmdLine) appData.savePositionFile = strdup(buf); } + if(autoClose) { // was called for updating settingsfile only + if(saveSettingsOnExit) SaveSettings(settingsFileName); + exit(0); + } + /* Finish initialization for fonts and sounds */ CreateFonts(); @@ -1425,8 +1495,11 @@ SaveSettings(char* name) ArgDescriptor *ad; char dir[MSG_SIZ], buf[MSG_SIZ]; int mps = appData.movesPerSession; + TimeMark now; + + if (!MainWindowUp() && !autoClose) return; - if (!MainWindowUp()) return; + GetTimeMark(&now); saveDate = now.sec; GetCurrentDirectory(MSG_SIZ, dir); if(MySearchPath(installDir, name, buf)) { @@ -1544,6 +1617,8 @@ SaveSettings(char* name) case ArgNone: case ArgBackupSettingsFile: case ArgSettingsFilename: ; + case ArgMaster: ; + case ArgInstall: ; } } fclose(f);