summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-10-28 19:37:30 -0700
committerMike Pavone <pavone@retrodev.com>2013-10-28 19:37:30 -0700
commitda665eb04a793552ed32ed8944dffbeb5220d7ae (patch)
tree5532dd1d7f8e0d4f43d469f7823a5a3d9ccbfc1c /config.c
parent070b44e5440b966f911ee974490c7c99c91ec3d1 (diff)
Allow OpenGL support to be disabled at compile time. Move generic utility functions out of config.c
Diffstat (limited to 'config.c')
-rw-r--r--config.c68
1 files changed, 3 insertions, 65 deletions
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdarg.h>
-#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-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;