This file is indexed.

/usr/include/openbabel-2.0/openbabel/lineend.h is in libopenbabel-dev 2.3.2+dfsg-2.2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/**********************************************************************
lineend.h - Stream buffer for filtering line endings, converting \r or \r\n -> \n

 Copyright (C) 1998 by James Kanze
 Copyright (C) 2007 by Chris Morley

This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
***********************************************************************/

#ifndef OB_LINEEND_H
#define OB_LINEEND_H

#include <streambuf>
#include <climits>

#ifndef OBCONV
#define OBCONV
#endif

namespace OpenBabel
{

/*! \class FilteringInputStreambuf lineend.h <openbabel/lineend.h>
  \brief Delivers characters from an istream or streambuf from a source
  while filtering

  Based on an article by James Kanze, "Filtering Streambufs"
  http://kanze.james.neuf.fr/articles/fltrsbf1.html

  A FilteringInputStreambuf delivers characters on request to an istream
  or a destination rdbuf(). It receives them from a source rdbuf.
  In doing the transfer it filters them in a way decided by the class
  specified in template parameter Extractor.

  seekg and tellg requests from the stream are passed through to source rdbuf.
  This allows return to a position in the input data that was previously noted.
  This is adequate to allow OpenBabel's fastsearch indexing, but may
  not be good enough for some other applications that use random access.

  A class LineEndingExtractor converts DOS and MAC line endings to the
  UNIX line ending.

  This filtering process is potentially extendable, with a chain of
  FilteringInputStreambufs each carrying out its filtering task.
  For instance a decompression streambuf could feed a LineEnding filter,
  which in tern was read by an input stream.
*/
  template< class Extractor >
  class FilteringInputStreambuf : public std::streambuf
  {
  public:
    FilteringInputStreambuf(
      std::streambuf*        source = NULL ,
      bool                   deleteWhenFinished = false
      ) ;
    virtual                 ~FilteringInputStreambuf()
    {
      //sync(); comment out so can be deleted in OBConversion destructor
    };
    virtual int              overflow( int ) {return EOF;};
    virtual int              underflow() ;
    virtual int              sync() ;

    //Pass the random acess functions to the source rdbuf and synchronize
    virtual std::streampos   seekoff(std::streamoff off, std::ios_base::seekdir way,
      std::ios_base::openmode which = std::ios_base::in | std::ios_base::out )
    {
      std::streampos ret = mySource->pubseekoff(off, way, which);
//      sync();
      return ret;
    };

    virtual std::streampos   seekpos(std::streampos sp,
      std::ios_base::openmode which = std::ios_base::in | std::ios_base::out )
    {
      std::streampos ret = mySource->pubseekpos(sp, which);
//      sync();
      return ret;
    };

    /// Returns current source.
    std::streambuf* GetSource()const
    {
      return mySource;
    };

    ///Changes the source
    void SetSource(std::streambuf* newsource)
    {
      mySource = newsource;
      setg( &myBuffer , &myBuffer , &myBuffer + 1 ) ;
    }

//    Extractor&   extractor() {return myExtractor;};

  private:
    std::streambuf*          mySource ;
    Extractor                myExtractor ;
    char                     myBuffer ;
    bool                     myDeleteWhenFinished ;
  } ;

//*******************************************************
  template< class Extractor >
  FilteringInputStreambuf< Extractor >::FilteringInputStreambuf(
    std::streambuf*        source ,
    bool                   deleteWhenFinished)
    : mySource(source), myDeleteWhenFinished(deleteWhenFinished)
  {
    setg( &myBuffer , &myBuffer , &myBuffer ) ;
  }

  //////////////////////////////////////////////////////////
  template< class Extractor >
  int
  FilteringInputStreambuf< Extractor >::underflow()
  {
    int result( EOF ) ;
    if( gptr() < egptr() )
      result = *gptr() ;
    else if ( mySource != NULL )
    {
      result = myExtractor( *mySource ) ;
      if ( result != EOF )
      {
        if( result < 0 || result > UCHAR_MAX )
          std::cerr << "FilteringInputStreambuf error" << std::endl;
        myBuffer = result ;
        setg( &myBuffer , &myBuffer , &myBuffer + 1 ) ;
      }
    }
    return result ;
  }

  //////////////////////////////////////////////////////
  template< class Extractor >
  int
  FilteringInputStreambuf< Extractor >::sync()
  {
    int result( 0 ) ;
    if ( mySource != NULL )
    {
      if ( gptr() < egptr() )
      {
        result = mySource->sputbackc( *gptr() ) ;
        setg( NULL , NULL , NULL ) ;
      }
      if ( mySource->pubsync() == EOF )
          result = EOF ;
    }
    return result ;
  }

//*********************************************
/// \class LineEndingExtractor lineend.h <openbabel/lineend.h>
  /// \brief Replaces CRLF (DOS) and CR (Mac OS 9) line endings by LF (POSIX)
class OBCONV LineEndingExtractor
{
public:
  int operator()( std::streambuf& src )
  {
    int ch( src.sbumpc() ) ;
    switch (ch)
    {
      case 13: //CR or CRLF
        if(src.sgetc() == 10)
          src.sbumpc(); //CRLF
        //fall through
      case 10: //LF
        return '\n';
        break;
      default:
        return ch;
    }
  }
  void finalize( std::streambuf& ) {}
};

} //namespace

#endif //OB_LINEEND_H
//! \file lineend.h
//! \brief Translate line endings automatically (UNIX, Classic Mac, DOS)