X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=e5822a482997246cb0b78a72bbdf5114d1452e03;hb=b12ca738583ee21b1533377b3424baba188ba2e0;hp=6542dc7fdbf05bb6feea2b2a8dc74a6939d49201;hpb=c2c8acae352bbda3afdfce9dbb78a5390e8885d8;p=xboard.git diff --git a/xboard.c b/xboard.c index 6542dc7..e5822a4 100644 --- a/xboard.c +++ b/xboard.c @@ -2798,6 +2798,7 @@ Enables icsEnables[] = { { "menuEngine.Engine #2 Settings", False }, { "menuEngine.Load Engine", False }, { "menuEdit.Annotate", False }, + { "menuOptions.Match", False }, { NULL, False } }; @@ -2924,7 +2925,7 @@ Enables machineThinkingEnables[] = { { "menuMode.Machine White", False }, { "menuMode.Machine Black", False }, { "menuMode.Two Machines", False }, - { "menuMode.Machine Match", False }, +// { "menuMode.Machine Match", False }, { "menuEngine.Retract Move", False }, { NULL, False } }; @@ -2943,7 +2944,7 @@ Enables userThinkingEnables[] = { { "menuMode.Machine White", True }, { "menuMode.Machine Black", True }, { "menuMode.Two Machines", True }, - { "menuMode.Machine Match", True }, +// { "menuMode.Machine Match", True }, { "menuEngine.Retract Move", True }, { NULL, False } }; @@ -3986,7 +3987,7 @@ void PieceMenuPopup(w, event, params, num_params) String *params; Cardinal *num_params; { - String whichMenu; int menuNr; + String whichMenu; int menuNr = -2; shiftKey = strcmp(params[0], "menuW"); // used to indicate black if (event->type == ButtonRelease) menuNr = RightClick(Release, event->xbutton.x, event->xbutton.y, &pmFromX, &pmFromY); @@ -5307,6 +5308,8 @@ void ModeHighlight() XtSetValues(XtNameToWidget(menuBarWidget, wname), args, 1); } oldmode = gameMode; + XtSetArg(args[0], XtNleftBitmap, matchMode && matchGame < appData.matchGames ? xMarkPixmap : None); + XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Machine Match"), args, 1); /* Maybe all the enables should be handled here, not just this one */ XtSetSensitive(XtNameToWidget(menuBarWidget, "menuMode.Training"), @@ -5832,8 +5835,6 @@ void MatchProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - if(gameMode != BeginningOfGame) { DisplayError(_("You can only start a match from the initial position."), 0); return; } - appData.matchGames = appData.defaultMatchGames; MatchEvent(2); } @@ -6763,6 +6764,8 @@ void DisplayMessage(message, extMessage) }; }; + safeStrCpy(lastMsg, message, MSG_SIZ); // [HGM] make available + /* need to test if messageWidget already exists, since this function can also be called during the startup, if for example a Xresource is not set up correctly */ @@ -7618,50 +7621,40 @@ int OpenTCP(host, port, pr) #if OMIT_SOCKETS DisplayFatalError(_("Socket support is not configured in"), 0, 2); #else /* !OMIT_SOCKETS */ + struct addrinfo hints; + struct addrinfo *ais, *ai; + int error; int s; - struct sockaddr_in sa; - struct hostent *hp; - unsigned short uport; ChildProc *cp; - if ((s = socket(AF_INET, SOCK_STREAM, 6)) < 0) { - return errno; - } - - memset((char *) &sa, (int)0, sizeof(struct sockaddr_in)); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = INADDR_ANY; - uport = (unsigned short) 0; - sa.sin_port = htons(uport); - if (bind(s, (struct sockaddr *) &sa, sizeof(struct sockaddr_in)) < 0) { - return errno; - } - - memset((char *) &sa, (int)0, sizeof(struct sockaddr_in)); - if (!(hp = gethostbyname(host))) { - int b0, b1, b2, b3; - if (sscanf(host, "%d.%d.%d.%d", &b0, &b1, &b2, &b3) == 4) { - hp = (struct hostent *) calloc(1, sizeof(struct hostent)); - hp->h_addrtype = AF_INET; - hp->h_length = 4; - hp->h_addr_list = (char **) calloc(2, sizeof(char *)); - hp->h_addr_list[0] = (char *) malloc(4); - hp->h_addr_list[0][0] = b0; - hp->h_addr_list[0][1] = b1; - hp->h_addr_list[0][2] = b2; - hp->h_addr_list[0][3] = b3; - } else { - return ENOENT; - } + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + error = getaddrinfo(host, port, &hints, &ais); + if (error != 0) { + /* a getaddrinfo error is not an errno, so can't return it */ + fprintf(debugFP, "getaddrinfo(%s, %s): %s\n", + host, port, gai_strerror(error)); + return ENOENT; + } + + for (ai = ais; ai != NULL; ai = ai->ai_next) { + if ((s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) { + error = errno; + continue; + } + if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0) { + error = errno; + continue; + } + error = 0; + break; } - sa.sin_family = hp->h_addrtype; - uport = (unsigned short) atoi(port); - sa.sin_port = htons(uport); - memcpy((char *) &sa.sin_addr, hp->h_addr, hp->h_length); + freeaddrinfo(ais); - if (connect(s, (struct sockaddr *) &sa, - sizeof(struct sockaddr_in)) < 0) { - return errno; + if (error != 0) { + return error; } cp = (ChildProc *) calloc(1, sizeof(ChildProc)); @@ -7670,7 +7663,6 @@ int OpenTCP(host, port, pr) cp->fdFrom = s; cp->fdTo = s; *pr = (ProcRef) cp; - #endif /* !OMIT_SOCKETS */ return 0;