MCPcopy Create free account
hub / github.com/acl-dev/acl / header_token

Function header_token

lib_acl_cpp/src/mime/internal/header_token.cpp:110–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108/* header_token - parse out the next item in a message header */
109
110ssize_t header_token(HEADER_TOKEN *token, ssize_t token_len,
111 ACL_VSTRING *token_buffer, const char **ptr,
112 const char *user_specials, int user_terminator)
113{
114 ssize_t comment_level;
115 const unsigned char *cp;
116 ssize_t len;
117 int ch;
118 ssize_t tok_count;
119 ssize_t n;
120
121 /*
122 * Initialize.
123 */
124 ACL_VSTRING_RESET(token_buffer);
125 cp = CU_CHAR_PTR(*ptr);
126 tok_count = 0;
127 if (user_specials == 0)
128 user_specials = LEX_822_SPECIALS;
129
130 /*
131 * Main parsing loop.
132 *
133 * XXX What was the reason to continue parsing when user_terminator is
134 * specified? Perhaps this was needed at some intermediate stage of
135 * development?
136 */
137 while ((ch = *cp) != 0 && (user_terminator != 0 || tok_count < token_len)) {
138 cp++;
139
140 /*
141 * Skip RFC 822 linear white space.
142 */
143 if (IS_SPACE_TAB_CR_LF(ch))
144 continue;
145
146 /*
147 * Terminator.
148 */
149 if (ch == user_terminator)
150 break;
151
152 /*
153 * Skip RFC 822 comment.
154 */
155 if (ch == '(') {
156 comment_level = 1;
157 while ((ch = *cp) != 0) {
158 cp++;
159 if (ch == '(') { /* comments can nest! */
160 comment_level++;
161 } else if (ch == ')') {
162 if (--comment_level == 0)
163 break;
164 } else if (ch == '\\') {
165 if ((ch = *cp) == 0)
166 break;
167 cp++;

Callers

nothing calls this directly

Calls 1

acl_vstring_truncateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…