+2005-11-05 Richard D. Worth <richard@theworths.org>
+
+ * src/args.c: Renamed ttt-args.c
+ * src/args.h: Renamed ttt-args.h
+ * src/ttt-args.c: (ttt_args_help), (ttt_args_usage),
+ (ttt_args_parse): Added ttt_ prefix.
+ * src/ttt-args.h: Added ttt_, TTT_ prefix.
+
+2005-11-05 Kevin Worth <kevin@cworth.org>
+
+ * src/ttt-board.c: (ttt_board_init): Implemented board_init.
+ * src/ttt-board.h: (ttt_board_t): Added cells array.
+
2005-11-05 Carl Worth <cworth@cworth.org>
* src/Makefile.am: Add ttt-board.[ch] and x.[ch]
+++ /dev/null
-/* args.c - Parse command-line arguments for ttt using getopt
- *
- * Copyright © 2005 Carl Worth
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Author: Carl Worth <cworth@cworth.org>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libgen.h>
-#include <getopt.h>
-
-#include "args.h"
-
-static const char ARGS_PROGRAM_VERSION[] = VERSION;
-static const char ARGS_PROGRAM_DESCRIPTION[] = "client-server tic-tac-toe game";
-static const char ARGS_PROGRAM_BUG_ADDRESS[] = "<cworth@cworth.org>";
-
-/* XXX: SAMPLE: */
-static char ARGS_PROGRAM_ARGDOC[] = "<file>";
-
-/* XXX: getopt is rather annoying in that you must maintain a
- * string-encoding of the options in addition to the table. For
- * example, to enable the sample display option below, one would have
- * to add "d:" to the optstring.
- *
- * A useful exercise would be to write a function to generate the
- * optstring from the table.
- *
- * The other annoying thing is that the table does not include help
- * strings, so the args_help function below must also be maintained
- * manually.
- */
-static char args_optstring[] = "hV";
-static struct option args_options[] = {
- /* name, has_arg, flag, val */
- /* XXX: SAMPLE:
- {"display", 1, 0, 'd'},
- */
- {"help", 0, 0, 'h'},
- {"version", 0, 0, 'V'},
- { 0 }
-};
-
-static void
-args_help (const char *argv0)
-{
- printf ("Usage: %s [OPTION] %s\n", argv0, ARGS_PROGRAM_ARGDOC);
- printf ("%s - %s\n", argv0, ARGS_PROGRAM_DESCRIPTION);
- puts ("");
- printf (" -h, --help\t\tGive this help list\n");
- printf (" -V, --version\t\tPrint program version\n");
- /* XXX: SAMPLE:
- printf (" -d, --display=DISPLAY\tX server to connect to");
- */
-}
-
-static void
-args_usage (const char *argv0)
-{
- printf ("Usage: %s [OPTION] %s\n", argv0, ARGS_PROGRAM_ARGDOC);
- printf ("Try `%s --help' for more information.\n", argv0);
-}
-
-int
-args_parse(args_t *args, int argc, char *argv[], int *args_first)
-{
- char *argv0_copy = strdup (argv[0]);
- char *argv0 = basename (argv0_copy);
-
- int c;
-
- /* XXX: SAMPLE:
- args->display = NULL;
- */
-
- while (1) {
- c = getopt_long (argc, argv, args_optstring, args_options, NULL);
- if (c == -1)
- break;
-
- switch (c) {
- /* XXX: SAMPLE:
- case 'd':
- args->display = optarg;
- break;
- */
- case 'V':
- printf ("%s\n", VERSION);
- exit (0);
- break;
-
- case 'h':
- args_help (argv0);
- exit (0);
- break;
-
- case '?':
- args_help (argv0);
- exit (1);
- break;
-
- default:
- fprintf (stderr, "Unhandled option `%c'\n", c);
- break;
- }
- }
-
- /* XXX: SAMPLE:
- if (argc - optind == 1) {
- args->file = argv[optind];
- } else {
- args_usage (argv0);
- }
- */
-
- if (args_first)
- *args_first = optind;
-
- free (argv0_copy);
-
- return 0;
-}
+++ /dev/null
-/* args.h - Parse command-line arguments for ttt using getopt
- *
- * Copyright © 2005 Carl Worth
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Author: Carl Worth <cworth@cworth.org>
- */
-
-#ifndef ARGS_H
-#define ARGS_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-typedef struct args
-{
- /* XXX: SAMPLE:
- char *display;
- */
- char *file;
-
-} args_t;
-
-int
-args_parse(args_t *args, int argc, char *argv[], int *args_first);
-
-#endif
--- /dev/null
+/* ttt-args.c - Parse command-line arguments for ttt using getopt
+ *
+ * Copyright © 2005 Carl Worth
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Carl Worth <cworth@cworth.org>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <libgen.h>
+#include <getopt.h>
+
+#include "ttt-args.h"
+
+static const char TTT_ARGS_PROGRAM_VERSION[] = VERSION;
+static const char TTT_ARGS_PROGRAM_DESCRIPTION[] = "client-server tic-tac-toe game";
+static const char TTT_ARGS_PROGRAM_BUG_ADDRESS[] = "<cworth@cworth.org>";
+
+/* XXX: SAMPLE: */
+static char TTT_ARGS_PROGRAM_ARGDOC[] = "<file>";
+
+/* XXX: getopt is rather annoying in that you must maintain a
+ * string-encoding of the options in addition to the table. For
+ * example, to enable the sample display option below, one would have
+ * to add "d:" to the optstring.
+ *
+ * A useful exercise would be to write a function to generate the
+ * optstring from the table.
+ *
+ * The other annoying thing is that the table does not include help
+ * strings, so the args_help function below must also be maintained
+ * manually.
+ */
+static char ttt_args_optstring[] = "hV";
+static struct option ttt_args_options[] = {
+ /* name, has_arg, flag, val */
+ /* XXX: SAMPLE:
+ {"display", 1, 0, 'd'},
+ */
+ {"help", 0, 0, 'h'},
+ {"version", 0, 0, 'V'},
+ { 0 }
+};
+
+static void
+ttt_args_help (const char *argv0)
+{
+ printf ("Usage: %s [OPTION] %s\n", argv0, TTT_ARGS_PROGRAM_ARGDOC);
+ printf ("%s - %s\n", argv0, TTT_ARGS_PROGRAM_DESCRIPTION);
+ puts ("");
+ printf (" -h, --help\t\tGive this help list\n");
+ printf (" -V, --version\t\tPrint program version\n");
+ /* XXX: SAMPLE:
+ printf (" -d, --display=DISPLAY\tX server to connect to");
+ */
+}
+
+static void
+ttt_args_usage (const char *argv0)
+{
+ printf ("Usage: %s [OPTION] %s\n", argv0, TTT_ARGS_PROGRAM_ARGDOC);
+ printf ("Try `%s --help' for more information.\n", argv0);
+}
+
+int
+ttt_args_parse(ttt_args_t *args, int argc, char *argv[], int *args_first)
+{
+ char *argv0_copy = strdup (argv[0]);
+ char *argv0 = basename (argv0_copy);
+
+ int c;
+
+ /* XXX: SAMPLE:
+ args->display = NULL;
+ */
+
+ while (1) {
+ c = getopt_long (argc, argv, ttt_args_optstring, ttt_args_options, NULL);
+ if (c == -1)
+ break;
+
+ switch (c) {
+ /* XXX: SAMPLE:
+ case 'd':
+ args->display = optarg;
+ break;
+ */
+ case 'V':
+ printf ("%s\n", VERSION);
+ exit (0);
+ break;
+
+ case 'h':
+ args_help (argv0);
+ exit (0);
+ break;
+
+ case '?':
+ args_help (argv0);
+ exit (1);
+ break;
+
+ default:
+ fprintf (stderr, "Unhandled option `%c'\n", c);
+ break;
+ }
+ }
+
+ /* XXX: SAMPLE:
+ if (argc - optind == 1) {
+ args->file = argv[optind];
+ } else {
+ args_usage (argv0);
+ }
+ */
+
+ if (args_first)
+ *args_first = optind;
+
+ free (argv0_copy);
+
+ return 0;
+}
--- /dev/null
+/* ttt-args.h - Parse command-line arguments for ttt using getopt
+ *
+ * Copyright © 2005 Carl Worth
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Carl Worth <cworth@cworth.org>
+ */
+
+#ifndef TTT_ARGS_H
+#define TTT_ARGS_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+typedef struct ttt_args
+{
+ /* XXX: SAMPLE:
+ char *display;
+ */
+ char *file;
+
+} ttt_args_t;
+
+int
+ttt_args_parse(ttt_args_t *args, int argc, char *argv[], int *args_first);
+
+#endif