hc
2024-08-12 233ab1bd4c5697f5cdec94e60206e8c6ac609b4c
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
/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2012-2014  Intel Corporation. All rights reserved.
 *
 *
 *  This library 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.
 *
 *  This library 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 this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */
 
#ifndef __A2DP_SOURCE_QUEUE__
#define __A2DP_SOURCE_QUEUE__
 
#include <stdbool.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
typedef void (*queue_destroy_func_t)(void *data);
 
struct queue;
 
struct queue_entry {
   void *data;
   struct queue_entry *next;
};
 
struct queue *queue_new(void);
void queue_destroy(struct queue *queue, queue_destroy_func_t destroy);
 
bool queue_push_tail(struct queue *queue, void *data);
bool queue_push_head(struct queue *queue, void *data);
bool queue_push_after(struct queue *queue, void *entry, void *data);
void *queue_pop_head(struct queue *queue);
void *queue_peek_head(struct queue *queue);
void *queue_peek_tail(struct queue *queue);
 
typedef void (*queue_foreach_func_t)(void *data, void *user_data);
 
void queue_foreach(struct queue *queue, queue_foreach_func_t function,
                           void *user_data);
 
typedef bool (*queue_match_func_t)(const void *data, const void *match_data);
 
void *queue_find(struct queue *queue, queue_match_func_t function,
                           const void *match_data);
 
bool queue_remove(struct queue *queue, void *data);
void *queue_remove_if(struct queue *queue, queue_match_func_t function,
                           void *user_data);
unsigned int queue_remove_all(struct queue *queue, queue_match_func_t function,
               void *user_data, queue_destroy_func_t destroy);
 
const struct queue_entry *queue_get_entries(struct queue *queue);
 
unsigned int queue_length(struct queue *queue);
bool queue_isempty(struct queue *queue);
 
#ifdef __cplusplus
}
#endif
 
#endif /* __A2DP_SOURCE_QUEUE__ */