src/ccstruct/boxread.cpp
bool ReadNextBox(int target_page, int *line_number, FILE *box_file, std::string &utf8_str,
                 TBOX *bounding_box) {
  int page = 0;
  char buff[kBoxReadBufSize]; // boxfile read buffer
  char *buffptr = buff;

  while (fgets(buff, sizeof(buff) - 1, box_file)) {
    (*line_number)++;

    buffptr = buff;
    const auto *ubuf = reinterpret_cast<const unsigned char *>(buffptr);
    if (ubuf[0] == 0xef && ubuf[1] == 0xbb && ubuf[2] == 0xbf) {
      buffptr += 3; // Skip unicode file designation.
    }
    // Check for blank lines in box file
    if (*buffptr == '\n' || *buffptr == '\0') {
      continue;
    }
    // Skip blank boxes.
    if (*buffptr == ' ' || *buffptr == '\t') {
      continue;
    }
    if (*buffptr != '\0') {
      if (!ParseBoxFileStr(buffptr, &page, utf8_str, bounding_box)) {
        tprintf("Box file format error on line %i; ignored\n", *line_number);
        continue;
      }
      if (target_page >= 0 && target_page != page) {
        continue; // Not on the appropriate page.
      }
      return true; // Successfully read a box.
    }
  }
  fclose(box_file);
  return false; // EOF
}
// As ReadNextBox above, but get a specific page number. (0-based)
// Use -1 to read any page number. Files without page number all
// read as if they are page 0.
As ReadNextBox above, but get a specific page number. (0-based)
Use -1 to read any page number. Files without page number all
read as if they are page 0.
As ReadNextBox above but get a specific page number . ( 0 - based ) Use - 1 to read any page number . Files without page number all read as if they are page 0 .
bool ReadNextBox(int target_page, int *line_number, FILE *box_file, std::string &utf8_str,
                 TBOX *bounding_box) {
  int page = 0;
  char buff[kBoxReadBufSize]; 
  char *buffptr = buff;
  while (fgets(buff, sizeof(buff) - 1, box_file)) {
    (*line_number)++;
    buffptr = buff;
    const auto *ubuf = reinterpret_cast<const unsigned char *>(buffptr);
    if (ubuf[0] == 0xef && ubuf[1] == 0xbb && ubuf[2] == 0xbf) {
      buffptr += 3; 
    }
    if (*buffptr == '\n' || *buffptr == '\0') {
      continue;
    }
    if (*buffptr == ' ' || *buffptr == '\t') {
      continue;
    }
    if (*buffptr != '\0') {
      if (!ParseBoxFileStr(buffptr, &page, utf8_str, bounding_box)) {
        tprintf("Box file format error on line %i; ignored\n", *line_number);
        continue;
      }
      if (target_page >= 0 && target_page != page) {
        continue; 
      }
      return true; 
    }
  }
  fclose(box_file);
  return false; 
}
bool ReadNextBox ( int target_page , int * line_number , FILE * box_file , std :: string & utf8_str , TBOX * bounding_box ) { int page = 0 ; char buff [ kBoxReadBufSize ] ; char * buffptr = buff ; while ( fgets ( buff , sizeof ( buff ) - 1 , box_file ) ) { ( * line_number ) ++ ; buffptr = buff ; const auto * ubuf = reinterpret_cast < const unsigned char * > ( buffptr ) ; if ( ubuf [ 0 ] == 0xef && ubuf [ 1 ] == 0xbb && ubuf [ 2 ] == 0xbf ) { buffptr += 3 ; } if ( * buffptr == ' \n ' || * buffptr == ' \0 ' ) { continue ; } if ( * buffptr == ' ' || * buffptr == ' \t ' ) { continue ; } if ( * buffptr != ' \0 ' ) { if ( ! ParseBoxFileStr ( buffptr , & page , utf8_str , bounding_box ) ) { tprintf ( " \n " , * line_number ) ; continue ; } if ( target_page >= 0 && target_page != page ) { continue ; } return true ; } } fclose ( box_file ) ; return false ; }
As ReadNextBox above, but get a specific page number.
As ReadNextBox above but get a specific page number .
// boxfile read buffer // Skip unicode file designation. // Check for blank lines in box file // Skip blank boxes. // Not on the appropriate page. // Successfully read a box. // EOF