From 3cf8438856230a7c4ff89816534854427f035b4a Mon Sep 17 00:00:00 2001 From: jacob janzen <53062115+JacobJanzen@users.noreply.github.com> Date: Wed, 14 Feb 2024 20:46:05 -0600 Subject: license under GPL (#6) --- src/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 758fc92..4ec71fa 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,21 @@ +/* +This file is part of urlg. +urlg 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 3 of the License, or (at your option) any later version. urlg 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 Foobar. If not, see +. +*/ #include +#include #include #include #include +#include "../config.h" #include "cavegen.h" #include "common.h" #include "display.h" @@ -86,8 +99,38 @@ bool game_update( return false; } -int main(void) +void print_version(void) { + printf("%s\n", PACKAGE_STRING); + printf("Copyright (C) 2024 Jacob Janzen\n"); + printf("This is free software; see the source for copying conditions.\n"); + printf( + "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n" + ); + printf("PARTICULAR PURPOSE.\n"); +} + +int main(int argc, char **argv) +{ + int option_index = 0; + int ch; + int version_flag = 0; + struct option longopts[] = { + {"version", no_argument, &version_flag, 'v'}, + }; + while ((ch = getopt_long(argc, argv, ":v", longopts, &option_index)) != -1 + ) { + switch (ch) { + case 'v' : version_flag = 1; break; + case 0 : break; + default : break; + } + } + if (version_flag) { + print_version(); + return EXIT_SUCCESS; + } + unsigned int seed = time(NULL); srand(seed); @@ -132,7 +175,6 @@ int main(void) display_status(disp, &player); display_message(disp, ""); - int ch; bool done = false; while (!done) { enum action action = display_process_input(); -- cgit v1.2.3