uint8_t *strncpyr(uint8_t *dest, const uint8_t *src, int8_t r, int32_t n)
{
int32_t pos = 0;
for(pos = 0; ((src[pos] != '\0') && (src[pos] != r) && (pos < n)); pos++)
{
dest[pos] = src[pos];
}
dest[pos] = 0;
return dest;
}