From da665eb04a793552ed32ed8944dffbeb5220d7ae Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Mon, 28 Oct 2013 19:37:30 -0700 Subject: Allow OpenGL support to be disabled at compile time. Move generic utility functions out of config.c --- config.c | 68 +++------------------------------------------------------------- 1 file changed, 3 insertions(+), 65 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index bff974d..3c557ea 100644 --- a/config.c +++ b/config.c @@ -1,80 +1,18 @@ /* Copyright 2013 Michael Pavone - This file is part of BlastEm. + This file is part of BlastEm. BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. */ #include "tern.h" +#include "util.h" #include #include #include -#include -#include #include #include #include -char * alloc_concat(char * first, char * second) -{ - int flen = strlen(first); - int slen = strlen(second); - char * ret = malloc(flen + slen + 1); - memcpy(ret, first, flen); - memcpy(ret+flen, second, slen+1); - return ret; -} - -char * alloc_concat_m(int num_parts, char ** parts) -{ - int total = 0; - for (int i = 0; i < num_parts; i++) { - total += strlen(parts[i]); - } - char * ret = malloc(total + 1); - *ret = 0; - for (int i = 0; i < num_parts; i++) { - strcat(ret, parts[i]); - } - return ret; -} - -long file_size(FILE * f) -{ - fseek(f, 0, SEEK_END); - long fsize = ftell(f); - fseek(f, 0, SEEK_SET); - return fsize; -} - -char * strip_ws(char * text) -{ - while (*text && (!isprint(*text) || isblank(*text))) - { - text++; - } - char * ret = text; - text = ret + strlen(ret) - 1; - while (text > ret && (!isprint(*text) || isblank(*text))) - { - *text = 0; - text--; - } - return ret; -} - -char * split_keyval(char * text) -{ - while (*text && !isblank(*text)) - { - text++; - } - if (!*text) { - return text; - } - *text = 0; - return text+1; -} - #define MAX_NEST 30 //way more than I'll ever need tern_node * parse_config(char * config_data) @@ -201,7 +139,7 @@ tern_node * load_config(char * expath) } free(path); load_in_app_dir: - + linktext = readlink_alloc("/proc/self/exe"); if (!linktext) { goto link_prob; -- cgit v1.2.3