done something
added 3rd argument: output file

to communicate the URI back to the caller
<string.h> needed for strlen()
unify code
even more code-unification via #defines