Esempio n. 1
0
int32 Hq32x2CompareInt32( Hq32x2 * p32x2A, int32 i32 )
{
  Hq32x2        tmp;

  Hq32x2FromInt32( &tmp, i32 );
  return Hq32x2Compare( p32x2A, &tmp );
}
Esempio n. 2
0
static int32 EditFilePos( register FILELIST *flptr, Hq32x2* file_pos )
{
  HQASSERT((file_pos != NULL),
           "EditFilePos: NULL position pointer");
  Hq32x2FromInt32(file_pos, (theIPtr(flptr) - theIBuffer(flptr)));
  return(0);
}
Esempio n. 3
0
void Hq32x2SubtractInt32( Hq32x2 * p32x2Result, Hq32x2 * p32x2A, int32 i32 )
{
  Hq32x2        tmp;

  Hq32x2FromInt32( &tmp, i32 );
  Hq32x2Subtract( p32x2Result, p32x2A, &tmp );
}
Esempio n. 4
0
void Hq32x2AddInt32( Hq32x2 * p32x2Result, Hq32x2 * p32x2A, int32 i32 )
{
  Hq32x2        tmp;

  Hq32x2FromInt32( &tmp, i32 );
  Hq32x2Add( p32x2Result, p32x2A, &tmp );
}
Esempio n. 5
0
/** Attempt to rewind the passed stream; 'rewound', if not NULL, will be set to
true if the the stream actually was rewound (closed streams, for example cannot
be rewound).

If the stream can be positioned, and has useful data waiting to be read, it's
position will be restored to that before the rewind at the end of the current
marking context. Note that when the same file is so marked more than once in any
single marking context, the file position will be that before the FIRST call to
to this method when we return to the enclosing marking context.

Returns false on error.
*/
Bool pdf_rewindstream(PDFCONTEXT *pdfc, OBJECT* stream, Bool* rewound)
{
  FILELIST *flptr ;

  if (rewound != NULL)
    *rewound = FALSE ;

  if ( oType( *stream ) != OFILE )
    return error_handler( TYPECHECK ) ;

  flptr = oFile( *stream ) ;
  HQASSERT(!isIOutputFile(flptr),
           "pdf_rewindstream - 'stream' should be an input stream.") ;

  if ( isIOpenFileFilter( stream , flptr )) {
    Hq32x2 filepos ;

    /* If the filter supports positioning, and has useful stuff left to read, we
    save a file position restore list entry, which will reset the position at
    the end of the current marking stream. */
    if ( (*theIMyFilePos(flptr))(flptr, &filepos) != EOF ) {
      int32 ch ;

      do {
        ch = Getc(flptr) ;
      } while ( ch >= 0 && IsWhiteSpace(ch) ) ;

      if ( ch != EOF ) {
        PDF_FILERESTORE_LIST *restore ;
        /* Add new restorelist entry of filepos, flptr. */

        if ( (restore = mm_alloc(mm_pool_temp,
                                 sizeof(PDF_FILERESTORE_LIST),
                                 MM_ALLOC_CLASS_PDF_FILERESTORE)) == NULL )
          return error_handler(VMERROR) ;

        /* Note that we are adding this to the start of the restore list; if
        this stream already has restore entries, they will be honored after this
        one, meaning that the file position after all restores will be set to
        that before the first call to this method, in this marking context. */
        restore->position = filepos ;
        restore->fileobj = *stream ;
        restore->next = pdfc->restorefiles ;
        pdfc->restorefiles = restore ;
      }
    }

    Hq32x2FromInt32(&filepos, 0);
    if ((*theIMyResetFile( flptr ))( flptr ) == EOF ||
        (*theIMySetFilePos( flptr ))( flptr , &filepos ) == EOF )
      return ( *theIFileLastError( flptr ))( flptr ) ;

    if (rewound != NULL)
      *rewound = TRUE ;
  }

  return TRUE ;
}
Esempio n. 6
0
static int32 StdFilePos( register FILELIST *flptr, Hq32x2* file_pos )
{
  /* return the offset from start of buffer */
  HQASSERT( ! isIFilter(flptr), "StdFilePos called on filter");
  HQASSERT((file_pos != NULL),
           "StdFilePos: NULL position pointer");
  Hq32x2FromInt32(file_pos, (theIPtr(flptr) - theIBuffer(flptr)));
  return(0);
}
Esempio n. 7
0
static int32 EditFileBytes( register FILELIST *flptr, Hq32x2* avail )
{
  HQASSERT((avail != NULL),
           "EditFileBytes: NULL bytecount pointer");
  if ( theICount(flptr) != EOF ) {
    Hq32x2FromInt32(avail, theICount(flptr));
    return(0);
  } else {
    /** \todo Can count be -ve for other than EOF? */
    return(EOF);
  }
}
Esempio n. 8
0
static int32 StdFileBytes( FILELIST *flptr, Hq32x2* avail )
/* must be an input file */
{
  /* return the number of bytes in the buffer */
  HQASSERT( ! isIFilter(flptr), "StdFileBytes called on filter");
  HQASSERT((avail != NULL),
           "StdFileBytes: NULL bytecount pointer");
  if ( theICount(flptr) != EOF ) {
    Hq32x2FromInt32(avail, theICount(flptr));
    return(0);
  } else {
    /** \todo Can count be -ve for other than EOF? */
    return(EOF);
  }
}
Esempio n. 9
0
/**
 * Update the read file progress for the top item on the stack.
 */
static void update_read_file_progress(void)
{
  Hq32x2 size;
  DEVICE_FILEDESCRIPTOR d;
  sw_tl_ref tl_ref;
  FILELIST *flptr;
  DEVICELIST *dev;
  int32 localcount;

  /* updating file on top of stack */
  flptr = stack_top(&tl_ref);
  d = theIDescriptor(flptr);
  if ((dev = theIDeviceList(flptr)) == NULL) {
    HQFAIL("update_file_progress: file with no device blocking updates, report to core");
    return;
  }
  HQASSERT(!isIReadWriteFile(flptr),
      "Should not be tracking progress on read-write files");

  /* theICount will sometimes be -1. Treat this as though it was zero */
  localcount = theICount(flptr);
  if (localcount < 0) {
    localcount = 0;
  }

  /* Do a relative seek of 0 bytes to find out where we are */
  Hq32x2FromInt32(&size, 0);
  if (!(*theISeekFile(dev))(dev, d, &size, SW_INCR))
    return;

  if (isIInputFile(flptr)) {
    Hq32x2SubtractInt32(&size, &size, localcount);
  }

  progress_current(tl_ref, (sw_tl_extent)Hq32x2ToDouble(&size));
  return;
}