T168_Debug222\appl\Barcode\Two\MPDF文件:PDFOBJ.C

/****************************************        B-N(伀)            *********************************/
/****************************************        B-N(仾)            *********************************/
/*********************************************************************
* Module Header
*
*  Identification:   pdfobj - Input/Output Object Module
*  Copyright (c) 1994-1997 Symbol Technologies, Inc.
*
* Edit History:      
*  $Log: PDFOBJ.C $
*  Revision 1.7  1997/11/21 00:23:56  Anne
*  Added Function to copy selected PDFObject fields and a function
*   to set them for code 128 emulation modes.
*  Revision 1.6  1997/04/30 18:56:58  toml
*  Fix bug in 32 bit land macro encode. The max file size was 
*  incorrect since it was using the 16-bit, non-huge limitation.
*  Revision 1.5  1997/04/24 13:19:50  toml
*  Added parsing ability for ECI protocol data -- recognize escapes
*  and remove double-slashes
*  Revision 1.4  1997/03/25 19:46:12  toml
*  Throw in a terminating NULL to the end of a memory output stream
*  The NULL character is not included into the objects length but
*  is performed to flag the end of a C style string output.
*  Revision 1.3  1997/03/13 20:23:50  toml
*  Ripped all WMF output handling and placed into OUTDIB.C
*  Revision 1.2  1997/03/06 16:13:04  toml
*  PDFObjGet and PDFObjLook return an int now. They return the
*  value -1 when EOF is reached.
*  Revision 1.1  1997/02/11 15:42:44  toml
*  Initial revision
*
*  Description:      Controls the input object which supplies the
*                    the library with data to encode.
*
*  Call Tree:         
*
**********************************************************************/

/*********************************************************************
                                 Include Files
*********************************************************************/
#include "pdfapi.h"
#include "apienc.h"
#include "pdfobj.h"
#include "memfunc.h"
#include "session.h"


/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14 #include <windowsx.h>      *//* Windows helper macros */
/* // 98.04.14 #endif                                                */

/*********************************************************************
                                    Defines
*********************************************************************/
#ifdef HUGE_PTRS
/*
* MAXENCODELEN calculated assuming macro PDF with a file id of one
* codeword, ECC level 0, 99,998 symbols of TC data with a compression
* factor of 2 characters/codeword
*/
#define  MAXENCODELEN   183996320UL    /* ECC 0, TC data, 99998 symbols */
/****************************************        B-N(伀)            *********************************/
/* typedef BUFDATA _huge *HUGEBUFPTR;                                        */
typedef BUFDATA *HUGEBUFPTR;
/****************************************        B-N(仾)            *********************************/
#elif (ENVTYPE == PDF_E_WIN32)
#define  MAXENCODELEN   183996320UL    /* ECC 0, TC data, 99998 symbols */
#else
#define  MAXENCODELEN   65000L
#endif

/*********************************************************************
                                Local Data
*********************************************************************/
#if LIBTYPE == PDF_L_STATIC
static char abObjBuf[ sizeof(PDFInState) ];
#endif /* LIB_STATIC */

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjFindLen
*
* Description:       This routine will try to determine the length of
*                    the input stream. When the application does not
*                    specify an encode length, an input length of zero,
*                    then we try to determine the number of bytes to
*                    encode.
*
* Synopsis:          uint32 PDFObjFindLen( LPPDFObject lpObj )
*
*  Parameters:       lpObj - input object
*
*  Return Value:     Number of bytes in input stream.
*
**********************************************************************/
static PDFSIZET PDFObjFindLen( LPPDFObject lpObj )
{
   PDFSIZET nLen;

   switch( IsIOType( lpObj ) ) {
/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14       case IOTYPE_CLIPBOARD:                                    */
/* // 98.04.14          if ( lpObj->access.clip.lpMem )                                */
/* // 98.04.14             nLen = STRLEN( lpObj->access.clip.lpMem );                        */
/* // 98.04.14          else                                            */
/* // 98.04.14             nLen = 0;                                        */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #endif *//* ENVTYPE == windows */

      case IOTYPE_CALLBACK:
         nLen = (*lpObj->access.func.lpfnCallback)( PDFIO_GETINLEN, NULL,
                  0, lpObj->access.func.lpAppArg );
      break;
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14       case IOTYPE_FILE:                                        */
/* // 98.04.14          nLen = (PDFSIZET)PDFFileLength( lpObj->access.file.hFile );                */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */
      case IOTYPE_MEMORY:
      default:
         nLen = 0;
      break;
   }
   return nLen;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjSyncInput
*
* Description:       This routine is invoked each time an encode is
*                    attempted. The input state variables are initialized
*                    as well as the input length variable.
*
*                    The following status values are returned:
*                       SEQ_BEGIN   The input has been initialized with
*                                   no bytes read
*                       SEQ_MID     Currently in a macro PDF sequence
*                       SEQ_EOF     No more data from input object
*
*                    The status' are required for macro PDF only -- normal
*                    symbols must contain the entire input stream. 
*
* Synopsis:          int PDFObjSyncInput( LPPDFObject lpObj, uint32 nFilelen )
*
*  Parameters:       lpObj - input object
*                    nFilelen - total length of input source
*
*  Return Value:     Returns a positive sequence status code; negative
*                    error code if failed.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Switch on input object state
*     Case first time:
*        Initialize object
*     Case subsequent read
*        Keep going
*     Case input exhausted
*        Reset state 
*  EndCase
* End Pseudocode *****************************************************
**********************************************************************/
SEQSTATE PDFObjSyncInput( LPPDFObject lpObjIn, PDFSIZET nFileLen )
{
   SEQSTATE nSeqStatus;
   /*
   * Guard against NULL input object pointer
   */
   if ( lpObjIn ) {
      if ( lpObjIn->ioDirection == PDFINPUT ) {
         switch( ((LPPDFInState)lpObjIn->lpState)->nState ) {
            case ST_NODATALOADED:
               /*
               * Set initial state
               */ 
               nSeqStatus = SEQ_BEGIN; /* assume we'll init okay */

               switch( IsIOType( lpObjIn ) ) {
/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14                   case IOTYPE_CLIPBOARD:                                */
/* // 98.04.14                                                              */
/* // 98.04.14                      * If clipboard contents have not been assigned then get a            */
/* // 98.04.14                      * copy of the clipboard data                        */
/* // 98.04.14                                                              */
/* // 98.04.14                      if ( !lpObjIn->access.clip.lpMem ) {                    */
/* // 98.04.14                         nFileLen = 0;                                */
/* // 98.04.14                         if ( IsClipboardFormatAvailable( CF_TEXT ) ) {                */
/* // 98.04.14                            if ( OpenClipboard( NULL ) ) {                    */
/* // 98.04.14                               HGLOBAL hClip = GetClipboardData( CF_TEXT );            */
/* // 98.04.14                               LPSTR lpSource = (LPSTR)GlobalLock( hClip );            */
/* // 98.04.14                                                                   */
/* // 98.04.14                               * Make a copy of the source information                */
/* // 98.04.14                                                                   */
/* // 98.04.14                               nFileLen = STRLEN( lpSource );                    */
/* // 98.04.14                               lpObjIn->access.clip.lpMem = (LPMEMBUF)GlobalAllocPtr( GMEM_MOVEABLE, nFileLen+1 );    */
/* // 98.04.14                               STRCPY( lpObjIn->access.clip.lpMem, lpSource );            */
/* // 98.04.14                                                     */
/* // 98.04.14                               GlobalUnlock( hClip );                        */
/* // 98.04.14                               CloseClipboard();                            */
/* // 98.04.14                            }                                    */
/* // 98.04.14                         }                                    */
/* // 98.04.14                      }                                        */
/* // 98.04.14                   break;                                        */
/* // 98.04.14 #endif *//* ENVTYPE == windows */
/* // 98.04.14                                                     */
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14                   case IOTYPE_FILE:                                */
/* // 98.04.14                                                              */
/* // 98.04.14                      * If file I/O type then we note the current position            */
/* // 98.04.14                      * before we proceed. In the event we need to rewind the            */
/* // 98.04.14                      * input file (for macro PDF) we reset back to the                */
/* // 98.04.14                      * saved position                                */
/* // 98.04.14                      lpObjIn->access.file.nInitPos = PDFFileTell( lpObjIn->access.file.hFile );    */
/* // 98.04.14                   break;                                        */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */

                  case IOTYPE_MEMORY:
                  case IOTYPE_CALLBACK:
                     ;  /* nothing to do -- just verified I/O type field */
                  break;
                  default:
                     nSeqStatus = ERR_INVALIDINPUTOBJECT;
                  break;
               }
               /*
               * See if input type was valid and initialize state variable 
               * and validate input length
               */
               if ( nSeqStatus == SEQ_BEGIN ) {
                  /*
                  * If application defered the input length then we
                  * try to determine it.
                  */
                  if ( nFileLen == 0 )
                     nFileLen = PDFObjFindLen( lpObjIn );

                  if ( nFileLen <= MAXENCODELEN ) {
                     lpObjIn->nLen = nFileLen;
                     ((LPPDFInState)lpObjIn->lpState)->nState = (nFileLen != 0 ? ST_ENCODINGDATA : ST_DATADONE);
                  }
                  else
                     nSeqStatus = ERR_TOOMUCHDATA;
               }
            break;
            case ST_ENCODINGDATA:
               if ( !PDFObjIsEOF( lpObjIn ) ) {
                  nSeqStatus = SEQ_MID;    /* continue encoding input data */
                  break;
               }
               /*
               * else -- exhausted data : FALL-THROUGH!
               */
            case ST_DATADONE:
               ((LPPDFInState)lpObjIn->lpState)->nState = ST_NODATALOADED;
               nSeqStatus = SEQ_EOF;
            break;
            default:
               nSeqStatus = ERR_INVALIDINPUTOBJECT;
            break;
         }
      }
      else
         nSeqStatus = ERR_NOTINPUTDEVICE;
   }
   else
      nSeqStatus = ERR_NULLDATASOURCE;

   return( nSeqStatus );
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      RefreshObjBuffer
*
* Description:       Fill the internal buffer of the input object with
*                    data from the source: file, routine or memory buffer.
*                    The gap between the 'get' pointer and the 'put'
*                    pointer is filled with data and the 'put' pointer
*                    is advanced.
*
*                    If the calculate-checksum option is enabled we
*                    update the running checksum with the new data.
*
* Synopsis:          void RefreshObjBuffer( LPPDFObject lpObj )
*
*  Parameters:       lpObj - input stream
*
*  Return Value:     None;
*
**********************************************************************/
static void RefreshObjBuffer( LPPDFObject lpObj )
{
   uint16 nGetBytes, nBytesRead;
   LPPDFInState lpState = (LPPDFInState)lpObj->lpState;
   LPBUF lpDest = &lpState->acBuf[ lpState->Put.nBuffOffset ];

   if ( lpState->Put.nBuffOffset < lpState->Get.nBuffOffset )
      nGetBytes = lpState->Get.nBuffOffset - lpState->Put.nBuffOffset;
   else
      nGetBytes = LOOKBUFLEN - lpState->Put.nBuffOffset;

   switch( lpObj->ioType ) {
      case IOTYPE_CALLBACK:
         nBytesRead = (uint16)(*lpObj->access.func.lpfnCallback)(
            PDFIO_READ,
            lpDest,
            nGetBytes,
            lpObj->access.func.lpAppArg );
      break;
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14       case IOTYPE_FILE:                                        */
/* // 98.04.14          nBytesRead = PDFReadFile( lpObj->access.file.hFile,                    */
/* // 98.04.14             lpDest,                                        */
/* // 98.04.14             nGetBytes );                                        */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */
      case IOTYPE_MEMORY:
#ifdef HUGE_PTRS
         if ( lpObj->fIsHuge ) {
            uint16 i;
            PDFSIZET nOffset = lpState->Put.nOffset;

            for( i=0; i < nGetBytes; i++, nOffset++ )
               lpDest[i] = ((HUGEBUFPTR)lpObj->access.lpMemBuffer)[ nOffset ];
         }
         else
#endif /* HUGE_PTRS */
            MEMCPY( lpDest,
               &lpObj->access.lpMemBuffer[ lpState->Put.nOffset ],
               nGetBytes );
         nBytesRead = nGetBytes;
      break;
/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14       case IOTYPE_CLIPBOARD:                                    */
/* // 98.04.14          MEMCPY( lpDest,                                        */
/* // 98.04.14             &lpObj->access.clip.lpMem[ lpState->Put.nOffset ],                    */
/* // 98.04.14             nGetBytes );                                        */
/* // 98.04.14          nBytesRead = nGetBytes;                                    */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #endif *//* ENVTYPE == windows */
      default:
         nBytesRead = 0;
      break;
   }
   /*
   * Advance the 'Put' pointer to account for added data to buffer
   * and overall offset (nOffset) into the input stream
   */
   lpState->Put.nBuffOffset += nBytesRead;
   if ( lpState->Put.nBuffOffset >= LOOKBUFLEN )
      lpState->Put.nBuffOffset = 0;

   lpState->Put.nOffset += nBytesRead;
}
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjLook
*
* Description:       This routine is used to 'look ahead' into the
*                    input stream. During PDF encoding we scan ahead
*                    into the data to determine the optimal mode for
*                    encoding. A separate pointer into the PDFObject's
*                    internal buffer is maintined for look-ahead. This
*                    pointer is distinct from the buffer pointer
*                    used to extract data from the object - when encoding
*                    the data for the symbol.
*
* Synopsis:          int16 PDFObjLook( LPPDFObject lpObj )
*
*  Parameters:       lpObj - input stream
*
*  Return Value:     Return the extracted data byte from the buffer (0-255)
*                    or -1 if at EOF
*
**********************************************************************/
int16 PDFObjLook( LPPDFObject lpObj )
{
   int16 nRetChar = -1;
   LPPDFInState lpState = (LPPDFInState)lpObj->lpState;
   /*
   * If an 'unget' character exists then return its value
   */
   if ( lpState->Look.cUnget != EOF_FLAG ) {
      nRetChar = (int16)((uchar)lpState->Look.cUnget);
      lpState->Look.cUnget = EOF_FLAG;
   }
   /*
   * Otherwise, make sure there is more data to get from input stream
   */
   else if ( lpState->Look.nOffset < lpObj->nLen ) {
      if ( lpObj->ioType == IOTYPE_MEMORY ) {
#ifdef HUGE_PTRS
         if ( lpObj->fIsHuge )
            nRetChar = (int16)(((HUGEBUFPTR)lpObj->access.lpMemBuffer)[ lpState->Look.nOffset ]);
         else
#endif /* HUGE_PTRS */
            nRetChar = (int16)(lpObj->access.lpMemBuffer[ lpState->Look.nOffset ]);
      }
/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14       else if ( lpObj->ioType == IOTYPE_CLIPBOARD ) {                        */
/* // 98.04.14          nRetChar = (int16)(lpObj->access.clip.lpMem[ lpState->Look.nOffset ]);            */
/* // 98.04.14       }                                                */
/* // 98.04.14 #endif *//* ENVTYPE == windows */
      else { /* input through IOTYPE_FILE or IOTYPE_CALLBACK */
         /*
         * See if we caught up to 'put' pointer (end of buffer), if so
         * then get more data into buffer
         */
         if ( lpState->Look.nOffset == lpState->Put.nOffset )
            (*lpState->pfnFillBuff)( lpObj );

         nRetChar = (int16)(lpState->acBuf[ lpState->Look.nBuffOffset++ ]);
         /*
         * Check for look-ahead buffer index wrap
         */
         if ( lpState->Look.nBuffOffset == LOOKBUFLEN )
            lpState->Look.nBuffOffset = 0;
      }
      /*
      * Advance overall input stream offset
      */
      lpState->Look.nOffset++;
      /*
      * Kluge ECI input stuff - check for escaped character
      */
      if ( lpState->fIsECIFormat && ((char)nRetChar == '\\') ) {
         /*
         * Get next char from buffer. If another '\' then simply return
         * the backslash, otherwise (must be a digit) if a digit then force
         * a simulated EOF since we're at an ECI transitional point
         */
         if ( lpState->Look.nOffset < lpObj->nLen ) {
            if ( lpObj->ioType == IOTYPE_MEMORY ) {
      #ifdef HUGE_PTRS
               if ( lpObj->fIsHuge )
                  nRetChar = (int16)(((HUGEBUFPTR)lpObj->access.lpMemBuffer)[ lpState->Look.nOffset ]);
               else
      #endif /* HUGE_PTRS */
                  nRetChar = (int16)(lpObj->access.lpMemBuffer[ lpState->Look.nOffset ]);
            }
/* // 98.04.14       #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14             else if ( lpObj->ioType == IOTYPE_CLIPBOARD ) {                    */
/* // 98.04.14                nRetChar = (int16)(lpObj->access.clip.lpMem[ lpState->Look.nOffset ]);        */
/* // 98.04.14             }                                            */
/* // 98.04.14       #endif *//* ENVTYPE == windows */
            else { /* input through IOTYPE_FILE or IOTYPE_CALLBACK */
               /*
               * See if we caught up to 'put' pointer (end of buffer), if so
               * then get more data into buffer
               */
               if ( lpState->Look.nOffset == lpState->Put.nOffset )
                  (*lpState->pfnFillBuff)( lpObj );

               nRetChar = (int16)(lpState->acBuf[ lpState->Look.nBuffOffset++ ]);
               /*
               * Check for look-ahead buffer index wrap
               */
               if ( lpState->Look.nBuffOffset == LOOKBUFLEN )
                  lpState->Look.nBuffOffset = 0;
            }
         }
         else
            nRetChar = -1;       /* EOF really reached */
         /*
         * Now see what type of character it is
         */
         if ( (char)nRetChar != '\\' ) {
            lpState->fAtECITagSeq = TRUE;    /* Mark pseudo-EOF */
            lpState->Look.cUnget = nRetChar;
            nRetChar = -1;    /* Flag caller that we're at EOF */
         }
      }
   }
   /*
   * ELSE no more in look-ahead buffer -- return -1 (should be
   *      detected by the PDFObjIsLookEOF() macro)
   */
   return nRetChar;
}
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjGet
*
* Description:       Remove a data byte from the PDFObject's internal
*                    buffer.
*
* Synopsis:          int PDFObjGet( LPPDFObject lpObj )
*
*  Parameters:       lpObj - input stream
*
*  Return Value:     Return the extracted data byte from the buffer (0-255)
*                    or -1 if at EOF
*
**********************************************************************/
int16 PDFObjGet( LPPDFObject lpObj )
{
   int16 nRetChar = -1;
   LPPDFInState lpState = (LPPDFInState)lpObj->lpState;
   /*
   * If an 'unget' character exists then return its value
   */
   if ( lpState->Get.cUnget != EOF_FLAG ) {
      nRetChar = (int16)((uchar)lpState->Get.cUnget);
      lpState->Get.cUnget = EOF_FLAG;
   }
   /*
   * Otherwise, make sure there is more data to get from input stream
   */
   else if ( lpState->Get.nOffset < lpObj->nLen ) {
      if ( lpObj->ioType == IOTYPE_MEMORY ) {
#ifdef HUGE_PTRS
         if ( lpObj->fIsHuge )
            nRetChar = (int16)(((HUGEBUFPTR)lpObj->access.lpMemBuffer)[ lpState->Get.nOffset ]);
         else
#endif /* HUGE_PTRS */
            nRetChar = (int16)(lpObj->access.lpMemBuffer[ lpState->Get.nOffset ]);
      }
/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14       else if ( lpObj->ioType == IOTYPE_CLIPBOARD ) {                        */
/* // 98.04.14          nRetChar = (int16)(lpObj->access.clip.lpMem[ lpState->Get.nOffset ]);            */
/* // 98.04.14       }                                                */
/* // 98.04.14 #endif *//* ENVTYPE == windows */
      else { /* input through IOTYPE_FILE or IOTYPE_CALLBACK */
         /*
         * See if we caught up to 'put' pointer (end of buffer), if so
         * then get more data into buffer
         */
         if ( lpState->Get.nOffset == lpState->Put.nOffset )
            (*lpState->pfnFillBuff)( lpObj );

         nRetChar = (int16)(lpState->acBuf[ lpState->Get.nBuffOffset++ ]);
         /*
         * Check for buffer index wrap
         */
         if ( lpState->Get.nBuffOffset == LOOKBUFLEN )
            lpState->Get.nBuffOffset = 0;
         /*
         * Make sure look-ahead buffer index keeps pace with the 'Get' ptr
         */
         lpState->Look.nBuffOffset = lpState->Get.nBuffOffset;
      }
      /*
      * Advance the input stream offset (nOffset) and update the look-ahead
      * offset so it keeps pace with it
      */
      lpState->Look.nOffset = ++lpState->Get.nOffset;
      /*
      * Big kluge for ECI formatted data -- if we see an escape character
      * then just eat it and return the next character. Note that the ECI
      * mode sequences (six digit ECI value) are detected through the 
      * LookAhead phase
      */   
      if ( lpState->fIsECIFormat && ((char)nRetChar == '\\') ) {
         /*
         * Clear the simulated EOF anytime we GET an escaped character
         * from the buffer
         */
         lpState->fAtECITagSeq = FALSE;

         if ( lpState->Get.nOffset < lpObj->nLen ) {
            if ( lpObj->ioType == IOTYPE_MEMORY ) {
      #ifdef HUGE_PTRS
               if ( lpObj->fIsHuge )
                  nRetChar = (int16)(((HUGEBUFPTR)lpObj->access.lpMemBuffer)[ lpState->Get.nOffset ]);
               else
      #endif /* HUGE_PTRS */
                  nRetChar = (int16)(lpObj->access.lpMemBuffer[ lpState->Get.nOffset ]);
            }
/* // 98.04.14       #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14             else if ( lpObj->ioType == IOTYPE_CLIPBOARD ) {                    */
/* // 98.04.14                nRetChar = (int16)(lpObj->access.clip.lpMem[ lpState->Get.nOffset ]);        */
/* // 98.04.14             }                                            */
/* // 98.04.14       #endif *//* ENVTYPE == windows */
            else { /* input through IOTYPE_FILE or IOTYPE_CALLBACK */
               /*
               * See if we caught up to 'put' pointer (end of buffer), if so
               * then get more data into buffer
               */
               if ( lpState->Get.nOffset == lpState->Put.nOffset )
                  (*lpState->pfnFillBuff)( lpObj );

               nRetChar = (int16)(lpState->acBuf[ lpState->Get.nBuffOffset++ ]);
               /*
               * Check for buffer index wrap
               */
               if ( lpState->Get.nBuffOffset == LOOKBUFLEN )
                  lpState->Get.nBuffOffset = 0;
               /*
               * Make sure look-ahead buffer index keeps pace with the 'Get' ptr
               */
               lpState->Look.nBuffOffset = lpState->Get.nBuffOffset;
            }
            /*
            * Advance the input stream offset (nOffset) and update the look-ahead
            * offset so it keeps pace with it
            */
            lpState->Look.nOffset = ++lpState->Get.nOffset;
         }
         else
            nRetChar = -1;    /* real EOF */
      }
      /*
      * Check for request to generate a running checksum on data
      */
/* // 98.04.14 #ifndef PDF_NOMACROPDF                                        */
/* // 98.04.14       if ( lpState->fDoCRC )                                    */
/* // 98.04.14          lpState->nCRC = CRC16Update( lpState->nCRC, (uint8)nRetChar );                */
/* // 98.04.14 #endif *//* PDF_NOMACROPDF */
   }
   /*
   * ELSE we've exhausted the stream -- return -1 (should be detected
   *      through the PDFObjIsEOF() macro)
   */
   return nRetChar;
}
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      ResetStateVars
*
* Description:       This routine will initialize the variables associated
*                    with an input objects state. The status information
*                    is maintained within a memory buffer: PDFInState.
*                    The caller can supply this buffer or, if none is
*                    supplied, the default state buffer is setup and
*                    returned.
*
* Synopsis:          void ResetStateVars( LPPDFObject lpObj, 
*                       LPPDFInState lpStateBuf )
*
*  Parameters:       lpObj - input stream to assign PDFInState buffer
*                    lpStateBuf - state buffer or NULL if default buffer
*                       is to be assigned.
*
*  Return Value:     None.
*
**********************************************************************/
static void ResetStateVars( LPPDFObject lpObj, LPPDFInState lpStateBuf )
{
   if ( lpObj->ioDirection == PDFINPUT ) {
      /*
      * If state buffer was not supplied then assign standard buffer -- a
      * single session (thread) may only have one active encode input
      * sequence.
      */
      if ( !lpStateBuf )
         lpStateBuf = (LPPDFInState)GetSessionPDFObjBuf();
      
      if ( lpStateBuf ) {
         MEMSET( lpStateBuf, 0, sizeof(PDFInState) );
      
         lpStateBuf->nState = ST_NODATALOADED;
         lpStateBuf->Get.cUnget = EOF_FLAG;
         lpStateBuf->Look.cUnget = EOF_FLAG;
         lpStateBuf->pfnFillBuff = RefreshObjBuffer;
         /*
         * Update callers lpObj with state buffer assigned/initialized
         */
         lpObj->lpState = lpStateBuf;
      }
   }
}
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjRewind
*
* Description:       Reset the input stream back to its initial state
*                    and data position.
*
* Synopsis:          void PDFObjRewind( LPPDFObject lpObj )
*
*  Parameters:       lpObj - input stream
*
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 void PDFObjRewind( LPPDFObject lpObj )                                */
/* // 98.04.14 {                                                */
/* // 98.04.14    if ( IsIODirection( lpObj ) == PDFINPUT ) {                            */
/* // 98.04.14                                                       */
/* // 98.04.14       * Reset look-ahead buffer pointers and state variables                    */
/* // 98.04.14                                                       */
/* // 98.04.14       ResetStateVars( lpObj, lpObj->lpState );                            */
/* // 98.04.14                                                       */
/* // 98.04.14       * Rewind the source of the data -- for memory input this is unecessary            */
/* // 98.04.14                                                       */
/* // 98.04.14       if ( IsIOType( lpObj ) == IOTYPE_CALLBACK )                        */
/* // 98.04.14          (void)(*lpObj->access.func.lpfnCallback)( PDFIO_REWIND, (LPVOID)0, 0, lpObj->access.func.lpAppArg );    */
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14       else if ( IsIOType( lpObj ) == IOTYPE_FILE )                        */
/* // 98.04.14          PDFRewindFileTo( lpObj->access.file.hFile, lpObj->access.file.nInitPos );        */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */
/* // 98.04.14                                                       */
/* // 98.04.14       * Re-sync the object with the input stream                            */
/* // 98.04.14                                                       */
/* // 98.04.14       (void)PDFObjSyncInput( lpObj, lpObj->nLen );                        */
/* // 98.04.14    }                                                */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjNewCallback
*
* Description:       Initialize a new PDFObject I/O stream using a callback
*                    function as a data source/destination.
*
* Synopsis:          void PDFObjNewCallback( LPPDFObject lpObj, 
*                       uint16 ioDirection, LPFNPDFIO lpfnCallback,
                        LPVOID lpArg, LPVOID lpStateBuf )
*
*  Parameters:       lpObj - I/O object to intialize
*                    ioDirection - I/O direction (input or output)
*                    lpfnCallback - address of function to be used for
*                       data requests/writes
*                    lpArg - optional generic argument, supplied by 
*                       caller, which is passed to callback function during
*                       I/O requests
*                    lpStateBuf - input object state buffer; NULL if default
*                       state buffer is to be used
*
*  Return Value:     None.
*
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 void PDFObjNewCallback( LPPDFObject lpObj, uint16 ioDirection, LPFNPDFIO lpfnCallback,        */
/* // 98.04.14                   LPVOID lpArg, LPVOID lpStateBuf )                        */
/* // 98.04.14 {                                                */
/* // 98.04.14    MEMSET( lpObj, 0, sizeof(PDFObject) );                            */
/* // 98.04.14                                                     */
/* // 98.04.14    lpObj->ioType = IOTYPE_CALLBACK;                                */
/* // 98.04.14    lpObj->ioDirection = ioDirection;                                */
/* // 98.04.14    lpObj->access.func.lpfnCallback = lpfnCallback;                        */
/* // 98.04.14    lpObj->access.func.lpAppArg = lpArg;                                */
/* // 98.04.14                                                     */
/* // 98.04.14    ResetStateVars( lpObj, lpStateBuf );                                */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjNewMem
*
* Description:       Initialize a new PDFObject I/O stream using a memory
*                    buffer as a data source/destination.
*
* Synopsis:          void PDFObjNewMem( LPPDFObject lpObj, 
*                       uint16 ioDirection, LPVOID lpBase, LPVOID lpStateBuf )
*
*  Parameters:       lpObj - I/O object to intialize
*                    ioDirection - I/O direction (input or output)
*                    lpBase - I/O memory buffer address
*                    lpStateBuf - input object state buffer; NULL if default
*                       state buffer is to be used
*
*  Return Value:     None.
*
**********************************************************************/
void PDFObjNewMem( LPPDFObject lpObj, uint16 ioDirection, LPVOID lpBase,
               LPVOID lpStateBuf )
{
   MEMSET( lpObj, 0, sizeof(PDFObject) );

   lpObj->ioType = IOTYPE_MEMORY;
   lpObj->ioDirection = ioDirection;
   lpObj->access.lpMemBuffer = (LPMEMBUF)lpBase;

   ResetStateVars( lpObj, lpStateBuf );
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjNewFile
*
* Description:       Initialize a new PDFObject I/O stream using an open
*                    file as a data source/destination.
* Description:       
*
* Synopsis:          void PDFObjNewFile( LPPDFObject lpObj, 
*                       uint16 ioDirection, int hFile, LPVOID lpStateBuf )
*
*  Parameters:       lpObj - I/O object to intialize
*                    ioDirection - I/O direction (input or output)
*                    hFile - open file handle
*                    lpStateBuf - input object state buffer; NULL if default
*                       state buffer is to be used
*
*  Return Value:     None.
*
**********************************************************************/
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14 void PDFObjNewFile( LPPDFObject lpObj, uint16 ioDirection, FILEHANDLE hFile,             */
/* // 98.04.14                LPVOID lpStateBuf )                                */
/* // 98.04.14 {                                                */
/* // 98.04.14    MEMSET( lpObj, 0, sizeof(PDFObject) );                            */
/* // 98.04.14                                                     */
/* // 98.04.14    lpObj->ioType = IOTYPE_FILE;                                    */
/* // 98.04.14    lpObj->ioDirection = ioDirection;                                */
/* // 98.04.14    lpObj->access.file.hFile = hFile;                                */
/* // 98.04.14                                                     */
/* // 98.04.14    ResetStateVars( lpObj, lpStateBuf );                                */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjNewFilename
*
* Description:       Initialize a new PDFObject I/O stream by openning
*                    the file specified. The PDFObject will be assigned
*                    as an IOTYPE_FILE with a flag signifying that the
*                    library was responsible for openning/creating the
*                    file. When the PDFObject is closed we will also
*                    close the file handle.
*
* Synopsis:          void PDFObjNewFilename( LPPDFObject lpObj, 
*                       uint16 ioDirection, LPCSTRING lpcszFile, LPVOID lpStateBuf )
*
*  Parameters:       lpObj - I/O object to intialize
*                    ioDirection - I/O direction (input or output)
*                    lpcszFile - name of file to open/create
*                    lpStateBuf - input object state buffer; NULL if default
*                       state buffer is to be used
*
*  Return Value:     None.
*
**********************************************************************/
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14 Bool PDFObjNewFilename( LPPDFObject lpObj, uint16 ioDirection,                    */
/* // 98.04.14                LPCSTRING lpcszFile, LPVOID lpStateBuf )                        */
/* // 98.04.14 {                                                */
/* // 98.04.14    MEMSET( lpObj, 0, sizeof(PDFObject) );                            */
/* // 98.04.14                                                     */
/* // 98.04.14    lpObj->access.file.hFile = PDFOpenFile( lpcszFile,                         */
/* // 98.04.14       (ioDirection == PDFINPUT ? FOPEN_READ : FOPEN_WRITE) );                    */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( lpObj->access.file.hFile != FOPEN_BADHANDLE ) {                        */
/* // 98.04.14       lpObj->ioType = IOTYPE_FILE;                                */
/* // 98.04.14       lpObj->access.file.fMustClose = TRUE;                            */
/* // 98.04.14       lpObj->ioDirection = ioDirection;                                */
/* // 98.04.14                                                     */
/* // 98.04.14       ResetStateVars( lpObj, lpStateBuf );                            */
/* // 98.04.14    }                                                */
/* // 98.04.14    return (IsIOType( lpObj ) == IOTYPE_FILE);                            */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjNewClipboard
*
* Description:       Initialize a new PDFObject I/O stream using the
*                    Windows clipboard as a source/destination.
*
* Synopsis:          void PDFObjNewClipboard( LPPDFObject lpObj, 
*                       uint16 ioDirection )
*
*  Parameters:       lpObj - I/O object to intialize
*                    ioDirection - I/O direction (input or output)
*                    lpStateBuf - input object state buffer; NULL if default
*                       state buffer is to be used
*
*  Return Value:     None.
*
**********************************************************************/
/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14 void PDFObjNewClipboard( LPPDFObject lpObj, uint16 ioDirection,                     */
/* // 98.04.14          LPVOID lpStateBuf )                                    */
/* // 98.04.14 {                                                */
/* // 98.04.14    MEMSET( lpObj, 0, sizeof(PDFObject) );                            */
/* // 98.04.14                                                     */
/* // 98.04.14    lpObj->ioType = IOTYPE_CLIPBOARD;                                */
/* // 98.04.14    lpObj->ioDirection = ioDirection;                                */
/* // 98.04.14    lpObj->access.clip.fmtOutput = DRIVERTYPE_NULL;                        */
/* // 98.04.14                                                     */
/* // 98.04.14    ResetStateVars( lpObj, lpStateBuf );                                */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif *//* ENVTYPE == windows */

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjAdd
*
* Description:       Transfer data from memory buffer out through the
*                    output object: lpObj.  As a side effect, the 'length'
*                    variable is incremented by the number of bytes
*                    transferred.
*
* Synopsis:          void PDFObjAdd( LPPDFObject lpObj, LPCVOID lpMem
*                             uint16 nAddLen )
*
*  Parameters:       lpObj - output object
*                    lpMem - memory buffer of data to write
*                    nAddLen - number of byte to transfer from lpMem
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Add data thru output object
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 void PDFObjAdd( LPPDFObject lpObj, LPCVOID lpMem, uint16 nAddLen )                */
/* // 98.04.14 {                                                */
/* // 98.04.14    switch( lpObj->ioType ) {                                    */
/* // 98.04.14       case IOTYPE_MEMORY:                                    */
/* // 98.04.14 #ifdef HUGE_PTRS                                            */
/* // 98.04.14          if ( lpObj->fIsHuge ) {                                    */
/* // 98.04.14             uint16 i;                                        */
/* // 98.04.14             PDFSIZET nOffset = lpObj->nLen;                            */
/* // 98.04.14                                                     */
/* // 98.04.14             for( i=0; i < nAddLen; i++, nOffset++ )                        */
/* // 98.04.14                ((HUGEBUFPTR)lpObj->access.lpMemBuffer)[ nOffset ] = ((LPMEMBUF)lpMem)[i];    */
/* // 98.04.14          }                                            */
/* // 98.04.14          else                                            */
/* // 98.04.14 #endif *//* HUGE_PTRS */
/* // 98.04.14             MEMCPY( &lpObj->access.lpMemBuffer[ lpObj->nLen ], lpMem, nAddLen );            */
/* // 98.04.14       break;                                            */
/* // 98.04.14       case IOTYPE_CALLBACK:                                    */
/* // 98.04.14          (void)(*lpObj->access.func.lpfnCallback)( PDFIO_WRITE, (LPVOID)lpMem, nAddLen, lpObj->access.func.lpAppArg );    */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14       case IOTYPE_FILE:                                        */
/* // 98.04.14          (void)PDFWriteFile( lpObj->access.file.hFile, lpMem, nAddLen );                */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */
/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14       case IOTYPE_CLIPBOARD:                                    */
/* // 98.04.14          MEMCPY( &lpObj->access.clip.lpMem[ lpObj->nLen ], lpMem, nAddLen );            */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #endif *//* ENVTYPE == windows */
/* // 98.04.14       default:                                            */
/* // 98.04.14          nAddLen = 0;      *//* unknown output format - nothing added */
/* // 98.04.14       break;                                            */
/* // 98.04.14    }                                                */
/* // 98.04.14    lpObj->nLen += nAddLen;                                    */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjInitOutput
*
* Description:       Clears the output len member variable as well as
*                    allocate an output buffer for IOTYPE_CLIPBOARD
*                    diestnations. This buffer will house the data
*                    to be pasted into the Windows clipboard.
*
* Synopsis:          void PDFObjInitOutput( LPPDFObject lpObj )
*
*  Parameters:       lpObj - output object
*
**********************************************************************/
#ifdef PDF_NOBARPATTERN
Bool PDFObjInitOutput( LPPDFObject lpObj )
{
   Bool fStatus;

   if ( IsIODirection( lpObj ) != PDFOUTPUT )
      return FALSE;

   switch( IsIOType( lpObj ) ) {
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14       case IOTYPE_FILE:                                        */
/* // 98.04.14 #endif                                                */
      case IOTYPE_MEMORY:
      case IOTYPE_CALLBACK:
         lpObj->nLen = 0;
         fStatus = TRUE;
      break;

/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14       case IOTYPE_CLIPBOARD: {                                    */
/* // 98.04.14                                                      */
/* // 98.04.14          * Need to check for a valid output format which is                    */
/* // 98.04.14          * supported by Windows clipboard                            */
/* // 98.04.14                                                      */
/* // 98.04.14          LPAppParamsRec lpApp = GetSessionSettings();                        */
/* // 98.04.14                                                     */
/* // 98.04.14          lpObj->access.clip.fmtOutput = (uint16)DriverQueryIOType( lpApp );            */
/* // 98.04.14          switch( lpObj->access.clip.fmtOutput ) {                        */
/* // 98.04.14             case DRIVERTYPE_CODEWORDS:                                */
/* // 98.04.14             case DRIVERTYPE_PATTERNS:                                */
/* // 98.04.14             case DRIVERTYPE_TIFF:                                */
/* // 98.04.14             case DRIVERTYPE_DIBMEM: {                                */
/* // 98.04.14                PDFSIZET nImageLen;                                */
/* // 98.04.14                                                            */
/* // 98.04.14                * Allocate a buffer to receive output data from driver. This            */
/* // 98.04.14                * buffer will be placed into the clipboard when complete                */
/* // 98.04.14                                                            */
/* // 98.04.14                if ( DriverQueryLen( lpApp, &nImageLen ) == ERR_NOERROR ) {            */
/* // 98.04.14                   lpObj->access.clip.lpMem = (LPMEMBUF)GlobalAllocPtr( GMEM_MOVEABLE, nImageLen );    */
/* // 98.04.14                                                           */
/* // 98.04.14                   * Check for memory allocation failure                        */
/* // 98.04.14                                                           */
/* // 98.04.14                   fStatus = lpObj->access.clip.lpMem != 0;                    */
/* // 98.04.14                }                                            */
/* // 98.04.14                else                                        */
/* // 98.04.14                   fStatus = FALSE;                                */
/* // 98.04.14                                                     */
/* // 98.04.14                lpObj->nLen = 0;                                    */
/* // 98.04.14             }                                            */
/* // 98.04.14             break;                                        */
/* // 98.04.14             case DRIVERTYPE_WMF:                                    */
/* // 98.04.14                lpObj->nLen = 0;                                    */
/* // 98.04.14             break;                                        */
/* // 98.04.14             default:                                        */
/* // 98.04.14                fStatus = FALSE;                                    */
/* // 98.04.14             break;                                        */
/* // 98.04.14          }                                            */
/* // 98.04.14       }                                                */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #endif *//* ENVTYPE == windows */
      default:
         fStatus = FALSE;
      break;
   }
   return fStatus;
}
#endif
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjAbort
*
* Description:       Cease input/output operations through the PDFObject
*                    type wihtout completing I/O operations -- as 
*                    opposed to PDFObjEndIO()
*
* Synopsis:          void PDFObjAbort( LPPDFObject lpObj )
*
*  Parameters:       lpObj - output object
*
**********************************************************************/
#ifdef PDF_NOBARPATTERN
void PDFObjAbort( LPPDFObject lpObj )
{
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14    if ( IsIOType( lpObj ) == IOTYPE_FILE ) {                            */
/* // 98.04.14                                                       */
/* // 98.04.14       * If the file type is a handle that our library was responsible                */
/* // 98.04.14       * for openning then we close it and invalidate the object. This                */
/* // 98.04.14       * forces the application to re-create the object for each transaction.            */
/* // 98.04.14       * A transaction is defined as a single PDFMakeImage() call, a complete            */
/* // 98.04.14       * macro PDFEncode() sequence, or a single non-macro PDFEncode() call.            */
/* // 98.04.14                                                       */
/* // 98.04.14       if ( lpObj->access.file.fMustClose ) {                            */
/* // 98.04.14          PDFFileClose( lpObj->access.file.hFile );                        */
/* // 98.04.14          lpObj->access.file.hFile = FOPEN_BADHANDLE;                        */
/* // 98.04.14          SetIOType( lpObj ) = IOTYPE_UNDEFINED;                            */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */

   if ( IsIODirection( lpObj ) == PDFINPUT ) {
      ((LPPDFInState)(lpObj)->lpState)->nState = ST_NODATALOADED;

/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14       if ( IsIOType( lpObj ) == IOTYPE_CLIPBOARD ) {                        */
/* // 98.04.14                                                      */
/* // 98.04.14          * Free up any memory allocated for copied (pasted) clipboard data            */
/* // 98.04.14                                                      */
/* // 98.04.14          if ( lpObj->access.clip.lpMem ) {                            */
/* // 98.04.14             (void)GlobalFreePtr( lpObj->access.clip.lpMem );                    */
/* // 98.04.14             lpObj->access.clip.lpMem = NULL;                            */
/* // 98.04.14          }                                            */
/* // 98.04.14       }                                                */
/* // 98.04.14 #endif *//* ENVTYPE == windows */
   }
}
#endif
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFObjEndIO
*
* Description:       Cease input/output operations through the PDFObject
*                    type. In the case of Windows Clipboard I/O we
*                    release any memory allocated and place the
*                    final block, for output, into the clipboard.
*
* Synopsis:          void PDFObjEndIO( LPPDFObject lpObj )
*
*  Parameters:       lpObj - output object
*
**********************************************************************/
#ifdef PDF_NOBARPATTERN
void PDFObjEndIO( LPPDFObject lpObj )
{
   /*
   * Close I/O operation thru the lpObj structure by closing any open
   * files and resetting state variable
   */
   PDFObjAbort( lpObj );
   /*
   * For memory buffer output, terminate the data with a zero in case
   * the format is a C string type
   */
   if ( (IsIODirection( lpObj ) == PDFOUTPUT) && (IsIOType( lpObj ) == IOTYPE_MEMORY) ) {
      lpObj->access.lpMemBuffer[ lpObj->nLen ] = '\0';
   }

/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14    if ( (IsIODirection( lpObj ) == PDFOUTPUT) && (IsIOType( lpObj ) == IOTYPE_CLIPBOARD) ) {    */
/* // 98.04.14       WORD nFormat;                                        */
/* // 98.04.14                                                       */
/* // 98.04.14       * Validate the output format against clipboard formats supported                */
/* // 98.04.14                                                       */
/* // 98.04.14       switch( lpObj->access.clip.fmtOutput ) {                            */
/* // 98.04.14          case DRIVERTYPE_CODEWORDS:                                */
/* // 98.04.14          case DRIVERTYPE_PATTERNS:                                */
/* // 98.04.14                                                         */
/* // 98.04.14             * Zero terminate the string                                */
/* // 98.04.14                                                         */
/* // 98.04.14             lpObj->access.clip.lpMem[ lpObj->nLen ] = '\0';                    */
/* // 98.04.14                                                     */
/* // 98.04.14             nFormat = CF_TEXT;                                    */
/* // 98.04.14          break;                                            */
/* // 98.04.14          case DRIVERTYPE_TIFF:                                    */
/* // 98.04.14             nFormat = CF_TIFF;                                    */
/* // 98.04.14          break;                                            */
/* // 98.04.14          case DRIVERTYPE_DIBMEM:                                    */
/* // 98.04.14             nFormat = CF_DIB;                                    */
/* // 98.04.14          break;                                            */
/* // 98.04.14          case DRIVERTYPE_WMF:                                    */
/* // 98.04.14                                                         */
/* // 98.04.14             * NOTE: The metafile output to the clipboard is handled directly            */
/* // 98.04.14             *       by the OUTDIB module. Therefore we invalidate the option            */
/* // 98.04.14             *       so nothing occurs here                            */
/* // 98.04.14             *                                            */
/* // 98.04.14             * FALLTHU!                                        */
/* // 98.04.14                                                         */
/* // 98.04.14          default:                                        */
/* // 98.04.14             nFormat = 0;                                        */
/* // 98.04.14          break;                                            */
/* // 98.04.14       }                                                */
/* // 98.04.14                                                       */
/* // 98.04.14       * If have a valid clipboard type and could open clipboard                    */
/* // 98.04.14                                                       */
/* // 98.04.14       if ( nFormat && OpenClipboard( NULL ) ) {                            */
/* // 98.04.14          HGLOBAL hClip;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14                                                      */
/* // 98.04.14          * Clipboard requires a handle to the object being added -- we                */
/* // 98.04.14          * remove our lock on the METAFILEPICT record                        */
/* // 98.04.14                                                      */
/* // 98.04.14          hClip = GlobalPtrHandle( lpObj->access.clip.lpMem );                    */
/* // 98.04.14          GlobalUnlock( hClip );                                    */
/* // 98.04.14                                                     */
/* // 98.04.14          EmptyClipboard();                                    */
/* // 98.04.14          SetClipboardData( nFormat, hClip );                            */
/* // 98.04.14          CloseClipboard();                                    */
/* // 98.04.14       }                                                */
/* // 98.04.14       else {                                            */
/* // 98.04.14          if ( lpObj->access.clip.lpMem != NULL )                            */
/* // 98.04.14             (void)GlobalFreePtr( lpObj->access.clip.lpMem );                    */
/* // 98.04.14       }                                                */
/* // 98.04.14       lpObj->access.clip.lpMem = NULL;                                */
/* // 98.04.14    }                                                */
/* // 98.04.14 #endif *//* ENVTYPE == windows */
}
#endif

/* // 98.04.14 #ifndef NO_C128EMULATION                                     */
/* // 98.04.14                                                     */
/* // 98.04.14 Routine Header *****************************************************                */
/* // 98.04.14 *                                                */
/* // 98.04.14 * Routine Name:      copyPDFObjectParams                                */
/* // 98.04.14 *                                                */
/* // 98.04.14 * Description:       Save the settings from lpObj to lpSavObjParams                 */
/* // 98.04.14 *                    so lpObj can be used for code 128 emulation and then can later be restored.    */
/* // 98.04.14 *                                                */
/* // 98.04.14 * Synopsis:          void setPDFObjectParams(LPPDFObject lpObj,                     */
/* // 98.04.14 *                               LPPDFSavObjParams lpSavObjParams)                */
/* // 98.04.14 *                                                */
/* // 98.04.14 *  Parameters:       lpObj - input object                             */
/* // 98.04.14 *                    lpSavObjParams - the settings from lpObj are copied here for later restoration    */
/* // 98.04.14 *                                                */
/* // 98.04.14 **********************************************************************/
/* // 98.04.14 void copyPDFObjectParams(LPPDFObject lpObj, LPPDFSavObjParams lpSavObjParams)            */
/* // 98.04.14 {                                                       */
/* // 98.04.14     LPPDFInState lpState = (LPPDFInState)(lpObj)->lpState;                        */
/* // 98.04.14     int16 i;                                            */
/* // 98.04.14                                                     */
/* // 98.04.14     lpSavObjParams->nLen = lpObj->nLen;                                 */
/* // 98.04.14     lpSavObjParams->ioType = lpObj->ioType;                                */
/* // 98.04.14                                                     */
/* // 98.04.14     lpSavObjParams->Look = lpState->Look;                                 */
/* // 98.04.14     lpSavObjParams->Put = lpState->Put;                                 */
/* // 98.04.14     lpSavObjParams->Get = lpState->Get;                                  */
/* // 98.04.14     lpSavObjParams->pfnFillBuff = lpState->pfnFillBuff;                          */
/* // 98.04.14     lpSavObjParams->nState = lpState->nState;                            */
/* // 98.04.14     lpSavObjParams->fDoCRC = lpState->fDoCRC;                             */
/* // 98.04.14     lpSavObjParams->nCRC = lpState->nCRC;                                 */
/* // 98.04.14     *//* while doing code 128 emulation fIsECIFormat, fAtECITagSeq, and fUseMacroCharSub are always false */
/* // 98.04.14     for( i = 0; i < MAX_C128_SEQUENCE; i++)                                */
/* // 98.04.14         lpSavObjParams->c128_acBuf[i] = lpState->acBuf[i];                    */
/* // 98.04.14                                                     */
/* // 98.04.14 }                                                */
/* // 98.04.14                                                     */
/* // 98.04.14 *********************************************************************                          */
/* // 98.04.14 * Routine Header *****************************************************                */
/* // 98.04.14 *                                                */
/* // 98.04.14 * Routine Name:      setPDFObjectParams                                */
/* // 98.04.14 *                                                */
/* // 98.04.14 * Description:       Either copy the saved params back to lpObj from lpSavObjParams or        */
/* // 98.04.14 *                    set lpObj buffer's values for code 128 emulation using the            */
/* // 98.04.14 *                    seqLength and c128 input values.                        */
/* // 98.04.14 *                                                */
/* // 98.04.14 * Synopsis:          void setPDFObjectParams(LPPDFObject lpObj,                     */
/* // 98.04.14 *                               LPPDFSavObjParams lpSavObjParams, int16 seqLength, LPBUF c128)    */
/* // 98.04.14 *                                                */
/* // 98.04.14 *  Parameters:       lpObj - input object                             */
/* // 98.04.14 *                    lpSavObjParams - if not null, these settings are copied to lpObj        */
/* // 98.04.14 *                    seqLength - if lpSavObjParam is null, this many chars are copied from c128 buffer to lpObj    */
/* // 98.04.14 *                    c128 - if lpSavObjParam is null, these are the char that are copied to the 1st */
/* // 98.04.14 *                           seqLength number of characters in lpObj's state acBuf        */
/* // 98.04.14 *                                                */
/* // 98.04.14 **********************************************************************/                
/* // 98.04.14 *//* this is used for one of the default params below when setting lpObj up for code 128 emulation */
/* // 98.04.14 static void DummyRefreshObjBuffer( LPPDFObject lpObj )                        */
/* // 98.04.14 {                                                */
/* // 98.04.14 }                                                */
/* // 98.04.14                                                  */
/* // 98.04.14 void setPDFObjectParams(LPPDFObject lpObj, LPPDFSavObjParams lpSavObjParams, int16 seqLength, LPBUF c128)    */
/* // 98.04.14 {                                                */
/* // 98.04.14                                                     */
/* // 98.04.14     LPPDFInState lpState = (LPPDFInState)(lpObj)->lpState;                        */
/* // 98.04.14     int16 i;                                            */
/* // 98.04.14                                                                       */
/* // 98.04.14     if(lpSavObjParams == NULL)  *//* set the Object up with the code128 */
/* // 98.04.14     {                                                */
/* // 98.04.14                                                     */
/* // 98.04.14         lpObj->nLen = seqLength;                                                  */
/* // 98.04.14         lpObj->ioType = IOTYPE_CALLBACK;                            */
/* // 98.04.14                                                     */
/* // 98.04.14         lpState->Look.nOffset = (PDFSIZET)0;                             */
/* // 98.04.14         lpState->Look.nBuffOffset = 0;                                 */
/* // 98.04.14         lpState->Look.cUnget = -1;                                */
/* // 98.04.14         lpState->Put.nOffset = (PDFSIZET)seqLength;                          */
/* // 98.04.14         lpState->Put.nBuffOffset = seqLength;                             */
/* // 98.04.14         lpState->Get.nOffset = 0;                                   */
/* // 98.04.14         lpState->Get.nBuffOffset = (PDFSIZET)0;                           */
/* // 98.04.14         lpState->Get.cUnget = -1;                                  */
/* // 98.04.14         lpState->pfnFillBuff = DummyRefreshObjBuffer;                          */
/* // 98.04.14         lpState->nState = ST_ENCODINGDATA;                            */
/* // 98.04.14         lpState->fDoCRC = FALSE;                                 */
/* // 98.04.14         lpState->nCRC = 0;                                     */
/* // 98.04.14         *//* while doing code 128 emulation fIsECIFormat, fAtECITagSeq, and fUseMacroCharSub are always false */
/* // 98.04.14                                                     */
/* // 98.04.14         for( i = 0; i < seqLength; i++)                                */
/* // 98.04.14             lpState->acBuf[i] = c128[i];                            */
/* // 98.04.14                                                                     */
/* // 98.04.14     }                                                */
/* // 98.04.14     else         *//* reset the Object with the saved parameters */
/* // 98.04.14     {                                                */
/* // 98.04.14         lpObj->nLen = lpSavObjParams->nLen;                            */
/* // 98.04.14         lpObj->ioType = lpSavObjParams->ioType;                            */
/* // 98.04.14                                                                       */
/* // 98.04.14         lpState->Look = lpSavObjParams->Look;                            */
/* // 98.04.14                                                     */
/* // 98.04.14         lpState->Put = lpSavObjParams->Put;                             */
/* // 98.04.14         lpState->Get = lpSavObjParams->Get;                              */
/* // 98.04.14         lpState->pfnFillBuff = lpSavObjParams->pfnFillBuff;                      */
/* // 98.04.14         lpState->nState = lpSavObjParams->nState;                        */
/* // 98.04.14         lpState->fDoCRC = lpSavObjParams->fDoCRC;                         */
/* // 98.04.14         lpState->nCRC = lpSavObjParams->nCRC;                             */
/* // 98.04.14         *//* while doing code 128 emulation fIsECIFormat, fAtECITagSeq, and fUseMacroCharSub are always false */
/* // 98.04.14         for( i = 0; i < MAX_C128_SEQUENCE; i++)                            */
/* // 98.04.14             lpState->acBuf[i] = lpSavObjParams->c128_acBuf[i];                */
/* // 98.04.14     }                                                */
/* // 98.04.14 }                                                */
/* // 98.04.14                                                  */
/* // 98.04.14                                                     */
/* // 98.04.14 #endif                                                */
 

以下为.h文件:PDFOBJ.H

/*********************************************************************
* Module Header
*
*  Identification:   PDFOBJ.H - Input/Output Object Module Header File
*  Copyright (c) 1994-1997 Symbol Technologies, Inc.
*
* Edit History:      
*  $Log: PDFOBJ.H $
*  Revision 1.5  1997/11/21 00:11:28  Anne
*  Created a typedef for the get and put structures in PDFInState data 
*  structure.  
*  Added a field in that data structure for the Boolean field fUseMacroCharSub
*  Added a data structure - PDFSaveObjParams - and 3 macros to be used
*  for code 128 emulation when selected data structure fields must be saved and restored
*  while encoding fixed and variable length user input field data:
*  PDFObjSetupStatic, PDFObjReSetupStatic, PDFObjRestoreFromStatic
*  Added 2 macros for Macro Character Substitution - PDFObjIsUsingMacroCharSub
*  and PDFObjSetMacroCharSub. 
*  Revision 1.4  1997/04/29 19:29:00  toml
*  Added PDFObjIsECIFormat macro to test for ECI input
*  Revision 1.3  1997/04/24 13:46:20  toml
*  Added parsing ability for ECI protocol data -- recognize escapes
*  and remove double-slashes
*  Revision 1.2  1997/03/06 16:09:10  toml
*  PDFObjGet & PDFObjLook return an int now
*  Revision 1.1  1997/01/20 19:59:28  toml
*  Initial revision
*
*  Description:      Requires PDFAPI.H
*
**********************************************************************/
#ifndef  __PDFOBJ_H__
#define  __PDFOBJ_H__
/*
* LOOKBUFLEN - size of look-ahead buffer allocated for input PDFObject. This
*  value represents the maximum, single barcode data content (all numerics).
*  All routines which use PDFObject to look/get data guarantee they will not
*  attempt to look ahead more than a single barcodes worth of data.
*
*  Note: PDFIO_MAX_READ is defined in PDFAPI.H
*/
#define  LOOKBUFLEN PDFIO_MAX_READ     /* capable of holding a barcode of all numerics */

#define  IOTYPE_UNDEFINED     0
#define  IOTYPE_MEMORY        1
#define  IOTYPE_CALLBACK      2
#define  IOTYPE_FILE          3
#define  IOTYPE_CLIPBOARD     4

#define  EOF_FLAG       (int)(-1)
/*
* Input Object State Values -- (PDFInState).nState
*/
#define  ST_NODATALOADED   1     /* initial state of input object */
#define  ST_ENCODINGDATA   2     /* actively removeing data for encoding */
#define  ST_DATADONE       3     /* exhausted input objet stream */

typedef void FNFILLBUFF( LPPDFObject lpObj );
typedef FNFILLBUFF *PFNFILLBUFF;


typedef struct s_pdfgetinstate {
      PDFSIZET nOffset;
      uint16 nBuffOffset;
      int16 cUnget;
}PDFInGetState;     
 
typedef struct {
      PDFSIZET nOffset;
      uint16 nBuffOffset;
}PDFInPutState;

typedef struct s_pdfinstate { /* input object state structure */
    PDFInGetState Get;  
    PDFInGetState Look; 
    PDFInPutState Put;
   PFNFILLBUFF pfnFillBuff;
   uint16 nState;
   Bool fDoCRC;                  /* calculate a running CRC on input data */
   Bool fIsECIFormat;            /* Uses ECI prefixed data */
   Bool fAtECITagSeq;            /* Simulate EOF due to ECI transition point */
    Bool fUseMacroCharSub;             /* Encoder is using macro character substitution in MicroPDF Symbol */   
    
   uint16 nCRC;                  /* current running CRC value */
   BUFDATA acBuf[ LOOKBUFLEN ];  /* look ahead buffer */
} PDFInState;
typedef PDFInState FAR *LPPDFInState;    

#ifndef NO_C128EMULATION 
/*  for MicroPDF code 128 emulation */
#define  MAX_C128_SEQUENCE    48    
typedef struct s_pdfinsavestate { /* input object state structure */    
    PDFSIZET nLen;
    uint16 ioType;  
    PDFInGetState Get;  
    PDFInGetState Look; 
    PDFInPutState Put; 
   PFNFILLBUFF pfnFillBuff;
   uint16 nState;
   Bool fDoCRC;                  /* calculate a running CRC on input data */
   uint16 nCRC;                  /* current running CRC value */
   BUFDATA c128_acBuf[MAX_C128_SEQUENCE ];  /* look ahead buffer */
} PDFSavObjParams;

typedef PDFSavObjParams FAR *LPPDFSavObjParams;    

void copyPDFObjectParams(LPPDFObject lpObj, LPPDFSavObjParams lpSavObjParams); 
void setPDFObjectParams(LPPDFObject lpObj, LPPDFSavObjParams lpSavObjParams, int16 seqLength, LPBUF c128);

#define  PDFObjSetupStatic( pObj, saveObj, staticData, dataLength ) do { \
    copyPDFObjectParams(pObj, (LPPDFSavObjParams)saveObj);   \
    setPDFObjectParams( pObj, NULL, dataLength, (LPBUF)staticData);\
   } while ( 0 )
#define PDFObjReSetupStatic( pObj, staticData, dataLength ) do {\
    setPDFObjectParams( pObj, NULL, dataLength, (LPBUF)staticData);\
    }while (0)
#define  PDFObjRestoreFromStatic( pObj, saveObj) do { \
    setPDFObjectParams( pObj, (LPPDFSavObjParams)saveObj, 0, NULL); \
    } while ( 0 )
#endif /* #ifndef NO_C128EMULATION  */                                                              


/*
* Note: lint -e717 turns off warning about do..while(0)
*/
#define  PDFObjUnget( pObj, ch ) /*lint -e717 */ do {                \
            LPPDFInState lpState = (LPPDFInState)(pObj)->lpState;    \
                                                                     \
            lpState->Get.cUnget = lpState->Look.cUnget = (ch);       \
            lpState->nState = ST_ENCODINGDATA;                       \
         } while ( 0 ) /*lint -restore */

#define  PDFObjLookReset( pObj ) /*lint -e717 */ do {                \
            LPPDFInState lpState = (LPPDFInState)(pObj)->lpState;    \
                                                                     \
            lpState->Look.nOffset = lpState->Get.nOffset;            \
            lpState->Look.nBuffOffset = lpState->Get.nBuffOffset;    \
            lpState->Look.cUnget = lpState->Get.cUnget;              \
            lpState->fAtECITagSeq = FALSE;                           \
         } while ( 0 ) /*lint -restore */

#define  PDFObjIsLookEOF( pObj ) (                                           \
           ( (((LPPDFInState)(pObj)->lpState)->Look.cUnget == EOF_FLAG) &&    \
            (((LPPDFInState)(pObj)->lpState)->Look.nOffset >= (pObj)->nLen) ) || \
            PDFObjAtECITrans( pObj ) \
         )

#define  PDFObjIsEOF( pObj ) (                                              \
            (((LPPDFInState)(pObj)->lpState)->Get.cUnget == EOF_FLAG) &&    \
            (((LPPDFInState)(pObj)->lpState)->Get.nOffset >= (pObj)->nLen)  \
         )

#define  PDFObjEnableCRC( pObj ) ( \
            ((LPPDFInState)(pObj)->lpState)->fDoCRC = TRUE, \
            ((LPPDFInState)(pObj)->lpState)->nCRC = 0       \
         )
#define  PDFObjDisableCRC( pObj ) (((LPPDFInState)(pObj)->lpState)->fDoCRC = FALSE)
#define  PDFObjGetCRC( pObj ) (/*const*/ uint16)(((LPPDFInState)(pObj)->lpState)->nCRC)

#define  PDFObjTell( pObj )   (/*const*/ PDFSIZET)( (pObj)->ioDirection == PDFINPUT ?      \
                                 ((LPPDFInState)(pObj)->lpState)->Get.nOffset : \
                                 (pObj)->nLen )

#define  IsIOType( pObj )        (/*const*/ uint16)( (pObj)->ioType )
#define  SetIOType( pObj )       ((pObj)->ioType)
#define  IsIODirection(pObj )    (/*const*/ uint16)( (pObj)->ioDirection )

#define  PDFObjIsECIFormat( pObj ) \
              (/*const*/ Bool)(((LPPDFInState)(pObj)->lpState)->fIsECIFormat)

#define  PDFObjSetECIFormat( pObj, fState ) \
              (((LPPDFInState)(pObj)->lpState)->fIsECIFormat = (fState))

#define  PDFObjAtECITrans( pObj ) ( \
            ((LPPDFInState)(pObj)->lpState)->fIsECIFormat && \
            ((LPPDFInState)(pObj)->lpState)->fAtECITagSeq    \
         )
        
#define  PDFObjIsUsingMacroCharSub( pObj ) \
              (/*const*/ Bool)(((LPPDFInState)(pObj)->lpState)->fUseMacroCharSub)
              
#define  PDFObjSetMacroCharSub( pObj, fState ) \
              (((LPPDFInState)(pObj)->lpState)->fUseMacroCharSub = (fState))


void PDFObjEndIO( LPPDFObject lpObj );
void PDFObjAbort( LPPDFObject lpObj );

/*
* PDFObject : PDFINPUT interface functions
*/
int16 PDFObjLook( LPPDFObject lpObj );
int16 PDFObjGet( LPPDFObject lpObj );
void PDFObjRewind( LPPDFObject lpObj );

/*
* Input object sequence status values
*/
typedef int16 SEQSTATE;
#define  SEQ_BEGIN      1
#define  SEQ_MID        2
#define  SEQ_EOF        3
SEQSTATE PDFObjSyncInput( LPPDFObject lpObj, PDFSIZET nFileLen );

void PDFObjNewCallback( LPPDFObject lpObj, uint16 ioDirection, LPFNPDFIO lpfnCallback,
                  LPVOID lpArg, LPVOID lpState );
void PDFObjNewMem( LPPDFObject lpObj, uint16 ioDirection, LPVOID lpBase, LPVOID lpState );

#ifndef PDF_NOFILEIO
void PDFObjNewFile( LPPDFObject lpObj, uint16 ioDirection, FILEHANDLE hFile, LPVOID lpState );
Bool PDFObjNewFilename( LPPDFObject lpObj, uint16 ioDirection, LPCSTRING lpcszFile, LPVOID lpState );
#endif /* PDF_NOFILEIO */

/* #if (ENVTYPE & PDF_E_WINMASK) != 0                                        */
/* void PDFObjNewClipboard( LPPDFObject lpObj, uint16 ioDirection, LPVOID lpState );                */
/* #endif                                                    */

#ifdef HUGE_PTRS
#define PDFObjSetHuge( pObj )   ( (pObj)->fIsHuge = TRUE )
#endif
/*
* PDFObject : PDFOUTPUT interface functions
*/
Bool PDFObjInitOutput( LPPDFObject lpObj );
void PDFObjAdd( LPPDFObject lpObj, LPCVOID lpMem, uint16 nBytes );

#define PDFObjGetLen( pObj )        ((/*const*/ PDFSIZET)( (pObj)->nLen ))

#endif /* __PDFOBJ_H__ */
 

  • 24
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值