Move compatibility code into a separate subdirectory src/port/

Also add the code for strlwr() even though it is not used (for
consistency).