ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
queue.h
Go to the documentation of this file.
1 /*
2  *
3  * BlueZ - Bluetooth protocol stack for Linux
4  *
5  * Copyright (C) 2012-2014 Intel Corporation. All rights reserved.
6  *
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 #include <stdbool.h>
25 
26 typedef void (*queue_destroy_func_t)(void *data);
27 
28 struct queue;
29 
30 struct queue_entry {
31  int ref_count;
32  void *data;
33  struct queue_entry *next;
34 };
35 
36 struct queue *queue_new(void);
37 void queue_destroy(struct queue *queue, queue_destroy_func_t destroy);
38 
39 bool queue_push_tail(struct queue *queue, void *data);
40 bool queue_push_head(struct queue *queue, void *data);
41 bool queue_push_after(struct queue *queue, void *entry, void *data);
42 void *queue_pop_head(struct queue *queue);
43 void *queue_peek_head(struct queue *queue);
44 void *queue_peek_tail(struct queue *queue);
45 
46 typedef void (*queue_foreach_func_t)(void *data, void *user_data);
47 
48 void queue_foreach(struct queue *queue, queue_foreach_func_t function,
49  void *user_data);
50 
51 typedef bool (*queue_match_func_t)(const void *data, const void *match_data);
52 
53 void *queue_find(struct queue *queue, queue_match_func_t function,
54  const void *match_data);
55 
56 bool queue_remove(struct queue *queue, void *data);
57 void *queue_remove_if(struct queue *queue, queue_match_func_t function,
58  void *user_data);
59 unsigned int queue_remove_all(struct queue *queue, queue_match_func_t function,
60  void *user_data, queue_destroy_func_t destroy);
61 
62 const struct queue_entry *queue_get_entries(struct queue *queue);
63 
64 unsigned int queue_length(struct queue *queue);
65 bool queue_isempty(struct queue *queue);
void * queue_peek_tail(struct queue *queue)
Definition: queue.c:310
void(* queue_destroy_func_t)(void *data)
Definition: queue.h:26
void * data
Definition: queue.h:32
bool queue_remove(struct queue *queue, void *data)
Definition: queue.c:402
void queue_destroy(struct queue *queue, queue_destroy_func_t destroy)
Definition: queue.c:102
bool queue_push_head(struct queue *queue, void *data)
Definition: queue.c:198
void * queue_find(struct queue *queue, queue_match_func_t function, const void *match_data)
Definition: queue.c:376
void queue_foreach(struct queue *queue, queue_foreach_func_t function, void *user_data)
Definition: queue.c:325
const struct queue_entry * queue_get_entries(struct queue *queue)
Definition: queue.c:540
Definition: queue.h:30
void * queue_remove_if(struct queue *queue, queue_match_func_t function, void *user_data)
Definition: queue.c:440
bool queue_push_tail(struct queue *queue, void *data)
Definition: queue.c:167
Definition: queue.c:40
unsigned int queue_length(struct queue *queue)
Definition: queue.c:555
int ref_count
Definition: queue.h:31
bool queue_push_after(struct queue *queue, void *entry, void *data)
Definition: queue.c:229
void(* queue_foreach_func_t)(void *data, void *user_data)
Definition: queue.h:46
bool(* queue_match_func_t)(const void *data, const void *match_data)
Definition: queue.h:51
struct queue * queue_new(void)
Definition: queue.c:81
void * queue_pop_head(struct queue *queue)
Definition: queue.c:268
bool queue_isempty(struct queue *queue)
Definition: queue.c:569
struct queue_entry * next
Definition: queue.h:33
void * queue_peek_head(struct queue *queue)
Definition: queue.c:297
unsigned int queue_remove_all(struct queue *queue, queue_match_func_t function, void *user_data, queue_destroy_func_t destroy)
Definition: queue.c:487