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

Function print_csv

tools/ipptool.c:3386–3481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3384 */
3385
3386static ipp_attribute_t * /* O - Next attribute */
3387print_csv(
3388 ipptool_test_t *data, /* I - Test data */
3389 ipp_t *ipp, /* I - Response message */
3390 ipp_attribute_t *attr, /* I - First attribute for line */
3391 int num_displayed, /* I - Number of attributes to display */
3392 char **displayed, /* I - Attributes to display */
3393 size_t *widths) /* I - Column widths */
3394{
3395 int i; /* Looping var */
3396 size_t maxlength; /* Max length of all columns */
3397 ipp_attribute_t *current = attr; /* Current attribute */
3398 char *values[MAX_DISPLAY], /* Strings to display */
3399 *valptr; /* Pointer into value */
3400
3401 /*
3402 * Get the maximum string length we have to show and allocate...
3403 */
3404
3405 for (i = 1, maxlength = widths[0]; i < num_displayed; i ++)
3406 if (widths[i] > maxlength)
3407 maxlength = widths[i];
3408
3409 maxlength += 2;
3410
3411 /*
3412 * Loop through the attributes to display...
3413 */
3414
3415 if (attr)
3416 {
3417 // Collect the values...
3418 memset(values, 0, sizeof(values));
3419
3420 for (; current; current = ippNextAttribute(ipp))
3421 {
3422 if (!ippGetName(current))
3423 break;
3424
3425 for (i = 0; i < num_displayed; i ++)
3426 {
3427 if (!strcmp(ippGetName(current), displayed[i]))
3428 {
3429 if ((values[i] = (char *)calloc(1, maxlength)) != NULL)
3430 ippAttributeString(current, values[i], maxlength);
3431 break;
3432 }
3433 }
3434 }
3435
3436 // Output the line...
3437 for (i = 0; i < num_displayed; i ++)
3438 {
3439 if (i)
3440 cupsFilePutChar(data->outfile, ',');
3441
3442 if (!values[i])
3443 continue;

Callers 1

do_testFunction · 0.85

Calls 5

ippNextAttributeFunction · 0.85
ippGetNameFunction · 0.85
ippAttributeStringFunction · 0.85
cupsFilePutCharFunction · 0.85
cupsFilePutsFunction · 0.85

Tested by

no test coverage detected