use a switch case, with each case being one potential way that the data is when the function is entered, or 
another one exits.

while(!done)
{
	switch(status)
	{
	case chunk header:
	case after chunk header:
	case no chunk header:
	}
}