Jump to content

SplProtWrite: Difference between revisions

From EDM2
Created page with "SplProtWrite is an optional API and is exported by protocol converters. It is called by PrtWrite to put a BIDI protocol wrapper around print data and then send the data to the..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
SplProtWrite is an optional API and is exported by protocol converters. It is called by PrtWrite to put a BIDI protocol wrapper around print data and then send the data to the printer.  
SplProtWrite is an optional API and is exported by protocol converters. It is called by PrtWrite to put a BIDI protocol wrapper around print data and then send the data to the printer.


SplProtWrite is responsible for breaking write packets into sub-packets to accommodate packet size restrictions from the printer.  
SplProtWrite is responsible for breaking write packets into sub-packets to accommodate packet size restrictions from the printer.


If the BIDI software protocol being used requires print job data to have a wrapper around it (see BIDI_Q_SW(800Ch) in BIDI Command Structures and Command Flow), the spooler calls SplProtWrite, the protocol converter's API. SplProtWrite then calls the port driver's SplPdWrite routine with an updated buffer.
If the BIDI software protocol being used requires print job data to have a wrapper around it (see BIDI_Q_SW(800Ch) in BIDI Command Structures and Command Flow), the spooler calls SplProtWrite, the protocol converter's API. SplProtWrite then calls the port driver's SplPdWrite routine with an updated buffer.


== Syntax ==
== Syntax ==
  SplProtWrite(hDevice, pszDeviceName,
  SplProtWrite(hDevice, pszDeviceName,
       pfnPdWrite, pfnBaseProtWrite, pchData,
       pfnPdWrite, pfnBaseProtWrite, pchData,
Line 11: Line 11:


== Parameters ==
== Parameters ==
;hDevice (HFILE) - input  
;hDevice (HFILE) - input:Handle from SplPdOpen to pass to SplPdWrite.
:Handle from SplPdOpen to pass to SplPdWrite.  
;pszDeviceName (PSZ) - input:Device name.
 
:Port name being written to.
;pszDeviceName (PSZ) - input  
;pfnPdWrite (PFN) - input:Address of port driver function SplPdWrite.
:Device name.  
;pfnBaseProtWrite (PFN) - input:Base protocol converter address for ProtWrite routine.
 
:This is NULL unless the protocol converter is an extension to the base protocol converter. If not NULL, the extension protocol converter can call the base converter at this address to let the base converter process the command.
:Port name being written to.  
; pchData (PVOID) - input: Pointer to the data buffer to write.
 
; cbInData (ULONG) - input: Length of information in pchData, in bytes.
;pfnPdWrite (PFN) - input  
; pcbWritten (PULONG) - output: Pointer to count of bytes actually written to the device.
:Address of port driver function SplPdWrite.  
: This value can be updated even when an unsuccessful return code is given, if some of the data was sent to the printer.
 
;pfnBaseProtWrite (PFN) - input  
:Base protocol converter address for ProtWrite routine.  
 
:This is NULL unless the protocol converter is an extension to the base protocol converter. If not NULL, the extension protocol converter can call the base converter at this address to let the base converter process the command.  
 
; pchData (PVOID) - input  
: Pointer to the data buffer to write.  
 
; cbInData (ULONG) - input  
: Length of information in pchData, in bytes.  
 
; pcbWritten (PULONG) - output  
: Pointer to count of bytes actually written to the device.  
 
: This value can be updated even when an unsuccessful return code is given, if some of the data was sent to the printer.  


== Returns ==
== Returns ==
; rc (ULONG) - returns : Return codes.
; rc (ULONG) - returns : Return codes.
 
 
*0 Success
 
:;Note:: *pcbWritten is updated with the number of bytes sent to the printer. If all bytes were not written, it should be considered an error.
 
*6(ERROR_INVALID_HANDLE)
:Invalid handle given.
 
*28(ERROR_OUT_OF_PAPER)
:The printer is out of paper.
 
*29(ERROR_WRITE_FAULT)
:Failure attempting to write to the device.
 
*32(ERROR_SHARING_VIOLATION)
:Another thread has access to this port using this handle. This situation can occur if another thread is in the process of a PrtWrite using this Prt handle.
 
*87(ERROR_INVALID_PARAMETER)
:An invalid buffer given.  


*0 Success
:;Note:: *pcbWritten is updated with the number of bytes sent to the printer. If all bytes were not written, it should be considered an error.
*6(ERROR_INVALID_HANDLE) :Invalid handle given.
*28(ERROR_OUT_OF_PAPER) :The printer is out of paper.
*29(ERROR_WRITE_FAULT) :Failure attempting to write to the device.
*32(ERROR_SHARING_VIOLATION) :Another thread has access to this port using this handle. This situation can occur if another thread is in the process of a PrtWrite using this Prt handle.
*87(ERROR_INVALID_PARAMETER) :An invalid buffer given.


== Sample ==
== Sample ==

Latest revision as of 19:54, 2 July 2023

SplProtWrite is an optional API and is exported by protocol converters. It is called by PrtWrite to put a BIDI protocol wrapper around print data and then send the data to the printer.

SplProtWrite is responsible for breaking write packets into sub-packets to accommodate packet size restrictions from the printer.

If the BIDI software protocol being used requires print job data to have a wrapper around it (see BIDI_Q_SW(800Ch) in BIDI Command Structures and Command Flow), the spooler calls SplProtWrite, the protocol converter's API. SplProtWrite then calls the port driver's SplPdWrite routine with an updated buffer.

Syntax

SplProtWrite(hDevice, pszDeviceName,
      pfnPdWrite, pfnBaseProtWrite, pchData,
      cbInData, pcbWritten);

Parameters

hDevice (HFILE) - input
Handle from SplPdOpen to pass to SplPdWrite.
pszDeviceName (PSZ) - input
Device name.
Port name being written to.
pfnPdWrite (PFN) - input
Address of port driver function SplPdWrite.
pfnBaseProtWrite (PFN) - input
Base protocol converter address for ProtWrite routine.
This is NULL unless the protocol converter is an extension to the base protocol converter. If not NULL, the extension protocol converter can call the base converter at this address to let the base converter process the command.
pchData (PVOID) - input
Pointer to the data buffer to write.
cbInData (ULONG) - input
Length of information in pchData, in bytes.
pcbWritten (PULONG) - output
Pointer to count of bytes actually written to the device.
This value can be updated even when an unsuccessful return code is given, if some of the data was sent to the printer.

Returns

rc (ULONG) - returns
Return codes.
  • 0 Success
Note
: *pcbWritten is updated with the number of bytes sent to the printer. If all bytes were not written, it should be considered an error.
  • 6(ERROR_INVALID_HANDLE) :Invalid handle given.
  • 28(ERROR_OUT_OF_PAPER) :The printer is out of paper.
  • 29(ERROR_WRITE_FAULT) :Failure attempting to write to the device.
  • 32(ERROR_SHARING_VIOLATION) :Another thread has access to this port using this handle. This situation can occur if another thread is in the process of a PrtWrite using this Prt handle.
  • 87(ERROR_INVALID_PARAMETER) :An invalid buffer given.

Sample

#define INCL_SPL
#define INCL_SPLBIDI
#include <os2.h>

HFILE     hDevice;           /*  Handle from SplPdOpen to pass to SplPdWrite. */
PSZ       pszDeviceName;     /*  Device name. */
PFN       pfnPdWrite;        /*  Address of port driver function SplPdWrite. */
PFN       pfnBaseProtWrite;  /*  Base protocol converter address for ProtWrite routine. */
PVOID     pchData;           /*  Pointer to the data buffer to write. */
ULONG     cbInData;          /*  Length of information in pchData, in bytes. */
PULONG    pcbWritten;        /*  Pointer to count of bytes actually written to the device. */
ULONG     rc;                /*  Return codes. */

rc = SplProtWrite(hDevice, pszDeviceName,
       pfnPdWrite, pfnBaseProtWrite, pchData,
       cbInData, pcbWritten);