static int mac_put_params(gx_device *dev, gs_param_list *plist) { gx_device_macos *mdev = (gx_device_macos *)dev; int isOpen = mdev->is_open; int code; int depth; gs_param_string outputFile; // Get the BitsPerPixel Parameter code = param_read_int(plist, "BitsPerPixel", &depth); if (!code) { code = mac_set_colordepth(dev, depth); if (code) param_return_error(plist, "BitsPerPixel", gs_error_rangecheck); } // Get OutputFile code = param_read_string(plist, "OutputFile", &outputFile); if (code < 0) { param_signal_error(plist, "OutputFile", code); return code; } else if (code == 0) { if (dev->LockSafetyParams && bytes_compare(outputFile.data, outputFile.size, (const byte *)mdev->outputFileName, strlen(mdev->outputFileName))) { param_signal_error(plist, "OutputFile", gs_error_invalidaccess); return gs_error_invalidaccess; } if (outputFile.size > (gp_file_name_sizeof - 1)) { param_signal_error(plist, "OutputFile", gs_error_limitcheck); return gs_error_limitcheck; } /* If filename changed, close file. */ if (outputFile.data != 0 && bytes_compare(outputFile.data, outputFile.size, (const byte *)mdev->outputFileName, strlen(mdev->outputFileName))) { /* Close the file if it's open. */ if (mdev->outputFile != NULL) { gx_device_close_output_file(dev, mdev->outputFileName, mdev->outputFile); memcpy(mdev->outputFileName, outputFile.data, outputFile.size); mdev->outputFileName[outputFile.size] = 0; gx_device_open_output_file(dev, mdev->outputFileName, true, true, &(mdev->outputFile)); } else { memcpy(mdev->outputFileName, outputFile.data, outputFile.size); mdev->outputFileName[outputFile.size] = 0; } } } // Get the Default Parameters mdev->is_open = 0; code = gx_default_put_params( dev, plist ); mdev->is_open = isOpen; return code; }
int gx_forward_put_params(gx_device * dev, gs_param_list * plist) { gx_device_forward * const fdev = (gx_device_forward *)dev; gx_device *tdev = fdev->target; int code; if (tdev == 0) return gx_default_put_params(dev, plist); code = dev_proc(tdev, put_params)(tdev, plist); if (code >= 0) gx_device_decache_colors(dev); return code; }
/* Put parameters. */ static int cgm_put_params(gx_device * dev, gs_param_list * plist) { gx_device_cgm *cdev = (gx_device_cgm *) dev; int ecode = 0; int code; const char *param_name; gs_param_string ofs; switch (code = param_read_string(plist, (param_name = "OutputFile"), &ofs)) { case 0: if (dev->LockSafetyParams && bytes_compare(ofs.data, ofs.size, (const byte *)cdev->fname, strlen(cdev->fname))) { ecode = gs_note_error(gs_error_invalidaccess); goto ofe; } if (ofs.size >= gp_file_name_sizeof) ecode = gs_error_limitcheck; else break; goto ofe; default: ecode = code; ofe:param_signal_error(plist, param_name, ecode); case 1: ofs.data = 0; break; } if (ecode < 0) return ecode; code = gx_default_put_params(dev, plist); if (code < 0) return code; if (ofs.data != 0) { /* Close the file if it's open. */ if (cdev->file != 0) { fclose(cdev->file); cdev->file = 0; } memcpy(cdev->fname, ofs.data, ofs.size); cdev->fname[ofs.size] = 0; cdev->file = fopen(cdev->fname, "wb"); if (cdev->file == 0) return_error(gs_error_ioerror); } return 0; }
int gx_forward_put_params(gx_device * dev, gs_param_list * plist) { gx_device_forward * const fdev = (gx_device_forward *)dev; gx_device *tdev = fdev->target; bool was_open; int code; if (tdev == 0) return gx_default_put_params(dev, plist); was_open = tdev->is_open; code = dev_proc(tdev, put_params)(tdev, plist); if (code == 0 && !tdev->is_open) { code = was_open ? 1 : 0; /* target device closed */ } if (code >= 0) gx_device_decache_colors(dev); return code; }