This file is indexed.

/usr/include/zmqpp/poller.hpp is in libzmqpp-dev 3.2.0-0ubuntu4.

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
/**
 * \file
 *
 * \date   9 Aug 2011
 * \author Ben Gray (\@benjamg)
 */

#ifndef ZMQPP_POLLER_HPP_
#define ZMQPP_POLLER_HPP_

#include <unordered_map>
#include <vector>

#include "compatibility.hpp"

namespace zmqpp
{

class socket;
typedef socket socket_t;

/*!
 * Polling wrapper.
 *
 * Allows access to polling for any number of sockets or file descriptors.
 */
class poller
{
public:
	static const long wait_forever; /*!< Block forever flag, default setting. */

	static const short poll_none;   /*!< No polling flags set. */
	static const short poll_in;     /*!< Monitor inbound flag. */
	static const short poll_out;    /*!< Monitor output flag. */
	static const short poll_error;  /*!< Monitor error flag.\n Only for file descriptors. */

	/*!
	 * Construct an empty polling model.
	 */
	poller();

	/*!
	 * Cleanup poller.
	 *
	 * Any sockets will need to be closed separately.
	 */
	~poller();

	/*!
	 * Add a socket to the polling model and set which events to monitor.
	 *
	 * \param socket the socket to monitor.
	 * \param event the event flags to monitor on the socket.
	 */
	void add(socket_t& socket, short const& event = poll_in);

	/*!
	 * Add a file descriptor to the polling model and set which events to monitor.
	 *
	 * \param descriptor the file descriptor to monitor.
	 * \param event the event flags to monitor.
	 */
	void add(int const& descriptor, short const& event = poll_in | poll_error);

	/*!
	 * Check if we are monitoring a given socket with this poller.
	 *
	 * \param socket the socket to check.
	 * \return true if it is there.
	 */
	bool has(socket_t const& socket);

	/*!
	 * Check if we are monitoring a given file descriptor with this poller.
	 *
	 * \param descriptor the file descriptor to check.
	 * \return true if it is there.
	 */
	bool has(int const& descriptor);

	/*!
	 * Stop monitoring a socket.
	 *
	 * \param socket the socket to stop monitoring.
	 */
	void remove(socket_t const& socket);

	/*!
	 * Stop monitoring a file descriptor.
	 *
	 * \param descriptor the file descriptor to stop monitoring.
	 */
	void remove(int const& descriptor);

	/*!
	 * Update the monitored event flags for a given socket.
	 *
	 * \param socket the socket to update event flags.
	 * \param event the event flags to monitor on the socket.
	 */
	void check_for(socket_t const& socket, short const& event);

	/*!
	 * Update the monitored event flags for a given file descriptor.
	 *
	 * \param descriptor the file descriptor to update event flags.
	 * \param event the event flags to monitor on the socket.
	 */
	void check_for(int const& descriptor, short const& event);

	/*!
	 * Poll for monitored events.
	 *
	 * By default this method will block forever or until at least one of the monitored
	 * sockets or file descriptors has events.
	 *
	 * If a timeout is set and was reached then this function returns false.
	 *
	 * \param timeout milliseconds to timeout.
	 * \return true if there is an event..
	 */
	bool poll(long timeout = wait_forever);

	/*!
	 * Get the event flags triggered for a socket.
	 *
	 * \param socket the socket to get triggered event flags for.
	 * \return the event flags.
	 */
	short events(socket_t const& socket) const;

	/*!
	 * Get the event flags triggered for a file descriptor.
	 *
	 * \param descriptor the file descriptor to get triggered event flags for.
	 * \return the event flags.
	 */
	short events(int const& descriptor) const;

	/*!
	 * Check either a file descriptor or socket for input events.
	 *
	 * Templated helper method that calls through to event and checks for a given flag
	 *
	 * \param watchable either a file descriptor or socket known to the poller.
	 * \return true if there is input.
	 */
	template<typename Watched>
	bool has_input(Watched const& watchable) const { return events(watchable) & poll_in; }

	/*!
	 * Check either a file descriptor or socket for output events.
	 *
	 * Templated helper method that calls through to event and checks for a given flag
	 *
	 * \param watchable either a file descriptor or socket known to the poller.
	 * \return true if there is output.
	 */
	template<typename Watched>
	bool has_output(Watched const& watchable) const { return events(watchable) & poll_out; }

	/*!
	 * Check a file descriptor.
	 *
	 * Templated helper method that calls through to event and checks for a given flag
	 *
	 * Technically this template works for sockets as well but the error flag is never set for
	 * sockets so I have no idea why someone would call it.
	 *
	 * \param watchable a file descriptor know to the poller.
	 * \return true if there is an error.
	 */
	template<typename Watched>
	bool has_error(Watched const& watchable) const { return events(watchable) & poll_error; }

private:
	std::vector<zmq_pollitem_t> _items;
	std::unordered_map<void *, size_t> _index;
	std::unordered_map<int, size_t> _fdindex;

	void reindex(size_t const index);
};

}

#endif /* ZMQPP_POLLER_HPP_ */