hmmer-3.3/easel/esl_sqio_ncbi.c
/* Function:  parse_integer()
 * Synopsis:  Parse an integer
 * Incept:    MSF, Mon Dec 10, 2009 [Janelia]
 *
 * Purpose:   Reads an integer from the header stream.  If the integer is
 *            more bytes than the native int format, the most significant
 *            bytes will be lost.
 *
 *            If <value> is non null, the parsed integer will be placed
 *            in the pointer.
 *
 * Returns:   <eslOK> on success.
 *            <eslEFORMAT> if there's a problem with the format.
 *
 */
parse_integer()
Synopsis:  Parse an integer
Incept:    MSF, Mon Dec 10, 2009 [Janelia]

Reads an integer from the header stream.  If the integer is
more bytes than the native int format, the most significant
bytes will be lost.

If  is non null, the parsed integer will be placed
in the pointer.

 on success.
 if there's a problem with the format.
parse_integer () Synopsis : Parse an integer Incept : MSF Mon Dec 10 2009 [ Janelia ] Reads an integer from the header stream . If the integer is more bytes than the native int format the most significant bytes will be lost . If is non null the parsed integer will be placed in the pointer . on success . if there ' s a problem with the format .
static int
parse_integer(ESL_SQNCBI_DATA *ncbi, int *value)
{
  int n;
  unsigned char  c;
  unsigned char *ptr;
  if (parse_expect(ncbi, "\x02", 1) != eslOK) return eslEFORMAT;
  if (parse_peek(ncbi, &c) != eslOK)          return eslEFORMAT;
  ptr = ncbi->hdr_ptr + 1;
  if (parse_advance(ncbi, c + 1) != eslOK)    return eslEFORMAT;
  n = 0;
  while (c > 0) {
    n = (n << 8) + (unsigned int) *ptr++;
    --c;
  }
  if (value != NULL) *value = n;
  return eslOK;
}
static int parse_integer ( ESL_SQNCBI_DATA * ncbi , int * value ) { int n ; unsigned char c ; unsigned char * ptr ; if ( parse_expect ( ncbi , " \x02 " , 1 ) != eslOK ) return eslEFORMAT ; if ( parse_peek ( ncbi , & c ) != eslOK ) return eslEFORMAT ; ptr = ncbi -> hdr_ptr + 1 ; if ( parse_advance ( ncbi , c + 1 ) != eslOK ) return eslEFORMAT ; n = 0 ; while ( c > 0 ) { n = ( n << 8 ) + ( unsigned int ) * ptr ++ ; -- c ; } if ( value != NULL ) * value = n ; return eslOK ; }
Function:  parse_integer()
 Synopsis:  Parse an integer
 Incept:    MSF, Mon Dec 10, 2009 [Janelia]
Function : parse_integer () Synopsis : Parse an integer Incept : MSF Mon Dec 10 2009 [ Janelia ]
/* get the length of the integer */ /* advance past the integer to make sure the buffer holds all
   * of the integer.  the pointer <ptr> points the the start of
   * the integer.
   */