| 484 | */ |
| 485 | |
| 486 | _ppd_cache_t * /* O - PPD cache and mapping data */ |
| 487 | _ppdCacheCreateWithFile( |
| 488 | const char *filename, /* I - File to read */ |
| 489 | ipp_t **attrs) /* IO - IPP attributes, if any */ |
| 490 | { |
| 491 | cups_file_t *fp; /* File */ |
| 492 | _ppd_cache_t *pc; /* PWG mapping data */ |
| 493 | pwg_size_t *size; /* Current size */ |
| 494 | pwg_map_t *map; /* Current map */ |
| 495 | _pwg_finishings_t *finishings; /* Current finishings option */ |
| 496 | int linenum, /* Current line number */ |
| 497 | num_bins, /* Number of bins in file */ |
| 498 | num_sizes, /* Number of sizes in file */ |
| 499 | num_sources, /* Number of sources in file */ |
| 500 | num_types; /* Number of types in file */ |
| 501 | char line[2048], /* Current line */ |
| 502 | *value, /* Pointer to value in line */ |
| 503 | *valueptr, /* Pointer into value */ |
| 504 | pwg_keyword[128], /* PWG keyword */ |
| 505 | ppd_keyword[PPD_MAX_NAME]; |
| 506 | /* PPD keyword */ |
| 507 | _pwg_print_color_mode_t print_color_mode; |
| 508 | /* Print color mode for preset */ |
| 509 | _pwg_print_quality_t print_quality; /* Print quality for preset */ |
| 510 | |
| 511 | |
| 512 | DEBUG_printf(("_ppdCacheCreateWithFile(filename=\"%s\")", filename)); |
| 513 | |
| 514 | /* |
| 515 | * Range check input... |
| 516 | */ |
| 517 | |
| 518 | if (attrs) |
| 519 | *attrs = NULL; |
| 520 | |
| 521 | if (!filename) |
| 522 | { |
| 523 | _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); |
| 524 | return (NULL); |
| 525 | } |
| 526 | |
| 527 | /* |
| 528 | * Open the file... |
| 529 | */ |
| 530 | |
| 531 | if ((fp = cupsFileOpen(filename, "r")) == NULL) |
| 532 | { |
| 533 | _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0); |
| 534 | return (NULL); |
| 535 | } |
| 536 | |
| 537 | /* |
| 538 | * Read the first line and make sure it has "#CUPS-PPD-CACHE-version" in it... |
| 539 | */ |
| 540 | |
| 541 | if (!cupsFileGets(fp, line, sizeof(line))) |
| 542 | { |
| 543 | _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0); |