$OpenBSD$
--- xgammon.c.orig	Tue Aug 29 07:28:41 1995
+++ xgammon.c	Mon Feb 14 19:43:12 2011
@@ -149,6 +149,7 @@ void usleep (unsigned long delay) {
 #define usleep(a) sleep((a/10))
 #endif
 
+#define LINESIZ 512
 
 
 XtAppContext	app_con;
@@ -179,7 +180,7 @@ MOVE		*compi_choice;
 
 FILE*		protokol_file = NULL;
 
-char * greetings = "Wellcome to xgammon  version 0.98\n   (C) 1994   Lambert Klasen   Detlef Steuer\n    We hope you enjoy it\n\n";
+char * greetings = "Welcome to xgammon  version 0.98\n   (C) 1994   Lambert Klasen   Detlef Steuer\n    We hope you enjoy it\n\n";
 
 XtActionsRec gammon_actions[] = {
 	{"PipCount",		PipCount},
@@ -227,8 +228,8 @@ static XtResource gammon_resources[] = {
 {"rollout",         "Rollout",         XtRBoolean, sizeof (int),     offset (rollout),           XtRString, "0"},
 {"numrollouts",     "NumRollouts",     XtRInt,     sizeof (int),     offset (num_rollouts),      XtRString, "100"},
 {"positionfile",    "PositionFile",    XtRString,  sizeof (char *),  offset (position_file),     XtRString, "xgammon.save"},
-{"database",        "Database",        XtRString,  sizeof (char *),  offset (database),          XtRString, "lib/xgammon.db"},
-{"server",          "Server",          XtRString,  sizeof (char *),  offset (server),            XtRString, "fraggel65.mdstud.chalmers.se"},
+{"database",        "Database",        XtRString,  sizeof (char *),  offset (database),          XtRString, DATABASE},
+{"server",          "Server",          XtRString,  sizeof (char *),  offset (server),            XtRString, "fibs.com"},
 {"port",            "Port",            XtRInt,     sizeof (int),     offset (port),              XtRString, "4321"},
 {"buttonmove",      "ButtonMove",      XtRBoolean, sizeof (int),     offset (button_move),       XtRString, "0"}
 
@@ -459,7 +460,7 @@ void XGammonGameLoop (void)
 void HumanLoop (int with_double) 
 {
 	if (Pin[BAR].count && complete_blockade ()) {
-		sprintf (add_text, "%s can't move.\n\n", Player[turn-1].name);
+		snprintf (add_text, LINESIZ, "%s can't move.\n\n", Player[turn-1].name);
 		AppendDialogText (LOWER, add_text);
 		return;
 	}
@@ -620,12 +621,12 @@ static int HandleCompiDoubling (void)
 		return DoublePopup ();
 	else {					/* opponent is computer */
 		if (! do_double (ANSWER)) {	/* resigned */
-			sprintf (add_text, "%s gives up. %s wins %d point\n\n", Player[other-1].name, Player[turn-1].name, doubler.value);
+			snprintf (add_text, LINESIZ, "%s gives up. %s wins %d point\n\n", Player[other-1].name, Player[turn-1].name, doubler.value);
 			ret = RESIGN;
 		} else {			/* accepted */
 			doubler.value *= 2;
 			DrawDoubler (doubler.value, doubler.owner);
-			sprintf (add_text,"%s accepts the double.\n\n", Player[other-1].name);
+			snprintf (add_text, LINESIZ, "%s accepts the double.\n\n", Player[other-1].name);
 			ret = ACCEPT;
 		}
 		AppendDialogText (LOWER, add_text);
@@ -830,16 +831,16 @@ static void PlayerInit (void)
 			Player[1].type = COMPUTER;
 			Player[0].MoveFunction = HumanLoop;
 			Player[1].MoveFunction = CompiLoop;
-			strcpy (Player[0].name, UserName());
-			strcpy (Player[1].name, "xgammon");
+			strlcpy (Player[0].name, UserName(), 25);
+			strlcpy (Player[1].name, "xgammon", 25);
 		}
 		else if (!strcmp (gammon_resource.human_stone, "white")) {
 			Player[0].type = COMPUTER;
 			Player[1].type = HUMAN;
 			Player[0].MoveFunction = CompiLoop;
 			Player[1].MoveFunction = HumanLoop;
-			strcpy (Player[0].name, "xgammon");
-			strcpy (Player[1].name, UserName());
+			strlcpy (Player[0].name, "xgammon", 25);
+			strlcpy (Player[1].name, UserName(), 25);
 		}
 	}
 	else if (!strcmp (gammon_resource.gamekind, "cvc")) {
@@ -847,8 +848,8 @@ static void PlayerInit (void)
 		Player[1].type = COMPUTER;
 		Player[0].MoveFunction = CompiLoop;
 		Player[1].MoveFunction = CompiLoop;
-		strcpy (Player[0].name, "black");
-		strcpy (Player[1].name, "white");
+		strlcpy (Player[0].name, "black", 25);
+		strlcpy (Player[1].name, "white", 25);
 		initialize = COMPUTER_TOURNAMENT;
 	}
 	else if (!strcmp (gammon_resource.gamekind, "hvh")) {
@@ -856,8 +857,8 @@ static void PlayerInit (void)
 		Player[1].type = HUMAN;
 		Player[0].MoveFunction = HumanLoop;
 		Player[1].MoveFunction = HumanLoop;
-		strcpy (Player[0].name, UserName());
-		strcpy (Player[1].name, "other");
+		strlcpy (Player[0].name, UserName(), 25);
+		strlcpy (Player[1].name, "other", 25);
 	}
 
 	Player[0].color = BLACK;
@@ -878,14 +879,14 @@ static void TournamentInit ()
 	if      (gammon_resource.moneygame) {
 		s = "money-game";
 		tournament.winning_point = 0;
-		sprintf (add_text, "%s and %s start a %s match.\n", Player[0].name, Player[1].name, s);
+		snprintf (add_text, LINESIZ, "%s and %s start a %s match.\n", Player[0].name, Player[1].name, s);
 	}
 
 	if (gammon_resource.winat)  {
 		s = "points";
 		tournament.winning_point = gammon_resource.winat;
 		gammon_resource.moneygame = 0;
-		sprintf (add_text, "%s and %s start a %d %s match.\n", Player[0].name, Player[1].name, tournament.winning_point, s);
+		snprintf (add_text, LINESIZ, "%s and %s start a %d %s match.\n", Player[0].name, Player[1].name, tournament.winning_point, s);
 	}
 
 	AppendDialogText (UPPER, add_text);
@@ -944,31 +945,31 @@ static void checkcmdline (int argc, char *argv[])
 	for (option=1; option<argc; option++) {
 		if (strcmp (argv[option], "-?") == 0 ||
 		    strcmp (argv[option], "-help") == 0) {
-puts ("xgammon [-otherdisplay (display)]
-        [-boardgeometry (string)]
-        [-boardcolor (color)] [-bc (color)]
-        [-darkcolor  (color)] [-dc (color)]
-        [-lightcolor (color)] [-lc (color)]
-        [-barcolor   (color)] [-b  (color)]
-        [-whitecolor (color)]        the stone color for \"white\"
-        [-blackcolor (color)]        the stone color for \"black\"
-        [-doublerfont (font)]        sets the (big) font for the doubler dice
-        [-doubling   +doubling]      sets if you wish the computer to double
-        [-h (black|white)]           set the color for the human player
-                                     (implies a human versus computer game)
-        [-gamekind -g (hvc|cvc|hvh)] sets the gamekind to either
-                                     human vs. human computer vs. computer
-                                     or human vs. computer (default)
-        [-winat      (points)]       play a tournament up to \"points\" points
-        [-watchmove  +wachmove]      if you wish to see the flying stones
-        [-buttonmove +buttonmove]    set stones by simply pressing button
-        [-autoplay   +autoplay]      automatic play when only one move
-                                     is possible
-        [-stonesteps (number)]       sets the stepsize the stones fly
-                                     in pixel (implies +watchmove)
-        [-delaytime (tsec.)]         sets the time the cumputer waits
-                                     after each turn (implies -watchmove)
-        [-?] [-help]                 print this string");
+puts ("xgammon [-otherdisplay (display)]"
+        "\t[-boardgeometry (string)]\n"
+        "\t[-boardcolor (color)] [-bc (color)]\n"
+        "\t[-darkcolor  (color)] [-dc (color)]\n"
+        "\t[-lightcolor (color)] [-lc (color)]\n"
+        "\t[-barcolor   (color)] [-b  (color)]\n"
+        "\t[-whitecolor (color)]        the stone color for \"white\"\n"
+        "\t[-blackcolor (color)]        the stone color for \"black\"\n"
+        "\t[-doublerfont (font)]        sets the (big) font for the doubler dice\n"
+        "\t[-doubling   +doubling]      sets if you wish the computer to double\n"
+        "\t[-h (black|white)]           set the color for the human player\n"
+          "\t                           (implies a human versus computer game)\n"
+        "\t[-gamekind -g (hvc|cvc|hvh)] sets the gamekind to either\n"
+            "\t                         human vs. human computer vs. computer\n"
+              "\t                       or human vs. computer (default)\n"
+        "\t[-winat      (points)]       play a tournament up to \"points\" points\n"
+        "\t[-watchmove  +wachmove]      if you wish to see the flying stones\n"
+        "\t[-buttonmove +buttonmove]    set stones by simply pressing button\n"
+        "\t[-autoplay   +autoplay]      automatic play when only one move\n"
+          "\t                           is possible\n"
+        "\t[-stonesteps (number)]       sets the stepsize the stones fly\n"
+          "\t                           in pixel (implies +watchmove)\n"
+        "\t[-delaytime (tsec.)]         sets the time the computer waits\n"
+          "\t                           after each turn (implies -watchmove)\n"
+        "\t[-?] [-help]                 print this string");
 		exit (0);
 		} else {
 			fprintf (stderr,"xgammon: unknown option %s (ignored)\n", argv[option]);
@@ -1075,7 +1076,7 @@ void MenuSelect (Widget w, XtPointer junk, XtPointer g
 	char   name[64];
 	char   *v[] = {"p", NULL};
 
-	strcpy (name, XtName (w));
+	strlcpy (name, XtName (w), 64);
 
 	if      (strncmp (name, "save position", 13) == 0) save (w, 0L, v, 0);
 	else if (strncmp (name, "load position", 13) == 0) load (w, 0L, v, 0);
@@ -1373,7 +1374,7 @@ static void PipCount (Widget w, XEvent *e, String *vec
 
 	simple_pipcount (&pip_count);
 
-	sprintf (add_text, " picount:\n black: %d, white: %d ", abs ((int) pip_count[BLACK]), abs ((int) pip_count[WHITE]));
+	snprintf (add_text, LINESIZ, " picount:\n black: %d, white: %d ", abs ((int) pip_count[BLACK]), abs ((int) pip_count[WHITE]));
 	Info (add_text);
 
 	pip_count_request = 1;
@@ -1419,7 +1420,7 @@ void restart (void)
 
 void Resign (int how)
 {
-	sprintf (add_text, "%s wants to resign\n", Player[turn-1].name);
+	snprintf (add_text, LINESIZ, "%s wants to resign\n", Player[turn-1].name);
 	AppendDialogText (LOWER, add_text);
 
 	Info ("accept");
