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

Function _ppdCacheWriteFile

cups/ppd-cache.c:2964–3185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2962 */
2963
2964int /* O - 1 on success, 0 on failure */
2965_ppdCacheWriteFile(
2966 _ppd_cache_t *pc, /* I - PPD cache and mapping data */
2967 const char *filename, /* I - File to write */
2968 ipp_t *attrs) /* I - Attributes to write, if any */
2969{
2970 int i, j, k; /* Looping vars */
2971 cups_file_t *fp; /* Output file */
2972 pwg_size_t *size; /* Current size */
2973 pwg_map_t *map; /* Current map */
2974 _pwg_finishings_t *f; /* Current finishing option */
2975 cups_option_t *option; /* Current option */
2976 const char *value; /* String value */
2977 char newfile[1024]; /* New filename */
2978
2979
2980 /*
2981 * Range check input...
2982 */
2983
2984 if (!pc || !filename)
2985 {
2986 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
2987 return (0);
2988 }
2989
2990 /*
2991 * Open the file and write with compression...
2992 */
2993
2994 snprintf(newfile, sizeof(newfile), "%s.N", filename);
2995 if ((fp = cupsFileOpen(newfile, "w9")) == NULL)
2996 {
2997 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
2998 return (0);
2999 }
3000
3001 /*
3002 * Standard header...
3003 */
3004
3005 cupsFilePrintf(fp, "#CUPS-PPD-CACHE-%d\n", _PPD_CACHE_VERSION);
3006
3007 /*
3008 * Output bins...
3009 */
3010
3011 if (pc->num_bins > 0)
3012 {
3013 cupsFilePrintf(fp, "NumBins %d\n", pc->num_bins);
3014 for (i = pc->num_bins, map = pc->bins; i > 0; i --, map ++)
3015 cupsFilePrintf(fp, "Bin %s %s\n", map->pwg, map->ppd);
3016 }
3017
3018 /*
3019 * Media sizes...
3020 */
3021

Callers 3

load_ppdFunction · 0.85
mainFunction · 0.85
test_ppd_cacheFunction · 0.85

Calls 10

_cupsSetErrorFunction · 0.85
cupsFileOpenFunction · 0.85
cupsFilePrintfFunction · 0.85
cupsFilePutCharFunction · 0.85
cupsFilePutConfFunction · 0.85
cupsArrayFirstFunction · 0.85
cupsArrayNextFunction · 0.85
ippLengthFunction · 0.85
ippWriteIOFunction · 0.85
cupsFileCloseFunction · 0.85

Tested by 2

mainFunction · 0.68
test_ppd_cacheFunction · 0.68