Ported send_command to C (man, i suck at this)