Use strtok_r rather than strtok
Use strlen() rather than harcoded string size. GCC should optimize
this to the hardcoded string size, so the result should be the same
but maybe prevents future mistakes.
replace strncpy() with snprintf() to avoid issues with NULL terminated
strings.