Basename helper function in misc.c, also capable of stripping extensions.