aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2014-10-13 18:55:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 20:18:26 -0400
commitd295634e965ecacdb44c6760b3ca4eae08812715 (patch)
tree6ec1c99bb6ca6e80be8e51c0371de6346fb702f7 /lib
parent3db2e9cdc085144e243495137273e2318c53a82f (diff)
lib / string_helpers: move documentation to c-file
The introduced function string_escape_mem() is a kind of opposite to string_unescape. We have several users of such functionality each of them created custom implementation. The series contains clean up of test suite, adding new call, and switching few users to use it via %*pE specifier. Test suite covers all of existing and most of potential use cases. This patch (of 11): The documentation of API belongs to c-file. This patch moves it accordingly. There is no functional change. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: "John W . Linville" <linville@tuxdriver.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/string_helpers.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 29033f319aea..74ec60469640 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -168,6 +168,44 @@ static bool unescape_special(char **src, char **dst)
168 return true; 168 return true;
169} 169}
170 170
171/**
172 * string_unescape - unquote characters in the given string
173 * @src: source buffer (escaped)
174 * @dst: destination buffer (unescaped)
175 * @size: size of the destination buffer (0 to unlimit)
176 * @flags: combination of the flags (bitwise OR):
177 * %UNESCAPE_SPACE:
178 * '\f' - form feed
179 * '\n' - new line
180 * '\r' - carriage return
181 * '\t' - horizontal tab
182 * '\v' - vertical tab
183 * %UNESCAPE_OCTAL:
184 * '\NNN' - byte with octal value NNN (1 to 3 digits)
185 * %UNESCAPE_HEX:
186 * '\xHH' - byte with hexadecimal value HH (1 to 2 digits)
187 * %UNESCAPE_SPECIAL:
188 * '\"' - double quote
189 * '\\' - backslash
190 * '\a' - alert (BEL)
191 * '\e' - escape
192 * %UNESCAPE_ANY:
193 * all previous together
194 *
195 * Description:
196 * The function unquotes characters in the given string.
197 *
198 * Because the size of the output will be the same as or less than the size of
199 * the input, the transformation may be performed in place.
200 *
201 * Caller must provide valid source and destination pointers. Be aware that
202 * destination buffer will always be NULL-terminated. Source string must be
203 * NULL-terminated as well.
204 *
205 * Return:
206 * The amount of the characters processed to the destination buffer excluding
207 * trailing '\0' is returned.
208 */
171int string_unescape(char *src, char *dst, size_t size, unsigned int flags) 209int string_unescape(char *src, char *dst, size_t size, unsigned int flags)
172{ 210{
173 char *out = dst; 211 char *out = dst;