deps/kb_meme/meme-5.0.1/src/buffer.c
/*
 * buf_fgets
 * reads data into the buffer but stops if an end of line
 * is encountered.
 * returns the number of bytes read
 */
buf_fgets
reads data into the buffer but stops if an end of line
is encountered.
returns the number of bytes read
buf_fgets reads data into the buffer but stops if an end of line is encountered . returns the number of bytes read
int buf_fgets(BUF_T *buf, FILE *fp) {
  int remaining, i, rvalue;
  char *dest, *s;
  remaining = (buf->limit - buf->position);
  if (remaining == 0) return 0;
  dest = (buf->buffer)+(buf->position);
  s = fgets(dest, remaining, fp);
  if (s == NULL) {
    return 0;
  }
  for (i = buf->position; i < buf->limit; ++i) {
    if (buf->buffer[i] == '\0') break;
  }
  rvalue = i - buf->position;
  buf->position = i;
  return rvalue;
}
int buf_fgets ( BUF_T * buf , FILE * fp ) { int remaining , i , rvalue ; char * dest , * s ; remaining = ( buf -> limit - buf -> position ) ; if ( remaining == 0 ) return 0 ; dest = ( buf -> buffer ) + ( buf -> position ) ; s = fgets ( dest , remaining , fp ) ; if ( s == NULL ) { return 0 ; } for ( i = buf -> position ; i < buf -> limit ; ++ i ) { if ( buf -> buffer [ i ] == ' \0 ' ) break ; } rvalue = i - buf -> position ; buf -> position = i ; return rvalue ; }
buf_fgets
 reads data into the buffer but stops if an end of line
 is encountered.
buf_fgets reads data into the buffer but stops if an end of line is encountered .