This file is indexed.

/usr/include/libwfut-0.2/libwfut/IO.h is in libwfut-0.2-dev 0.2.1-2.

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
// This file may be redistributed and modified only under the terms of
// the GNU Lesser General Public License (See COPYING for details).
// Copyright (C) 2005 - 2008 Simon Goodall

#ifndef LIBWFUT_IO_H
#define LIBWFUT_IO_H 1

#include <cassert>
#include <string>
#include <map>
#include <deque>
#include <cstdio>

#include <zlib.h>
#include <curl/curl.h>
#include <sigc++/signal.h>

#include <libwfut/types.h>

namespace WFUT {
  // Internal data struct representing a single file being downloaded.
  typedef struct {
    std::string filename;
    std::string path;
    std::string url;
    bool executable;
    FILE *fp;
    uLong actual_crc32;
    uLong expected_crc32;
    CURL *handle;
  } DataStruct;

/**
 * The IO class wraps most of the CURL related calls, taking a URL to a file and
 * writing it to a local file.
 */ 
class IO {
public:
  IO() :
     m_initialised(false),
     m_mhandle(NULL),
     m_num_to_process(1)
  {}

  virtual ~IO() {
    assert(m_initialised == false);
  }

  /**
   * The init method initialises the CURL backend. 
   */
  int init();

  /**
   * The init method cleans up the CURL backend. 
   */
  int shutdown();

  /**
   * Poll network for data chunks to download and write to disk.
   */ 
  int poll();

  /**
   * Tell CURL to immediately download the file in the given URL and save it to
   * the given filename, optionally checking the CRC32 value. This is a blocking
   *  call.
   *  @param filename Destination filename
   *  @param url Remote location.
   *  @param expected_crc32 The expected crc32 value of the file. 0 to ignore.
   */
  int downloadFile(const std::string &filename, const std::string &url, uLong expected_crc32);

  /**
   * Tell CURL to immediately download the file in the given URL and save it 
   * using the given FILE pointer, optionally checking the CRC32 value. This is
   * a blocking  call.
   *  @param fp Open file descriptor to write file data into.
   *  @param url Remote location.
   *  @param expected_crc32 The expected crc32 value of the file. 0 to ignore.
   */
  int downloadFile(FILE *fp, const std::string &url, uLong expected_crc32);

  /**
   * Queue a file to be downloaded using the poll function.
   * @see IO::poll
   * @param path The directory to save the file into.
   * @param filename The filename minus the directory.
   * @param url The full URL of the file
   * @param expected_crc32 The expected CRC32 value of the file. 0 to ignore.
   * @param executable Flag for whether to set the executable flag when ndownloaded.
   */ 
  int queueFile(const std::string &path, const std::string &filename, const std::string &url, uLong expected_crc32, bool executable);

  /**
   * The DownloadComplete signal is fired when a file is successfully downloade.
   */
  sigc::signal<void, const std::string&, const std::string&> DownloadComplete;
  /**
   * The DownloadFailed signal is fired when a file fails to download 
   * successfully.
   */
  sigc::signal<void, const std::string&, const std::string&, const std::string&> DownloadFailed;

  /**
   * Returns the maximum number of simultaneous downloads allowed.
   */
  int getMaxDownloads() const { return m_num_to_process; }
  /**
   * Set the maximum number of simultaneous downloads allowed. Multiple 
   * downloads will cause multiple connections to be opened, even if the same
   * remote server is used.
   */ 
  void setMaxDownloads(int i) { m_num_to_process = i; }

  /**
   * Abort all current and pending downloads.
   */ 
  void abortAll();

  /**
   * Abort the download of the specified file.
   */ 
  void abortDownload(const std::string &);

private:

  void abortDownload(DataStruct *ds);

  bool m_initialised;
  CURLM *m_mhandle;
  std::map<std::string, DataStruct*> m_files;
  std::deque<CURL*> m_handles;
  int m_num_to_process;
};

} /* namespace WFUT */

#endif /* LIBEFUT_IO_H */