diff options
| author | Aiden Woodruff <aiden.woodruff@gmail.com> | 2018-08-14 14:47:54 -0500 |
|---|---|---|
| committer | Aiden Woodruff <aiden.woodruff@gmail.com> | 2018-08-14 14:47:54 -0500 |
| commit | 367fe4bbf4791add4f2238e3ca9dbfc82b8b22ce (patch) | |
| tree | 21ee0e82f48f8d1ab2d0b26e000139b6ab0ab935 /src | |
| parent | b801521b8f662bca827bbbd08561e0a647a06fd2 (diff) | |
| download | life-367fe4bbf4791add4f2238e3ca9dbfc82b8b22ce.tar.gz life-367fe4bbf4791add4f2238e3ca9dbfc82b8b22ce.tar.bz2 life-367fe4bbf4791add4f2238e3ca9dbfc82b8b22ce.zip | |
Folder setup changed
Moved things into docs or src folders
Created tests folder so make check is better
Check control characters in life.c with CTRL macro (bitwise AND 037)
Create small window for fancy rule entry
Change some division by two to bitshifts
Use configure to make man page (keep version up to date)
Move warnings and pedantic to AM_CFLAGS
Move include option to AM_CPPFLAGS
Version 1.6.0
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rw-r--r-- | src/Makefile.in | 680 | ||||
| -rw-r--r-- | src/cmdline-life.c | 684 | ||||
| -rw-r--r-- | src/cmdline-life.h | 211 | ||||
| -rw-r--r-- | src/life-macros.h | 10 | ||||
| -rw-r--r-- | src/life.c | 265 | ||||
| -rw-r--r-- | src/life.ggo | 10 | ||||
| -rw-r--r-- | src/life.h | 35 | ||||
| -rw-r--r-- | src/menus.c | 176 | ||||
| -rw-r--r-- | src/menus.h | 36 | ||||
| -rw-r--r-- | src/updatemap.c | 74 | ||||
| -rw-r--r-- | src/updatemap.h | 30 |
12 files changed, 2215 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..e308a9f --- /dev/null +++ b/src/Makefile.am | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | bin_PROGRAMS = life | ||
| 2 | life_SOURCES = life.c cmdline-life.c updatemap.c menus.c | ||
| 3 | life_CFLAGS = -Wall -pedantic | ||
| 4 | include_HEADERS = life.h updatemap.h menus.h cmdline-life.h life-macros.h | ||
diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..bd9200c --- /dev/null +++ b/src/Makefile.in | |||
| @@ -0,0 +1,680 @@ | |||
| 1 | # Makefile.in generated by automake 1.15 from Makefile.am. | ||
| 2 | # @configure_input@ | ||
| 3 | |||
| 4 | # Copyright (C) 1994-2014 Free Software Foundation, Inc. | ||
| 5 | |||
| 6 | # This Makefile.in is free software; the Free Software Foundation | ||
| 7 | # gives unlimited permission to copy and/or distribute it, | ||
| 8 | # with or without modifications, as long as this notice is preserved. | ||
| 9 | |||
| 10 | # This program is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without | ||
| 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
| 13 | # PARTICULAR PURPOSE. | ||
| 14 | |||
| 15 | @SET_MAKE@ | ||
| 16 | |||
| 17 | |||
| 18 | VPATH = @srcdir@ | ||
| 19 | am__is_gnu_make = { \ | ||
| 20 | if test -z '$(MAKELEVEL)'; then \ | ||
| 21 | false; \ | ||
| 22 | elif test -n '$(MAKE_HOST)'; then \ | ||
| 23 | true; \ | ||
| 24 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ | ||
| 25 | true; \ | ||
| 26 | else \ | ||
| 27 | false; \ | ||
| 28 | fi; \ | ||
| 29 | } | ||
| 30 | am__make_running_with_option = \ | ||
| 31 | case $${target_option-} in \ | ||
| 32 | ?) ;; \ | ||
| 33 | *) echo "am__make_running_with_option: internal error: invalid" \ | ||
| 34 | "target option '$${target_option-}' specified" >&2; \ | ||
| 35 | exit 1;; \ | ||
| 36 | esac; \ | ||
| 37 | has_opt=no; \ | ||
| 38 | sane_makeflags=$$MAKEFLAGS; \ | ||
| 39 | if $(am__is_gnu_make); then \ | ||
| 40 | sane_makeflags=$$MFLAGS; \ | ||
| 41 | else \ | ||
| 42 | case $$MAKEFLAGS in \ | ||
| 43 | *\\[\ \ ]*) \ | ||
| 44 | bs=\\; \ | ||
| 45 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | ||
| 46 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ | ||
| 47 | esac; \ | ||
| 48 | fi; \ | ||
| 49 | skip_next=no; \ | ||
| 50 | strip_trailopt () \ | ||
| 51 | { \ | ||
| 52 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ | ||
| 53 | }; \ | ||
| 54 | for flg in $$sane_makeflags; do \ | ||
| 55 | test $$skip_next = yes && { skip_next=no; continue; }; \ | ||
| 56 | case $$flg in \ | ||
| 57 | *=*|--*) continue;; \ | ||
| 58 | -*I) strip_trailopt 'I'; skip_next=yes;; \ | ||
| 59 | -*I?*) strip_trailopt 'I';; \ | ||
| 60 | -*O) strip_trailopt 'O'; skip_next=yes;; \ | ||
| 61 | -*O?*) strip_trailopt 'O';; \ | ||
| 62 | -*l) strip_trailopt 'l'; skip_next=yes;; \ | ||
| 63 | -*l?*) strip_trailopt 'l';; \ | ||
| 64 | -[dEDm]) skip_next=yes;; \ | ||
| 65 | -[JT]) skip_next=yes;; \ | ||
| 66 | esac; \ | ||
| 67 | case $$flg in \ | ||
| 68 | *$$target_option*) has_opt=yes; break;; \ | ||
| 69 | esac; \ | ||
| 70 | done; \ | ||
| 71 | test $$has_opt = yes | ||
| 72 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) | ||
| 73 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) | ||
| 74 | pkgdatadir = $(datadir)/@PACKAGE@ | ||
| 75 | pkgincludedir = $(includedir)/@PACKAGE@ | ||
| 76 | pkglibdir = $(libdir)/@PACKAGE@ | ||
| 77 | pkglibexecdir = $(libexecdir)/@PACKAGE@ | ||
| 78 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd | ||
| 79 | install_sh_DATA = $(install_sh) -c -m 644 | ||
| 80 | install_sh_PROGRAM = $(install_sh) -c | ||
| 81 | install_sh_SCRIPT = $(install_sh) -c | ||
| 82 | INSTALL_HEADER = $(INSTALL_DATA) | ||
| 83 | transform = $(program_transform_name) | ||
| 84 | NORMAL_INSTALL = : | ||
| 85 | PRE_INSTALL = : | ||
| 86 | POST_INSTALL = : | ||
| 87 | NORMAL_UNINSTALL = : | ||
| 88 | PRE_UNINSTALL = : | ||
| 89 | POST_UNINSTALL = : | ||
| 90 | bin_PROGRAMS = life$(EXEEXT) | ||
| 91 | subdir = src | ||
| 92 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 | ||
| 93 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac | ||
| 94 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ | ||
| 95 | $(ACLOCAL_M4) | ||
| 96 | DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \ | ||
| 97 | $(am__DIST_COMMON) | ||
| 98 | mkinstalldirs = $(install_sh) -d | ||
| 99 | CONFIG_HEADER = $(top_builddir)/config.h | ||
| 100 | CONFIG_CLEAN_FILES = | ||
| 101 | CONFIG_CLEAN_VPATH_FILES = | ||
| 102 | am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)" | ||
| 103 | PROGRAMS = $(bin_PROGRAMS) | ||
| 104 | am_life_OBJECTS = life-life.$(OBJEXT) life-cmdline-life.$(OBJEXT) \ | ||
| 105 | life-updatemap.$(OBJEXT) life-menus.$(OBJEXT) | ||
| 106 | life_OBJECTS = $(am_life_OBJECTS) | ||
| 107 | life_LDADD = $(LDADD) | ||
| 108 | life_LINK = $(CCLD) $(life_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ | ||
| 109 | -o $@ | ||
| 110 | AM_V_P = $(am__v_P_@AM_V@) | ||
| 111 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) | ||
| 112 | am__v_P_0 = false | ||
| 113 | am__v_P_1 = : | ||
| 114 | AM_V_GEN = $(am__v_GEN_@AM_V@) | ||
| 115 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) | ||
| 116 | am__v_GEN_0 = @echo " GEN " $@; | ||
| 117 | am__v_GEN_1 = | ||
| 118 | AM_V_at = $(am__v_at_@AM_V@) | ||
| 119 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) | ||
| 120 | am__v_at_0 = @ | ||
| 121 | am__v_at_1 = | ||
| 122 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) | ||
| 123 | depcomp = $(SHELL) $(top_srcdir)/depcomp | ||
| 124 | am__depfiles_maybe = depfiles | ||
| 125 | am__mv = mv -f | ||
| 126 | AM_V_lt = $(am__v_lt_@AM_V@) | ||
| 127 | am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) | ||
| 128 | am__v_lt_0 = --silent | ||
| 129 | am__v_lt_1 = | ||
| 130 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ | ||
| 131 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) | ||
| 132 | AM_V_CC = $(am__v_CC_@AM_V@) | ||
| 133 | am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) | ||
| 134 | am__v_CC_0 = @echo " CC " $@; | ||
| 135 | am__v_CC_1 = | ||
| 136 | CCLD = $(CC) | ||
| 137 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ | ||
| 138 | AM_V_CCLD = $(am__v_CCLD_@AM_V@) | ||
| 139 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) | ||
| 140 | am__v_CCLD_0 = @echo " CCLD " $@; | ||
| 141 | am__v_CCLD_1 = | ||
| 142 | SOURCES = $(life_SOURCES) | ||
| 143 | DIST_SOURCES = $(life_SOURCES) | ||
| 144 | am__can_run_installinfo = \ | ||
| 145 | case $$AM_UPDATE_INFO_DIR in \ | ||
| 146 | n|no|NO) false;; \ | ||
| 147 | *) (install-info --version) >/dev/null 2>&1;; \ | ||
| 148 | esac | ||
| 149 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; | ||
| 150 | am__vpath_adj = case $$p in \ | ||
| 151 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ | ||
| 152 | *) f=$$p;; \ | ||
| 153 | esac; | ||
| 154 | am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; | ||
| 155 | am__install_max = 40 | ||
| 156 | am__nobase_strip_setup = \ | ||
| 157 | srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` | ||
| 158 | am__nobase_strip = \ | ||
| 159 | for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" | ||
| 160 | am__nobase_list = $(am__nobase_strip_setup); \ | ||
| 161 | for p in $$list; do echo "$$p $$p"; done | \ | ||
| 162 | sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ | ||
| 163 | $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ | ||
| 164 | if (++n[$$2] == $(am__install_max)) \ | ||
| 165 | { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ | ||
| 166 | END { for (dir in files) print dir, files[dir] }' | ||
| 167 | am__base_list = \ | ||
| 168 | sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ | ||
| 169 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | ||
| 170 | am__uninstall_files_from_dir = { \ | ||
| 171 | test -z "$$files" \ | ||
| 172 | || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ | ||
| 173 | || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ | ||
| 174 | $(am__cd) "$$dir" && rm -f $$files; }; \ | ||
| 175 | } | ||
| 176 | HEADERS = $(include_HEADERS) | ||
| 177 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) | ||
| 178 | # Read a list of newline-separated strings from the standard input, | ||
| 179 | # and print each of them once, without duplicates. Input order is | ||
| 180 | # *not* preserved. | ||
| 181 | am__uniquify_input = $(AWK) '\ | ||
| 182 | BEGIN { nonempty = 0; } \ | ||
| 183 | { items[$$0] = 1; nonempty = 1; } \ | ||
| 184 | END { if (nonempty) { for (i in items) print i; }; } \ | ||
| 185 | ' | ||
| 186 | # Make sure the list of sources is unique. This is necessary because, | ||
| 187 | # e.g., the same source file might be shared among _SOURCES variables | ||
| 188 | # for different programs/libraries. | ||
| 189 | am__define_uniq_tagged_files = \ | ||
| 190 | list='$(am__tagged_files)'; \ | ||
| 191 | unique=`for i in $$list; do \ | ||
| 192 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
| 193 | done | $(am__uniquify_input)` | ||
| 194 | ETAGS = etags | ||
| 195 | CTAGS = ctags | ||
| 196 | am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp | ||
| 197 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | ||
| 198 | ACLOCAL = @ACLOCAL@ | ||
| 199 | AMTAR = @AMTAR@ | ||
| 200 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ | ||
| 201 | AUTOCONF = @AUTOCONF@ | ||
| 202 | AUTOHEADER = @AUTOHEADER@ | ||
| 203 | AUTOMAKE = @AUTOMAKE@ | ||
| 204 | AWK = @AWK@ | ||
| 205 | CC = @CC@ | ||
| 206 | CCDEPMODE = @CCDEPMODE@ | ||
| 207 | CFLAGS = @CFLAGS@ | ||
| 208 | CPP = @CPP@ | ||
| 209 | CPPFLAGS = @CPPFLAGS@ | ||
| 210 | CYGPATH_W = @CYGPATH_W@ | ||
| 211 | DEFS = @DEFS@ | ||
| 212 | DEPDIR = @DEPDIR@ | ||
| 213 | ECHO_C = @ECHO_C@ | ||
| 214 | ECHO_N = @ECHO_N@ | ||
| 215 | ECHO_T = @ECHO_T@ | ||
| 216 | EGREP = @EGREP@ | ||
| 217 | EXEEXT = @EXEEXT@ | ||
| 218 | GREP = @GREP@ | ||
| 219 | INSTALL = @INSTALL@ | ||
| 220 | INSTALL_DATA = @INSTALL_DATA@ | ||
| 221 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ | ||
| 222 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ | ||
| 223 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | ||
| 224 | LDFLAGS = @LDFLAGS@ | ||
| 225 | LIBOBJS = @LIBOBJS@ | ||
| 226 | LIBS = @LIBS@ | ||
| 227 | LTLIBOBJS = @LTLIBOBJS@ | ||
| 228 | MAKEINFO = @MAKEINFO@ | ||
| 229 | MKDIR_P = @MKDIR_P@ | ||
| 230 | OBJEXT = @OBJEXT@ | ||
| 231 | PACKAGE = @PACKAGE@ | ||
| 232 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ | ||
| 233 | PACKAGE_NAME = @PACKAGE_NAME@ | ||
| 234 | PACKAGE_STRING = @PACKAGE_STRING@ | ||
| 235 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ | ||
| 236 | PACKAGE_URL = @PACKAGE_URL@ | ||
| 237 | PACKAGE_VERSION = @PACKAGE_VERSION@ | ||
| 238 | PATH_SEPARATOR = @PATH_SEPARATOR@ | ||
| 239 | SET_MAKE = @SET_MAKE@ | ||
| 240 | SHELL = @SHELL@ | ||
| 241 | STRIP = @STRIP@ | ||
| 242 | VERSION = @VERSION@ | ||
| 243 | abs_builddir = @abs_builddir@ | ||
| 244 | abs_srcdir = @abs_srcdir@ | ||
| 245 | abs_top_builddir = @abs_top_builddir@ | ||
| 246 | abs_top_srcdir = @abs_top_srcdir@ | ||
| 247 | ac_ct_CC = @ac_ct_CC@ | ||
| 248 | am__include = @am__include@ | ||
| 249 | am__leading_dot = @am__leading_dot@ | ||
| 250 | am__quote = @am__quote@ | ||
| 251 | am__tar = @am__tar@ | ||
| 252 | am__untar = @am__untar@ | ||
| 253 | bindir = @bindir@ | ||
| 254 | build_alias = @build_alias@ | ||
| 255 | builddir = @builddir@ | ||
| 256 | datadir = @datadir@ | ||
| 257 | datarootdir = @datarootdir@ | ||
| 258 | docdir = @docdir@ | ||
| 259 | dvidir = @dvidir@ | ||
| 260 | exec_prefix = @exec_prefix@ | ||
| 261 | host_alias = @host_alias@ | ||
| 262 | htmldir = @htmldir@ | ||
| 263 | includedir = @includedir@ | ||
| 264 | infodir = @infodir@ | ||
| 265 | install_sh = @install_sh@ | ||
| 266 | libdir = @libdir@ | ||
| 267 | libexecdir = @libexecdir@ | ||
| 268 | localedir = @localedir@ | ||
| 269 | localstatedir = @localstatedir@ | ||
| 270 | mandir = @mandir@ | ||
| 271 | mkdir_p = @mkdir_p@ | ||
| 272 | oldincludedir = @oldincludedir@ | ||
| 273 | pdfdir = @pdfdir@ | ||
| 274 | prefix = @prefix@ | ||
| 275 | program_transform_name = @program_transform_name@ | ||
| 276 | psdir = @psdir@ | ||
| 277 | runstatedir = @runstatedir@ | ||
| 278 | sbindir = @sbindir@ | ||
| 279 | sharedstatedir = @sharedstatedir@ | ||
| 280 | srcdir = @srcdir@ | ||
| 281 | sysconfdir = @sysconfdir@ | ||
| 282 | target_alias = @target_alias@ | ||
| 283 | top_build_prefix = @top_build_prefix@ | ||
| 284 | top_builddir = @top_builddir@ | ||
| 285 | top_srcdir = @top_srcdir@ | ||
| 286 | life_SOURCES = life.c cmdline-life.c updatemap.c menus.c | ||
| 287 | life_CFLAGS = -Wall -pedantic | ||
| 288 | include_HEADERS = life.h updatemap.h menus.h cmdline-life.h life-macros.h | ||
| 289 | all: all-am | ||
| 290 | |||
| 291 | .SUFFIXES: | ||
| 292 | .SUFFIXES: .c .o .obj | ||
| 293 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) | ||
| 294 | @for dep in $?; do \ | ||
| 295 | case '$(am__configure_deps)' in \ | ||
| 296 | *$$dep*) \ | ||
| 297 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ | ||
| 298 | && { if test -f $@; then exit 0; else break; fi; }; \ | ||
| 299 | exit 1;; \ | ||
| 300 | esac; \ | ||
| 301 | done; \ | ||
| 302 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ | ||
| 303 | $(am__cd) $(top_srcdir) && \ | ||
| 304 | $(AUTOMAKE) --gnu src/Makefile | ||
| 305 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status | ||
| 306 | @case '$?' in \ | ||
| 307 | *config.status*) \ | ||
| 308 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ | ||
| 309 | *) \ | ||
| 310 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ | ||
| 311 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ | ||
| 312 | esac; | ||
| 313 | |||
| 314 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) | ||
| 315 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
| 316 | |||
| 317 | $(top_srcdir)/configure: $(am__configure_deps) | ||
| 318 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
| 319 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) | ||
| 320 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
| 321 | $(am__aclocal_m4_deps): | ||
| 322 | install-binPROGRAMS: $(bin_PROGRAMS) | ||
| 323 | @$(NORMAL_INSTALL) | ||
| 324 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ | ||
| 325 | if test -n "$$list"; then \ | ||
| 326 | echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ | ||
| 327 | $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ | ||
| 328 | fi; \ | ||
| 329 | for p in $$list; do echo "$$p $$p"; done | \ | ||
| 330 | sed 's/$(EXEEXT)$$//' | \ | ||
| 331 | while read p p1; do if test -f $$p \ | ||
| 332 | ; then echo "$$p"; echo "$$p"; else :; fi; \ | ||
| 333 | done | \ | ||
| 334 | sed -e 'p;s,.*/,,;n;h' \ | ||
| 335 | -e 's|.*|.|' \ | ||
| 336 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ | ||
| 337 | sed 'N;N;N;s,\n, ,g' | \ | ||
| 338 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ | ||
| 339 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ | ||
| 340 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ | ||
| 341 | else { print "f", $$3 "/" $$4, $$1; } } \ | ||
| 342 | END { for (d in files) print "f", d, files[d] }' | \ | ||
| 343 | while read type dir files; do \ | ||
| 344 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ | ||
| 345 | test -z "$$files" || { \ | ||
| 346 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ | ||
| 347 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ | ||
| 348 | } \ | ||
| 349 | ; done | ||
| 350 | |||
| 351 | uninstall-binPROGRAMS: | ||
| 352 | @$(NORMAL_UNINSTALL) | ||
| 353 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ | ||
| 354 | files=`for p in $$list; do echo "$$p"; done | \ | ||
| 355 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ | ||
| 356 | -e 's/$$/$(EXEEXT)/' \ | ||
| 357 | `; \ | ||
| 358 | test -n "$$list" || exit 0; \ | ||
| 359 | echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ | ||
| 360 | cd "$(DESTDIR)$(bindir)" && rm -f $$files | ||
| 361 | |||
| 362 | clean-binPROGRAMS: | ||
| 363 | -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) | ||
| 364 | |||
| 365 | life$(EXEEXT): $(life_OBJECTS) $(life_DEPENDENCIES) $(EXTRA_life_DEPENDENCIES) | ||
| 366 | @rm -f life$(EXEEXT) | ||
| 367 | $(AM_V_CCLD)$(life_LINK) $(life_OBJECTS) $(life_LDADD) $(LIBS) | ||
| 368 | |||
| 369 | mostlyclean-compile: | ||
| 370 | -rm -f *.$(OBJEXT) | ||
| 371 | |||
| 372 | distclean-compile: | ||
| 373 | -rm -f *.tab.c | ||
| 374 | |||
| 375 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/life-cmdline-life.Po@am__quote@ | ||
| 376 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/life-life.Po@am__quote@ | ||
| 377 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/life-menus.Po@am__quote@ | ||
| 378 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/life-updatemap.Po@am__quote@ | ||
| 379 | |||
| 380 | .c.o: | ||
| 381 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||
| 382 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | ||
| 383 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ | ||
| 384 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 385 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< | ||
| 386 | |||
| 387 | .c.obj: | ||
| 388 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` | ||
| 389 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | ||
| 390 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ | ||
| 391 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 392 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` | ||
| 393 | |||
| 394 | life-life.o: life.c | ||
| 395 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -MT life-life.o -MD -MP -MF $(DEPDIR)/life-life.Tpo -c -o life-life.o `test -f 'life.c' || echo '$(srcdir)/'`life.c | ||
| 396 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/life-life.Tpo $(DEPDIR)/life-life.Po | ||
| 397 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='life.c' object='life-life.o' libtool=no @AMDEPBACKSLASH@ | ||
| 398 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 399 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -c -o life-life.o `test -f 'life.c' || echo '$(srcdir)/'`life.c | ||
| 400 | |||
| 401 | life-life.obj: life.c | ||
| 402 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -MT life-life.obj -MD -MP -MF $(DEPDIR)/life-life.Tpo -c -o life-life.obj `if test -f 'life.c'; then $(CYGPATH_W) 'life.c'; else $(CYGPATH_W) '$(srcdir)/life.c'; fi` | ||
| 403 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/life-life.Tpo $(DEPDIR)/life-life.Po | ||
| 404 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='life.c' object='life-life.obj' libtool=no @AMDEPBACKSLASH@ | ||
| 405 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 406 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -c -o life-life.obj `if test -f 'life.c'; then $(CYGPATH_W) 'life.c'; else $(CYGPATH_W) '$(srcdir)/life.c'; fi` | ||
| 407 | |||
| 408 | life-cmdline-life.o: cmdline-life.c | ||
| 409 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -MT life-cmdline-life.o -MD -MP -MF $(DEPDIR)/life-cmdline-life.Tpo -c -o life-cmdline-life.o `test -f 'cmdline-life.c' || echo '$(srcdir)/'`cmdline-life.c | ||
| 410 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/life-cmdline-life.Tpo $(DEPDIR)/life-cmdline-life.Po | ||
| 411 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cmdline-life.c' object='life-cmdline-life.o' libtool=no @AMDEPBACKSLASH@ | ||
| 412 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 413 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -c -o life-cmdline-life.o `test -f 'cmdline-life.c' || echo '$(srcdir)/'`cmdline-life.c | ||
| 414 | |||
| 415 | life-cmdline-life.obj: cmdline-life.c | ||
| 416 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -MT life-cmdline-life.obj -MD -MP -MF $(DEPDIR)/life-cmdline-life.Tpo -c -o life-cmdline-life.obj `if test -f 'cmdline-life.c'; then $(CYGPATH_W) 'cmdline-life.c'; else $(CYGPATH_W) '$(srcdir)/cmdline-life.c'; fi` | ||
| 417 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/life-cmdline-life.Tpo $(DEPDIR)/life-cmdline-life.Po | ||
| 418 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cmdline-life.c' object='life-cmdline-life.obj' libtool=no @AMDEPBACKSLASH@ | ||
| 419 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 420 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -c -o life-cmdline-life.obj `if test -f 'cmdline-life.c'; then $(CYGPATH_W) 'cmdline-life.c'; else $(CYGPATH_W) '$(srcdir)/cmdline-life.c'; fi` | ||
| 421 | |||
| 422 | life-updatemap.o: updatemap.c | ||
| 423 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -MT life-updatemap.o -MD -MP -MF $(DEPDIR)/life-updatemap.Tpo -c -o life-updatemap.o `test -f 'updatemap.c' || echo '$(srcdir)/'`updatemap.c | ||
| 424 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/life-updatemap.Tpo $(DEPDIR)/life-updatemap.Po | ||
| 425 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='updatemap.c' object='life-updatemap.o' libtool=no @AMDEPBACKSLASH@ | ||
| 426 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 427 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -c -o life-updatemap.o `test -f 'updatemap.c' || echo '$(srcdir)/'`updatemap.c | ||
| 428 | |||
| 429 | life-updatemap.obj: updatemap.c | ||
| 430 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -MT life-updatemap.obj -MD -MP -MF $(DEPDIR)/life-updatemap.Tpo -c -o life-updatemap.obj `if test -f 'updatemap.c'; then $(CYGPATH_W) 'updatemap.c'; else $(CYGPATH_W) '$(srcdir)/updatemap.c'; fi` | ||
| 431 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/life-updatemap.Tpo $(DEPDIR)/life-updatemap.Po | ||
| 432 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='updatemap.c' object='life-updatemap.obj' libtool=no @AMDEPBACKSLASH@ | ||
| 433 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 434 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -c -o life-updatemap.obj `if test -f 'updatemap.c'; then $(CYGPATH_W) 'updatemap.c'; else $(CYGPATH_W) '$(srcdir)/updatemap.c'; fi` | ||
| 435 | |||
| 436 | life-menus.o: menus.c | ||
| 437 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -MT life-menus.o -MD -MP -MF $(DEPDIR)/life-menus.Tpo -c -o life-menus.o `test -f 'menus.c' || echo '$(srcdir)/'`menus.c | ||
| 438 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/life-menus.Tpo $(DEPDIR)/life-menus.Po | ||
| 439 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='menus.c' object='life-menus.o' libtool=no @AMDEPBACKSLASH@ | ||
| 440 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 441 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -c -o life-menus.o `test -f 'menus.c' || echo '$(srcdir)/'`menus.c | ||
| 442 | |||
| 443 | life-menus.obj: menus.c | ||
| 444 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -MT life-menus.obj -MD -MP -MF $(DEPDIR)/life-menus.Tpo -c -o life-menus.obj `if test -f 'menus.c'; then $(CYGPATH_W) 'menus.c'; else $(CYGPATH_W) '$(srcdir)/menus.c'; fi` | ||
| 445 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/life-menus.Tpo $(DEPDIR)/life-menus.Po | ||
| 446 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='menus.c' object='life-menus.obj' libtool=no @AMDEPBACKSLASH@ | ||
| 447 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
| 448 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(life_CFLAGS) $(CFLAGS) -c -o life-menus.obj `if test -f 'menus.c'; then $(CYGPATH_W) 'menus.c'; else $(CYGPATH_W) '$(srcdir)/menus.c'; fi` | ||
| 449 | install-includeHEADERS: $(include_HEADERS) | ||
| 450 | @$(NORMAL_INSTALL) | ||
| 451 | @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ | ||
| 452 | if test -n "$$list"; then \ | ||
| 453 | echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ | ||
| 454 | $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ | ||
| 455 | fi; \ | ||
| 456 | for p in $$list; do \ | ||
| 457 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ | ||
| 458 | echo "$$d$$p"; \ | ||
| 459 | done | $(am__base_list) | \ | ||
| 460 | while read files; do \ | ||
| 461 | echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ | ||
| 462 | $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ | ||
| 463 | done | ||
| 464 | |||
| 465 | uninstall-includeHEADERS: | ||
| 466 | @$(NORMAL_UNINSTALL) | ||
| 467 | @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ | ||
| 468 | files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ | ||
| 469 | dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) | ||
| 470 | |||
| 471 | ID: $(am__tagged_files) | ||
| 472 | $(am__define_uniq_tagged_files); mkid -fID $$unique | ||
| 473 | tags: tags-am | ||
| 474 | TAGS: tags | ||
| 475 | |||
| 476 | tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) | ||
| 477 | set x; \ | ||
| 478 | here=`pwd`; \ | ||
| 479 | $(am__define_uniq_tagged_files); \ | ||
| 480 | shift; \ | ||
| 481 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ | ||
| 482 | test -n "$$unique" || unique=$$empty_fix; \ | ||
| 483 | if test $$# -gt 0; then \ | ||
| 484 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ | ||
| 485 | "$$@" $$unique; \ | ||
| 486 | else \ | ||
| 487 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ | ||
| 488 | $$unique; \ | ||
| 489 | fi; \ | ||
| 490 | fi | ||
| 491 | ctags: ctags-am | ||
| 492 | |||
| 493 | CTAGS: ctags | ||
| 494 | ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) | ||
| 495 | $(am__define_uniq_tagged_files); \ | ||
| 496 | test -z "$(CTAGS_ARGS)$$unique" \ | ||
| 497 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ | ||
| 498 | $$unique | ||
| 499 | |||
| 500 | GTAGS: | ||
| 501 | here=`$(am__cd) $(top_builddir) && pwd` \ | ||
| 502 | && $(am__cd) $(top_srcdir) \ | ||
| 503 | && gtags -i $(GTAGS_ARGS) "$$here" | ||
| 504 | cscopelist: cscopelist-am | ||
| 505 | |||
| 506 | cscopelist-am: $(am__tagged_files) | ||
| 507 | list='$(am__tagged_files)'; \ | ||
| 508 | case "$(srcdir)" in \ | ||
| 509 | [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ | ||
| 510 | *) sdir=$(subdir)/$(srcdir) ;; \ | ||
| 511 | esac; \ | ||
| 512 | for i in $$list; do \ | ||
| 513 | if test -f "$$i"; then \ | ||
| 514 | echo "$(subdir)/$$i"; \ | ||
| 515 | else \ | ||
| 516 | echo "$$sdir/$$i"; \ | ||
| 517 | fi; \ | ||
| 518 | done >> $(top_builddir)/cscope.files | ||
| 519 | |||
| 520 | distclean-tags: | ||
| 521 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags | ||
| 522 | |||
| 523 | distdir: $(DISTFILES) | ||
| 524 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ | ||
| 525 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ | ||
| 526 | list='$(DISTFILES)'; \ | ||
| 527 | dist_files=`for file in $$list; do echo $$file; done | \ | ||
| 528 | sed -e "s|^$$srcdirstrip/||;t" \ | ||
| 529 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ | ||
| 530 | case $$dist_files in \ | ||
| 531 | */*) $(MKDIR_P) `echo "$$dist_files" | \ | ||
| 532 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ | ||
| 533 | sort -u` ;; \ | ||
| 534 | esac; \ | ||
| 535 | for file in $$dist_files; do \ | ||
| 536 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ | ||
| 537 | if test -d $$d/$$file; then \ | ||
| 538 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ | ||
| 539 | if test -d "$(distdir)/$$file"; then \ | ||
| 540 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ | ||
| 541 | fi; \ | ||
| 542 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ | ||
| 543 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ | ||
| 544 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ | ||
| 545 | fi; \ | ||
| 546 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ | ||
| 547 | else \ | ||
| 548 | test -f "$(distdir)/$$file" \ | ||
| 549 | || cp -p $$d/$$file "$(distdir)/$$file" \ | ||
| 550 | || exit 1; \ | ||
| 551 | fi; \ | ||
| 552 | done | ||
| 553 | check-am: all-am | ||
| 554 | check: check-am | ||
| 555 | all-am: Makefile $(PROGRAMS) $(HEADERS) | ||
| 556 | installdirs: | ||
| 557 | for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \ | ||
| 558 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ | ||
| 559 | done | ||
| 560 | install: install-am | ||
| 561 | install-exec: install-exec-am | ||
| 562 | install-data: install-data-am | ||
| 563 | uninstall: uninstall-am | ||
| 564 | |||
| 565 | install-am: all-am | ||
| 566 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am | ||
| 567 | |||
| 568 | installcheck: installcheck-am | ||
| 569 | install-strip: | ||
| 570 | if test -z '$(STRIP)'; then \ | ||
| 571 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ | ||
| 572 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ | ||
| 573 | install; \ | ||
| 574 | else \ | ||
| 575 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ | ||
| 576 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ | ||
| 577 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ | ||
| 578 | fi | ||
| 579 | mostlyclean-generic: | ||
| 580 | |||
| 581 | clean-generic: | ||
| 582 | |||
| 583 | distclean-generic: | ||
| 584 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) | ||
| 585 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) | ||
| 586 | |||
| 587 | maintainer-clean-generic: | ||
| 588 | @echo "This command is intended for maintainers to use" | ||
| 589 | @echo "it deletes files that may require special tools to rebuild." | ||
| 590 | clean: clean-am | ||
| 591 | |||
| 592 | clean-am: clean-binPROGRAMS clean-generic mostlyclean-am | ||
| 593 | |||
| 594 | distclean: distclean-am | ||
| 595 | -rm -rf ./$(DEPDIR) | ||
| 596 | -rm -f Makefile | ||
| 597 | distclean-am: clean-am distclean-compile distclean-generic \ | ||
| 598 | distclean-tags | ||
| 599 | |||
| 600 | dvi: dvi-am | ||
| 601 | |||
| 602 | dvi-am: | ||
| 603 | |||
| 604 | html: html-am | ||
| 605 | |||
| 606 | html-am: | ||
| 607 | |||
| 608 | info: info-am | ||
| 609 | |||
| 610 | info-am: | ||
| 611 | |||
| 612 | install-data-am: install-includeHEADERS | ||
| 613 | |||
| 614 | install-dvi: install-dvi-am | ||
| 615 | |||
| 616 | install-dvi-am: | ||
| 617 | |||
| 618 | install-exec-am: install-binPROGRAMS | ||
| 619 | |||
| 620 | install-html: install-html-am | ||
| 621 | |||
| 622 | install-html-am: | ||
| 623 | |||
| 624 | install-info: install-info-am | ||
| 625 | |||
| 626 | install-info-am: | ||
| 627 | |||
| 628 | install-man: | ||
| 629 | |||
| 630 | install-pdf: install-pdf-am | ||
| 631 | |||
| 632 | install-pdf-am: | ||
| 633 | |||
| 634 | install-ps: install-ps-am | ||
| 635 | |||
| 636 | install-ps-am: | ||
| 637 | |||
| 638 | installcheck-am: | ||
| 639 | |||
| 640 | maintainer-clean: maintainer-clean-am | ||
| 641 | -rm -rf ./$(DEPDIR) | ||
| 642 | -rm -f Makefile | ||
| 643 | maintainer-clean-am: distclean-am maintainer-clean-generic | ||
| 644 | |||
| 645 | mostlyclean: mostlyclean-am | ||
| 646 | |||
| 647 | mostlyclean-am: mostlyclean-compile mostlyclean-generic | ||
| 648 | |||
| 649 | pdf: pdf-am | ||
| 650 | |||
| 651 | pdf-am: | ||
| 652 | |||
| 653 | ps: ps-am | ||
| 654 | |||
| 655 | ps-am: | ||
| 656 | |||
| 657 | uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS | ||
| 658 | |||
| 659 | .MAKE: install-am install-strip | ||
| 660 | |||
| 661 | .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ | ||
| 662 | clean-binPROGRAMS clean-generic cscopelist-am ctags ctags-am \ | ||
| 663 | distclean distclean-compile distclean-generic distclean-tags \ | ||
| 664 | distdir dvi dvi-am html html-am info info-am install \ | ||
| 665 | install-am install-binPROGRAMS install-data install-data-am \ | ||
| 666 | install-dvi install-dvi-am install-exec install-exec-am \ | ||
| 667 | install-html install-html-am install-includeHEADERS \ | ||
| 668 | install-info install-info-am install-man install-pdf \ | ||
| 669 | install-pdf-am install-ps install-ps-am install-strip \ | ||
| 670 | installcheck installcheck-am installdirs maintainer-clean \ | ||
| 671 | maintainer-clean-generic mostlyclean mostlyclean-compile \ | ||
| 672 | mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ | ||
| 673 | uninstall-am uninstall-binPROGRAMS uninstall-includeHEADERS | ||
| 674 | |||
| 675 | .PRECIOUS: Makefile | ||
| 676 | |||
| 677 | |||
| 678 | # Tell versions [3.59,3.63) of GNU make to not export all variables. | ||
| 679 | # Otherwise a system limit (for SysV at least) may be exceeded. | ||
| 680 | .NOEXPORT: | ||
diff --git a/src/cmdline-life.c b/src/cmdline-life.c new file mode 100644 index 0000000..e4d81c5 --- /dev/null +++ b/src/cmdline-life.c | |||
| @@ -0,0 +1,684 @@ | |||
| 1 | /* | ||
| 2 | File autogenerated by gengetopt version 2.22.6 | ||
| 3 | generated with the following command: | ||
| 4 | gengetopt --file-name=cmdline-life | ||
| 5 | |||
| 6 | The developers of gengetopt consider the fixed text that goes in all | ||
| 7 | gengetopt output files to be in the public domain: | ||
| 8 | we make no copyright claims on it. | ||
| 9 | */ | ||
| 10 | |||
| 11 | /* If we use autoconf. */ | ||
| 12 | #ifdef HAVE_CONFIG_H | ||
| 13 | #include "config.h" | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #include <stdio.h> | ||
| 17 | #include <stdlib.h> | ||
| 18 | #include <string.h> | ||
| 19 | |||
| 20 | #ifndef FIX_UNUSED | ||
| 21 | #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #include <getopt.h> | ||
| 25 | |||
| 26 | #include "cmdline-life.h" | ||
| 27 | |||
| 28 | const char *gengetopt_args_info_purpose = ""; | ||
| 29 | |||
| 30 | const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]..."; | ||
| 31 | |||
| 32 | const char *gengetopt_args_info_versiontext = ""; | ||
| 33 | |||
| 34 | const char *gengetopt_args_info_description = ""; | ||
| 35 | |||
| 36 | const char *gengetopt_args_info_detailed_help[] = { | ||
| 37 | " -h, --help Print help and exit", | ||
| 38 | " --detailed-help Print help, including all details and hidden options,\n and exit", | ||
| 39 | " -V, --version Print version and exit", | ||
| 40 | " -r, --ruleint=rule Specify rule-int on command line (default=`6152')", | ||
| 41 | " -d, --delay=INT Specify delay time", | ||
| 42 | " Specify delay time, multiplied by 10ms", | ||
| 43 | "\nDimensions:", | ||
| 44 | " -W, --width=INT Specify width", | ||
| 45 | " -H, --height=INT Specify height", | ||
| 46 | " -m, --maximize Maximize dimensions for terminal", | ||
| 47 | " If specified, cancels out height and/or width options", | ||
| 48 | "\nCharacters:", | ||
| 49 | " -L, --live=CH Character for a live cell", | ||
| 50 | " -D, --dead=CH Character for a dead cell", | ||
| 51 | 0 | ||
| 52 | }; | ||
| 53 | |||
| 54 | static void | ||
| 55 | init_help_array(void) | ||
| 56 | { | ||
| 57 | gengetopt_args_info_help[0] = gengetopt_args_info_detailed_help[0]; | ||
| 58 | gengetopt_args_info_help[1] = gengetopt_args_info_detailed_help[1]; | ||
| 59 | gengetopt_args_info_help[2] = gengetopt_args_info_detailed_help[2]; | ||
| 60 | gengetopt_args_info_help[3] = gengetopt_args_info_detailed_help[3]; | ||
| 61 | gengetopt_args_info_help[4] = gengetopt_args_info_detailed_help[4]; | ||
| 62 | gengetopt_args_info_help[5] = gengetopt_args_info_detailed_help[6]; | ||
| 63 | gengetopt_args_info_help[6] = gengetopt_args_info_detailed_help[7]; | ||
| 64 | gengetopt_args_info_help[7] = gengetopt_args_info_detailed_help[8]; | ||
| 65 | gengetopt_args_info_help[8] = gengetopt_args_info_detailed_help[9]; | ||
| 66 | gengetopt_args_info_help[9] = gengetopt_args_info_detailed_help[11]; | ||
| 67 | gengetopt_args_info_help[10] = gengetopt_args_info_detailed_help[12]; | ||
| 68 | gengetopt_args_info_help[11] = gengetopt_args_info_detailed_help[13]; | ||
| 69 | gengetopt_args_info_help[12] = 0; | ||
| 70 | |||
| 71 | } | ||
| 72 | |||
| 73 | const char *gengetopt_args_info_help[13]; | ||
| 74 | |||
| 75 | typedef enum {ARG_NO | ||
| 76 | , ARG_STRING | ||
| 77 | , ARG_INT | ||
| 78 | } cmdline_parser_arg_type; | ||
| 79 | |||
| 80 | static | ||
| 81 | void clear_given (struct gengetopt_args_info *args_info); | ||
| 82 | static | ||
| 83 | void clear_args (struct gengetopt_args_info *args_info); | ||
| 84 | |||
| 85 | static int | ||
| 86 | cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, | ||
| 87 | struct cmdline_parser_params *params, const char *additional_error); | ||
| 88 | |||
| 89 | |||
| 90 | static char * | ||
| 91 | gengetopt_strdup (const char *s); | ||
| 92 | |||
| 93 | static | ||
| 94 | void clear_given (struct gengetopt_args_info *args_info) | ||
| 95 | { | ||
| 96 | args_info->help_given = 0 ; | ||
| 97 | args_info->detailed_help_given = 0 ; | ||
| 98 | args_info->version_given = 0 ; | ||
| 99 | args_info->ruleint_given = 0 ; | ||
| 100 | args_info->delay_given = 0 ; | ||
| 101 | args_info->width_given = 0 ; | ||
| 102 | args_info->height_given = 0 ; | ||
| 103 | args_info->maximize_given = 0 ; | ||
| 104 | args_info->live_given = 0 ; | ||
| 105 | args_info->dead_given = 0 ; | ||
| 106 | } | ||
| 107 | |||
| 108 | static | ||
| 109 | void clear_args (struct gengetopt_args_info *args_info) | ||
| 110 | { | ||
| 111 | FIX_UNUSED (args_info); | ||
| 112 | args_info->ruleint_arg = 6152; | ||
| 113 | args_info->ruleint_orig = NULL; | ||
| 114 | args_info->delay_orig = NULL; | ||
| 115 | args_info->width_orig = NULL; | ||
| 116 | args_info->height_orig = NULL; | ||
| 117 | args_info->live_arg = NULL; | ||
| 118 | args_info->live_orig = NULL; | ||
| 119 | args_info->dead_arg = NULL; | ||
| 120 | args_info->dead_orig = NULL; | ||
| 121 | |||
| 122 | } | ||
| 123 | |||
| 124 | static | ||
| 125 | void init_args_info(struct gengetopt_args_info *args_info) | ||
| 126 | { | ||
| 127 | |||
| 128 | init_help_array(); | ||
| 129 | args_info->help_help = gengetopt_args_info_detailed_help[0] ; | ||
| 130 | args_info->detailed_help_help = gengetopt_args_info_detailed_help[1] ; | ||
| 131 | args_info->version_help = gengetopt_args_info_detailed_help[2] ; | ||
| 132 | args_info->ruleint_help = gengetopt_args_info_detailed_help[3] ; | ||
| 133 | args_info->delay_help = gengetopt_args_info_detailed_help[4] ; | ||
| 134 | args_info->width_help = gengetopt_args_info_detailed_help[7] ; | ||
| 135 | args_info->height_help = gengetopt_args_info_detailed_help[8] ; | ||
| 136 | args_info->maximize_help = gengetopt_args_info_detailed_help[9] ; | ||
| 137 | args_info->live_help = gengetopt_args_info_detailed_help[12] ; | ||
| 138 | args_info->dead_help = gengetopt_args_info_detailed_help[13] ; | ||
| 139 | |||
| 140 | } | ||
| 141 | |||
| 142 | void | ||
| 143 | cmdline_parser_print_version (void) | ||
| 144 | { | ||
| 145 | printf ("%s %s\n", | ||
| 146 | (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), | ||
| 147 | CMDLINE_PARSER_VERSION); | ||
| 148 | |||
| 149 | if (strlen(gengetopt_args_info_versiontext) > 0) | ||
| 150 | printf("\n%s\n", gengetopt_args_info_versiontext); | ||
| 151 | } | ||
| 152 | |||
| 153 | static void print_help_common(void) { | ||
| 154 | cmdline_parser_print_version (); | ||
| 155 | |||
| 156 | if (strlen(gengetopt_args_info_purpose) > 0) | ||
| 157 | printf("\n%s\n", gengetopt_args_info_purpose); | ||
| 158 | |||
| 159 | if (strlen(gengetopt_args_info_usage) > 0) | ||
| 160 | printf("\n%s\n", gengetopt_args_info_usage); | ||
| 161 | |||
| 162 | printf("\n"); | ||
| 163 | |||
| 164 | if (strlen(gengetopt_args_info_description) > 0) | ||
| 165 | printf("%s\n\n", gengetopt_args_info_description); | ||
| 166 | } | ||
| 167 | |||
| 168 | void | ||
| 169 | cmdline_parser_print_help (void) | ||
| 170 | { | ||
| 171 | int i = 0; | ||
| 172 | print_help_common(); | ||
| 173 | while (gengetopt_args_info_help[i]) | ||
| 174 | printf("%s\n", gengetopt_args_info_help[i++]); | ||
| 175 | } | ||
| 176 | |||
| 177 | void | ||
| 178 | cmdline_parser_print_detailed_help (void) | ||
| 179 | { | ||
| 180 | int i = 0; | ||
| 181 | print_help_common(); | ||
| 182 | while (gengetopt_args_info_detailed_help[i]) | ||
| 183 | printf("%s\n", gengetopt_args_info_detailed_help[i++]); | ||
| 184 | } | ||
| 185 | |||
| 186 | void | ||
| 187 | cmdline_parser_init (struct gengetopt_args_info *args_info) | ||
| 188 | { | ||
| 189 | clear_given (args_info); | ||
| 190 | clear_args (args_info); | ||
| 191 | init_args_info (args_info); | ||
| 192 | } | ||
| 193 | |||
| 194 | void | ||
| 195 | cmdline_parser_params_init(struct cmdline_parser_params *params) | ||
| 196 | { | ||
| 197 | if (params) | ||
| 198 | { | ||
| 199 | params->override = 0; | ||
| 200 | params->initialize = 1; | ||
| 201 | params->check_required = 1; | ||
| 202 | params->check_ambiguity = 0; | ||
| 203 | params->print_errors = 1; | ||
| 204 | } | ||
| 205 | } | ||
| 206 | |||
| 207 | struct cmdline_parser_params * | ||
| 208 | cmdline_parser_params_create(void) | ||
| 209 | { | ||
| 210 | struct cmdline_parser_params *params = | ||
| 211 | (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); | ||
| 212 | cmdline_parser_params_init(params); | ||
| 213 | return params; | ||
| 214 | } | ||
| 215 | |||
| 216 | static void | ||
| 217 | free_string_field (char **s) | ||
| 218 | { | ||
| 219 | if (*s) | ||
| 220 | { | ||
| 221 | free (*s); | ||
| 222 | *s = 0; | ||
| 223 | } | ||
| 224 | } | ||
| 225 | |||
| 226 | |||
| 227 | static void | ||
| 228 | cmdline_parser_release (struct gengetopt_args_info *args_info) | ||
| 229 | { | ||
| 230 | |||
| 231 | free_string_field (&(args_info->ruleint_orig)); | ||
| 232 | free_string_field (&(args_info->delay_orig)); | ||
| 233 | free_string_field (&(args_info->width_orig)); | ||
| 234 | free_string_field (&(args_info->height_orig)); | ||
| 235 | free_string_field (&(args_info->live_arg)); | ||
| 236 | free_string_field (&(args_info->live_orig)); | ||
| 237 | free_string_field (&(args_info->dead_arg)); | ||
| 238 | free_string_field (&(args_info->dead_orig)); | ||
| 239 | |||
| 240 | |||
| 241 | |||
| 242 | clear_given (args_info); | ||
| 243 | } | ||
| 244 | |||
| 245 | |||
| 246 | static void | ||
| 247 | write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) | ||
| 248 | { | ||
| 249 | FIX_UNUSED (values); | ||
| 250 | if (arg) { | ||
| 251 | fprintf(outfile, "%s=\"%s\"\n", opt, arg); | ||
| 252 | } else { | ||
| 253 | fprintf(outfile, "%s\n", opt); | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 257 | |||
| 258 | int | ||
| 259 | cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) | ||
| 260 | { | ||
| 261 | int i = 0; | ||
| 262 | |||
| 263 | if (!outfile) | ||
| 264 | { | ||
| 265 | fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); | ||
| 266 | return EXIT_FAILURE; | ||
| 267 | } | ||
| 268 | |||
| 269 | if (args_info->help_given) | ||
| 270 | write_into_file(outfile, "help", 0, 0 ); | ||
| 271 | if (args_info->detailed_help_given) | ||
| 272 | write_into_file(outfile, "detailed-help", 0, 0 ); | ||
| 273 | if (args_info->version_given) | ||
| 274 | write_into_file(outfile, "version", 0, 0 ); | ||
| 275 | if (args_info->ruleint_given) | ||
| 276 | write_into_file(outfile, "ruleint", args_info->ruleint_orig, 0); | ||
| 277 | if (args_info->delay_given) | ||
| 278 | write_into_file(outfile, "delay", args_info->delay_orig, 0); | ||
| 279 | if (args_info->width_given) | ||
| 280 | write_into_file(outfile, "width", args_info->width_orig, 0); | ||
| 281 | if (args_info->height_given) | ||
| 282 | write_into_file(outfile, "height", args_info->height_orig, 0); | ||
| 283 | if (args_info->maximize_given) | ||
| 284 | write_into_file(outfile, "maximize", 0, 0 ); | ||
| 285 | if (args_info->live_given) | ||
| 286 | write_into_file(outfile, "live", args_info->live_orig, 0); | ||
| 287 | if (args_info->dead_given) | ||
| 288 | write_into_file(outfile, "dead", args_info->dead_orig, 0); | ||
| 289 | |||
| 290 | |||
| 291 | i = EXIT_SUCCESS; | ||
| 292 | return i; | ||
| 293 | } | ||
| 294 | |||
| 295 | int | ||
| 296 | cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) | ||
| 297 | { | ||
| 298 | FILE *outfile; | ||
| 299 | int i = 0; | ||
| 300 | |||
| 301 | outfile = fopen(filename, "w"); | ||
| 302 | |||
| 303 | if (!outfile) | ||
| 304 | { | ||
| 305 | fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); | ||
| 306 | return EXIT_FAILURE; | ||
| 307 | } | ||
| 308 | |||
| 309 | i = cmdline_parser_dump(outfile, args_info); | ||
| 310 | fclose (outfile); | ||
| 311 | |||
| 312 | return i; | ||
| 313 | } | ||
| 314 | |||
| 315 | void | ||
| 316 | cmdline_parser_free (struct gengetopt_args_info *args_info) | ||
| 317 | { | ||
| 318 | cmdline_parser_release (args_info); | ||
| 319 | } | ||
| 320 | |||
| 321 | /** @brief replacement of strdup, which is not standard */ | ||
| 322 | char * | ||
| 323 | gengetopt_strdup (const char *s) | ||
| 324 | { | ||
| 325 | char *result = 0; | ||
| 326 | if (!s) | ||
| 327 | return result; | ||
| 328 | |||
| 329 | result = (char*)malloc(strlen(s) + 1); | ||
| 330 | if (result == (char*)0) | ||
| 331 | return (char*)0; | ||
| 332 | strcpy(result, s); | ||
| 333 | return result; | ||
| 334 | } | ||
| 335 | |||
| 336 | int | ||
| 337 | cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) | ||
| 338 | { | ||
| 339 | return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); | ||
| 340 | } | ||
| 341 | |||
| 342 | int | ||
| 343 | cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, | ||
| 344 | struct cmdline_parser_params *params) | ||
| 345 | { | ||
| 346 | int result; | ||
| 347 | result = cmdline_parser_internal (argc, argv, args_info, params, 0); | ||
| 348 | |||
| 349 | if (result == EXIT_FAILURE) | ||
| 350 | { | ||
| 351 | cmdline_parser_free (args_info); | ||
| 352 | exit (EXIT_FAILURE); | ||
| 353 | } | ||
| 354 | |||
| 355 | return result; | ||
| 356 | } | ||
| 357 | |||
| 358 | int | ||
| 359 | cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) | ||
| 360 | { | ||
| 361 | int result; | ||
| 362 | struct cmdline_parser_params params; | ||
| 363 | |||
| 364 | params.override = override; | ||
| 365 | params.initialize = initialize; | ||
| 366 | params.check_required = check_required; | ||
| 367 | params.check_ambiguity = 0; | ||
| 368 | params.print_errors = 1; | ||
| 369 | |||
| 370 | result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); | ||
| 371 | |||
| 372 | if (result == EXIT_FAILURE) | ||
| 373 | { | ||
| 374 | cmdline_parser_free (args_info); | ||
| 375 | exit (EXIT_FAILURE); | ||
| 376 | } | ||
| 377 | |||
| 378 | return result; | ||
| 379 | } | ||
| 380 | |||
| 381 | int | ||
| 382 | cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) | ||
| 383 | { | ||
| 384 | FIX_UNUSED (args_info); | ||
| 385 | FIX_UNUSED (prog_name); | ||
| 386 | return EXIT_SUCCESS; | ||
| 387 | } | ||
| 388 | |||
| 389 | |||
| 390 | static char *package_name = 0; | ||
| 391 | |||
| 392 | /** | ||
| 393 | * @brief updates an option | ||
| 394 | * @param field the generic pointer to the field to update | ||
| 395 | * @param orig_field the pointer to the orig field | ||
| 396 | * @param field_given the pointer to the number of occurrence of this option | ||
| 397 | * @param prev_given the pointer to the number of occurrence already seen | ||
| 398 | * @param value the argument for this option (if null no arg was specified) | ||
| 399 | * @param possible_values the possible values for this option (if specified) | ||
| 400 | * @param default_value the default value (in case the option only accepts fixed values) | ||
| 401 | * @param arg_type the type of this option | ||
| 402 | * @param check_ambiguity @see cmdline_parser_params.check_ambiguity | ||
| 403 | * @param override @see cmdline_parser_params.override | ||
| 404 | * @param no_free whether to free a possible previous value | ||
| 405 | * @param multiple_option whether this is a multiple option | ||
| 406 | * @param long_opt the corresponding long option | ||
| 407 | * @param short_opt the corresponding short option (or '-' if none) | ||
| 408 | * @param additional_error possible further error specification | ||
| 409 | */ | ||
| 410 | static | ||
| 411 | int update_arg(void *field, char **orig_field, | ||
| 412 | unsigned int *field_given, unsigned int *prev_given, | ||
| 413 | char *value, const char *possible_values[], | ||
| 414 | const char *default_value, | ||
| 415 | cmdline_parser_arg_type arg_type, | ||
| 416 | int check_ambiguity, int override, | ||
| 417 | int no_free, int multiple_option, | ||
| 418 | const char *long_opt, char short_opt, | ||
| 419 | const char *additional_error) | ||
| 420 | { | ||
| 421 | char *stop_char = 0; | ||
| 422 | const char *val = value; | ||
| 423 | int found; | ||
| 424 | char **string_field; | ||
| 425 | FIX_UNUSED (field); | ||
| 426 | |||
| 427 | stop_char = 0; | ||
| 428 | found = 0; | ||
| 429 | |||
| 430 | if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) | ||
| 431 | { | ||
| 432 | if (short_opt != '-') | ||
| 433 | fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", | ||
| 434 | package_name, long_opt, short_opt, | ||
| 435 | (additional_error ? additional_error : "")); | ||
| 436 | else | ||
| 437 | fprintf (stderr, "%s: `--%s' option given more than once%s\n", | ||
| 438 | package_name, long_opt, | ||
| 439 | (additional_error ? additional_error : "")); | ||
| 440 | return 1; /* failure */ | ||
| 441 | } | ||
| 442 | |||
| 443 | FIX_UNUSED (default_value); | ||
| 444 | |||
| 445 | if (field_given && *field_given && ! override) | ||
| 446 | return 0; | ||
| 447 | if (prev_given) | ||
| 448 | (*prev_given)++; | ||
| 449 | if (field_given) | ||
| 450 | (*field_given)++; | ||
| 451 | if (possible_values) | ||
| 452 | val = possible_values[found]; | ||
| 453 | |||
| 454 | switch(arg_type) { | ||
| 455 | case ARG_INT: | ||
| 456 | if (val) *((int *)field) = strtol (val, &stop_char, 0); | ||
| 457 | break; | ||
| 458 | case ARG_STRING: | ||
| 459 | if (val) { | ||
| 460 | string_field = (char **)field; | ||
| 461 | if (!no_free && *string_field) | ||
| 462 | free (*string_field); /* free previous string */ | ||
| 463 | *string_field = gengetopt_strdup (val); | ||
| 464 | } | ||
| 465 | break; | ||
| 466 | default: | ||
| 467 | break; | ||
| 468 | }; | ||
| 469 | |||
| 470 | /* check numeric conversion */ | ||
| 471 | switch(arg_type) { | ||
| 472 | case ARG_INT: | ||
| 473 | if (val && !(stop_char && *stop_char == '\0')) { | ||
| 474 | fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); | ||
| 475 | return 1; /* failure */ | ||
| 476 | } | ||
| 477 | break; | ||
| 478 | default: | ||
| 479 | ; | ||
| 480 | }; | ||
| 481 | |||
| 482 | /* store the original value */ | ||
| 483 | switch(arg_type) { | ||
| 484 | case ARG_NO: | ||
| 485 | break; | ||
| 486 | default: | ||
| 487 | if (value && orig_field) { | ||
| 488 | if (no_free) { | ||
| 489 | *orig_field = value; | ||
| 490 | } else { | ||
| 491 | if (*orig_field) | ||
| 492 | free (*orig_field); /* free previous string */ | ||
| 493 | *orig_field = gengetopt_strdup (value); | ||
| 494 | } | ||
| 495 | } | ||
| 496 | }; | ||
| 497 | |||
| 498 | return 0; /* OK */ | ||
| 499 | } | ||
| 500 | |||
| 501 | |||
| 502 | int | ||
| 503 | cmdline_parser_internal ( | ||
| 504 | int argc, char **argv, struct gengetopt_args_info *args_info, | ||
| 505 | struct cmdline_parser_params *params, const char *additional_error) | ||
| 506 | { | ||
| 507 | int c; /* Character of the parsed option. */ | ||
| 508 | |||
| 509 | int error_occurred = 0; | ||
| 510 | struct gengetopt_args_info local_args_info; | ||
| 511 | |||
| 512 | int override; | ||
| 513 | int initialize; | ||
| 514 | int check_required; | ||
| 515 | int check_ambiguity; | ||
| 516 | |||
| 517 | package_name = argv[0]; | ||
| 518 | |||
| 519 | override = params->override; | ||
| 520 | initialize = params->initialize; | ||
| 521 | check_required = params->check_required; | ||
| 522 | check_ambiguity = params->check_ambiguity; | ||
| 523 | |||
| 524 | if (initialize) | ||
| 525 | cmdline_parser_init (args_info); | ||
| 526 | |||
| 527 | cmdline_parser_init (&local_args_info); | ||
| 528 | |||
| 529 | optarg = 0; | ||
| 530 | optind = 0; | ||
| 531 | opterr = params->print_errors; | ||
| 532 | optopt = '?'; | ||
| 533 | |||
| 534 | while (1) | ||
| 535 | { | ||
| 536 | int option_index = 0; | ||
| 537 | |||
| 538 | static struct option long_options[] = { | ||
| 539 | { "help", 0, NULL, 'h' }, | ||
| 540 | { "detailed-help", 0, NULL, 0 }, | ||
| 541 | { "version", 0, NULL, 'V' }, | ||
| 542 | { "ruleint", 1, NULL, 'r' }, | ||
| 543 | { "delay", 1, NULL, 'd' }, | ||
| 544 | { "width", 1, NULL, 'W' }, | ||
| 545 | { "height", 1, NULL, 'H' }, | ||
| 546 | { "maximize", 0, NULL, 'm' }, | ||
| 547 | { "live", 1, NULL, 'L' }, | ||
| 548 | { "dead", 1, NULL, 'D' }, | ||
| 549 | { 0, 0, 0, 0 } | ||
| 550 | }; | ||
| 551 | |||
| 552 | c = getopt_long (argc, argv, "hVr:d:W:H:mL:D:", long_options, &option_index); | ||
| 553 | |||
| 554 | if (c == -1) break; /* Exit from `while (1)' loop. */ | ||
| 555 | |||
| 556 | switch (c) | ||
| 557 | { | ||
| 558 | case 'h': /* Print help and exit. */ | ||
| 559 | cmdline_parser_print_help (); | ||
| 560 | cmdline_parser_free (&local_args_info); | ||
| 561 | exit (EXIT_SUCCESS); | ||
| 562 | |||
| 563 | case 'V': /* Print version and exit. */ | ||
| 564 | cmdline_parser_print_version (); | ||
| 565 | cmdline_parser_free (&local_args_info); | ||
| 566 | exit (EXIT_SUCCESS); | ||
| 567 | |||
| 568 | case 'r': /* Specify rule-int on command line. */ | ||
| 569 | |||
| 570 | |||
| 571 | if (update_arg( (void *)&(args_info->ruleint_arg), | ||
| 572 | &(args_info->ruleint_orig), &(args_info->ruleint_given), | ||
| 573 | &(local_args_info.ruleint_given), optarg, 0, "6152", ARG_INT, | ||
| 574 | check_ambiguity, override, 0, 0, | ||
| 575 | "ruleint", 'r', | ||
| 576 | additional_error)) | ||
| 577 | goto failure; | ||
| 578 | |||
| 579 | break; | ||
| 580 | case 'd': /* Specify delay time. */ | ||
| 581 | |||
| 582 | |||
| 583 | if (update_arg( (void *)&(args_info->delay_arg), | ||
| 584 | &(args_info->delay_orig), &(args_info->delay_given), | ||
| 585 | &(local_args_info.delay_given), optarg, 0, 0, ARG_INT, | ||
| 586 | check_ambiguity, override, 0, 0, | ||
| 587 | "delay", 'd', | ||
| 588 | additional_error)) | ||
| 589 | goto failure; | ||
| 590 | |||
| 591 | break; | ||
| 592 | case 'W': /* Specify width. */ | ||
| 593 | |||
| 594 | |||
| 595 | if (update_arg( (void *)&(args_info->width_arg), | ||
| 596 | &(args_info->width_orig), &(args_info->width_given), | ||
| 597 | &(local_args_info.width_given), optarg, 0, 0, ARG_INT, | ||
| 598 | check_ambiguity, override, 0, 0, | ||
| 599 | "width", 'W', | ||
| 600 | additional_error)) | ||
| 601 | goto failure; | ||
| 602 | |||
| 603 | break; | ||
| 604 | case 'H': /* Specify height. */ | ||
| 605 | |||
| 606 | |||
| 607 | if (update_arg( (void *)&(args_info->height_arg), | ||
| 608 | &(args_info->height_orig), &(args_info->height_given), | ||
| 609 | &(local_args_info.height_given), optarg, 0, 0, ARG_INT, | ||
| 610 | check_ambiguity, override, 0, 0, | ||
| 611 | "height", 'H', | ||
| 612 | additional_error)) | ||
| 613 | goto failure; | ||
| 614 | |||
| 615 | break; | ||
| 616 | case 'm': /* Maximize dimensions for terminal. */ | ||
| 617 | |||
| 618 | |||
| 619 | if (update_arg( 0 , | ||
| 620 | 0 , &(args_info->maximize_given), | ||
| 621 | &(local_args_info.maximize_given), optarg, 0, 0, ARG_NO, | ||
| 622 | check_ambiguity, override, 0, 0, | ||
| 623 | "maximize", 'm', | ||
| 624 | additional_error)) | ||
| 625 | goto failure; | ||
| 626 | |||
| 627 | break; | ||
| 628 | case 'L': /* Character for a live cell. */ | ||
| 629 | |||
| 630 | |||
| 631 | if (update_arg( (void *)&(args_info->live_arg), | ||
| 632 | &(args_info->live_orig), &(args_info->live_given), | ||
| 633 | &(local_args_info.live_given), optarg, 0, 0, ARG_STRING, | ||
| 634 | check_ambiguity, override, 0, 0, | ||
| 635 | "live", 'L', | ||
| 636 | additional_error)) | ||
| 637 | goto failure; | ||
| 638 | |||
| 639 | break; | ||
| 640 | case 'D': /* Character for a dead cell. */ | ||
| 641 | |||
| 642 | |||
| 643 | if (update_arg( (void *)&(args_info->dead_arg), | ||
| 644 | &(args_info->dead_orig), &(args_info->dead_given), | ||
| 645 | &(local_args_info.dead_given), optarg, 0, 0, ARG_STRING, | ||
| 646 | check_ambiguity, override, 0, 0, | ||
| 647 | "dead", 'D', | ||
| 648 | additional_error)) | ||
| 649 | goto failure; | ||
| 650 | |||
| 651 | break; | ||
| 652 | |||
| 653 | case 0: /* Long option with no short option */ | ||
| 654 | if (strcmp (long_options[option_index].name, "detailed-help") == 0) { | ||
| 655 | cmdline_parser_print_detailed_help (); | ||
| 656 | cmdline_parser_free (&local_args_info); | ||
| 657 | exit (EXIT_SUCCESS); | ||
| 658 | } | ||
| 659 | |||
| 660 | case '?': /* Invalid option. */ | ||
| 661 | /* `getopt_long' already printed an error message. */ | ||
| 662 | goto failure; | ||
| 663 | |||
| 664 | default: /* bug: option not considered. */ | ||
| 665 | fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); | ||
| 666 | abort (); | ||
| 667 | } /* switch */ | ||
| 668 | } /* while */ | ||
| 669 | |||
| 670 | |||
| 671 | |||
| 672 | |||
| 673 | cmdline_parser_release (&local_args_info); | ||
| 674 | |||
| 675 | if ( error_occurred ) | ||
| 676 | return (EXIT_FAILURE); | ||
| 677 | |||
| 678 | return 0; | ||
| 679 | |||
| 680 | failure: | ||
| 681 | |||
| 682 | cmdline_parser_release (&local_args_info); | ||
| 683 | return (EXIT_FAILURE); | ||
| 684 | } | ||
diff --git a/src/cmdline-life.h b/src/cmdline-life.h new file mode 100644 index 0000000..99579f3 --- /dev/null +++ b/src/cmdline-life.h | |||
| @@ -0,0 +1,211 @@ | |||
| 1 | /** @file cmdline-life.h | ||
| 2 | * @brief The header file for the command line option parser | ||
| 3 | * generated by GNU Gengetopt version 2.22.6 | ||
| 4 | * http://www.gnu.org/software/gengetopt. | ||
| 5 | * DO NOT modify this file, since it can be overwritten | ||
| 6 | * @author GNU Gengetopt by Lorenzo Bettini */ | ||
| 7 | |||
| 8 | #ifndef CMDLINE_LIFE_H | ||
| 9 | #define CMDLINE_LIFE_H | ||
| 10 | |||
| 11 | /* If we use autoconf. */ | ||
| 12 | #ifdef HAVE_CONFIG_H | ||
| 13 | #include "config.h" | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #include <stdio.h> /* for FILE */ | ||
| 17 | |||
| 18 | #ifdef __cplusplus | ||
| 19 | extern "C" { | ||
| 20 | #endif /* __cplusplus */ | ||
| 21 | |||
| 22 | #ifndef CMDLINE_PARSER_PACKAGE | ||
| 23 | /** @brief the program name (used for printing errors) */ | ||
| 24 | #define CMDLINE_PARSER_PACKAGE PACKAGE | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #ifndef CMDLINE_PARSER_PACKAGE_NAME | ||
| 28 | /** @brief the complete program name (used for help and version) */ | ||
| 29 | #ifdef PACKAGE_NAME | ||
| 30 | #define CMDLINE_PARSER_PACKAGE_NAME PACKAGE_NAME | ||
| 31 | #else | ||
| 32 | #define CMDLINE_PARSER_PACKAGE_NAME PACKAGE | ||
| 33 | #endif | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #ifndef CMDLINE_PARSER_VERSION | ||
| 37 | /** @brief the program version */ | ||
| 38 | #define CMDLINE_PARSER_VERSION VERSION | ||
| 39 | #endif | ||
| 40 | |||
| 41 | /** @brief Where the command line options are stored */ | ||
| 42 | struct gengetopt_args_info | ||
| 43 | { | ||
| 44 | const char *help_help; /**< @brief Print help and exit help description. */ | ||
| 45 | const char *detailed_help_help; /**< @brief Print help, including all details and hidden options, and exit help description. */ | ||
| 46 | const char *version_help; /**< @brief Print version and exit help description. */ | ||
| 47 | int ruleint_arg; /**< @brief Specify rule-int on command line (default='6152'). */ | ||
| 48 | char * ruleint_orig; /**< @brief Specify rule-int on command line original value given at command line. */ | ||
| 49 | const char *ruleint_help; /**< @brief Specify rule-int on command line help description. */ | ||
| 50 | int delay_arg; /**< @brief Specify delay time. */ | ||
| 51 | char * delay_orig; /**< @brief Specify delay time original value given at command line. */ | ||
| 52 | const char *delay_help; /**< @brief Specify delay time help description. */ | ||
| 53 | int width_arg; /**< @brief Specify width. */ | ||
| 54 | char * width_orig; /**< @brief Specify width original value given at command line. */ | ||
| 55 | const char *width_help; /**< @brief Specify width help description. */ | ||
| 56 | int height_arg; /**< @brief Specify height. */ | ||
| 57 | char * height_orig; /**< @brief Specify height original value given at command line. */ | ||
| 58 | const char *height_help; /**< @brief Specify height help description. */ | ||
| 59 | const char *maximize_help; /**< @brief Maximize dimensions for terminal help description. */ | ||
| 60 | char * live_arg; /**< @brief Character for a live cell. */ | ||
| 61 | char * live_orig; /**< @brief Character for a live cell original value given at command line. */ | ||
| 62 | const char *live_help; /**< @brief Character for a live cell help description. */ | ||
| 63 | char * dead_arg; /**< @brief Character for a dead cell. */ | ||
| 64 | char * dead_orig; /**< @brief Character for a dead cell original value given at command line. */ | ||
| 65 | const char *dead_help; /**< @brief Character for a dead cell help description. */ | ||
| 66 | |||
| 67 | unsigned int help_given ; /**< @brief Whether help was given. */ | ||
| 68 | unsigned int detailed_help_given ; /**< @brief Whether detailed-help was given. */ | ||
| 69 | unsigned int version_given ; /**< @brief Whether version was given. */ | ||
| 70 | unsigned int ruleint_given ; /**< @brief Whether ruleint was given. */ | ||
| 71 | unsigned int delay_given ; /**< @brief Whether delay was given. */ | ||
| 72 | unsigned int width_given ; /**< @brief Whether width was given. */ | ||
| 73 | unsigned int height_given ; /**< @brief Whether height was given. */ | ||
| 74 | unsigned int maximize_given ; /**< @brief Whether maximize was given. */ | ||
| 75 | unsigned int live_given ; /**< @brief Whether live was given. */ | ||
| 76 | unsigned int dead_given ; /**< @brief Whether dead was given. */ | ||
| 77 | |||
| 78 | } ; | ||
| 79 | |||
| 80 | /** @brief The additional parameters to pass to parser functions */ | ||
| 81 | struct cmdline_parser_params | ||
| 82 | { | ||
| 83 | int override; /**< @brief whether to override possibly already present options (default 0) */ | ||
| 84 | int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ | ||
| 85 | int check_required; /**< @brief whether to check that all required options were provided (default 1) */ | ||
| 86 | int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ | ||
| 87 | int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ | ||
| 88 | } ; | ||
| 89 | |||
| 90 | /** @brief the purpose string of the program */ | ||
| 91 | extern const char *gengetopt_args_info_purpose; | ||
| 92 | /** @brief the usage string of the program */ | ||
| 93 | extern const char *gengetopt_args_info_usage; | ||
| 94 | /** @brief the description string of the program */ | ||
| 95 | extern const char *gengetopt_args_info_description; | ||
| 96 | /** @brief all the lines making the help output */ | ||
| 97 | extern const char *gengetopt_args_info_help[]; | ||
| 98 | /** @brief all the lines making the detailed help output (including hidden options and details) */ | ||
| 99 | extern const char *gengetopt_args_info_detailed_help[]; | ||
| 100 | |||
| 101 | /** | ||
| 102 | * The command line parser | ||
| 103 | * @param argc the number of command line options | ||
| 104 | * @param argv the command line options | ||
| 105 | * @param args_info the structure where option information will be stored | ||
| 106 | * @return 0 if everything went fine, NON 0 if an error took place | ||
| 107 | */ | ||
| 108 | int cmdline_parser (int argc, char **argv, | ||
| 109 | struct gengetopt_args_info *args_info); | ||
| 110 | |||
| 111 | /** | ||
| 112 | * The command line parser (version with additional parameters - deprecated) | ||
| 113 | * @param argc the number of command line options | ||
| 114 | * @param argv the command line options | ||
| 115 | * @param args_info the structure where option information will be stored | ||
| 116 | * @param override whether to override possibly already present options | ||
| 117 | * @param initialize whether to initialize the option structure my_args_info | ||
| 118 | * @param check_required whether to check that all required options were provided | ||
| 119 | * @return 0 if everything went fine, NON 0 if an error took place | ||
| 120 | * @deprecated use cmdline_parser_ext() instead | ||
| 121 | */ | ||
| 122 | int cmdline_parser2 (int argc, char **argv, | ||
| 123 | struct gengetopt_args_info *args_info, | ||
| 124 | int override, int initialize, int check_required); | ||
| 125 | |||
| 126 | /** | ||
| 127 | * The command line parser (version with additional parameters) | ||
| 128 | * @param argc the number of command line options | ||
| 129 | * @param argv the command line options | ||
| 130 | * @param args_info the structure where option information will be stored | ||
| 131 | * @param params additional parameters for the parser | ||
| 132 | * @return 0 if everything went fine, NON 0 if an error took place | ||
| 133 | */ | ||
| 134 | int cmdline_parser_ext (int argc, char **argv, | ||
| 135 | struct gengetopt_args_info *args_info, | ||
| 136 | struct cmdline_parser_params *params); | ||
| 137 | |||
| 138 | /** | ||
| 139 | * Save the contents of the option struct into an already open FILE stream. | ||
| 140 | * @param outfile the stream where to dump options | ||
| 141 | * @param args_info the option struct to dump | ||
| 142 | * @return 0 if everything went fine, NON 0 if an error took place | ||
| 143 | */ | ||
| 144 | int cmdline_parser_dump(FILE *outfile, | ||
| 145 | struct gengetopt_args_info *args_info); | ||
| 146 | |||
| 147 | /** | ||
| 148 | * Save the contents of the option struct into a (text) file. | ||
| 149 | * This file can be read by the config file parser (if generated by gengetopt) | ||
| 150 | * @param filename the file where to save | ||
| 151 | * @param args_info the option struct to save | ||
| 152 | * @return 0 if everything went fine, NON 0 if an error took place | ||
| 153 | */ | ||
| 154 | int cmdline_parser_file_save(const char *filename, | ||
| 155 | struct gengetopt_args_info *args_info); | ||
| 156 | |||
| 157 | /** | ||
| 158 | * Print the help | ||
| 159 | */ | ||
| 160 | void cmdline_parser_print_help(void); | ||
| 161 | /** | ||
| 162 | * Print the detailed help (including hidden options and details) | ||
| 163 | */ | ||
| 164 | void cmdline_parser_print_detailed_help(void); | ||
| 165 | /** | ||
| 166 | * Print the version | ||
| 167 | */ | ||
| 168 | void cmdline_parser_print_version(void); | ||
| 169 | |||
| 170 | /** | ||
| 171 | * Initializes all the fields a cmdline_parser_params structure | ||
| 172 | * to their default values | ||
| 173 | * @param params the structure to initialize | ||
| 174 | */ | ||
| 175 | void cmdline_parser_params_init(struct cmdline_parser_params *params); | ||
| 176 | |||
| 177 | /** | ||
| 178 | * Allocates dynamically a cmdline_parser_params structure and initializes | ||
| 179 | * all its fields to their default values | ||
| 180 | * @return the created and initialized cmdline_parser_params structure | ||
| 181 | */ | ||
| 182 | struct cmdline_parser_params *cmdline_parser_params_create(void); | ||
| 183 | |||
| 184 | /** | ||
| 185 | * Initializes the passed gengetopt_args_info structure's fields | ||
| 186 | * (also set default values for options that have a default) | ||
| 187 | * @param args_info the structure to initialize | ||
| 188 | */ | ||
| 189 | void cmdline_parser_init (struct gengetopt_args_info *args_info); | ||
| 190 | /** | ||
| 191 | * Deallocates the string fields of the gengetopt_args_info structure | ||
| 192 | * (but does not deallocate the structure itself) | ||
| 193 | * @param args_info the structure to deallocate | ||
| 194 | */ | ||
| 195 | void cmdline_parser_free (struct gengetopt_args_info *args_info); | ||
| 196 | |||
| 197 | /** | ||
| 198 | * Checks that all the required options were specified | ||
| 199 | * @param args_info the structure to check | ||
| 200 | * @param prog_name the name of the program that will be used to print | ||
| 201 | * possible errors | ||
| 202 | * @return | ||
| 203 | */ | ||
| 204 | int cmdline_parser_required (struct gengetopt_args_info *args_info, | ||
| 205 | const char *prog_name); | ||
| 206 | |||
| 207 | |||
| 208 | #ifdef __cplusplus | ||
| 209 | } | ||
| 210 | #endif /* __cplusplus */ | ||
| 211 | #endif /* CMDLINE_LIFE_H */ | ||
diff --git a/src/life-macros.h b/src/life-macros.h new file mode 100644 index 0000000..32eb3f0 --- /dev/null +++ b/src/life-macros.h | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #ifndef has | ||
| 2 | #define has(var, bit) (((var) & (bit)) == (bit)) | ||
| 3 | #endif | ||
| 4 | |||
| 5 | #ifndef foreach | ||
| 6 | #define foreach(func, count, first,...) \ | ||
| 7 | {typeof(first) things[] = {__VA_ARGS__}; \ | ||
| 8 | func(first); \ | ||
| 9 | for (int _i = 0; _i < count - 1; _i++) func(things[_i]);} | ||
| 10 | #endif | ||
diff --git a/src/life.c b/src/life.c new file mode 100644 index 0000000..61b61b4 --- /dev/null +++ b/src/life.c | |||
| @@ -0,0 +1,265 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | * An arbitrary cellular automata model using ncurses | ||
| 4 | * Copyright (C) 2018 Aiden Woodruff | ||
| 5 | |||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 3 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | |||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | |||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | */ | ||
| 20 | #include "life.h" | ||
| 21 | |||
| 22 | #ifndef stat_bar_print | ||
| 23 | // Print text to status bar in the nice way, without erasing or refreshing | ||
| 24 | #define stat_bar_print(win,...) \ | ||
| 25 | mvwprintw(win, 0, 0, __VA_ARGS__); \ | ||
| 26 | for (int _i = getcurx(win); _i < getmaxx(win); _i++) waddch(win, ' '); | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #ifndef CTRL | ||
| 30 | #define CTRL(ch) ((ch) & 037) | ||
| 31 | #endif | ||
| 32 | |||
| 33 | int main (int argc, char * argv[]) { | ||
| 34 | srand(time(NULL)); | ||
| 35 | unsigned int RULE = 0; | ||
| 36 | int ruleint = 0; | ||
| 37 | int ch = 0; | ||
| 38 | int livecell = '#'; | ||
| 39 | int deadcell = '.'; | ||
| 40 | int timeout_val = 50; | ||
| 41 | int width = 36; | ||
| 42 | int height = 18; | ||
| 43 | int x = 0; | ||
| 44 | int y = 0; | ||
| 45 | int playing = 0; | ||
| 46 | int delaymax = 10; | ||
| 47 | int delay = 0; | ||
| 48 | unsigned int generation = 0; | ||
| 49 | WINDOW * board = NULL; | ||
| 50 | WINDOW * stat_bar = NULL; | ||
| 51 | WINDOW * entry = NULL; | ||
| 52 | WINDOW * rule_entry_box = NULL; | ||
| 53 | WINDOW * rule_entry = NULL; | ||
| 54 | char * map = NULL; | ||
| 55 | struct gengetopt_args_info args_info; | ||
| 56 | if (cmdline_parser(argc, argv, &args_info) != 0) { | ||
| 57 | fprintf(stderr, "Couldn't correctly parse commandline arguments.\n"); | ||
| 58 | exit(EXIT_FAILURE); | ||
| 59 | } | ||
| 60 | initscr(); | ||
| 61 | raw(); | ||
| 62 | curs_set(0); | ||
| 63 | noecho(); | ||
| 64 | RULE = args_info.ruleint_arg; | ||
| 65 | if (args_info.width_given) { | ||
| 66 | if (args_info.width_arg > COLS) { | ||
| 67 | width = COLS; | ||
| 68 | } else if (args_info.width_arg < 1) { | ||
| 69 | width = 1; | ||
| 70 | } else { | ||
| 71 | width = args_info.width_arg; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | if (args_info.height_given) { | ||
| 75 | if (args_info.height_arg > LINES - 2) { | ||
| 76 | height = LINES - 2; | ||
| 77 | } else if (args_info.height_arg < 1) { | ||
| 78 | height = 1; | ||
| 79 | } else { | ||
| 80 | height = args_info.height_arg; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | if (args_info.delay_given) { | ||
| 84 | if (args_info.delay_arg > 20) { | ||
| 85 | delaymax = 20; | ||
| 86 | } else if (args_info.delay_arg < 1) { | ||
| 87 | delaymax = 1; | ||
| 88 | } else { | ||
| 89 | delaymax = args_info.delay_arg; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | if (args_info.live_given) { | ||
| 93 | if (strlen(args_info.live_arg) > 1) { | ||
| 94 | fprintf(stderr, "Live character must be one character long.\n"); | ||
| 95 | endwin(); | ||
| 96 | exit(EXIT_FAILURE); | ||
| 97 | } else { | ||
| 98 | livecell = (isprint((int) args_info.live_arg[0]) != 0 ? (int) args_info.live_arg[0] : livecell); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | if (args_info.dead_given) { | ||
| 102 | if (strlen(args_info.dead_arg) > 1) { | ||
| 103 | fprintf(stderr, "Dead character must be one character long.\n"); | ||
| 104 | endwin(); | ||
| 105 | exit(EXIT_FAILURE); | ||
| 106 | } else { | ||
| 107 | deadcell = (isprint((int) args_info.dead_arg[0]) != 0 ? (int) args_info.dead_arg[0] : deadcell); | ||
| 108 | } | ||
| 109 | } | ||
| 110 | if (args_info.maximize_given) { | ||
| 111 | width = COLS; | ||
| 112 | height = LINES - 2; | ||
| 113 | } | ||
| 114 | cmdline_parser_free(&args_info); | ||
| 115 | board = newwin(LINES - 2, COLS, 0, 0); | ||
| 116 | stat_bar = newwin(1, 0, LINES - 2, 0); | ||
| 117 | entry = newwin(1, 0, LINES - 1, 0); | ||
| 118 | rule_entry_box = newwin(10, 36, (LINES >> 1) - 5, (COLS >> 1) - 18); | ||
| 119 | wborder(rule_entry_box, 0, 0, 0, 0, 0, 0, 0, 0); | ||
| 120 | rule_entry = derwin(rule_entry_box, 8, 34, 1, 1); | ||
| 121 | keypad(rule_entry, RULE); | ||
| 122 | keypad(board, TRUE); | ||
| 123 | wstandout(stat_bar); | ||
| 124 | map = malloc((height * width)+1); | ||
| 125 | memset(map, 0, height * width + 1); | ||
| 126 | memset(map, deadcell, height * width); | ||
| 127 | x = width >> 2; | ||
| 128 | y = height >> 2; | ||
| 129 | while (ch != 'q') { | ||
| 130 | foreach(werase, 4, stdscr, board, stat_bar, entry); | ||
| 131 | if (playing == FALSE) { | ||
| 132 | // Numpad and arrow directions | ||
| 133 | switch(ch) { | ||
| 134 | case KEY_UP: | ||
| 135 | if (y > 0) y--; | ||
| 136 | break; | ||
| 137 | case KEY_DOWN: | ||
| 138 | if (y < height - 1) y++; | ||
| 139 | break; | ||
| 140 | case KEY_LEFT: | ||
| 141 | if (x > 0) x--; | ||
| 142 | break; | ||
| 143 | case KEY_RIGHT: | ||
| 144 | if (x < width - 1) x++; | ||
| 145 | break; | ||
| 146 | case KEY_A1: | ||
| 147 | if (x > 0) x--; | ||
| 148 | if (y > 0) y--; | ||
| 149 | break; | ||
| 150 | case KEY_A3: | ||
| 151 | if (x < width - 1) x++; | ||
| 152 | if (y > 0) y--; | ||
| 153 | break; | ||
| 154 | case KEY_C1: | ||
| 155 | if (x > 0) x--; | ||
| 156 | if (y < height - 1) y++; | ||
| 157 | break; | ||
| 158 | case KEY_C3: | ||
| 159 | if (x < width - 1) x++; | ||
| 160 | if (y < height - 1) y++; | ||
| 161 | break; | ||
| 162 | case ' ': | ||
| 163 | if (map[y*width+x] == deadcell) { | ||
| 164 | map[y*width+x] = livecell; | ||
| 165 | } else if (map[y*width+x] == livecell) { | ||
| 166 | map[(y*width)+x] = deadcell; | ||
| 167 | } | ||
| 168 | break; | ||
| 169 | case '\n': | ||
| 170 | playing = TRUE; | ||
| 171 | wtimeout(board, timeout_val); | ||
| 172 | break; | ||
| 173 | case 'c': | ||
| 174 | memset(map, deadcell, width*height); | ||
| 175 | break; | ||
| 176 | case 'r': | ||
| 177 | werase(stat_bar); | ||
| 178 | stat_bar_print(stat_bar, "Rule int - Current: %d - Default: 6152 - Max: 262143", RULE); | ||
| 179 | wrefresh(stat_bar); | ||
| 180 | { | ||
| 181 | int old_rule = RULE; | ||
| 182 | RULE = read_num(entry, 0, 262143); | ||
| 183 | if (RULE == 0) { | ||
| 184 | RULE = old_rule; | ||
| 185 | } | ||
| 186 | } | ||
| 187 | werase(stat_bar); | ||
| 188 | werase(entry); | ||
| 189 | break; | ||
| 190 | case 'h': | ||
| 191 | wtimeout(board, -1); | ||
| 192 | foreach(werase, 3, stdscr, board, stat_bar); | ||
| 193 | stat_bar_print(stat_bar, "Press any key to return"); | ||
| 194 | print_help(board); | ||
| 195 | foreach(wnoutrefresh, 3, stdscr, board, stat_bar); | ||
| 196 | doupdate(); | ||
| 197 | getch(); | ||
| 198 | wtimeout(board, timeout_val); | ||
| 199 | break; | ||
| 200 | case 'w': | ||
| 201 | wtimeout(board, -1); | ||
| 202 | foreach(werase, 4, stdscr, board, stat_bar, entry); | ||
| 203 | stat_bar_print(stat_bar, "Press any key to return"); | ||
| 204 | print_copying_warranty(board); | ||
| 205 | foreach(wnoutrefresh, 3, stdscr, entry, stat_bar); | ||
| 206 | doupdate(); | ||
| 207 | getch(); | ||
| 208 | wtimeout(board, timeout_val); | ||
| 209 | break; | ||
| 210 | case CTRL('r'): | ||
| 211 | foreach(werase, 4, stdscr, board, stat_bar, entry); | ||
| 212 | stat_bar_print(stat_bar, "Click Cancel to exit or Done to exit and save rule"); | ||
| 213 | wrefresh(stat_bar); | ||
| 214 | wrefresh(rule_entry_box); | ||
| 215 | ruleint = fancy_rules(rule_entry, RULE, timeout_val); | ||
| 216 | if (ruleint != -1) { | ||
| 217 | RULE = ruleint; | ||
| 218 | } | ||
| 219 | break; | ||
| 220 | default: | ||
| 221 | // Nothing | ||
| 222 | break; | ||
| 223 | } | ||
| 224 | } else { // ie PLAYING == TRUE | ||
| 225 | if (ch == '\n') { | ||
| 226 | playing = FALSE; | ||
| 227 | wtimeout(board, -1); | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | // Commands that don't depend on state | ||
| 232 | if (ch == ',') { | ||
| 233 | delaymax -= (delaymax > 1 ? 1 : 0); | ||
| 234 | } else if (ch == '.') { | ||
| 235 | delaymax += (delaymax < 20 ? 1 : 0); | ||
| 236 | } else if (ch== CTRL('l')) { | ||
| 237 | foreach(wclear, 4, stdscr, entry, stat_bar, board); | ||
| 238 | } | ||
| 239 | for (int i = 0; i < height; ++i) { | ||
| 240 | mvwaddnstr(board, i, 0, map + (i * width), width); | ||
| 241 | } | ||
| 242 | mvwchgat(board, y, x, 1, A_STANDOUT, COLOR_PAIR(0), NULL); | ||
| 243 | stat_bar_print(stat_bar, "(%d, %d)\t\tGeneration: %d\t\tDelay Time: %d", x, y, generation, delaymax); | ||
| 244 | foreach(wnoutrefresh, 4, stdscr, board, entry, stat_bar); | ||
| 245 | doupdate(); | ||
| 246 | if (playing == TRUE) { | ||
| 247 | delay++; | ||
| 248 | if (delay >= delaymax) { | ||
| 249 | delay = 0; | ||
| 250 | generation++; | ||
| 251 | update_map(map, width, height, livecell, deadcell, RULE); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | ch = wgetch(board); | ||
| 255 | ch = tolower(ch); | ||
| 256 | } | ||
| 257 | foreach(werase, 6, stdscr, board, stat_bar, entry, rule_entry, rule_entry_box); | ||
| 258 | foreach(delwin, 5, entry, stat_bar, board, rule_entry, rule_entry_box); | ||
| 259 | board = stat_bar = entry = rule_entry = rule_entry_box = NULL; | ||
| 260 | endwin(); | ||
| 261 | delwin(stdscr); | ||
| 262 | free(map); | ||
| 263 | map = NULL; | ||
| 264 | exit(EXIT_SUCCESS); | ||
| 265 | } | ||
diff --git a/src/life.ggo b/src/life.ggo new file mode 100644 index 0000000..3e85b6b --- /dev/null +++ b/src/life.ggo | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | args "--file-name=cmdline-life" | ||
| 2 | option "ruleint" r "Specify rule-int on command line" typestr="rule" default="6152" int optional | ||
| 3 | option "delay" d "Specify delay time" details="Specify delay time, multiplied by 10ms" int optional | ||
| 4 | section "Dimensions" | ||
| 5 | option "width" W "Specify width" int optional | ||
| 6 | option "height" H "Specify height" int optional | ||
| 7 | option "maximize" m "Maximize dimensions for terminal" optional details="If specified, cancels out height and/or width options" | ||
| 8 | section "Characters" | ||
| 9 | option "live" L "Character for a live cell" typestr="CH" string optional | ||
| 10 | option "dead" D "Character for a dead cell" typestr="CH" string optional | ||
diff --git a/src/life.h b/src/life.h new file mode 100644 index 0000000..bad4815 --- /dev/null +++ b/src/life.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | * An arbitrary cellular automata model using ncurses | ||
| 4 | * Copyright (C) 2018 Aiden Woodruff | ||
| 5 | |||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 3 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | |||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | |||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | */ | ||
| 20 | |||
| 21 | // C standard libraries | ||
| 22 | #include <stdlib.h> | ||
| 23 | #include <string.h> | ||
| 24 | #include <stdio.h> | ||
| 25 | #include <time.h> | ||
| 26 | #include <ctype.h> | ||
| 27 | |||
| 28 | // Module Libraries | ||
| 29 | #include <ncurses.h> | ||
| 30 | |||
| 31 | // Project Libraries | ||
| 32 | #include "life-macros.h" | ||
| 33 | #include "cmdline-life.h" | ||
| 34 | #include "updatemap.h" | ||
| 35 | #include "menus.h" | ||
diff --git a/src/menus.c b/src/menus.c new file mode 100644 index 0000000..7c2abd8 --- /dev/null +++ b/src/menus.c | |||
| @@ -0,0 +1,176 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | * An arbitrary cellular automata model using ncurses | ||
| 4 | * Copyright (C) 2018 Aiden Woodruff | ||
| 5 | |||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 3 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | |||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | |||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | */ | ||
| 20 | #include "menus.h" | ||
| 21 | |||
| 22 | int print_copying_warranty (WINDOW * win) { | ||
| 23 | const char * WARRANTY = " THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.\n EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.\n THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.\n SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION."; | ||
| 24 | return waddstr(win, WARRANTY); | ||
| 25 | } | ||
| 26 | |||
| 27 | int print_help (WINDOW * win) { | ||
| 28 | if (waddstr(win, "Arrow keys - Motion\n") == OK && | ||
| 29 | waddstr(win, "Space - Flip cell (if it's alive, to dead, and vice versa)\n") == OK && | ||
| 30 | waddstr(win, "Enter - Pause/Play\n") == OK && | ||
| 31 | waddstr(win, "\tN.B. - Many keys can only be used while paused.\n") == OK && | ||
| 32 | waddstr(win, ", - Lower delay time\n") == OK && | ||
| 33 | waddstr(win, ". - Increase delay time\n") == OK && | ||
| 34 | waddstr(win, "R - Input a rule-int\n") == OK && | ||
| 35 | waddstr(win, "Ctrl+R - Open the fancy rule menu\n") == OK && | ||
| 36 | waddstr(win, "Ctrl+L - Redraw screen\n") == OK && | ||
| 37 | waddstr(win, "W - Show warranty\n") == OK && | ||
| 38 | waddstr(win, "V - Print version\n") == OK) { | ||
| 39 | return OK; | ||
| 40 | } else { | ||
| 41 | return ERR; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | int read_num (WINDOW * win, int min, int max) { | ||
| 46 | int ret = 0; | ||
| 47 | werase(win); | ||
| 48 | int width = getmaxx(win); | ||
| 49 | char * text = (char*) malloc((size_t)(width + 1)); | ||
| 50 | memset(text, 0, (size_t)(width + 1)); | ||
| 51 | curs_set(1); | ||
| 52 | echo(); | ||
| 53 | wgetnstr(win, text, (size_t)(width + 1)); | ||
| 54 | ret = (int) strtol((const char *) text, NULL, 10); | ||
| 55 | if (!(ret >= min && ret <= max)) { | ||
| 56 | ret = 0; | ||
| 57 | } | ||
| 58 | noecho(); | ||
| 59 | curs_set(0); | ||
| 60 | free(text); | ||
| 61 | return ret; | ||
| 62 | } | ||
| 63 | |||
| 64 | // Fancy rule menu, returns new rules or -1 on fail | ||
| 65 | int fancy_rules (WINDOW * win, int ruleint, int speed) { | ||
| 66 | int done = FALSE; | ||
| 67 | int cursor = 0; | ||
| 68 | int ch = 0; | ||
| 69 | wtimeout(win, speed); | ||
| 70 | while (done == FALSE && ch != 'q') { | ||
| 71 | werase(win); | ||
| 72 | waddstr(win, "Press space to toggle buttons\n"); | ||
| 73 | wprintw(win, "Rule int: %d\n", ruleint); | ||
| 74 | waddstr(win, "B012345678/S012345678\n"); | ||
| 75 | waddch(win, 'B'); | ||
| 76 | for (int i = 0; i < 9; i++) { | ||
| 77 | if (cursor == i) { | ||
| 78 | wstandout(win); | ||
| 79 | } | ||
| 80 | waddch(win, has(ruleint, 1 << i) ? '1' : '0'); | ||
| 81 | if (cursor == i) { | ||
| 82 | wstandend(win); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | waddstr(win, "/S"); | ||
| 86 | for (int i = 9; i < 18; i++) { | ||
| 87 | if (cursor == i) { | ||
| 88 | wstandout(win); | ||
| 89 | } | ||
| 90 | waddch(win, has(ruleint, 1 << i) ? '1' : '0'); | ||
| 91 | if (cursor == i) { | ||
| 92 | wstandend(win); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | waddstr(win, "\n"); | ||
| 96 | if (cursor == 18) { | ||
| 97 | wstandout(win); | ||
| 98 | waddstr(win, "Cancel"); | ||
| 99 | wstandend(win); | ||
| 100 | } else { | ||
| 101 | waddstr(win, "Cancel"); | ||
| 102 | } | ||
| 103 | waddstr(win, " "); | ||
| 104 | if (cursor == 19) { | ||
| 105 | wstandout(win); | ||
| 106 | waddstr(win, "Default"); | ||
| 107 | wstandend(win); | ||
| 108 | } else { | ||
| 109 | waddstr(win, "Default"); | ||
| 110 | } | ||
| 111 | waddstr(win, " "); | ||
| 112 | if (cursor == 20) { | ||
| 113 | wstandout(win); | ||
| 114 | waddstr(win, "Done"); | ||
| 115 | wstandend(win); | ||
| 116 | } else { | ||
| 117 | waddstr(win, "Done"); | ||
| 118 | } | ||
| 119 | wrefresh(win); | ||
| 120 | if (ch == KEY_LEFT) { | ||
| 121 | if (cursor > 0 && cursor < 18) { | ||
| 122 | cursor--; | ||
| 123 | } else if (cursor > 18) { | ||
| 124 | cursor--; | ||
| 125 | } | ||
| 126 | } else if (ch == KEY_RIGHT) { | ||
| 127 | if (cursor < 17) { | ||
| 128 | cursor++; | ||
| 129 | } else if (cursor > 17 && cursor < 20) { | ||
| 130 | cursor++; | ||
| 131 | } | ||
| 132 | } else if (ch == KEY_UP || ch == KEY_DOWN) { | ||
| 133 | if (cursor > 17) { | ||
| 134 | switch (cursor) { | ||
| 135 | case 18: | ||
| 136 | cursor = 0; | ||
| 137 | break; | ||
| 138 | case 19: | ||
| 139 | cursor = 6; | ||
| 140 | break; | ||
| 141 | case 20: | ||
| 142 | cursor = 13; | ||
| 143 | break; | ||
| 144 | } | ||
| 145 | } else { | ||
| 146 | if (cursor > -1 && cursor < 6) { | ||
| 147 | cursor = 18; | ||
| 148 | } else if (cursor > 5 && cursor < 13) { | ||
| 149 | cursor = 19; | ||
| 150 | } else if (cursor > 12) { | ||
| 151 | cursor = 20; | ||
| 152 | } | ||
| 153 | } | ||
| 154 | } else if (ch == ' ' || ch == '\n') { | ||
| 155 | switch (cursor) { | ||
| 156 | case 18: | ||
| 157 | ruleint = -1; | ||
| 158 | done = TRUE; | ||
| 159 | break; | ||
| 160 | case 19: | ||
| 161 | ruleint = 6152; | ||
| 162 | break; | ||
| 163 | case 20: | ||
| 164 | done = TRUE; | ||
| 165 | break; | ||
| 166 | default: | ||
| 167 | ruleint ^= 1 << cursor; | ||
| 168 | break; | ||
| 169 | } | ||
| 170 | } | ||
| 171 | if (done == FALSE) { | ||
| 172 | ch = wgetch(win); | ||
| 173 | } | ||
| 174 | } | ||
| 175 | return ruleint; | ||
| 176 | } | ||
diff --git a/src/menus.h b/src/menus.h new file mode 100644 index 0000000..26da8f5 --- /dev/null +++ b/src/menus.h | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | * An arbitrary cellular automata model using ncurses | ||
| 4 | * Copyright (C) 2018 Aiden Woodruff | ||
| 5 | |||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 3 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | |||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | |||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | */ | ||
| 20 | |||
| 21 | #include <string.h> | ||
| 22 | #include <stdlib.h> | ||
| 23 | |||
| 24 | #include <ncurses.h> | ||
| 25 | |||
| 26 | #include "life-macros.h" | ||
| 27 | |||
| 28 | #ifndef LIFE_MENUS_H_ | ||
| 29 | #define LIFE_MENUS_H_ | ||
| 30 | |||
| 31 | int print_copying_warranty (WINDOW * win); | ||
| 32 | int print_help (WINDOW * win); | ||
| 33 | int read_num (WINDOW * win, int min, int max); | ||
| 34 | int fancy_rules (WINDOW * win, int ruleint, int speed); | ||
| 35 | |||
| 36 | #endif // LIFE_MENUS_H_ | ||
diff --git a/src/updatemap.c b/src/updatemap.c new file mode 100644 index 0000000..539def8 --- /dev/null +++ b/src/updatemap.c | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | * An arbitrary cellular automata model using ncurses | ||
| 4 | * Copyright (C) 2018 Aiden Woodruff | ||
| 5 | |||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 3 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | |||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | |||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | */ | ||
| 20 | #include "updatemap.h" | ||
| 21 | |||
| 22 | char * update_map (char * base_map, const int width, const int height, char livecell, char deadcell, const unsigned int ruleint) { | ||
| 23 | char * intermap = (char*) strndup(base_map, width * height); | ||
| 24 | for (int i = 0, x = 0, y = 0, surround = 0; i < width*height; i++, surround = 0) { | ||
| 25 | x = i % width; | ||
| 26 | y = (i - x) / width; | ||
| 27 | /* | ||
| 28 | Where i is the current cell: | ||
| 29 | A1 | A2 | A3 | ||
| 30 | ----|----|---- | ||
| 31 | B1 | i | B3 | ||
| 32 | ----|----|---- | ||
| 33 | C1 | C2 | C3 | ||
| 34 | */ | ||
| 35 | if (x > 0) { | ||
| 36 | if (base_map[i-1] == livecell) surround++; // B1 | ||
| 37 | if (y > 0) { | ||
| 38 | if (base_map[i-width-1] == livecell) surround++; // A1 | ||
| 39 | } | ||
| 40 | if (y < height - 1) { | ||
| 41 | if (base_map[i-1+width] == livecell) surround++; // C1 | ||
| 42 | } | ||
| 43 | } | ||
| 44 | if (x < width - 1) { | ||
| 45 | if (base_map[i+1] == livecell) surround++; // B3 | ||
| 46 | if (y > 0) { | ||
| 47 | if (base_map[i+1-width] == livecell) surround++; // A3 | ||
| 48 | } | ||
| 49 | if (y < height - 1) { | ||
| 50 | if (base_map[i + 1 + width] == livecell) surround++; // C3 | ||
| 51 | } | ||
| 52 | } | ||
| 53 | if (y > 0) { | ||
| 54 | if (base_map[i - width] == livecell) surround++; | ||
| 55 | } | ||
| 56 | if (y < height - 1) { | ||
| 57 | if (base_map[i + width] == livecell) surround++; | ||
| 58 | } | ||
| 59 | if (base_map[i] == deadcell) { | ||
| 60 | if (has(ruleint, 1 << surround)) { | ||
| 61 | intermap[i] = livecell; | ||
| 62 | } | ||
| 63 | } else if (base_map[i] == livecell) { | ||
| 64 | if (!has(ruleint, 1 << (surround + 9))) { | ||
| 65 | intermap[i] = deadcell; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | // Rewrite map | ||
| 71 | strcpy(base_map, intermap); | ||
| 72 | free(intermap); | ||
| 73 | return base_map; | ||
| 74 | } | ||
diff --git a/src/updatemap.h b/src/updatemap.h new file mode 100644 index 0000000..6773998 --- /dev/null +++ b/src/updatemap.h | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | * An arbitrary cellular automata model using ncurses | ||
| 4 | * Copyright (C) 2018 Aiden Woodruff | ||
| 5 | |||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 3 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | |||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | |||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | */ | ||
| 20 | #include <stdlib.h> | ||
| 21 | #include <string.h> | ||
| 22 | |||
| 23 | #include "life-macros.h" | ||
| 24 | |||
| 25 | #ifndef LIFE_UPDATEMAP_H_ | ||
| 26 | #define LIFE_UPDATEMAP_H_ | ||
| 27 | |||
| 28 | char * update_map (char * base_map, const int width, const int height, char livecell, char deadcell, const unsigned int ruleint); | ||
| 29 | |||
| 30 | #endif // LIFE_UPDATEMAP_H_ | ||
