Include stdlib.h, string.h or strings.h, and xalloc.h. Use strip_trailing_slashes rather than open-coding it.