From 2d776fcd61be168e1ff0ff2e4a5e71835e7cea19 Mon Sep 17 00:00:00 2001 From: oroborus Date: Sat, 28 Jun 2008 16:38:35 +0000 Subject: - prekopanie adresarovej struktury, prva cast git-svn-id: http://opensvn.csie.org/tuxanci_ng@77 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/base/main.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 src/base/main.c (limited to 'src/base/main.c') diff --git a/src/base/main.c b/src/base/main.c new file mode 100644 index 0000000..ffebbe0 --- /dev/null +++ b/src/base/main.c @@ -0,0 +1,126 @@ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "base/main.h" +#include "base/tux.h" + +#ifndef PUBLIC_SERVER +#include "client/game.h" +#endif + +#ifdef PUBLIC_SERVER +#include "server/publicServer.h" +#endif + +static int my_argc; +static char **my_argv; + +list_t *listHelp; + +char* getParam(char *s) +{ + int i; + int len; + + len = strlen(s); + + for( i = 1 ; i < my_argc ; i++ ) + { + //printf("%s %s\n", s, my_argv[i]); + + if( strlen(my_argv[i]) < len ) + { + continue; + } + + if( strncmp(s, my_argv[i], len) == 0 ) + { + return strchr(my_argv[i], '=')+1; + } + } + + return NULL; +} + +char* getParamElse(char *s1, char *s2) +{ + char *ret; + ret = getParam(s1); + + if( ret == NULL) + { + return s2; + } + + return ret; +} + +bool_t isParamFlag(char *s) +{ + int i; + + for( i = 0 ; i < my_argc ; i++ ) + { + if( strcmp(s, my_argv[i]) == 0 ) + { + return TRUE; + } + } + + return FALSE; +} + +char *getString(int n) +{ + char str[STR_NUM_SIZE]; + sprintf(str, "%d", n); + return strdup(str); +} + +int* newInt(int x) +{ + int *new; + new = malloc( sizeof(int) ); + *new = x; + return new; +} + +void accessExistFile(const char *s) +{ + if( access(s, F_OK) != 0 ) + { + fprintf(stderr, "File %s not found !\nProgram shutdown !\n", s); + exit(-1); + } +} + +int main(int argc, char *argv[]) +{ + listHelp = newList(); + + srand( (unsigned) time(NULL) ); + + my_argc = argc; + my_argv = argv; +/* + test_space(); + exit(0); +*/ + +#ifndef PUBLIC_SERVER + startGame(); +#endif + +#ifdef PUBLIC_SERVER + startPublicServer(); +#endif + + return 0; +} -- cgit v1.2.3