(void) strcpy(res, file); (void) strcpy(res + (p - file), ext);
(void) strlcpy(res, file, len); (void) strlcpy(res + (p - file), ext, len - (p - file));
extendfile(path, ext)	char *path;	char *ext;{	char *file;	char *res;	char *p;	if ((file = strrchr(path, '/')) == NULL)		file = path;	else		file++;	res = alloc(strlen(file) + strlen(ext) + 1);	if (res == NULL) {		fprintf(stderr, "could not allocate memory\n");		exit(1);	}	p = strrchr(file, '.');	if (p == NULL)		p = file + strlen(file);	(void) strcpy(res, file);	(void) strcpy(res + (p - file), ext);	return (res);}