view src/init.c @ 4:90cd3d9a6ca3

Moved function array declaration, modified the ftoa function so it does not return trailing 0s Also added a return value to sGet though that seems to break some things... The errors for this were very odd, see TODO notes in std.c and init.c
author Jonathan Pevarnek <pevarnj@gmail.com>
date Wed, 02 Mar 2011 00:37:32 -0500
parents 0aa0ad9e1cc3
children 348c59c36703
line wrap: on
line source

/*
 * This is where everything starts
 */

#include <std.h>
#include <operations.h>
#include <stack.h>

void dumpBuffer(char *a, int b)
{
	int i;
	for(i = 0; i < b; i++) {
		int foo = (int) a[i];
		char c[10];
		itoa(foo, c);
		sPrint(c);
		sPrint("\n");
	}
}

void start(u64 __memsize)
{
	/*
	int foo;
	char bar[20];
	char string[20] = "This is a test";
	dumpBuffer(string, 10);
	sPrint("Please enter an operation: ");
	foo = getline(string, 10);
	itoa(foo, bar);
	sPrint(bar);
	sPrint("\n");
	dumpBuffer(string, 10);
	sPrint("Please enter a second operation: ");
	sGet(string, 4);
	dumpBuffer(string, 10);
	*/

	struct Stack theStack;
	struct Stack *stack = &theStack;
	initStack(stack);
	while(1) {
		int opVal;
		double toStore;
		char input[30];
		sPrint("Please enter an operation or value: ");
		sGet(input, 30);
		opVal = arrayLookup(input, operationNames, MAXOP);
//		opVal = arrayLookup(sGet(input, 30), operationNames, MAXOP); //TODO figure out what is wrong with this...
		if(opVal != MAXOP) {
			(*operation[opVal]) (stack); //call the function array
		} else {
			toStore = atof(input);
			push(stack, toStore);
		}
	}

	for(;;)
		;
}