/* Open the win_dib driver */ static int win_dib_open(gx_device * dev) { int code = win_open(dev); if (code < 0) return code; #ifdef __WIN32__ if (!is_win32s) wdev->hmtx = CreateMutex(NULL, FALSE, NULL); /* unnamed mutex, initially unowned */ #endif if (gdev_mem_device_for_bits(dev->color_info.depth) == 0) { win_close(dev); return_error(gs_error_rangecheck); } code = win_dib_alloc_bitmap((gx_device_win *) dev, dev); if (code < 0) { win_close(dev); return code; } /* notify caller about new device */ if (pgsdll_callback) { (*pgsdll_callback) (GSDLL_DEVICE, (unsigned char *)dev, 1); (*pgsdll_callback) (GSDLL_SIZE, (unsigned char *)dev, (dev->width & 0xffff) + ((ulong) (dev->height & 0xffff) << 16)); } code = install_internal_subclass_devices((gx_device **)&dev, NULL); return code; }
static int bbox_open_device(gx_device * dev) { gx_device_bbox *bdev = (gx_device_bbox *) dev; int code; if (bdev->free_standing) { gx_device_forward_fill_in_procs((gx_device_forward *) dev); bdev->box_procs = box_procs_default; bdev->box_proc_data = bdev; code = install_internal_subclass_devices((gx_device **)&bdev, NULL); if (code < 0) return code; } if (bdev->box_procs.init_box == box_procs_default.init_box) BBOX_INIT_BOX(bdev); /* gx_forward_open_device doesn't exist */ { gx_device *tdev = bdev->target; int code = (tdev && bdev->forward_open_close ? gs_opendevice(tdev) : 0); bbox_copy_params(bdev, true); return code; } }
static int tfax_open(gx_device * pdev) { gx_device_printer * const ppdev = (gx_device_printer *)pdev; int code; /* Use our own warning and error message handlers in libtiff */ tiff_set_handlers(); ppdev->file = NULL; code = gdev_prn_allocate_memory(pdev, NULL, 0, 0); if (code < 0) return code; if (ppdev->OpenOutputFile) if ((code = gdev_prn_open_printer_seekable(pdev, 1, true)) < 0) return code; code = install_internal_subclass_devices((gx_device **)&pdev, NULL); return code; }
/* Open the output file and stream. */ int gdev_vector_open_file_options(gx_device_vector * vdev, uint strmbuf_size, int open_options) { bool binary = !(open_options & VECTOR_OPEN_FILE_ASCII); int code = -1; /* (only for testing, never returned) */ cmm_dev_profile_t *icc_struct = 0; /* Open the file as seekable or sequential, as requested. */ if (!(open_options & VECTOR_OPEN_FILE_SEQUENTIAL)) { /* Try to open as seekable. */ code = gx_device_open_output_file((gx_device *)vdev, vdev->fname, binary, true, &vdev->file); } if (code < 0 && (open_options & (VECTOR_OPEN_FILE_SEQUENTIAL | VECTOR_OPEN_FILE_SEQUENTIAL_OK))) { /* Try to open as sequential. */ code = gx_device_open_output_file((gx_device *)vdev, vdev->fname, binary, false, &vdev->file); } if ((code >= 0) && (dev_proc(vdev, get_profile) != NULL)) { code = dev_proc(vdev, get_profile)((gx_device *)vdev, &icc_struct); } if (code < 0) return code; if ((vdev->strmbuf = gs_alloc_bytes(vdev->v_memory, strmbuf_size, "vector_open(strmbuf)")) == 0 || (vdev->strm = s_alloc(vdev->v_memory, "vector_open(strm)")) == 0 || ((open_options & VECTOR_OPEN_FILE_BBOX) && (vdev->bbox_device = gs_alloc_struct_immovable(vdev->v_memory, gx_device_bbox, &st_device_bbox, "vector_open(bbox_device)")) == 0) ) { if (vdev->bbox_device) gs_free_object(vdev->v_memory, vdev->bbox_device, "vector_open(bbox_device)"); vdev->bbox_device = 0; if (vdev->strm) gs_free_object(vdev->v_memory, vdev->strm, "vector_open(strm)"); vdev->strm = 0; if (vdev->strmbuf) gs_free_object(vdev->v_memory, vdev->strmbuf, "vector_open(strmbuf)"); vdev->strmbuf = 0; gx_device_close_output_file((gx_device *)vdev, vdev->fname, vdev->file); vdev->file = 0; return_error(gs_error_VMerror); } vdev->strmbuf_size = strmbuf_size; swrite_file(vdev->strm, vdev->file, vdev->strmbuf, strmbuf_size); vdev->open_options = open_options; /* * We don't want finalization to close the file, but we do want it * to flush the stream buffer. */ vdev->strm->procs.close = vdev->strm->procs.flush; if (vdev->bbox_device) { gx_device_bbox_init(vdev->bbox_device, NULL, vdev->v_memory); rc_increment(vdev->bbox_device); vdev->bbox_device->icc_struct = icc_struct; rc_increment(vdev->bbox_device->icc_struct); gx_device_set_resolution((gx_device *) vdev->bbox_device, vdev->HWResolution[0], vdev->HWResolution[1]); /* Do the right thing about upright vs. inverted. */ /* (This is dangerous in general, since the procedure */ /* might reference non-standard elements.) */ set_dev_proc(vdev->bbox_device, get_initial_matrix, dev_proc(vdev, get_initial_matrix)); (*dev_proc(vdev->bbox_device, open_device)) ((gx_device *) vdev->bbox_device); } code = install_internal_subclass_devices((gx_device **)&vdev, NULL); if (code < 0) return code; return 0; }