#include "console.h"


void console(char *fmt, ...)
{
	char		newstring[500];								// Holds Our String
	va_list		ap;											// Pointer To List Of Arguments

	if (fmt == NULL)										// If There's No Text
		return;												// Do Nothing

	va_start(ap, fmt);										// Parses The String For Variables
	    vsprintf(newstring, fmt, ap);							// And Converts Symbols To Actual Numbers
	va_end(ap);												// Results Are Stored In Text

	printf("%s\n",newstring);
}


int split(char *orig,char *param,char splitter)
{
	//fill param with everything after splitter
	for (unsigned int i=0;i<strlen(orig);i++)
	{
		if ((orig[i]==splitter))
		{
			//i is terminator
			//fill up to space(i-1+1)
			memcpy(param,orig+(i+1),strlen(orig)-(i));
			//memcpy(orig,orig,i);
			orig[i]=0;
			return true;
		}
	}

	//fills if not filled
//	memcpy(a,orig,strlen(orig));
	return false;
}


void stripfilenamedown(char *filename)
{
	char first[100];
	strcpy(first,filename);
	char second[100]={0};
	char tmp[100]={0};

	while(split(first,second,'\\'));
	{
		strcpy(tmp,first);
		strcpy(first,second);
		strcpy(second,first);
	}
	
	split(second,first,'.');

	strcpy(filename,second);
}
	

