cfs/src/perfutil/Util.cc
/**
 * Read a list of integers from the given file descriptor delimited by the
 * given delimiter.
 */
Read a list of integers from the given file descriptor delimited by the
given delimiter.
Read a list of integers from the given file descriptor delimited by the given delimiter .
std::vector<int>
readIntegers(int fd, char delimiter) {
  std::vector<int> tids;
  char buf[1024];
  lseek(fd, 0, SEEK_SET);
  memset(buf, 0, 1024);
  int retVal = read(fd, buf, 1024);
  int x = 0;
  do {
    if (retVal == -1) {
      fprintf(stderr, "Error reading file %d; errno %d: %s\n", fd, errno,
              strerror(errno));
    }
    for (int i = 0; i < retVal; i++) {
      char c = buf[i];
      if (c == delimiter) {
        tids.push_back(x);
        x = 0;
      } else {
        x *= 10;
        x += (c - '0');
      }
    }
    memset(buf, 0, 1024);
    retVal = read(fd, buf, 1024);
  } while (retVal > 0);
  return tids;
}
std :: vector < int > readIntegers ( int fd , char delimiter ) { std :: vector < int > tids ; char buf [ 1024 ] ; lseek ( fd , 0 , SEEK_SET ) ; memset ( buf , 0 , 1024 ) ; int retVal = read ( fd , buf , 1024 ) ; int x = 0 ; do { if ( retVal == -1 ) { fprintf ( stderr , " \n " , fd , errno , strerror ( errno ) ) ; } for ( int i = 0 ; i < retVal ; i ++ ) { char c = buf [ i ] ; if ( c == delimiter ) { tids . push_back ( x ) ; x = 0 ; } else { x *= 10 ; x += ( c - ' ' ) ; } } memset ( buf , 0 , 1024 ) ; retVal = read ( fd , buf , 1024 ) ; } while ( retVal > 0 ) ; return tids ; }
Read a list of integers from the given file descriptor delimited by the
 given delimiter.
Read a list of integers from the given file descriptor delimited by the given delimiter .