This is the structure used to represent a device type (class) implementation in the Harlequin RIP core. More...
#include "swdevice.h"
Data Fields | |
int32 | devicenumber |
The device type number. | |
int32 | devicetypeflags |
Flags to indicate specifics of device. More... | |
int32 | sizeof_private |
The size of the private data to allocate when a device instance is mounted. | |
int32 | unused1 |
Reserved for future use. | |
DEVICELIST_TICKLE | unused2 |
Reserved for future use. | |
DEVICELIST_LAST_ERROR | last_error |
Return last error for this device. More... | |
DEVICELIST_INIT | device_init |
Call to initialise device. More... | |
DEVICELIST_OPEN | open_file |
Call to open file on device. More... | |
DEVICELIST_READ | read_file |
Call to read data from file on device. More... | |
DEVICELIST_WRITE | write_file |
Call to write data to file on device. More... | |
DEVICELIST_CLOSE | close_file |
Call to close file on device. More... | |
DEVICELIST_ABORT | abort_file |
Call to abort action on the device. More... | |
DEVICELIST_SEEK | seek_file |
Call to seek file on device. More... | |
DEVICELIST_BYTES | bytes_file |
Call to get bytes available for open file. More... | |
DEVICELIST_STATUS_FILE | status_file |
Call to check status of file. More... | |
DEVICELIST_START_LIST | start_file_list |
Call to start iterating file names. More... | |
DEVICELIST_NEXT | next_file |
Call to get next file in list. More... | |
DEVICELIST_END_LIST | end_file_list |
Call to end listing. More... | |
DEVICELIST_RENAME | rename_file |
Rename file on the device. More... | |
DEVICELIST_DELETE | delete_file |
Remove file from device. More... | |
DEVICELIST_SET_PARAM | set_param |
Call to set a device parameter. More... | |
DEVICELIST_START_PARAM | start_param |
Call to start iterating device parameters. More... | |
DEVICELIST_GET_PARAM | get_param |
Call to get the next device parameter. More... | |
DEVICELIST_STATUS_DEVICE | status_device |
Call to get the status of the device. More... | |
DEVICELIST_DISMOUNT | device_dismount |
Call to dismount the device. More... | |
DEVICELIST_BUFFER_SIZE | buffer_size |
Optional call to return buffer size. More... | |
DEVICELIST_IOCTL | ioctl_call |
For "special" control notifications. More... | |
DEVICELIST_SPARE | spare |
Spare slot. | |
This is the structure used to represent a device type (class) implementation in the Harlequin RIP core.
A number of macros, e.g., theIDevTypeNumber()
, are for convenience in accessing the fields of the structures: don't feel obliged to use them. You may want to call methods functions on a device in your own code, and the macros provide a notation for doing so.
DEVICELIST_ABORT DeviceType::abort_file |
Call to abort action on the device.
dev | The current device. |
descriptor | A descriptor returned by a previous open call. |
Calling this method is equivalent to calling a DEVICELIST_CLOSE method, except that it signals an error in the processing of the file. Any data waiting to be written to the file will be discarded.
DEVICELIST_BUFFER_SIZE DeviceType::buffer_size |
Optional call to return buffer size.
dev | The current device. |
DEVICELIST_BYTES DeviceType::bytes_file |
Call to get bytes available for open file.
dev | The current device. |
descriptor | A descriptor returned by a previous open call. |
bytes | The number of bytes available. |
reason | One of SW_BYTES_AVAIL_REL, SW_BYTES_TOTAL_ABS. |
TRUE
if there are bytes available (in which case return 0 in bytes if the number is not known), FALSE
for failure.This routine returns the number of bytes available for reading without waiting. See the bytesavailable
operator, described in [RB3]. If the number of bytes available is not known, but it is possible that there are some, 0 should be returned in bytes and TRUE
should be returned. If the file has reached EOF or when some other error occurs, such as when the file is open for writing only, FALSE
should be returned and the DEVICELIST_LAST_ERROR method should return DeviceIOError.
The value of reason is one of:
DEVICELIST_CLOSE DeviceType::close_file |
Call to close file on device.
dev | The current device. |
descriptor | A descriptor returned by a previous open call. |
Any data waiting to be written on the file will be written before this call returns. Note that the Harlequin Core itself buffers data read from or written to a file, and so the device implementation normally need not (and indeed should not) also implement a buffering scheme.
DEVICELIST_DELETE DeviceType::delete_file |
Remove file from device.
dev | The current device. |
filename | The name of a file to remove. |
This routine removes the file with the given name. If the file has been opened it is implementation-dependent whether any further operations can be done with the open file. This permits the file to be closed in the underlying operating system, if necessary, before deleting this file, as is necessary for example with Windows.
If there is no file named filename, then the DEVICELIST_LAST_ERROR method should return DeviceUndefined. If the device does not support renaming, or the particular filename is not permitted to be changed, then the DEVICELIST_LAST_ERROR method should return DeviceInvalidAccess. After any other failure, the DEVICELIST_LAST_ERROR method should return DeviceIOError.
DEVICELIST_DISMOUNT DeviceType::device_dismount |
Call to dismount the device.
dev | The current device. |
This routine is called when a device is dismounted. All files open when the Harlequin Core unmounted the device will have been closed. The routine should perform any required tasks, such as freeing any resources used by that device.
DEVICELIST_INIT DeviceType::device_init |
Call to initialise device.
dev | The current device. |
This call is made once for each device instance, and will be the first call for the device instance.
int32 DeviceType::devicetypeflags |
Flags to indicate specifics of device.
Values are a combination of the DEVICETYPE_flags values.
DEVICELIST_END_LIST DeviceType::end_file_list |
Call to end listing.
dev | The current device. |
handle | A file list iterator pointer returned by the DEVICELIST_START_LIST method. |
This method is called to free any resources allocated to enumerate file names. If DEVICELIST_START_LIST was successful, this routine will be called at any time after it. It is possible that not all matches have been requested.
After a failure, the DEVICELIST_LAST_ERROR method should return DeviceIOError.
DEVICELIST_GET_PARAM DeviceType::get_param |
Call to get the next device parameter.
dev | The current device. |
param | A structure in which to store the parameter value. If the paramname field is NULL , then store the next parameter in an iteration, otherwise store the value of the requested parameter. |
This routine has two functions. If the DEVICEPARAM::paramname field of the param argument is NULL
when it is called, the next parameter name and value in an iteration started by DEVICELIST_START_PARAM should be returned through the DEVICEPARAM structure. If the DEVICEPARAM::paramname field is not NULL
then the value of that specific parameter name should be returned through the DEVICEPARAM structure.
In the second case if the parameter name is not recognized the routine should return ParamIgnored, otherwise it should return ParamAccepted. If an error occurs, ParamError should be returned and the DEVICELIST_LAST_ERROR method should return an appropriate error code.
If not returning ParamIgnored, the DEVICEPARAM::type field must be set to one of DEVICEPARAM_type values. The appropriate union field and length if necessary should be set to the value of the parameter. If a string value is returned, the string value field should point to the device's local copy of the string. The RIP will copy the string into its own storage. If returning a composite object (an array or a dictionary), the implementation may allocate memory for the DEVICEPARAM array representing the composite object and store the memory pointer in the DEVICEPARAM::paramval.compobval field. The RIP will copy the value into its own storage as necessary. This memory should be freed by the device type implementation on the next call to DEVICELIST_GET_PARAM or DEVICELIST_START_PARAM. The client is required to call DEVICELIST_START_PARAM if the final call it made to DEVICELIST_GET_PARAM returned a composite object.
If returning the next parameter (DEVICEPARAM::paramname is NULL
on function entry) the DEVICEPARAM::paramname field should be set to point to the name of the parameter being returned, and the DEVICEPARAM::paramnamelen field set to the length of that name.
The Harlequin RIP SDK provides some utility routines to assist writing parameter methods:
DEVICELIST_IOCTL DeviceType::ioctl_call |
For "special" control notifications.
dev | The current device. |
fileDescriptor | A descriptor returned by a previous open call. |
opcode | A device-specific value, or one of the generic values: |
%os%
device. arg | A data parameter for the control function. |
0 | for success |
-1 | for failure. |
-2 | if the opcode is not implemented. |
DEVICELIST_LAST_ERROR DeviceType::last_error |
Return last error for this device.
dev | The current device. |
%pagebuffer%
device may also return one of: DeviceReOutput, DeviceNotReady, DeviceCancelPage, DeviceReOutputPageBuffer. Any value greater than or equal to MON_CLASS_ERROR will be interpreted as a sw_mon_type error UID, and may be deconstructed using the macros in monevent.h to get the error subclass, PostScript error, and error UID.This method should use a thread local variable to store and retrieve the error code. The device instance may be called from multiple different RIP or SDK threads. The RIP skins provide the functions skindevices_set_last_error() and skindevices_last_error() that a device type implementation can use to set or retrieve a thread-local variable containing the device error.
DEVICELIST_NEXT DeviceType::next_file |
Call to get next file in list.
dev | The current device. |
handle | A file list iterator pointer returned by the device type's DEVICELIST_START_LIST method. |
pattern | The pattern passed to the DEVICELIST_START_LIST method. |
entry | A structure in which to store the next matching filename. |
If there is another match for the pattern, a pointer to the filename should be stored in the entry argument's FILEENTRY::name field, and its length should be stored in the FILEENTRY::namelength field. The file name need not be zero-terminated. It must not be string on the C stack. The return value of the method should be FileNameMatch if there was a match.
After a failure, the DEVICELIST_LAST_ERROR method should return:
After a failure, the DEVICELIST_LAST_ERROR method should return DeviceIOError.
Note that if the underlying file system supports directories and the permissions on one or more directories do not allow the filenames in those directories to be enumerated this should not be treated as an error. The routine should just ignore those directories and continue the search for matches.
The Harlequin Core provides two routines to help implement this method in a device type. These are:
TRUE
if a zero-terminated string matches a zero-terminated pattern, or FALSE
if the string does not match the pattern.DEVICELIST_OPEN DeviceType::open_file |
Call to open file on device.
dev | The current device. |
filename | The file name to open. |
openflags | One of the following: SW_RDONLY, SW_WRONLY, SW_RDWR, Combined (using bitwise OR) with any combination of: SW_APPEND, SW_CREAT, SW_TRUNC, SW_EXCL. |
Descriptors have to be unique only for each device; different devices (even of the same device type) can use the same number for different files without confusion.
The PostScript language model of files is of a stream of bytes; that is, there is no record structure or distinction between binary and text files. The implementation of this method call must open the file in the appropriate way to support this (for example, by opening all files in binary mode on Windows).
After a failure, the DEVICELIST_LAST_ERROR method should return:
DEVICELIST_READ DeviceType::read_file |
Call to read data from file on device.
dev | The current device. |
descriptor | A descriptor returned by a previous open call. |
buff | Buffer into which the data read is stored. |
len | The maximum number of bytes to read. |
Unless the device type specifies an explicit size (as described in device_buffersize determine file buffer size the space available in buff (len) is guaranteed to be at least 1024 bytes, although the read routine can return fewer if appropriate.
If an error occurs, the Harlequin Core will not assume anything about the contents of the buffer. Thus, it is safe to put bytes into this buffer even if an error occurs at some point before all the bytes have been read. After a failure, the DEVICELIST_LAST_ERROR method should return DeviceIOError.
DEVICELIST_RENAME DeviceType::rename_file |
Rename file on the device.
dev | The current device. |
file1 | The name of a file to rename. |
file2 | The name to which file1 will be renamed. |
If there is no file named file1, then the DEVICELIST_LAST_ERROR method should return DeviceUndefined. If the device does not support renaming, or the particular filenames are not permitted to be changed, then the DEVICELIST_LAST_ERROR method should return DeviceInvalidAccess. After any other failure, the DEVICELIST_LAST_ERROR method should return DeviceIOError.
DEVICELIST_SEEK DeviceType::seek_file |
Call to seek file on device.
dev | The current device. |
descriptor | A descriptor returned by a previous open call. |
destn | The location to seek to. |
flags | One of SW_SET, SW_INCR, SW_XTND. |
TRUE
for success, FALSE
for failure.Some devices will be able to support positionable files that is, there is a current file position associated with the open file and the next read or write will read from, or write to, bytes at that point, and this current file position can be set.
The flags parameter indicates how the destn parameter should be interpreted. If flags is SW_SET, the current file position should be set to destn bytes from the start of the file. If flags is SW_INCR, the current file position should be changed by destn bytes, and if flags is SW_XTND, the current file position should be set to the length of the file plus destn. If this results in the current file position being beyond the current end of the file, the file is open for writing, and the file permissions allow it to be extended, then file will be extended to the current file position. [RB3] does not specify the values in any bytes between the old and new lengths of the file.
Calls to this method with a value of zero in the destn argument have special meanings. The meaning of such a call depends on the value of the flags argument. Even if a device cannot support seeking, it is usually possible to implement support for some or all of these special calls:
TRUE
if it does, or FALSE
otherwise.After a failure, the DEVICELIST_LAST_ERROR method should return DeviceIOError.
DEVICELIST_SET_PARAM DeviceType::set_param |
Call to set a device parameter.
dev | The current device. |
param | A structure describing the parameter to set and its value. |
The PostScript language operator setdevparams
will call this device routine. The param argument specifies the device parameter name and its value in the DEVICEPARAM structure. Parameters are always named by a string, specified by DEVICEPARAM::paramname and DEVICEPARAM::paramnamelen, and accessible through theIDevParamName() and theIDevParamNameLen() macros. Note that the parameter name is not necessarily zero-terminated, the parameter length should always be checked when accessing the parameter name.
The DEVICEPARAM::type field indicates the type of the parameter to set. This will be one of:
Strings set using this method are stored in the Harlequin Core internal memory which may be re-used; therefore, if the device needs to keep referring to the string, it must copy it into its own memory.
This method returns a code to indicate the success or failure of setting the parameter:
The following device parameters are valid for all devices, and are not passed to the device. They are handled internally by the Harlequin Core:
invalidaccess
error is generated if the device's type has not been set yet.The Harlequin RIP SDK provides some utility routines to assist writing parameter methods:
DEVICELIST_START_LIST DeviceType::start_file_list |
Call to start iterating file names.
dev | The current device. |
pattern | A file pattern to match. |
NULL
for failure. If it is known that no files match the pattern, then NULL
may be returned, and an immediate call to the DEVICELIST_LAST_ERROR routine should return DeviceNoError.This routine should do any initializion necessary such that successive calls to DEVICELIST_NEXT return filenames matching that template. The pointer returned by this function will be passed to the each call to DEVICELIST_NEXT. The implementation of DEVICELIST_NEXT should use the pointer to identify where in the enumeration of files matching this pattern it has reached. It is possible to have recursive calls to filenameforall
, so nested filename enumerations must be supported.
If for some reason the enumeration cannot be started, the routine should return NULL
. After a failure, the DEVICELIST_LAST_ERROR method should return:
If this function succeeds, the device type's DEVICELIST_END_LIST method must be called after iterating file names.
DEVICELIST_START_PARAM DeviceType::start_param |
Call to start iterating device parameters.
dev | The current device. |
This routine is called by the PostScript language operator currentdevparams
to determine how many parameters will be returned, and to start enumerating them. The number returned need not be the same as the number of device parameter names recognized by the device, because some device parameters can be write only, or a parameter may only be returned once a value has been set for it. The number excludes the parameters that are handled by the interpreter itself (/Password
, /DeviceType
, /Enable
). Following this call, DEVICELIST_GET_PARAM will be called multiple times with a NULL
DEVICEPARAM::paramname field to get each of the parameters.
If there are no such device parameters, 0 should be returned. If an error occurs, -1 should be returned.
DEVICELIST_STATUS_DEVICE DeviceType::status_device |
Call to get the status of the device.
dev | The current device. |
devstat | A structure in which to return the status of the device. |
This routine returns information on the device. The interpretation of these is device-dependent, but for a device that supports files such as a hard disk:
DEVICELIST_STATUS_FILE DeviceType::status_file |
Call to check status of file.
dev | The current device. |
filename | The file to check status. |
statbuff | Pointer to a structure in which to put the file status. |
This routine returns information about a named file on the device. If the file exists, the fields in the structure pointed to by the statbuff argument should be set appropriately and 0 is returned to indicate success:
Suitable default values may be substituted for either time if they are not supported by the underlying file system. The time units and origin are not defined by [RB3]: the only legal interpretation of these values by a PostScript language program is to assume that a larger value means a later time. This implies that the value should not overflow a signed 32-bit integer in the near future. Global Graphics recommends that if the implementation has a real time clock, the times should be measured in seconds since 00:00:00 (midnight), 1st Jan. 1970. If additionally, the implementation supports time zones, this should be in measured in the UTC time zone. This is the same as the UNIX definition. If there is no real time clock, any monotonically increasing value can be used. If files persist between invocations of the product, the current value of this "clock" must be stored in some permanent storage.
After a failure, the DEVICELIST_LAST_ERROR method should return DeviceIOError.
DEVICELIST_WRITE DeviceType::write_file |
Call to write data to file on device.
dev | The current device. |
descriptor | A descriptor returned by a previous open call. |
buff | Buffer from which the data written is taken. |
len | The maximum number of bytes to write. |
After a failure, the DEVICELIST_LAST_ERROR method should return DeviceIOError.