Token parsing code.

This commit is contained in:
Michael R Sweet
2021-05-01 22:38:11 -04:00
parent e107b94c83
commit 4b05ca6436
5 changed files with 409 additions and 19 deletions

View File

@@ -23,6 +23,23 @@ static ssize_t read_buffer(pdfio_file_t *pdf, char *buffer, size_t bytes);
static bool write_buffer(pdfio_file_t *pdf, const void *buffer, size_t bytes);
//
// '_pdfioFileConsume()' - Consume bytes from the file.
//
bool // O - `true` on sucess, `false` on EOF
_pdfioFileConsume(pdfio_file_t *pdf, // I - PDF file
size_t bytes) // I - Bytes to consume
{
if ((size_t)(pdf->bufend - pdf->bufptr) > bytes)
pdf->bufptr += bytes;
else if (_pdfioFileSeek(pdf, (off_t)bytes, SEEK_CUR) < 0)
return (false);
return (true);
}
//
// '_pdfioFileDefaultError()' - Default error callback.
//
@@ -114,7 +131,7 @@ _pdfioFileGetToken(pdfio_file_t *pdf, // I - PDF file
char *buffer,// I - String buffer
size_t bufsize)// I - Size of string buffer
{
return (_pdfioTokenRead(buffer, bufsize, (_pdfio_token_cb_t)_pdfioFilePeek, (_pdfio_token_cb_t)_pdfioFileRead, pdf));
return (_pdfioTokenRead(pdf, buffer, bufsize, (_pdfio_tpeek_cb_t)_pdfioFilePeek, (_pdfio_tconsume_cb_t)_pdfioFileConsume, pdf));
}