1 2005-12-09 Carl Worth <cworth@cworth.org>
3 * src/ttt-server.c (main): Put the initial server started message
4 in the log file as well.
6 2005-12-09 Carl Worth <cworth@cworth.org>
9 * src/ttt-args.c: (ttt_args_help), (ttt_args_parse): Add a -u,
10 --user option for controlling the uid under which the server
14 * src/ttt-server.c: (ttt_server_register_client), (main): Recert
15 the dup of stdout which wasn't working. Instead just print client
16 join information on stderr so that it goes into the log. Implement
17 support for the user option by calling setuid to drop root
18 privileges the process might start out with.
20 2005-12-09 Bryan Worth <bryan@theworths.org>
21 * src/ttt-curses-client.c: added error checking to ttt_create_client
22 call. Added ability to escape server commands by prepending with "/".
23 Added ability so override port number with port=xxxx entry in
26 2005-12-08 Carl Worth <cworth@cworth.org>
28 * src/ttt-server.c (main): When detached dup stdout to stderr so
29 that everything appears in the log file.
31 2005-12-08 Carl Worth <cworth@cworth.org>
34 * src/ttt-args.c: (ttt_args_help), (ttt_args_parse): Add
35 -d,--detach and --pid-file=FILE options for running the server as
38 * src/ttt-server.c: (ttt_server_statistics),
39 (ttt_server_verify_username), (_detach_and_write_child_pid_to),
40 (main): Add support for detaching and writing out the child PID to
44 * src/x.c: (xfopen), (xdup2): Two new x-functions.
46 2005-12-08 Carl Worth <cworth@cworth.org>
48 * src/ttt-args.c: (ttt_args_help), (ttt_args_parse):
50 * src/ttt-server.c: (ttt_server_statistics),
51 (ttt_server_verify_username), (_detach_and_write_child_pid_to),
53 * src/x.c: (xfopen), (xdup2):
56 2005-12-08 Bryan Worth <bryan@theworths.org>
57 * src/ttt-curses-client.c: Multiple improvements!
58 Username taken from USER environment variable and stored as
59 preference in ~/.ttt/client.conf (username=xxxxxx). Backspace
60 should now work correctly with all term types. Status messages
61 display in seperate area. "MESSAGE" reply from server is
62 suppressed. Eliminated most global variables.
65 2005-12-08 Carl Worth <cworth@cworth.org>
67 * src/Makefile.am: Fix rule to auto-generate ttt-lex.h.
69 * src/ttt-lex.h: Remove generated file from revision control.
71 * src/ttt-lex.l: Add copyright/license blurb.
74 * src/ttt-client.c: (yy_init_globals), (use_yy_init_globals):
75 Shut off some annoying compiler warnings due to flex bugs (only
78 2005-12-07 Richard D. Worth <richard@theworths.org>
80 * PROTOCOL: Remove unused error NOT_IN_GAME. Add error
83 * TODO: Add error NOT_VALID_MOVE.
86 * src/ttt-error.c: (ttt_error_string): Add section comments. Add
89 2005-12-06 Bryan Worth <bryan@theworths.org>
90 * src/ttt-error.c: fixed missing errors (NO_INVITE, NO_GAME)
92 2005-12-06 Richard D. Worth <richard@theworths.org>
94 * PROTOCOL: Add error NO_INVITE
96 * TODO: Uncheck INVITE, ACCEPT
98 * src/ttt-error.c: (ttt_error_string): Add errors NO_INVITE,
101 * src/ttt-client.c: (_ttt_client_execute_message),
102 (_ttt_client_execute_help), (_ttt_client_execute_version),
103 (_ttt_client_execute_invite), (_ttt_client_execute_accept),
104 (_ttt_client_execute_retract), (_ttt_client_execute_decline):
105 Whitespace changes. Partially implement RETRACT, DECLINE.
107 2005-12-05 Richard D. Worth <richard@theworths.org>
109 * PROTOCOL: Fill some missing possible error occurrences.
111 * TODO: Check off INVITE, ACCEPT, ERROR COMMAND, ERROR NO_USER
114 * src/ttt-server.c: (ttt_server_verify_username):
115 * src/ttt-client.c: (_ttt_client_execute_help),
116 (_ttt_client_execute_invite), (_ttt_client_execute_accept):
117 Implement INVITE, ACCEPT
119 2005-12-05 Richard D. Worth <richard@theworths.org>
121 * src/ttt-curses-client.c: (mvprintstr), (mvwprintstr), (wprint),
122 (main), (finish): Whitespace changes.
124 2005-12-04 Bryan Worth <bryan@theworths.org>
125 * src/ttt-socket.c: (ttt_socket_create_client) fixed socket to be
126 non-blocking. (ttt_socket_read) added return value for number
128 * Makefile.am: added necessary code for new curses-client program.
129 * src/ttt-curses-client: new ncurses based client
131 2005-12-03 Richard D. Worth <richard@theworths.org>
133 * PROTOCOL: Add RETRACT, DECLINE. Add game identifier for all game
136 * TODO: Add RETRACT, DECLINE, notices.
138 2005-12-03 Richard D. Worth <richard@theworths.org>
140 * PROTOCOL: Add underscores to error codes. Add STATISTICS
141 command. Remove statistics from WHO.
143 * TODO: Add STATISTICS. Check off STATISTICS.
145 * src/ttt.h: Define TTT_SERVER_PROTOCOL_VERSION for VERSION.
147 * src/ttt-error.c: (ttt_error_string): Add underscores to error
151 * src/ttt-client.c: (_ttt_client_execute_helo),
152 (_ttt_client_execute_statistics), (_ttt_client_execute_message),
153 (_ttt_client_execute_version), (_ttt_client_execute_quit),
154 (_ttt_client_init), (_ttt_client_fini), (ttt_client_get_username),
155 (ttt_client_set_username): Rename client->name to
156 client->username. Implement STATISTICS. Complete implementation of
160 * src/ttt-server.c: (ttt_server_register_client),
161 (ttt_server_unregister_client), (ttt_server_who),
162 (ttt_server_statistics): Track rename of client->name to
163 client->username. Add server helper for STATISTICS.
165 2005-12-02 Richard D. Worth <richard@theworths.org>
167 * TODO: Check off Global commands, HELP, VERSION.
169 * src/ttt-client.c: (_ttt_client_execute_message),
170 (_ttt_client_execute_help), (_execute_request): Whitespace
171 changes. Implement HELP with usage and short description.
173 * src/ttt-server.c: Update the server welcome message.
175 2005-12-01 Richard D. Worth <richard@theworths.org>
177 * TODO: Check off NOTICE MESSAGE, ERROR NONAMESET.
179 * PROTOCOL: Add NONAMESET error in possible errors where
180 applicable. Add description for MESSAGE.
182 * src/ttt-token.h: Add token typedef. Rename token type enum.
184 * src/ttt-lex.l: Add support for quoted string as single token.
185 * src/ttt-lex.h: Autogenerated.
187 * src/ttt-client.c: (_ttt_client_execute_helo),
188 (_ttt_client_execute_who), (_ttt_client_execute_message),
189 (_ttt_client_execute_help), (_ttt_client_execute_version),
190 (_ttt_client_execute_quit), (_ttt_client_init), (_read_request),
191 (_execute_request): Whitespace changes. Implement VERSION,
192 HELP. Change args_required back to args_min and args_max (see
193 PROTOCOL\HELP). Modify MESSAGE to accept one token arg and quote
194 output. Return NONAMESET error where applicable.
196 2005-11-29 Carl Worth <cworth@cworth.org>
199 * src/ttt-socket.c: (ttt_socket_create_client): New function for
200 creating a client socket.
203 * src/x.c: (xconnect): Add xconnect. Return a couple of useful
204 error status values so that callers can recover on connection
205 refused or host unreachable.
207 * src/ttt.h: Add TTT_STATUS_CONNECTION_REFUSED and
208 TTT_STATUS_NETWORK_UNREACHABLE.
210 2005-11-28 Kevin Worth <kevin@theworths.org>
212 * PROTOCOL: Changed board cell numbering to start with zero
216 * src/test-board.c: (main): Added new file for testing.
218 * src/ttt-board.c: (ttt_board_init), (ttt_board_to_string):
219 * src/ttt-board.h: Implemented board_to_string.
221 2005-11-28 kevin worth <kevin@theworths.org>
224 * src/ttt-board.h: Moved struct def from ttt-board.h into
225 ttt-board.c to make it private
230 2005-11-28 Carl Worth <cworth@cworth.org>
232 * TODO: Add instructions on using the first letter of our names to
233 indicate we are working on something.
235 2005-11-25 Bryan Worth <bryan@theworths.org>
236 * ttt-client.c, ttt-server.c, ttt-error.c changed line breaks to
237 <crlf> (\r\n) for network compatibility
239 2005-11-25 Bryan Worth <bryan@theworths.org>
240 * TODO: checked off NOTICE USER and NOTICE QUIT
241 *src/ttt-client.c: (_ttt_client_execute_helo): implement NOTICE USER
242 *(_ttt_client_execute_quit): implement NOTICE QUIT
244 2005-11-25 Bryan Worth <bryan@theworths.org>
245 * TODO: checked off MESSAGE
247 *src/ttt-client.c: (_ttt_client_execute_message): Implement MESSAGE
248 *(_execute_request): changed arg_required to behave as a minimum
249 instead of an absolute number to allow optional arguments such as
252 2005-11-25 Richard D. Worth <richard@theworths.org>
254 * TODO: checked off WHO, QUIT, ERROR SYNTAX
256 * src/ttt-client.c: (_ttt_client_execute_helo), (_ttt_client_init),
257 (ttt_client_get_num_wins):
259 * src/ttt-server.c: (ttt_server_who): Whitespace changes. Add
260 missing player win count for WHO.
262 2005-11-24 Richard D. Worth <richard@theworths.org>
264 * AUTHORS: Add Richard D. Worth
265 * TODO: Add newline before EOF
267 * src/ttt-client.c: (_ttt_client_execute_who):
269 * src/ttt-server.c: (ttt_server_who): Implement WHO.
271 2005-11-24 Carl Worth <cworth@cworth.org>
273 * PROTOCOL: Document QUIT.
275 * src/ttt-client.c: (_ttt_client_execute_helo),
276 (_ttt_client_execute_quit), (_ttt_client_init), (_ttt_client_fini),
277 (_execute_request), (_handle_requests_thread): Implement QUIT. Add
278 client->registered flag and unregister only if registered. Change
279 from args_min and args_max to args_required.
282 * src/ttt-error.c: (ttt_error_string):
283 * src/ttt-server.c: (ttt_server_register_client): Put underscores
284 in TTT_ERRROR names for better readability.
286 2005-11-24 Carl Worth <cworth@cworth.org>
289 * src/ttt-server.c: (ttt_server_init),
290 (ttt_server_register_client): Remove unique-name generation from
291 the server. The client is going to have to have code to do this
294 * src/ttt-client.c: Change minimum arguments for HELO from 0 to 1.
296 * TODO: Note that HELO and ERROR INVALIDNAME are implemented in
299 2005-11-23 Richard D. Worth <richard@theworths.org>
301 * PROTOCOL: Remove unused servername
303 * src/ttt-client.h: * src/ttt-client.c:
304 (_ttt_client_execute_helo), (_ttt_client_init),
305 (_ttt_client_fini), (_execute_request), (ttt_client_get_name),
306 (ttt_client_set_name): Added command descriptions structure. Match
307 command case-insensitively, dispatch to execute
308 function. Implement HELO command. Register on HELO instead of on
311 * src/ttt-server.h: * src/ttt-server.c: (ttt_server_init),
312 (ttt_server_register_client), (ttt_server_unregister_client),
313 (ttt_server_get_host), (ttt_server_get_port), (main): Added host
314 and port to server. Make client registration name-based rather
317 * src/x.c: (xstrdup): Return NULL on NULL
319 * src/ttt-lex.h: Regenerated
321 2005-11-22 Carl Worth <cworth@cworth.org>
323 * TODO: Add TODO file listing all the stuff from the protocol that
324 needs to be implemented.
331 * src/ttt-token.h: Add support for a flex-based tokenizer which
332 tokenizes newlines and space-separated strings.
334 * src/ttt-client.c: (_ttt_client_init), (_ttt_client_fini),
335 (_append_to_request), (_free_request), (_read_request),
336 (_execute_request): Use new tokenizer to tokenize input into an
337 array of request strings.
339 2005-11-15 Carl Worth <cworth@cworth.org>
343 * src/ttt-error.c: (ttt_error_string): Add error values and error
344 strings from protocol.
346 * src/ttt.h: Add typedefs for ttt_client_t and ttt_server_t so
347 that there's no problem with ttt-client.h and ttt-server.h needing
348 to mutually include each other.
351 * src/ttt-server.c: (ttt_server_register_client),
352 (ttt_server_unregister_client), (_ttt_server_accept), (main): Push
353 the client request handling thread back down into ttt-client.c
354 where it really does belong. The server code no longer ever
355 reaches down inside the ttt_client_t structure. Export
356 ttt_server_register_client and ttt_server_unregister_client. Add
357 documentation for ttt_server_broadcast. Document locking semantics
358 for all functions which acquire the server lock.
361 * src/ttt-client.c: (_ttt_client_create), (_ttt_client_destroy),
362 (_read_into_request_until), (_read_request), (_execute_request),
363 (_handle_requests_thread), (ttt_client_new), (ttt_client_get_id):
364 Pull the ttt_client structure definition back down inside the
365 ttt-client.c file. Don't export ttt_client_create and
366 ttt_client_destroy anymore, but instead just use static
367 _ttt_client_init and _ttt_client_fini. Implement the broadcast by
368 just passing a client pointer around and using client->request
369 rather than passing char *request all over. Document new
370 ttt_client_new and remove ttt_client_read_line. Add locking to
371 ttt_client_send and document it. Add ttt_client_get_id.
373 2005-11-14 Carl Worth <cworth@cworth.org>
375 Server now acts as a very simple chat server.
378 * src/ttt-client.c: (ttt_client_create), (ttt_client_destroy),
379 (_append_to_request), (ttt_client_read_into_request_until),
380 (ttt_client_read_line), (ttt_client_send): Add support to do a
381 buffering read within the client and to reuse the buffer (which
382 grows by doubling) from one request to the next. Add function to
383 send a message to a client.
385 * src/ttt-server.c: (ttt_server_init), (ttt_server_create_client):
386 Add support for a client idea. Resize the server's client list by
388 * src/ttt-server.c: (ttt_server_destroy_client): Add support to
390 * src/ttt-server.c: (_handle_client_requests_thread),
391 (_accept_client): Move handling of client requests up to
392 ttt-server.c from ttt-client.c. Use threads rather than a fork per
395 * src/ttt-server.h: (ttt_server_broadcast): Add function to send a
396 message to all connected clients.
399 * src/ttt-socket.c: (ttt_socket_read),
400 (ttt_socket_write): Add functions to do blocking read or write of
401 the specified number of bytes.
403 * src/ttt-socket.c: (ttt_socket_accept): Remove fork, so that the
404 accept function call can take care of anything like that itself.
407 * src/x.c: (xread), (xwrite): New wrappers for read and write.
409 * src/ttt.h: Add TTT_STATUS_EOF, TRUE, and FALSE.
411 * src/ttt.c: Need to include ttt-args.h explicitly now.
413 2005-11-11 Carl Worth <cworth@cworth.org>
416 * src/ttt-server.c: (ttt_server_init), (ttt_server_add_client),
417 (_accept_client), (main): Add a new ttt_server_t object with a
418 mutex-protected list of clients. Move client handling code down
419 into new ttt-client.c.
422 * src/ttt-client.c: (ttt_client_create), (ttt_client_destroy),
423 (ttt_client_handle_requests): New ttt_client_t object that simply
424 holds a pointer back to the server as well as the client socket
428 * src/ttt-socket.c: (ttt_socket_accept): Add closure argument. Add
429 a call to fork before calling the accept callback.
431 * src/ttt-args.c: Hide unused ttt_args_usage from the compiler to
432 keep it from complaining.
434 * src/ttt.c: (main): Rename the client main program from
435 ttt-client to ttt.c, (since the server code now has its own
439 * src/Makefile.am: Include and link with pthread now that we have
440 pthread-based mutex locking.
442 2005-11-11 Carl Worth <cworth@pippin.local>
444 * src/ttt-server.c: (main): Don't assign to stderr which is
445 apparently an invalid lvalue on Mac OS X.
448 * src/x.c: (xfreopen): Change return type to void.
450 * src/ttt-board.c: (ttt_board_to_string): Add missing return
453 2005-11-11 Carl Worth <cworth@cworth.org>
455 * configure.in: Key off of src/ttt.h instead of src/ttt.c which no
458 2005-11-11 Carl Worth <cworth@cworth.org>
462 * src/x.h: Move include of stdarg.h from x.c to ttt.h.
464 2005-11-11 Carl Worth <cworth@cworth.org>
466 * src/ttt-board.h: Include ttt.h to get standard includes.
468 * src/ttt-socket.c: Replace include of netinet/ip.h with
469 netinet/in.h which seems to be necessary for BSD libc, (eg. Mac OS
472 2005-11-09 Carl Worth <cworth@cworth.org>
476 * src/ttt-server.c: (ttt_dispatch), (main):
478 * src/ttt-socket.c: (_sockaddr_init), (_wait_for_connection),
479 (ttt_socket_create_server), (ttt_socket_accept): Push a lot of
480 code out of ttt-server.c down into a new ttt_socket abstraction
481 layer. The code is much easier to read now. The server also no
482 longer exits when the first client exits, but continues to listen
483 for more connections.
485 2005-11-09 Carl Worth <cworth@cworth.org>
488 * src/ttt-args.c: (ttt_args_help), (ttt_args_parse): Add support
489 for -h,--host, -p,--port, and --log-file command-line arguments.
491 * src/ttt-server.c: (main): Use host, port, and log-file
492 command-line arguments.
494 * src/ttt-client.c: (main): Track change in signature of
498 * src/x.c: (xfdopen), (xfreopen): More wrappers.
500 2005-11-08 Carl Worth <cworth@cworth.org>
503 * src/ttt-server.c: (_sockaddr_init), (_wait_for_connection),
504 (main): Add socket, bind, listen, accept calls to provide a
505 simple, functional, one-shot server demonstration.
508 * src/x.c: (xsocket), (xbind), (xlisten), (xfcntl), (xselect): Add
509 more wrapped system calls.
511 2005-11-07 Carl Worth <cworth@cworth.org>
513 * src/ttt.h: Grab some useful definitions from wdo.h:
514 ASSERT_NOT_REACHEED and TTT_PRINTF_FORMAT. Add several needed
517 * src/Makefile.am: Rip out not-yet existing ttt-command and
520 * src/ttt-args.c: (ttt_args_parse): Track name change from
521 args_help to ttt_args_help.
523 * src/ttt.c: Remove in favor of ttt-server.c and ttt-client.c.
525 * src/x.h: Add prototype for xfwrite.
527 2005-11-05 Richard D. Worth <richard@theworths.org>
529 * src/ttt-board.c: (ttt_board_init): Added for loop counter init.
530 * src/ttt-board.h: Added prototypes.
532 2005-11-05 Richard D. Worth <richard@theworths.org>
534 * src/args.c: Renamed ttt-args.c
535 * src/args.h: Renamed ttt-args.h
536 * src/ttt-args.c: (ttt_args_help), (ttt_args_usage),
537 (ttt_args_parse): Added ttt_ prefix.
538 * src/ttt-args.h: Added ttt_, TTT_ prefix.
540 2005-11-05 Kevin Worth <kevin@cworth.org>
542 * src/ttt-board.c: (ttt_board_init): Implemented board_init.
543 * src/ttt-board.h: (ttt_board_t): Added cells array.
545 2005-11-05 Carl Worth <cworth@cworth.org>
547 * src/Makefile.am: Add ttt-board.[ch] and x.[ch]
550 * src/ttt-board.c: (ttt_board_init), (ttt_board_init_from_string),
551 (ttt_board_to_string), (ttt_board_write): Add some stub functions
552 for Richard and Kevin to have some practice
553 implementing. Functions to represent a board and to go to/from a
557 * src/x.c: (xasprintf), (xvasprintf), (xpipe), (xfork), (xmalloc),
558 (xcalloc), (xrealloc), (xfdopen), (xstrdup), (xfwrite): Several
559 utility functions that make system calls, check the result, and
560 exit on any error. This will simplify the error checking needed in
561 programs using these functions.
563 2005-11-05 Carl Worth <cworth@cworth.org>
565 * src/Makefile.am: Break things up for separate ttt-client and
566 ttt-server and programs.