This file is indexed.

/usr/include/qb/qbloop.h is in libqb-dev 0.16.0.real-1ubuntu3.

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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/*
 * Copyright (C) 2010 Red Hat, Inc.
 *
 * Author: Angus Salkeld <asalkeld@redhat.com>
 *
 * This file is part of libqb.
 *
 * libqb is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * libqb 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with libqb.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef QB_LOOP_H_DEFINED
#define QB_LOOP_H_DEFINED

/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */

#include <signal.h>
#include <stdint.h>

/**
 * @file qbloop.h
 *
 * Main loop manages timers, jobs and polling sockets.
 *
 * @example tcpserver.c
 */


/**
 * Priorites for jobs, timers & poll
 */
enum qb_loop_priority {
	QB_LOOP_LOW = 0,
	QB_LOOP_MED = 1,
	QB_LOOP_HIGH = 2,
};

/**
 * An opaque data type representing the main loop.
 */
typedef struct qb_loop qb_loop_t;

typedef uint64_t qb_loop_timer_handle;

typedef void *qb_loop_signal_handle;

typedef int32_t (*qb_loop_poll_dispatch_fn) (int32_t fd, int32_t revents, void *data);
typedef void (*qb_loop_job_dispatch_fn)(void *data);
typedef void (*qb_loop_timer_dispatch_fn)(void *data);
typedef int32_t (*qb_loop_signal_dispatch_fn)(int32_t rsignal, void *data);

typedef void (*qb_loop_poll_low_fds_event_fn) (int32_t not_enough, int32_t fds_available);

/**
 * Create a new main loop.
 * 
 * @return loop instance.
 */
qb_loop_t * qb_loop_create(void);

/**
 *
 */
void qb_loop_destroy(struct qb_loop * l);

/**
 * Stop the main loop.
 * @param l pointer to the loop instance
 */
void qb_loop_stop(qb_loop_t *l);

/**
 * Run the main loop.
 *
 * @param l pointer to the loop instance
 */
void qb_loop_run(qb_loop_t *l);


/**
 * Add a job to the mainloop.
 *
 * This is run in the next cycle of the loop.
 * @note it is a one-shot job.
 *
 * @param l pointer to the loop instance
 * @param p the priority
 * @param data user data passed into the dispatch function
 * @param dispatch_fn callback function
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_job_add(qb_loop_t *l,
			enum qb_loop_priority p,
			void *data,
			qb_loop_job_dispatch_fn dispatch_fn);


/**
 * Delete a job from the mainloop.
 *
 * This will try to delete the job if it hasn't run yet.
 *
 * @note this will remove the first job that matches the
 * paramaters (priority, data, dispatch_fn).
 *
 * @param l pointer to the loop instance
 * @param p the priority
 * @param data user data passed into the dispatch function
 * @param dispatch_fn callback function
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_job_del(struct qb_loop *l,
			enum qb_loop_priority p,
			void *data,
			qb_loop_job_dispatch_fn dispatch_fn);

/**
 * Add a timer to the mainloop.
 * @note it is a one-shot job.
 *
 * @param l pointer to the loop instance
 * @param p the priority
 * @param nsec_duration nano-secs in the future to run the dispatch.
 * @param data user data passed into the dispatch function
 * @param dispatch_fn callback function
 * @param timer_handle_out handle to delete the timer if needed.
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_timer_add(qb_loop_t *l,
			  enum qb_loop_priority p,
			  uint64_t nsec_duration,
			  void *data,
			  qb_loop_timer_dispatch_fn dispatch_fn,
			  qb_loop_timer_handle * timer_handle_out);

/**
 * Delete a timer that is still outstanding.
 *
 * @param l pointer to the loop instance
 * @param th handle to delete the timer if needed.
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_timer_del(qb_loop_t *l, qb_loop_timer_handle th);

/**
 * Check to see if a timer that is still outstanding.
 *
 * @param l pointer to the loop instance
 * @param th handle to delete the timer if needed.
 * @retval QB_TRUE yes this timer is outstanding
 * @retval QB_FALSE this timer does not exist or has expired
 */
int32_t qb_loop_timer_is_running(qb_loop_t *l, qb_loop_timer_handle th);

/**
 * Get the time remaining before it expires.
 *
 * @note if the timer has already expired it will return 0
 *
 * @param l pointer to the loop instance
 * @param th timer handle.
 * @return nano seconds left
 */
uint64_t qb_loop_timer_expire_time_get(struct qb_loop *l, qb_loop_timer_handle th);

/**
 * Set a callback to receive events on file descriptors
 * getting low.
 * @param l pointer to the loop instance
 * @param fn callback function.
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_poll_low_fds_event_set(qb_loop_t *l,
				       qb_loop_poll_low_fds_event_fn fn);

/**
 * Add a poll job to the mainloop.
 * @note it is a re-occuring job.
 *
 * @param l pointer to the loop instance
 * @param p the priority
 * @param fd file descriptor.
 * @param events (POLLIN|POLLOUT) etc ....
 * @param data user data passed into the dispatch function
 * @param dispatch_fn callback function
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_poll_add(qb_loop_t *l,
			     enum qb_loop_priority p,
			     int32_t fd,
			     int32_t events,
			     void *data,
			     qb_loop_poll_dispatch_fn dispatch_fn);

/**
 * Modify a poll job.
 *
 * @param l pointer to the loop instance
 * @param p the priority
 * @param fd file descriptor.
 * @param events (POLLIN|POLLOUT) etc ....
 * @param data user data passed into the dispatch function
 * @param dispatch_fn callback function
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_poll_mod(qb_loop_t *l,
			 enum qb_loop_priority p,
			 int32_t fd,
			 int32_t events,
			 void *data,
			 qb_loop_poll_dispatch_fn dispatch_fn);

/**
 * Delete a poll job.
 *
 * @param l pointer to the loop instance
 * @param fd file descriptor.
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_poll_del(qb_loop_t *l, int32_t fd);

/**
 * Add a signal job.
 *
 * Get a callback on this signal (not in the context of the signal).
 *
 * @param l pointer to the loop instance
 * @param p the priority
 * @param sig (SIGHUP or SIGINT) etc ....
 * @param data user data passed into the dispatch function
 * @param dispatch_fn callback function
 * @param handle (out) a reference to the signal job
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_signal_add(qb_loop_t *l,
			   enum qb_loop_priority p,
			   int32_t sig,
			   void *data,
			   qb_loop_signal_dispatch_fn dispatch_fn,
			   qb_loop_signal_handle *handle);

/**
 * Modify the signal job
 *
 * @param l pointer to the loop instance
 * @param p the priority
 * @param sig (SIGHUP or SIGINT) etc ....
 * @param data user data passed into the dispatch function
 * @param dispatch_fn callback function
 * @param handle (in) a reference to the signal job
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_signal_mod(qb_loop_t *l,
			   enum qb_loop_priority p,
			   int32_t sig,
			   void *data,
			   qb_loop_signal_dispatch_fn dispatch_fn,
			   qb_loop_signal_handle handle);

/**
 * Delete the signal job.
 *
 * @param l pointer to the loop instance
 * @param handle (in) a reference to the signal job
 * @return status (0 == ok, -errno == failure)
 */
int32_t qb_loop_signal_del(qb_loop_t *l,
			   qb_loop_signal_handle handle);

/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif /* __cplusplus */
/* *INDENT-ON* */
#endif /* QB_LOOP_H_DEFINED */