globally it looks better
a couple of stylistic remarks, but you need to go further for not using errorlevel inside the function and its helper
perhaps, it's worthwhile to split the patch in two:
* first one to no longer use error level internally, adapt list_directory prototype... (in the details, it's fine to use return errorlevel = ERROR_* while parsing the arguments in case of error, but when this is done all the rest of the code should use only the return_code (and set errorlevel when exiting WCMD_dir)) * the second one to plug in the ctrl-c handling and breaking from the various loops