diff config.c @ 495:39cad98d2789

Allow OpenGL support to be disabled at compile time. Move generic utility functions out of config.c
author Mike Pavone <pavone@retrodev.com>
date Mon, 28 Oct 2013 19:37:30 -0700
parents 140af5509ce7
children 6fc71114d145
line wrap: on
line diff
--- a/config.c	Sun Oct 27 22:08:02 2013 -0700
+++ b/config.c	Mon Oct 28 19:37:30 2013 -0700
@@ -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 @@
 	}
 	free(path);
 load_in_app_dir:
-	
+
 	linktext = readlink_alloc("/proc/self/exe");
 	if (!linktext) {
 		goto link_prob;