diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-29 18:27:14 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-29 18:27:14 +0100 |
| commit | a301310bef5706273148fd10d05d7666bc8f5838 (patch) | |
| tree | 2b9f156d402a39501d8b39d4d42d652f4c1bad6a | |
| parent | ab80fa342031a548b549e4581cb946982b433c3a (diff) | |
started with the manual and integrating it in main.c
| -rw-r--r-- | src/main.c | 8 | ||||
| -rw-r--r-- | src/manual.c | 28 | ||||
| -rw-r--r-- | src/manual.h | 6 |
3 files changed, 40 insertions, 2 deletions
@@ -5,6 +5,7 @@ #include <getopt.h> #include "data_store.h" #include "game.h" +#include "manual.h" #define DEFAULT_PORT "12345" @@ -20,7 +21,7 @@ static void print_usage(const char* name) "\t-l\t\t\tstart server\n" "\t-u username\t\tyour nickname in the player list (default: $USER)\n" "\t-p port\t\t\tport to use for connecting/listening (default: %s)\n" - "\t-m\t\t\tdisplay the manual (TODO)\n"; + "\t-m\t\t\tdisplay the manual\n"; fprintf(stderr, usage, name, DEFAULT_PORT); exit(EXIT_FAILURE); @@ -35,7 +36,7 @@ int main(int argc, char *argv[]) bool servermode = false; data_store_t *ds = data_store(); - const char* accepted = "u:s:p:n:hl"; + const char* accepted = "u:s:p:n:hlm"; while((opt = getopt(argc, argv, accepted)) != -1) { switch(opt) @@ -56,6 +57,9 @@ int main(int argc, char *argv[]) case 'l': servermode = true; break; + case 'm': + print_manual(); + break; case 'h': // help default: print_usage(argv[0]); diff --git a/src/manual.c b/src/manual.c new file mode 100644 index 0000000..0dc4ebb --- /dev/null +++ b/src/manual.c @@ -0,0 +1,28 @@ +#include "manual.h" +#include <stdio.h> +#include <stdlib.h> + +static const char* manual_text = +"Oxen is a multiplayer card game for up to 10 players.\n\n" +"Usage (see also 'oxen -h'):\n" +" One player has to host the game and needs to specify '-l' to start\n" +" a server on the specified port ('-p port', default is 12345).\n" +" It will wait for the specified number of clients ('-n num') to connect\n" +" before starting the game. After the server is listening, a local client\n" +" will automatically be started and connected to it.\n" +" When it is running, other players can connect to it by specifying its\n" +" hostname or IP address ('-s address') and port number (if different to\n" +" default).\n" +" Players can set their nickname with '-u name' or by setting the USER\n" +" environment variable.\n" +"\n"; + +/** + * Print manual on stdout + */ +void print_manual(void) +{ + printf("%s", manual_text); + exit(EXIT_SUCCESS); +} + diff --git a/src/manual.h b/src/manual.h new file mode 100644 index 0000000..3e43a41 --- /dev/null +++ b/src/manual.h @@ -0,0 +1,6 @@ +#ifndef OXEN_MANUAL_H +#define OXEN_MANUAL_H + +void print_manual(void); + +#endif // OXEN_MANUAL_H |
