Exemple #1
0
/*
 * vispath --
 *	strsvis(3) encodes path, which must not be longer than MAXPATHLEN
 *	characters long, and returns a pointer to a static buffer containing
 *	the result.
 */
char *
vispath(const char *path)
{
	static const char extra[] = { ' ', '\t', '\n', '\\', '#', '\0' };
	static const char extra_glob[] = { ' ', '\t', '\n', '\\', '#', '*',
	    '?', '[', '\0' };
	static char pathbuf[4*MAXPATHLEN + 1];

	if (flavor == F_NETBSD6)
		strsvis(pathbuf, path, VIS_CSTYLE, extra);
	else
		strsvis(pathbuf, path, VIS_OCTAL, extra_glob);
	return pathbuf;
}
Exemple #2
0
/*
 * vispath --
 *	strsvis(3) encodes path, which must not be longer than MAXPATHLEN
 *	characters long, and returns a pointer to a static buffer containing
 *	the result.
 */
char *
vispath(const char *path)
{
	const char extra[] = { ' ', '\t', '\n', '\\', '#', '\0' };
	static char pathbuf[4*MAXPATHLEN + 1];

	strsvis(pathbuf, path, VIS_CSTYLE, extra);
	return(pathbuf);
}
Exemple #3
0
/*
 * strvis, strvisx - visually encode characters from src into dst
 *
 *	Dst must be 4 times the size of src to account for possible
 *	expansion.  The length of dst, not including the trailing NULL,
 *	is returned.
 *
 *	Strvisx encodes exactly len bytes from src into dst.
 *	This is useful for encoding a block of data.
 */
int
strvis(char *dst, const char *src, int flag)
{
	char *extra = NULL;
	int rv;

	MAKEEXTRALIST(flag, extra, "");
	if (!extra) {
		*dst = '\0';		/* can't create extra, return "" */
		return 0;
	}
	rv = strsvis(dst, src, flag, extra);
	free(extra);
	return rv;
}
Exemple #4
0
/*
 * vispath --
 *	strsvis(3) encodes path, which must not be longer than MAXPATHLEN
 *	characters long, and returns a pointer to a static buffer containing
 *	the result.
 */
char *
vispath(const char *path)
{
	const char extra[] = { ' ', '\t', '\n', '\\', '#',
#ifdef notyet
	    /*
	     * We don't encode the globbing characters yet, because they
	     * get encoded as \c and strunvis fails to decode them
	     */
	    '*', '?', '[',
#endif
	    '\0' };
	static char pathbuf[4*MAXPATHLEN + 1];

	strsvis(pathbuf, path, VIS_CSTYLE, extra);
	return(pathbuf);
}