annotate src/lib/strescape.h @ 22636:96e51a11c0aa

lib: Implement t_strsplit_tabescaped_inplace() This is a more efficient version of t_strsplit_tabescaped(), which modifies the input string instead of duplicating it.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sat, 04 Nov 2017 01:39:38 +0200
parents 9af7c7196540
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6410
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 1329
diff changeset
1 #ifndef STRESCAPE_H
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 1329
diff changeset
2 #define STRESCAPE_H
896
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
1329
ae229b7acb4c Mailbox names are now sent through imap-quoter instead of just escaping it.
Timo Sirainen <tss@iki.fi>
parents: 1216
diff changeset
4 #define IS_ESCAPED_CHAR(c) ((c) == '"' || (c) == '\\' || (c) == '\'')
896
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5
1329
ae229b7acb4c Mailbox names are now sent through imap-quoter instead of just escaping it.
Timo Sirainen <tss@iki.fi>
parents: 1216
diff changeset
6 /* escape all '\', '"' and "'" characters */
896
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 const char *str_escape(const char *str);
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 /* remove all '\' characters, append to given string */
903
fd8888f6f037 Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents: 898
diff changeset
10 void str_append_unescaped(string_t *dest, const void *src, size_t src_size);
896
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 /* remove all '\' characters */
1216
3784730cfcd8 str_unescape(): return char*
Timo Sirainen <tss@iki.fi>
parents: 903
diff changeset
13 char *str_unescape(char *str);
896
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14
17112
9735c6fb7e39 liblib: Added str_unescape_next()
Timo Sirainen <tss@iki.fi>
parents: 15068
diff changeset
15 /* Remove all '\' chars from str until '"' is reached and return the unescaped
9735c6fb7e39 liblib: Added str_unescape_next()
Timo Sirainen <tss@iki.fi>
parents: 15068
diff changeset
16 string. *str is updated to point to the character after the '"'. Returns 0
9735c6fb7e39 liblib: Added str_unescape_next()
Timo Sirainen <tss@iki.fi>
parents: 15068
diff changeset
17 if ok, -1 if '"' wasn't found. */
9735c6fb7e39 liblib: Added str_unescape_next()
Timo Sirainen <tss@iki.fi>
parents: 15068
diff changeset
18 int str_unescape_next(const char **str, const char **unescaped_r);
9735c6fb7e39 liblib: Added str_unescape_next()
Timo Sirainen <tss@iki.fi>
parents: 15068
diff changeset
19
9484
5a6fe52a0cfc Added str_append_tabunescaped(). str_tabescape*() now escapes also CR. Added unit tests.
Timo Sirainen <tss@iki.fi>
parents: 9232
diff changeset
20 /* For Dovecot's internal protocols: Escape \001, \t, \r and \n characters
9232
2dcf2f313329 Added str_tabescape*() to write escaped strings to Dovecot's IPC protocols.
Timo Sirainen <tss@iki.fi>
parents: 6410
diff changeset
21 using \001. */
2dcf2f313329 Added str_tabescape*() to write escaped strings to Dovecot's IPC protocols.
Timo Sirainen <tss@iki.fi>
parents: 6410
diff changeset
22 const char *str_tabescape(const char *str);
15068
002e0a120c2a Renamed str_tabescape_write() to str_append_tabescaped()
Timo Sirainen <tss@iki.fi>
parents: 13083
diff changeset
23 void str_append_tabescaped(string_t *dest, const char *src);
20600
9af7c7196540 lib: Add binary-safe tabescape
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 20339
diff changeset
24 void str_append_tabescaped_n(string_t *dest, const unsigned char *src, size_t src_size);
9484
5a6fe52a0cfc Added str_append_tabunescaped(). str_tabescape*() now escapes also CR. Added unit tests.
Timo Sirainen <tss@iki.fi>
parents: 9232
diff changeset
25 void str_append_tabunescaped(string_t *dest, const void *src, size_t src_size);
9516
aad42b172e1a Added str_tabunescape().
Timo Sirainen <tss@iki.fi>
parents: 9484
diff changeset
26 char *str_tabunescape(char *str);
20339
327fcf6d2205 lib: Added t_str_tabunescape()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 17112
diff changeset
27 const char *t_str_tabunescape(const char *str);
9232
2dcf2f313329 Added str_tabescape*() to write escaped strings to Dovecot's IPC protocols.
Timo Sirainen <tss@iki.fi>
parents: 6410
diff changeset
28
13083
e07d2e37053d liblib: Added [tp]_strsplit_tabescaped()
Timo Sirainen <tss@iki.fi>
parents: 9516
diff changeset
29 char **p_strsplit_tabescaped(pool_t pool, const char *str);
e07d2e37053d liblib: Added [tp]_strsplit_tabescaped()
Timo Sirainen <tss@iki.fi>
parents: 9516
diff changeset
30 const char *const *t_strsplit_tabescaped(const char *str);
22636
96e51a11c0aa lib: Implement t_strsplit_tabescaped_inplace()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20600
diff changeset
31 /* Same as t_strsplit_tabescaped(), but the input string is modified and the
96e51a11c0aa lib: Implement t_strsplit_tabescaped_inplace()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20600
diff changeset
32 returned pointers inside the array point to the original string. */
96e51a11c0aa lib: Implement t_strsplit_tabescaped_inplace()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20600
diff changeset
33 const char *const *t_strsplit_tabescaped_inplace(char *str);
13083
e07d2e37053d liblib: Added [tp]_strsplit_tabescaped()
Timo Sirainen <tss@iki.fi>
parents: 9516
diff changeset
34
896
21ffcce83c70 Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 #endif