From: Carl Worth Date: Tue, 8 Nov 2005 00:44:57 +0000 (+0000) Subject: 2005-11-07 Carl Worth X-Git-Url: https://git.cworth.org/git?p=ttt;a=commitdiff_plain;h=80c3009d01077a141a0803267a1f0aff217ed61c;hp=ad9f96f734bb560c25ceca4facc85a84f4c3993f 2005-11-07 Carl Worth * src/ttt.h: Grab some useful definitions from wdo.h: ASSERT_NOT_REACHEED and TTT_PRINTF_FORMAT. Add several needed include directives. * src/Makefile.am: Rip out not-yet existing ttt-command and ttt-error. * src/ttt-args.c: (ttt_args_parse): Track name change from args_help to ttt_args_help. * src/ttt.c: Remove in favor of ttt-server.c and ttt-client.c. * src/x.h: Add prototype for xfwrite. --- diff --git a/ChangeLog b/ChangeLog index e7d6dd6..08b40e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-11-07 Carl Worth + + * src/ttt.h: Grab some useful definitions from wdo.h: + ASSERT_NOT_REACHEED and TTT_PRINTF_FORMAT. Add several needed + include directives. + + * src/Makefile.am: Rip out not-yet existing ttt-command and + ttt-error. + + * src/ttt-args.c: (ttt_args_parse): Track name change from + args_help to ttt_args_help. + + * src/ttt.c: Remove in favor of ttt-server.c and ttt-client.c. + + * src/x.h: Add prototype for xfwrite. + 2005-11-05 Richard D. Worth * src/ttt-board.c: (ttt_board_init): Added for loop counter init. diff --git a/src/Makefile.am b/src/Makefile.am index 2e7ae73..4c3bd16 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,10 +5,6 @@ ttt_common_sources = \ ttt-args.h \ ttt-board.c \ ttt-board.h \ - ttt-command.c \ - ttt-command.h \ - ttt-error.c \ - ttt-error.h \ x.c \ x.h diff --git a/src/ttt-args.c b/src/ttt-args.c index 302e301..2e47205 100644 --- a/src/ttt-args.c +++ b/src/ttt-args.c @@ -106,12 +106,12 @@ ttt_args_parse(ttt_args_t *args, int argc, char *argv[], int *args_first) break; case 'h': - args_help (argv0); + ttt_args_help (argv0); exit (0); break; case '?': - args_help (argv0); + ttt_args_help (argv0); exit (1); break; @@ -125,7 +125,7 @@ ttt_args_parse(ttt_args_t *args, int argc, char *argv[], int *args_first) if (argc - optind == 1) { args->file = argv[optind]; } else { - args_usage (argv0); + ttt_args_usage (argv0); } */ diff --git a/src/ttt-client.c b/src/ttt-client.c new file mode 100644 index 0000000..b42db7a --- /dev/null +++ b/src/ttt-client.c @@ -0,0 +1,35 @@ +/* ttt.c - client-server tic-tac-toe game + * + * 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 + */ + +#include "ttt.h" + +int +main (int argc, char **argv) +{ + ttt_args_t args; + int args_first; + + ttt_args_parse (&args, argc, argv, &args_first); + + /* XXX: insert code here */ + + return 0; +} diff --git a/src/ttt-server.c b/src/ttt-server.c new file mode 100644 index 0000000..b42db7a --- /dev/null +++ b/src/ttt-server.c @@ -0,0 +1,35 @@ +/* ttt.c - client-server tic-tac-toe game + * + * 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 + */ + +#include "ttt.h" + +int +main (int argc, char **argv) +{ + ttt_args_t args; + int args_first; + + ttt_args_parse (&args, argc, argv, &args_first); + + /* XXX: insert code here */ + + return 0; +} diff --git a/src/ttt.c b/src/ttt.c deleted file mode 100644 index b5ec1d5..0000000 --- a/src/ttt.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ttt.c - client-server tic-tac-toe game - * - * 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 - */ - -#include "ttt.h" - -int -main (int argc, char **argv) -{ - args_t args; - int args_first; - - args_parse (&args, argc, argv, &args_first); - - /* XXX: insert code here */ - - return 0; -} diff --git a/src/ttt.h b/src/ttt.h index 910c688..0f2f7e5 100644 --- a/src/ttt.h +++ b/src/ttt.h @@ -26,6 +26,31 @@ #include "config.h" #endif -#include "args.h" +/* We use _GNU_SOURCE to get things like asprintf. */ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +#define ASSERT_NOT_REACHED \ +do { \ + static const int NOT_REACHED = 0; \ + assert (NOT_REACHED); \ + exit (1); \ +} while (0) + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define TTT_PRINTF_FORMAT(fmt_index, va_index) \ + __attribute__((__format__(__printf__, fmt_index, va_index))) +#else +#define TTT_PRINTF_FORMAT(fmt_index, va_index) +#endif + +#include "ttt-args.h" +#include "x.h" #endif diff --git a/src/x.h b/src/x.h index 52c3acd..45bf6a9 100644 --- a/src/x.h +++ b/src/x.h @@ -23,7 +23,7 @@ #define _X_H_ void -xasprintf (char **strp, const char *fmt, ...) WDO_PRINTF_FORMAT(2, 3); +xasprintf (char **strp, const char *fmt, ...) TTT_PRINTF_FORMAT(2, 3); void xvasprintf (char **strp, const char *fmt, va_list ap); @@ -49,4 +49,7 @@ xfdopen (int filedes, const char *mode); char * xstrdup (const char *s); +void +xfwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream); + #endif /* _X_H_ */