STRING_ENQUOTE(3)

NAME
string_enquote, string_dequote - doubly quoted string conversion routines

LIBRARY
PDEL Library (libpdel, -lpdel)

SYNOPSIS
#include <stdio.h>
#include <pdel/util/string_quote.h>
char *
string_enquote(const char *str, const char *mtype);
char *
string_dequote(FILE *input, const char *mtype);

DESCRIPTION
These routines handle converting strings to and from a printable form, namely, doubly-quoted strings with C backslash escapes.

string_enquote() encodes the string str using only printable characters and returns the result, which will begin and end with a double quote character. The returned string is allocated with typed_mem(3) type mtype and must be freed by the caller.

string_dequote() reads and parses a doubly-quoted string from input and returns the result, allocated with typed_mem(3) type mtype. The caller must free the returned string. The input stream is assumed to be pointing at the character after the opening double quote character. Upon return, it will be pointing to the character after the closing double quote character.

string_dequote() parses in a liberal manner and does not detect parse errors. Any malformed backslash escapes are passed through unchanged. In other words, if string_dequote() is passed a string that was produced by string_enquote(), it guarantees to reproduce the original string; however, it will successfully parse any input string.

RETURN VALUES
If there was a system error, string_enquote() and string_dequote() return NULL with errno set to the appropriate value. string_dequote() also returns NULL if the end of file is encountered before the closing quote character, in which case errno is set to EINVAL.

SEE ALSO
string_fp(3), libpdel(3), typed_mem(3)

HISTORY
The PDEL library was developed at Packet Design, LLC. http://www.packetdesign.com/

AUTHORS
Archie Cobbs <archie@freebsd.org>