Harlequin RIP SDK

Core implementation of the interaction between the RIP and the skin. More...

#include "hhrsdk.h"
#include "skintest.h"
#include "argusage.h"
#include "libtiffrast.h"
#include "frametiffrast.h"
#include "asynctiffrast.h"
#include "generateformat.h"
#include "skintestdata.h"
#include "inputserrors.h"
#include "hvdrast.h"
#include "rawrast.h"
#include "jpegrast.h"
#include "pngrast.h"
#include "rlerast.h"
#include "nonerast.h"
#include "cmm_example.h"
#include "cmm_littlecms.h"
#include "cmm_hybrid.h"
#include "cmm_purecolor.h"
#include "htm4x4.h"
#include "htm8ml.h"
#include <stdio.h>
#include <string.h>

Macros

#define DEVICE_MOUNT_PS(dev_)
 PostScript to mount a non-filesystem device (no /Prefix). More...
 

Functions

static HqBool RegisterHandlers (void)
 Registers the event handlers to be made available to the RIP. More...
 
static HqBool RegisterHTMs (void)
 Registers the halftone modules to be made available to the RIP. More...
 
static HqBool RegisterAlternateCMMs (void)
 Registers the alternate Color Management Modules to be made available to the RIP. More...
 
static HqBool RegisterRasterBackends (void)
 Registers the raster backend handlers to be made available to the RIP. More...
 
static HqBool ValidateOutputTargetAndDestination (const uint8 *pOutputTarget, const char *const valid_targets[])
 Check for invalid combinations of output target/destination. More...
 
static HqBool MountAllDrives (void)
 Run a sequence of PostScript control jobs through the RIP to mount all of the available filesystem routes as file devices. More...
 
static HqBool MountOtherDevices (SkinDynamicBuffer *mount)
 Generate the PostScript that will mount other devices including ram and jobtmp. More...
 
static HqBool registerDiscardStreamWriter (HqnWriteStream *pWriteStream)
 Configure the specified data-discarding write stream object, and register it using registerStreamWriter(). More...
 
void FileFormat (uint8 *format)
 This function allows you to override the default output format. Supported output format names can be found in skintest.c. More...
 
void OverridePGBType (uint8 *type)
 Called in response to the example command-line application's -o (output) switch, this function is used to override any value of /PageBufferType from the page device. If the existing value is "LE", then the override will be performed silently; for other values, a warning will be issued.
 
uint8GetPageBufferType (int32 *pLen)
 Obtain the PageBufferType in use, taking into account any override value. More...
 
void OverrideOutputTarget (uint8 *target)
 Called in response to the example command-line application's -s (output target) switch, this function is used to override any value of /OutputTarget from the page device.
 
void PrintCopyright (void)
 Output the content of COPYRIGHT.txt to the monitor.
 
int32 ProcessJobs (SwLeDoParams *params)
 Boot the Harlequin RIP core and process jobs from input queues. More...
 
static sw_inputq_result list_setups (const sw_inputq_setup *setup, size_t size, void *data)
 Input API setup iteration function.
 
void ListSetupsAndConfigs (SwLeDoParams *params)
 This function runs RIP to list available output types and configuration names. More...
 
HqBool RasterFilename (RasterDescription *pRasterDescription, const char *fileformat, const char *const valid_targets[], uint8 *rasterFilename, uint8 *rasterPSFilename)
 Raster filename function, used to generate filenames for raster backends from a template and raster description. More...
 
RASTER_PLANERasterPlaneFromDescription (const RasterDescription *pRD, uint32 pindex)
 
HqBool GenerateFilename (const char *format, const RasterDescription *pRasterDescription, uint8 *pFilename, int32 length)
 Generates a filename or message for this job / page / sep. More...
 
HqBool GeneratePSFilename (const char *fileformat, const RasterDescription *pRasterDescription, uint8 *pFilename)
 Generates a PS filename for this job / page / sep. More...
 
static HqBool configureSocketDevice (const char *pszAddress, int32 nPort)
 Set the IP address and port number used when outputting to the socket device. More...
 
static int32 discardStream_Close (void *pPrivate)
 'Close' method for the data-discarding write stream.
 
static int32 discardStream_Seek (void *pPrivate, Hq32x2 *destination, int32 flags)
 'Seek' method for the data-discarding write stream. More...
 
static int32 discardStream_Bytes (void *pPrivate, Hq32x2 *pBytes, int32 reason)
 'Bytes' method for the data-discarding write stream. More...
 
static int32 discardStream_Write (void *pPrivate, uint8 *buff, int32 len)
 'Write' method for the data-discarding write stream. More...
 
static void monitorStderr (uint32 buflen, const uint8 *buffer)
 
static void monitorFileWrite (uint32 buflen, const uint8 *buffer, HqBool do_flush, FileDesc *fd)
 
void monitorFile (uint32 buflen, const uint8 *buffer)
 
intptr_t monitorFileOptions (intptr_t options)
 
HqBool monitorFileStart (SwLeMONITORCALLBACK *monitorCallback)
 Initialise the monitorFile() output. More...
 
void monitorFileEnd (void)
 
static sw_event_result monitor_channel (void *ctx, sw_event *evt)
 Monitor through events contextualisation. The core performs transcoding of unrecognised encodings to the Unicode Private Use Area, so event messages are always UTF-8. The fallback monitor handler, which writes event messages to the %monitor% device, undoes the transcoding, providing the raw bytes to device write. Rather than repeat that detection and decoding here, we install a monitor handler that picks the output channel that the %monitor% device will use, and calls the rest of the event handler chain. This is compatible with the colour monitor handler.
 
HqBool monitorFileHandleEvents (HqBool compatible)
 Register event handlers to contextualise monitor events, sending them to an appropriate monitor file stream. More...
 
void HqCustomAssertMon (const char *filename, int line, const char *format, va_list vlist, int assertflag)
 Wrapper for HqCustomAssert() to ensure output goes to the stderr channel, rather than the stdout channel, when using the monitor file callback.
 
void HqCustomTraceMon (const char *filename, int line, const char *format, va_list vlist)
 Wrapper for HqCustomTrace() to ensure output goes to the stderr channel, rather than the stdout channel, when using the monitor file callback.
 
void jsonSavePS (void)
 Enable saving of PostScript representation of JSON config files.
 
void * CurrentJobContext (void)
 Return the job context attached to the currently processing job. This is the job context pointer provided to raster callbacks, initially created by the input queue job submission.
 
void init_C_runtime_skintest (void)
 Re-initialize all global state in the clrip application layer. More...
 

Variables

static pthread_key_t mon_channel_key
 
static sw_event_handlers mon_handlers []
 

Detailed Description

Core implementation of the interaction between the RIP and the skin.

Macro Definition Documentation

◆ DEVICE_MOUNT_PS

#define DEVICE_MOUNT_PS (   dev_)
Value:
"mark {\n" \
" (%%" dev_ "%%) dup devmount pop\n" \
" <<\n" \
" /Password 0\n" \
" /DeviceType 16#%x\n" \
" /Enable true\n" \
" >> setdevparams\n" \
"} stopped cleartomark\n"

PostScript to mount a non-filesystem device (no /Prefix).

If the device is already mounted we make sure it is also enabled. This is a format string, so percent characters are doubled. All of the parameters we are setting are non device-specific, so we can unconditionally mount and set the parameters.

Function Documentation

◆ configureSocketDevice()

static HqBool configureSocketDevice ( const char *  pszAddress,
int32  nPort 
)
static

Set the IP address and port number used when outputting to the socket device.

Parameters
pszAddressAn IP address (nnn.nnn.nnn.nnn).
nPortThe port number to use.
Returns
TRUE on success.

◆ discardStream_Bytes()

static int32 discardStream_Bytes ( void *  pPrivate,
Hq32x2 pBytes,
int32  reason 
)
static

'Bytes' method for the data-discarding write stream.

Always returns FALSE as data is not available to be read back and the total size is unknown.

◆ discardStream_Seek()

static int32 discardStream_Seek ( void *  pPrivate,
Hq32x2 destination,
int32  flags 
)
static

'Seek' method for the data-discarding write stream.

Seeking on the discard stream always succeeds, but usually has no effect. For the special case of seeking by zero relative to the current stream position, the function will update the destination parameter with the number of bytes that were written since the discard stream was opened.

◆ discardStream_Write()

static int32 discardStream_Write ( void *  pPrivate,
uint8 buff,
int32  len 
)
static

'Write' method for the data-discarding write stream.

We update the count of bytes written and discard the input data.

◆ monitorFileWrite()

static void monitorFileWrite ( uint32  buflen,
const uint8 buffer,
HqBool  do_flush,
FileDesc fd 
)
static

Helper function for monitorFile.

◆ monitorStderr()

static void monitorStderr ( uint32  buflen,
const uint8 buffer 
)
static

Default monitor callback to route all messages to stderr.

Parameters
buflenThe length of the message to output.
[in]bufferA buffer of data to output. This is written to stderr verbatim.

This is installed on startup by init_C_runtime_skintest() so we don't lose any output.

◆ MountAllDrives()

static HqBool MountAllDrives ( void  )
static

Run a sequence of PostScript control jobs through the RIP to mount all of the available filesystem routes as file devices.

Generate the PostScript that will mount drives. This allows PostScript to be submitted to the RIP which refers to any drive. For example, the way in which PDF files are submitted need to be done by a control job, and that control job needs to reference the PDF file, and it might be on one of these drives.

This must be called after having started the RIP.

Returns
TRUE if all drives were mounted successfully, otherwise FALSE.

◆ MountOtherDevices()

static HqBool MountOtherDevices ( SkinDynamicBuffer mount)
static

Generate the PostScript that will mount other devices including ram and jobtmp.

The jobtmp device provides a temporary storage area whose contents may (or may not) be cleared by external client code in between jobs. This device is only mounted when the SW resources folder is read-only, or compiled into RAM. The purpose of this device is to provide an alternative to tmp, which will actually be backed by RAM in these cases. The jobtmp device is mounted explicitly as a disk volume. The skin pagebuffer (PGB) device in particular takes advantage of this. See KGetBandCacheDev() in pgbdev.c.

◆ RegisterAlternateCMMs()

static HqBool RegisterAlternateCMMs ( void  )
static

Registers the alternate Color Management Modules to be made available to the RIP.

Returns
TRUE if all modules were registered successfully, and FALSE otherwise.
See also
SwRegisterCMM()

◆ registerDiscardStreamWriter()

static HqBool registerDiscardStreamWriter ( HqnWriteStream pWriteStream)
static

Configure the specified data-discarding write stream object, and register it using registerStreamWriter().

Returns
TRUE on success, FALSE otherwise.

◆ RegisterHandlers()

static HqBool RegisterHandlers ( void  )
static

Registers the event handlers to be made available to the RIP.

Returns
TRUE if all handlers were registered successfully, and FALSE otherwise.
See also
SwRegisterHandlers()

◆ RegisterHTMs()

static HqBool RegisterHTMs ( void  )
static

Registers the halftone modules to be made available to the RIP.

Returns
TRUE if all modules were registered successfully, and FALSE otherwise.
See also
SwRegisterHTM()

◆ RegisterRasterBackends()

static HqBool RegisterRasterBackends ( void  )
static

Registers the raster backend handlers to be made available to the RIP.

Return values
TRUEAll raster backend handlers were registered successfully
FALSEIf any raster backend handler was not registered

◆ ValidateOutputTargetAndDestination()

static HqBool ValidateOutputTargetAndDestination ( const uint8 pOutputTarget,
const char *const  valid_targets[] 
)
static

Check for invalid combinations of output target/destination.

Returns
TRUE if the combination is valid.

Variable Documentation

◆ mon_channel_key

pthread_key_t mon_channel_key
static

Channel (FILE) to send raw output to. This is a per-thread key because the expectation is that an event or wrapper function will contextualise output channel, then ultimately

◆ mon_handlers

sw_event_handlers mon_handlers[]
static
Initial value:
= {
{ monitor_fallback, ((void*)0) , 0, SWEVT_MONITOR, MON_FALLBACK - 100},
}
@ MON_FALLBACK
Definition: monevent.h:123
@ MON_PRE_DEFAULT
Definition: monevent.h:118
static sw_event_result monitor_channel(void *ctx, sw_event *evt)
Monitor through events contextualisation. The core performs transcoding of unrecognised encodings to ...
Definition: skintest.c:2007
@ SWEVT_MONITOR
Definition: swevents.h:206

Event handlers for monitor through events. We register two channels, one just before the default handler to handle contextualisation of the monitor channel, and the other as a fallback to the RIP's fallback. If the RIP is not running, we just send output directly to the default monitor callback installed.