Annotation of embedaddon/libpdel/util/string_enquote.3, revision 1.1
1.1 ! misho 1: .\" Copyright (c) 2001-2002 Packet Design, LLC.
! 2: .\" All rights reserved.
! 3: .\"
! 4: .\" Subject to the following obligations and disclaimer of warranty,
! 5: .\" use and redistribution of this software, in source or object code
! 6: .\" forms, with or without modifications are expressly permitted by
! 7: .\" Packet Design; provided, however, that:
! 8: .\"
! 9: .\" (i) Any and all reproductions of the source or object code
! 10: .\" must include the copyright notice above and the following
! 11: .\" disclaimer of warranties; and
! 12: .\" (ii) No rights are granted, in any manner or form, to use
! 13: .\" Packet Design trademarks, including the mark "PACKET DESIGN"
! 14: .\" on advertising, endorsements, or otherwise except as such
! 15: .\" appears in the above copyright notice or in the software.
! 16: .\"
! 17: .\" THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
! 18: .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
! 19: .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
! 20: .\" THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
! 21: .\" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
! 22: .\" OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
! 23: .\" OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
! 24: .\" OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
! 25: .\" RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE
! 26: .\" LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
! 27: .\" OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
! 28: .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
! 29: .\" DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
! 30: .\" USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
! 31: .\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 32: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
! 33: .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
! 34: .\" THE POSSIBILITY OF SUCH DAMAGE.
! 35: .\"
! 36: .\" Author: Archie Cobbs <archie@freebsd.org>
! 37: .\"
! 38: .\" $Id: string_enquote.3,v 1.9 2004/06/02 17:24:39 archie Exp $
! 39: .\"
! 40: .Dd April 22, 2002
! 41: .Dt STRING_ENQUOTE 3
! 42: .Os
! 43: .Sh NAME
! 44: .Nm string_enquote ,
! 45: .Nm string_dequote
! 46: .Nd doubly quoted string conversion routines
! 47: .Sh LIBRARY
! 48: PDEL Library (libpdel, \-lpdel)
! 49: .Sh SYNOPSIS
! 50: .In stdio.h
! 51: .In pdel/util/string_quote.h
! 52: .Ft "char *"
! 53: .Fn string_enquote "const char *str" "const char *mtype"
! 54: .Ft "char *"
! 55: .Fn string_dequote "FILE *input" "const char *mtype"
! 56: .Sh DESCRIPTION
! 57: These routines handle converting strings to and from a printable form,
! 58: namely, doubly-quoted strings with C backslash escapes.
! 59: .Pp
! 60: .Fn string_enquote
! 61: encodes the string
! 62: .Fa str
! 63: using only printable characters and returns the result, which will begin
! 64: and end with a double quote character.
! 65: The returned string is allocated with
! 66: .Xr typed_mem 3
! 67: type
! 68: .Fa mtype
! 69: and must be freed by the caller.
! 70: .Pp
! 71: .Fn string_dequote
! 72: reads and parses a doubly-quoted string from
! 73: .Fa input
! 74: and returns the result, allocated with
! 75: .Xr typed_mem 3
! 76: type
! 77: .Fa mtype .
! 78: The caller must free the returned string.
! 79: The input stream is assumed to be pointing at the character after the
! 80: opening double quote character.
! 81: Upon return, it will be pointing to the character after the closing double
! 82: quote character.
! 83: .Pp
! 84: .Fn string_dequote
! 85: parses in a liberal manner and does not detect parse errors.
! 86: Any malformed backslash escapes are passed through unchanged.
! 87: In other words, if
! 88: .Fn string_dequote
! 89: is passed a string that was produced by
! 90: .Fn string_enquote ,
! 91: it guarantees to reproduce the original string;
! 92: however, it will successfully parse any input string.
! 93: .Sh RETURN VALUES
! 94: If there was a system error,
! 95: .Fn string_enquote
! 96: and
! 97: .Fn string_dequote
! 98: return
! 99: .Dv NULL
! 100: with
! 101: .Va errno
! 102: set to the appropriate value.
! 103: .Fn string_dequote
! 104: also returns
! 105: .Dv NULL
! 106: if the end of file is encountered before the closing quote character,
! 107: in which case
! 108: .Va errno
! 109: is set to
! 110: .Er EINVAL .
! 111: .Sh SEE ALSO
! 112: .Xr string_fp 3 ,
! 113: .Xr libpdel 3 ,
! 114: .Xr typed_mem 3
! 115: .Sh HISTORY
! 116: The PDEL library was developed at Packet Design, LLC.
! 117: .Dv "http://www.packetdesign.com/"
! 118: .Sh AUTHORS
! 119: .An Archie Cobbs Aq archie@freebsd.org
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>