MCPcopy Create free account
hub / github.com/OpenPrinting/cups / httpGetSubField2

Function httpGetSubField2

cups/http.c:1367–1492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1365 */
1366
1367char * /* O - Value or @code NULL@ */
1368httpGetSubField2(http_t *http, /* I - HTTP connection */
1369 http_field_t field, /* I - Field index */
1370 const char *name, /* I - Name of sub-field */
1371 char *value, /* O - Value string */
1372 int valuelen) /* I - Size of value buffer */
1373{
1374 const char *fptr; /* Pointer into field */
1375 char temp[HTTP_MAX_VALUE], /* Temporary buffer for name */
1376 *ptr, /* Pointer into string buffer */
1377 *end; /* End of value buffer */
1378
1379 DEBUG_printf(("2httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, valuelen=%d)", (void *)http, field, name, (void *)value, valuelen));
1380
1381 if (value)
1382 *value = '\0';
1383
1384 if (!http || !name || !value || valuelen < 2 ||
1385 field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX || !http->fields[field])
1386 return (NULL);
1387
1388 end = value + valuelen - 1;
1389
1390 for (fptr = http->fields[field]; *fptr;)
1391 {
1392 /*
1393 * Skip leading whitespace...
1394 */
1395
1396 while (_cups_isspace(*fptr))
1397 fptr ++;
1398
1399 if (*fptr == ',')
1400 {
1401 fptr ++;
1402 continue;
1403 }
1404
1405 /*
1406 * Get the sub-field name...
1407 */
1408
1409 for (ptr = temp;
1410 *fptr && *fptr != '=' && !_cups_isspace(*fptr) &&
1411 ptr < (temp + sizeof(temp) - 1);
1412 *ptr++ = *fptr++);
1413
1414 *ptr = '\0';
1415
1416 DEBUG_printf(("4httpGetSubField2: name=\"%s\"", temp));
1417
1418 /*
1419 * Skip trailing chars up to the '='...
1420 */
1421
1422 while (_cups_isspace(*fptr))
1423 fptr ++;
1424

Callers 2

httpGetSubFieldFunction · 0.85
_httpUpdateFunction · 0.85

Calls 1

_cups_isspaceFunction · 0.85

Tested by

no test coverage detected