hmmer-3.3/easel/esl_sqio_ncbi.c
/* Function:  parse_expect()
 * Synopsis:  Expect the next bytes to parse match
 * Incept:    MSF, Mon Dec 10, 2009 [Janelia]
 *
 * Purpose:   Match if the next <len> bytes to parse match the bytes
 *            in <str>.  If the bytes do not match, throw <eslEFORMAT>
 *            error.  Advance the parsers pointer.
 *
 * Returns:   <eslOK> on success
 * 
 * Throws:    <eslEFORMAT> if there are insufficient bytes remaining
 *            in the header or if the data to parse does not match
 *            what is expected.
 */
parse_expect()
Synopsis:  Expect the next bytes to parse match
Incept:    MSF, Mon Dec 10, 2009 [Janelia]

Match if the next  bytes to parse match the bytes
in .  If the bytes do not match, throw 
error.  Advance the parsers pointer.

 on success

 if there are insufficient bytes remaining
in the header or if the data to parse does not match
what is expected.
parse_expect () Synopsis : Expect the next bytes to parse match Incept : MSF Mon Dec 10 2009 [ Janelia ] Match if the next bytes to parse match the bytes in . If the bytes do not match throw error . Advance the parsers pointer . on success if there are insufficient bytes remaining in the header or if the data to parse does not match what is expected .
static int
parse_expect(ESL_SQNCBI_DATA *ncbi, void *str, int len)
{
  int size;
  unsigned char *c;
  unsigned char *limit;
  size  = ncbi->hoff - ncbi->roff;
  limit = ncbi->hdr_buf + size;
  if (ncbi->hdr_ptr + len > limit) {
      ESL_FAIL(eslEFORMAT, ncbi->errbuf, "Expecting %d bytes at %d : 0x%X(%d)\n",
	       len, (uint32_t) (ncbi->hdr_ptr - ncbi->hdr_buf), ncbi->roff, size); 
  }
  c = (unsigned char *) str;
  while (len--) {
    if (*ncbi->hdr_ptr != *c) {
      ESL_FAIL(eslEFORMAT, ncbi->errbuf, "Expecting 0x%X found 0x%X at %d : 0x%X(%d)\n",
	       *ncbi->hdr_ptr, *c, (uint32_t) (ncbi->hdr_ptr - ncbi->hdr_buf), ncbi->roff, size); 
    }
    ncbi->hdr_ptr++;
    c++;
  }
  return eslOK;
}
static int parse_expect ( ESL_SQNCBI_DATA * ncbi , void * str , int len ) { int size ; unsigned char * c ; unsigned char * limit ; size = ncbi -> hoff - ncbi -> roff ; limit = ncbi -> hdr_buf + size ; if ( ncbi -> hdr_ptr + len > limit ) { ESL_FAIL ( eslEFORMAT , ncbi -> errbuf , " \n " , len , ( uint32_t ) ( ncbi -> hdr_ptr - ncbi -> hdr_buf ) , ncbi -> roff , size ) ; } c = ( unsigned char * ) str ; while ( len -- ) { if ( * ncbi -> hdr_ptr != * c ) { ESL_FAIL ( eslEFORMAT , ncbi -> errbuf , " \n " , * ncbi -> hdr_ptr , * c , ( uint32_t ) ( ncbi -> hdr_ptr - ncbi -> hdr_buf ) , ncbi -> roff , size ) ; } ncbi -> hdr_ptr ++ ; c ++ ; } return eslOK ; }
Function:  parse_expect()
 Synopsis:  Expect the next bytes to parse match
 Incept:    MSF, Mon Dec 10, 2009 [Janelia]
Function : parse_expect () Synopsis : Expect the next bytes to parse match Incept : MSF Mon Dec 10 2009 [ Janelia ]
/* verify the buffer has atleast len bytes remaining */ /* check the buffer matches the token string */