main()
{
    while(1)
    {
        foo(); //call foo
        bar(); //have a drink while waiting
        wd();  //feed dog
    }
}

foo()
{
    static char state = 0;

    switch (state)
    {
    case 0:
        nbrToSend = sprintf(buffer, [string of 255 chars]);
        state++;'
    case 1:
        if (flush()) //returns true when flushed
            state++;
    case 2:
        nbrToSend = sprintf(buffer, [string of 255 chars]);
        state++;'
    case 3:
        if (flush()) //returns true when flushed
            state++;
    default:
        state = 0;
    }
}
