Escape and Unescape Illegal Characters in URIs

/*
**	(c) COPYRIGHT CERN 1994.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
This module have been spawned from HTParse, as it then can be used in utility programs without loading a whole bunch of the library code. It contains functions for escaping and unescaping a URI for reserved characters in URIs.

This module is implemented by RoverEscape.c, and it is a part of the Library of Common Code.

#ifndef ROVERESCAPE_H
#define ROVERESCAPE_H

Encode Unacceptable Characters using %xy

This funtion takes a string containing any sequence of ASCII characters, and returns a malloced string containing the same infromation but with all "unacceptable" characters represented in the form %xy where x and y are two hex digits.
extern char *RoverEscape(char *str, unsigned char mask);
The following are valid mask values. The terms are the BNF names in the URI document.
#define URL_XALPHAS	(unsigned char) 1
#define URL_XPALPHAS	(unsigned char) 2
#define URL_PATH	(unsigned char) 4
#define TCL_ESC		(unsigned char) 8
#define SH_ESC		(unsigned char) 16

Decode %xy Escaped Characters

This function takes a pointer to a string in which character smay have been encoded in %xy form, where xy is the acsii hex code for character 16x+y. The string is converted in place, as it will never grow.
extern char *RoverUnescape(char *str);

extern void bartospace(char *str);
extern char *RoverEscapeShellCmd(char *str);
extern char *RoverEscapeTcl(char *str);
extern int ind(char *str, char ch);

#endif	/* ROVERESCAPE_H */
End of RoverEscape Module