MCPcopy Create free account
hub / github.com/apache/httpd / ap_size_list_item

Function ap_size_list_item

server/util.c:1254–1306  ·  view source on GitHub ↗

Size an HTTP header field list item, as separated by a comma. * The return value is a pointer to the beginning of the non-empty list item * within the original string (or NULL if there is none) and the address * of field is shifted to the next non-comma, non-whitespace character. * len is the length of the item excluding any beginning whitespace. */

Source from the content-addressed store, hash-verified

1252 * len is the length of the item excluding any beginning whitespace.
1253 */
1254AP_DECLARE(const char *) ap_size_list_item(const char **field, int *len)
1255{
1256 const unsigned char *ptr = (const unsigned char *)*field;
1257 const unsigned char *token;
1258 int in_qpair, in_qstr, in_com;
1259
1260 /* Find first non-comma, non-whitespace byte */
1261
1262 while (*ptr == ',' || apr_isspace(*ptr))
1263 ++ptr;
1264
1265 token = ptr;
1266
1267 /* Find the end of this item, skipping over dead bits */
1268
1269 for (in_qpair = in_qstr = in_com = 0;
1270 *ptr && (in_qpair || in_qstr || in_com || *ptr != ',');
1271 ++ptr) {
1272
1273 if (in_qpair) {
1274 in_qpair = 0;
1275 }
1276 else {
1277 switch (*ptr) {
1278 case '\\': in_qpair = 1; /* quoted-pair */
1279 break;
1280 case '"' : if (!in_com) /* quoted string delim */
1281 in_qstr = !in_qstr;
1282 break;
1283 case '(' : if (!in_qstr) /* comment (may nest) */
1284 ++in_com;
1285 break;
1286 case ')' : if (in_com) /* end comment */
1287 --in_com;
1288 break;
1289 default : break;
1290 }
1291 }
1292 }
1293
1294 if ((*len = (ptr - token)) == 0) {
1295 *field = (const char *)ptr;
1296 return NULL;
1297 }
1298
1299 /* Advance field pointer to the next non-comma, non-white byte */
1300
1301 while (*ptr == ',' || apr_isspace(*ptr))
1302 ++ptr;
1303
1304 *field = (const char *)ptr;
1305 return (const char *)token;
1306}
1307
1308/* Retrieve an HTTP header field list item, as separated by a comma,
1309 * while stripping insignificant whitespace and lowercasing anything not in

Callers 1

ap_get_list_itemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected