.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "TSURLPERCENTENCODE" "3ts" "Jan 06, 2024" "9.2" "Apache Traffic Server" .SH NAME TSUrlPercentEncode \- traffic Server URL percent encoding API .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX #include .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B \fI\%TSReturnCode\fP TSUrlPercentEncode(\fI\%TSMBuffer\fP bufp, \fI\%TSMLoc\fP offset, char *dst, size_t dst_size, size_t *length, const unsigned char *map) .UNINDENT .INDENT 0.0 .TP .B \fI\%TSReturnCode\fP TSStringPercentEncode(const char *str, int str_len, char *dst, size_t dst_size, size_t *length, const unsigned char *map) .UNINDENT .INDENT 0.0 .TP .B \fI\%TSReturnCode\fP TSStringPercentDecode(const char *str, size_t str_len, char *dst, size_t dst_size, size_t *length) .UNINDENT .SH DESCRIPTION .sp The URL data structure is a parsed version of a standard internet URL. The Traffic Server URL API provides access to URL data stored in marshal buffers. The URL functions can create, copy, retrieve or delete entire URLs, and retrieve or modify parts of URLs, such as their host, port or scheme information. .sp \fI\%TSUrlPercentEncode()\fP performs percent\-encoding of the URL object, storing the new string in the \fIdst\fP buffer. The \fIlength\fP parameter will be set to the new (encoded) string length, or \fB0\fP if the encoding failed. \fI\%TSStringPercentEncode()\fP is similar but operates on a string. If the optional \fImap\fP parameter is provided (not \fBNULL\fP) , it should be a map of characters to encode. .sp \fI\%TSStringPercentDecode()\fP perform percent\-decoding of the string in the \fIstr\fP buffer, writing to the \fIdst\fP buffer. The source and destination can be the same, in which case the decoded string is written on top of the source string. The decoded string is guaranteed to be no longer than the source string, but will include a terminating null which, if there are no escapes, makes the destination one longer than the source. In practice this means the destination length needs to be bumped up by one to account for the null, and a string can\(aqt be decoded in place if it\(aqs not already null terminated with the length of the destination including the null, but the length of the source \fInot\fP including the null. E.g. .INDENT 0.0 .INDENT 3.5 .sp .EX static char const ORIGINAL[] = \(dqA string without escapes, but null terminated\(dq; char * source = TSstrdup(ORIGINAL); // make it writeable. size_t length; // return value. // sizeof(ORIGINAL) includes the null, so don\(aqt include that in the input. static const size_t N_CHARS = sizeof(ORIGINAL) \- 1; TSReturnCode result = TSStringPercentDecode(source, N_CHARS, source, N_CHARS + 1, &length); ink_assert(length == N_CHARS); .EE .UNINDENT .UNINDENT .SH RETURN VALUES .sp All these APIs returns a \fI\%TSReturnCode\fP, indicating success (\fI\%TS_SUCCESS\fP) or failure (\fI\%TS_ERROR\fP) of the operation. .SH SEE ALSO .sp \fBTSAPI(3ts)\fP, \fBTSUrlCreate(3ts)\fP, \fBTSUrlHostGet(3ts)\fP, \fBTSUrlHostSet(3ts)\fP, \fBTSUrlStringGet(3ts)\fP .SH COPYRIGHT 2024, dev@trafficserver.apache.org .\" Generated by docutils manpage writer. .