コード例 #1
0
ファイル: gdevprna.c プロジェクト: BorodaZizitopa/ghostscript
/* LEAVE DEVICE in a state where it must be re-opened/re-init'd */
static int			/* ret 0 ok no flush, -ve error code */
flush_page(
           gx_device_printer * pwdev,	/* async writer device to flush */
           bool partial	/* true if only partial page */
)
{
    gx_device_clist *const pcldev = (gx_device_clist *) pwdev;
    gx_device_clist_writer *const pcwdev = &pcldev->writer;
    int flush_code = 0;
    int add_code = 0;

    /* do NOT close files before sending to page queue */
    flush_code = clist_end_page(pcwdev);
    add_code = gx_page_queue_add_page(pcwdev, pwdev->page_queue,
                                (partial ? GX_PAGE_QUEUE_ACTION_PARTIAL_PAGE :
                                 GX_PAGE_QUEUE_ACTION_FULL_PAGE),
                                      &pcwdev->page_info, 0);

    /* Device no longer has BANDFILES, so it must be re-init'd by caller */
    pcwdev->page_info.bfile = pcwdev->page_info.cfile = 0;

    /* return the worst of the status. */
    if (flush_code < 0)
        return flush_code;
    return add_code;
}
コード例 #2
0
ファイル: gxclpage.c プロジェクト: SynEmira/ruby-ghostscript
/* Save a page. */
int
gdev_prn_save_page(gx_device_printer * pdev, gx_saved_page * page,
                   int num_copies)
{
    gx_device_clist *cdev = (gx_device_clist *) pdev;

    /* Make sure we are banding. */
    if (!pdev->buffer_space)
        return_error(gs_error_rangecheck);
    if (strlen(pdev->dname) >= sizeof(page->dname))
        return_error(gs_error_limitcheck);
    {
        gx_device_clist_writer * const pcldev =
            (gx_device_clist_writer *)pdev;
        int code;

        if ((code = clist_end_page(pcldev)) < 0 ||
            (code = cdev->common.page_info.io_procs->fclose(pcldev->page_cfile, pcldev->page_cfname, false)) < 0 ||
            (code = cdev->common.page_info.io_procs->fclose(pcldev->page_bfile, pcldev->page_bfname, false)) < 0
            )
            return code;
        /* Save the device information. */
        memcpy(&page->device, pdev, sizeof(gx_device));
        strcpy(page->dname, pdev->dname);
        /* Save the page information. */
        page->info = pcldev->page_info;
        page->info.cfile = 0;
        page->info.bfile = 0;
    }
    /* Save other information. */
    page->num_copies = num_copies;
    return (*gs_clist_device_procs.open_device) ((gx_device *) pdev);
}
コード例 #3
0
ファイル: gdevprna.c プロジェクト: BorodaZizitopa/ghostscript
/* Output page causes file to get added to page queue for later rasterizing */
static int
gdev_prn_async_write_output_page(gx_device * pdev, int num_copies, int flush)
{
    gx_device_printer *const pwdev = (gx_device_printer *) pdev;
    gx_device_clist_writer *const pcwdev =
        &((gx_device_clist *) pdev)->writer;
    int flush_code;
    int add_code;
    int open_code;
    int one_last_time = 1;

    /* do NOT close files before sending to page queue */
    flush_code = clist_end_page(pcwdev);
    add_code = gx_page_queue_add_page(pcwdev, pwdev->page_queue,
                                (flush ? GX_PAGE_QUEUE_ACTION_FULL_PAGE :
                                 GX_PAGE_QUEUE_ACTION_COPY_PAGE),
                                      &pcwdev->page_info, num_copies);
    if (flush && (flush_code >= 0) && (add_code >= 0)) {
        /* This page is finished */
        gx_finish_output_page(pdev, num_copies, flush);
    }

    /* Open new band files to take the place of ones added to page queue */
    while ((open_code = (*gs_clist_device_procs.open_device)
            ((gx_device *) pdev)) == gs_error_VMerror) {
        /* Open failed, try after a page gets rendered */
        if (!gx_page_queue_wait_one_page(pwdev->page_queue)
            && one_last_time-- <= 0)
            break;
    }

    return
        (flush_code < 0 ? flush_code : open_code < 0 ? open_code :
         add_code < 0 ? add_code : 0);
}
コード例 #4
0
ファイル: gxclpage.c プロジェクト: computersforpeace/ghostpdl
/* Save a page. The elements are allocated by this function in non_gc_memory */
int
gdev_prn_save_page(gx_device_printer * pdev, gx_saved_page * page)
{
    gx_device_clist *cdev = (gx_device_clist *) pdev;
    gx_device_clist_writer * const pcldev = (gx_device_clist_writer *)pdev;
    int code;

    /* Make sure we are banding. */
    if (!PRINTER_IS_CLIST(pdev))
        return_error(gs_error_rangecheck);

    if ((code = clist_end_page(pcldev)) < 0 ||
        (code = cdev->common.page_info.io_procs->fclose(pcldev->page_info.cfile, pcldev->page_info.cfname, false)) < 0 ||
        (code = cdev->common.page_info.io_procs->fclose(pcldev->page_info.bfile, pcldev->page_info.bfname, false)) < 0
        )
        return code;
    return do_page_save(pdev, page, NULL);
}