diff options
-rw-r--r-- | .gitignore | 81 | ||||
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | src/log.c | 53 | ||||
-rw-r--r-- | src/log.h | 23 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/util.h | 1 |
9 files changed, 184 insertions, 28 deletions
@@ -112,3 +112,84 @@ cmud* data/ design/ mud.conf +# Created by https://www.toptal.com/developers/gitignore/api/autotools,vim +# Edit at https://www.toptal.com/developers/gitignore?templates=autotools,vim + +### Autotools ### +# http://www.gnu.org/software/automake + +Makefile.in +/ar-lib +/mdate-sh +/py-compile +/test-driver +/ylwrap +.deps/ +.dirstamp + +# http://www.gnu.org/software/autoconf + +autom4te.cache +/autoscan.log +/autoscan-*.log +/aclocal.m4 +/compile +/config.cache +/config.guess +/config.h.in +/config.log +/config.status +/config.sub +/configure +/configure.scan +/depcomp +/install-sh +/missing +/stamp-h1 + +# https://www.gnu.org/software/libtool/ + +/ltmain.sh + +# http://www.gnu.org/software/texinfo + +/texinfo.tex + +# http://www.gnu.org/software/m4/ + +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 + +# Generated Makefile +# (meta build system like autotools, +# can automatically generate from config.status script +# (which is called by configure script)) +Makefile + +### Autotools Patch ### + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +# End of https://www.toptal.com/developers/gitignore/api/autotools,vim diff --git a/Makefile b/Makefile deleted file mode 100644 index 7b4075e..0000000 --- a/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -CC=gcc -CFLAGS=-I. -SRCS=src/main.c src/login.c src/server.c src/data.c src/util.c src/game.c -BIN=cmud -LFLAGS=-largon2 -lpthread - -%.o: %.c - $(CC) -c -o $@ $< $(CFLAGS) - -dev: $(SRCS) - $(CC) -o $(BIN)-devel $(SRCS) $(LFLAGS) -g - -main: $(SRCS) - $(CC) -o $(BIN) $(SRCS) $(LFLAGS) $(CFLAGS) - -dist: main - tar czvf $(BIN).tar.gz $(BIN) - -srcdist: clean - tar czvf $(BIN)-src.tar.gz Makefile .gitignore src/ - -clean: - rm -f $(BIN)* - -install: main - -run: dev - ./cmud-devel diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..3061250 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,6 @@ +bin_PROGRAMS = cmud + +cmud_SOURCES = src/data.c src/game.c src/log.c src/login.c src/main.c src/server.c src/util.c +cmud_LDADD = -largon2 -lpthread +cmud_LDFLAGS = $(all_libraries) + @@ -3,3 +3,12 @@ Experimenting with network programming in C by, how else, building a MUD engine. This is a spiritual successor of `~muirrum/hakkardrs`, but that project never really got off the ground. + +## Dependencies +This project requires `argon2`, `pthread`, and your preferred libc. Development +happens on a Gentoo x86 laptop with glibc. + +## Building +Run `make dev` for a development symbols build, and `make main` for a non-debug +symbols build. `make dist` builds a tarball, and `make src` builds an src +tarball. diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..55de648 --- /dev/null +++ b/configure.ac @@ -0,0 +1,9 @@ +AC_INIT([cmud], [0.1]) +AC_CONFIG_SRCDIR(src/main.c) +AC_PROG_CC + +AM_INIT_AUTOMAKE([1.12] foreign [subdir-objects]) +AC_CONFIG_FILES([Makefile]) +AC_CHECK_HEADERS([argon2.h]) + +AC_OUTPUT diff --git a/src/log.c b/src/log.c new file mode 100644 index 0000000..c6e2af2 --- /dev/null +++ b/src/log.c @@ -0,0 +1,53 @@ +/* + * ===================================================================================== + * + * Filename: log.c + * + * Description: Implementations for logging framework + * + * Version: 1.0 + * Created: 10/27/2022 10:02:48 AM + * Revision: none + * Compiler: gcc + * + * Author: Cara Salter (cara@devcara.com) + * Organization: + * + * ===================================================================================== + */ + +/* ##### HEADER FILE INCLUDES ################################################### */ + +#include <stdlib.h> +#include <time.h> + + +/* ##### FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE ##################### */ + + +/* + * === FUNCTION ====================================================================== + * Name: debug + * Description: Outputs debugging information to stdout + * ===================================================================================== + */ +int debug(char msg[]) { + /* :TODO:10/27/2022 11:48:32 AM:: Fix time get */ + + time_t cur_time = time(NULL); + struct tm t = *localtime(&t); + + printf("now: %d-%02d-%02d %02d:%02d:%02d\n", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec); + return 0; +} + + +/* + * === FUNCTION ====================================================================== + * Name: info + * Description: Outputs informational messages to stdout + * ===================================================================================== + */ +int info(char msg[]) { + return 0; +} /* ----- end of function info ----- */ diff --git a/src/log.h b/src/log.h new file mode 100644 index 0000000..cf2fa3e --- /dev/null +++ b/src/log.h @@ -0,0 +1,23 @@ +/* + * ===================================================================================== + * + * Filename: log.h + * + * Description: Header file for logging framework + * + * Version: 1.0 + * Created: 10/27/2022 09:56:57 AM + * Revision: none + * Compiler: gcc + * + * Author: Cara Salter (cara@devcara.com) + * Organization: + * + * ===================================================================================== + */ + + +/* ##### EXPORTED FUNCTION DECLARATIONS ######################################### */ + /* :TODO:10/27/2022 11:48:08 AM:: Sort out other levels */ +int debug(char msg[]); +int info(char msg[]); @@ -2,6 +2,7 @@ * Initializes main game loop and hands off to listeners * */ #include "server.h" +#include "log.h" #include <stdlib.h> #include <stdio.h> @@ -14,6 +15,7 @@ int main() { int err = 0; server_t server = {0}; err = server_listen(&server); + debug("Test"); if (err) { printf("Failed to listen on address"); return err; @@ -18,6 +18,7 @@ #include <ctype.h> #include <string.h> +#include "log.h" char* trimwhitespace(char* str); |