Add a configure check for strtok() and add locks around its use