/usr/include/yuma/ncx/dlq.h is in libyuma-dev 2.9-1+b2.
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 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | /*
* Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _H_dlq
#define _H_dlq
/* FILE: dlq.h
*********************************************************************
* *
* P U R P O S E *
* *
*********************************************************************
dlq provides general double-linked list and queue support:
API Functions
=============
QUEUE initialization/cleanup
* dlq_createQue - create and initialize dynamic queue hdr
* dlq_destroyQue - destroy previously created dynamic queue
* dlq_createSQue - initialize static queue hdr, no destroy needed
FIFO queue operations
* dlq_enque - add node to end of list
* dlq_block_enque - add N nodes to end of list
* dlq_deque - return first node, remove from list
TEST queue operations
* dlq_empty - return TRUE if queue is empty, FALSE otherwise
LINEAR search (linked list)
* dlq_nextEntry - return node AFTER param node - leave in list
* dlq_prevEntry - return node BEFORE param node - leave in list
* dlq_firstEntry - return first node in the Q
* dlq_lastEntry - return last node in the Q
Q INSERTION operations
* dlq_insertAhead - add node in list ahead of param node
* dlq_insertAfter - add node in list after param node
* dlq_block_insertAhead - add N nodes in list ahead of param node
* dlq_block_insertAfter - add N nodes in list after param node
* dlq_block_move - move contents of srcQ to the destintaion Q
Q DELETION operations
* dlq_remove - remove a node from a linked list
Q DEBUG operations
* dlq_dumpHdr - printf Q header info (CPP_DEBUG required)
CPP Macros Used:
================
CPP_DEBUG - enables debug code
CPP_NO_MACROS - forces function calls instead of macros for
some functions. Should not be used except in some debug modes
CPP_ICHK - this will force function calls instead of macros and
enable lots of parameter checking (internal checks). Should
only be used for unit test debugging
ENTER_CRIT - this macro hook can be set to call an enter critical
section function for thread-safe queueing
EXIT_CRIT - this macro hook can be set to call an exit critical
section function for thread-safe queueing
*********************************************************************
* *
* C H A N G E H I S T O R Y *
* *
*********************************************************************
date init comment
----------------------------------------------------------------------
06-jan-89 abb Begun.
18-jan-91 abb adapted for depend project
12-mar-91 abb adapted for DAVID sbee project
14-jun-91 abb changed que.h to dlq.h
27-apr-05 abb update docs and use for netconf project
15-feb-06 abb make DLQ module const compatible
get rid of dlq_hdrPT, as this doesn't work
for const pointers.
15-sep-06 abb added dlq_swap function
26-jan-07 abb added dlq_hdr_t alias for NCX naming conventions
12-oct-07 abb add dlq_count
*/
#include "procdefs.h"
#ifdef __cplusplus
extern "C" {
#endif
/********************************************************************
*
* C O N S T A N T S
*
*********************************************************************/
/* que header types */
#define DLQ_NULL_NODE 1313
#define DLQ_SHDR_NODE 2727
#define DLQ_DHDR_NODE 3434
#define DLQ_DATA_NODE 5757
#define DLQ_DEL_NODE 8686
#define DLQ_DEL_DHDR 9696
#define dlq_hdr_t dlq_hdrT
/********************************************************************
*
* T Y P E S
*
*********************************************************************/
typedef struct TAGdlq_hdrT
{
unsigned short hdr_typ;
struct TAGdlq_hdrT *prev;
struct TAGdlq_hdrT *next;
} dlq_hdrT;
/* shorthand macros */
#define _hdr_node(P) (((const dlq_hdrT *)(P))->hdr_typ==DLQ_SHDR_NODE \
|| ((const dlq_hdrT *)(P))->hdr_typ==DLQ_DHDR_NODE)
#define _data_node(P) (((const dlq_hdrT *)(P))->hdr_typ==DLQ_DATA_NODE)
/********************************************************************
*
* F U N C T I O N S
*
*********************************************************************/
#ifdef CPP_DEBUG
/********************************************************************
* FUNCTION dlq_dumpHdr
*
* use log_debug to dump a Queue header contents
*
* INPUTS:
* nodeP == Q header cast as a void *
*********************************************************************/
extern void dlq_dumpHdr (const void *nodeP);
#endif
/********************************************************************
* FUNCTION dlq_createQue
*
* create a dynamic queue header
*
* RETURNS:
* pointer to malloced queue header
* NULL if memory error
*********************************************************************/
extern dlq_hdrT * dlq_createQue (void);
/********************************************************************
* FUNCTION dlq_createSQue
*
* create a static queue header
*
* INPUTS:
* queAddr == pointer to malloced queue header to initialize
*********************************************************************/
extern void dlq_createSQue (dlq_hdrT * queAddr);
/********************************************************************
* FUNCTION dlq_destroyQue
*
* free a dynamic queue header previously allocated
* with dlq_createQue
*
* INPUTS:
* listP == pointer to malloced queue header to free
*********************************************************************/
extern void dlq_destroyQue (dlq_hdrT * listP);
/********************************************************************
* FUNCTION dlq_enque
*
* add a queue node to the end of a queue list
*
* INPUTS:
* newP == pointer to queue entry to add
* listP == pointer to queue list to put newP
*********************************************************************/
extern void dlq_enque (REG void *newP, REG dlq_hdrT * listP);
/********************************************************************
* FUNCTION dlq_deque
*
* remove the first queue node from the queue list
*
* INPUTS:
* listP == pointer to queue list remove the first entry
*
* RETURNS:
* pointer to removed first entry
* NULL if the queue was empty
*********************************************************************/
extern void *dlq_deque (dlq_hdrT * listP);
/********************************************************************
* FUNCTION dlq_nextEntry
*
* get the next queue entry after the current entry
*
* INPUTS:
* nodeP == pointer to current queue entry to use
*
* RETURNS:
* pointer to next queue entry
* NULL if the no next entry was found
*********************************************************************/
#if defined(CPP_NO_MACROS)
extern void *dlq_nextEntry (const void *nodeP);
#else
#define dlq_nextEntry(P) (_data_node(((const dlq_hdrT *) (P))->next) ? \
((const dlq_hdrT *) (P))->next : NULL)
#endif /* END CPP_NO_MACROS */
/********************************************************************
* FUNCTION dlq_prevEntry
*
* get the previous queue entry before the current entry
*
* INPUTS:
* nodeP == pointer to current queue entry to use
*
* RETURNS:
* pointer to previous queue entry
* NULL if the no previous entry was found
*********************************************************************/
#if defined(CPP_NO_MACROS)
extern void *dlq_prevEntry (const void *nodeP);
#else
#define dlq_prevEntry(P) (_data_node(((const dlq_hdrT *) (P))->prev ) ? \
((const dlq_hdrT *) (P))->prev : NULL)
#endif /* CPP_NO_MACROS */
/********************************************************************
* FUNCTION dlq_insertAhead
*
* insert the new queue entry before the current entry
*
* INPUTS:
* newP == pointer to new queue entry to insert ahead of nodeP
* nodeP == pointer to current queue entry to insert ahead
*********************************************************************/
extern void dlq_insertAhead (void *newP, void *nodeP);
/********************************************************************
* FUNCTION dlq_insertAfter
*
* insert the new queue entry after the current entry
*
* INPUTS:
* newP == pointer to new queue entry to insert after nodeP
* nodeP == pointer to current queue entry to insert after
*********************************************************************/
extern void dlq_insertAfter (void *newP, void *nodeP);
/********************************************************************
* FUNCTION dlq_remove
*
* remove the queue entry from its queue list
* entry MUST have been enqueued somehow before
* this function is called
*
* INPUTS:
* nodeP == pointer to queue entry to remove from queue
*********************************************************************/
extern void dlq_remove (void *nodeP);
/********************************************************************
* FUNCTION dlq_swap
*
* remove the cur_node queue entry from its queue list
* and replace it with the new_node
* cur_node entry MUST have been enqueued somehow before
* this function is called.
* new_node MUST NOT already be in a queue
*
* INPUTS:
* new_node == pointer to new queue entry to put into queue
* cur_node == pointer to current queue entry to remove from queue
*********************************************************************/
extern void dlq_swap (void *new_node, void *cur_node);
/********************************************************************
* FUNCTION dlq_firstEntry
*
* get the first entry in the queue list
*
* INPUTS:
* listP == pointer to queue list to get the first entry from
*
* RETURNS:
* pointer to first queue entry
* NULL if the queue is empty
*********************************************************************/
#if defined(CPP_NO_MACROS)
extern void *dlq_firstEntry (const dlq_hdrT * listP);
#else
#define dlq_firstEntry(P) ((P) != ((const dlq_hdrT *)(P))->next ? \
((const dlq_hdrT *)(P))->next : NULL)
#endif /* CPP_NO_MACROS */
/********************************************************************
* FUNCTION dlq_lastEntry
*
* get the last entry in the queue list
*
* INPUTS:
* listP == pointer to queue list to get the last entry from
*
* RETURNS:
* pointer to last queue entry
* NULL if the queue is empty
*********************************************************************/
#if defined(CPP_NO_MACROS)
extern void *dlq_lastEntry (const dlq_hdrT * listP);
#else
#define dlq_lastEntry(P) ((P) != ((const dlq_hdrT *)(P))->next ? \
((const dlq_hdrT *)(P))->prev : NULL)
#endif /* CPP_NO_MACROS */
/********************************************************************
* FUNCTION dlq_empty
*
* check if queue list is empty
*
* INPUTS:
* listP == pointer to queue list to check
*
* RETURNS:
* TRUE if queue is empty
* FALSE if queue is not empty
*********************************************************************/
#if defined(CPP_NO_MACROS)
extern boolean dlq_empty (const dlq_hdrT * listP);
#else
#define dlq_empty(P) (boolean)((P)==((const dlq_hdrT *)(P))->next)
#endif /* CPP_NO_MACROS */
/********************************************************************
* FUNCTION dlq_block_enque
*
* add all the queue entries in the srcP queue list to the
* end of the dstP queue list
*
* INPUTS:
* srcP == pointer to queue list entry to add end of dstP list
* dstP == pointer to queue list to add all newP entries
*********************************************************************/
extern void dlq_block_enque (dlq_hdrT * srcP, dlq_hdrT * dstP);
/********************************************************************
* FUNCTION dlq_block_insertAhead
*
* insert all the entries in the srcP queue list before
* the dstP queue entry
*
* INPUTS:
* srcP == pointer to new queue list to insert all entries
* ahead of dstP
* dstP == pointer to current queue entry to insert ahead
*********************************************************************/
extern void dlq_block_insertAhead (dlq_hdrT *srcP, void *dstP);
/********************************************************************
* FUNCTION dlq_block_insertAfter
*
* insert all the entries in the srcP queue list after
* the dstP queue entry
*
* INPUTS:
* srcP == pointer to new queue list to insert all entries
* after dstP
* dstP == pointer to current queue entry to insert after
*********************************************************************/
extern void dlq_block_insertAfter (dlq_hdrT *srcP, void *dstP);
/********************************************************************
* FUNCTION dlq_block_move
*
* enque from [srcP .. end of srcQ list] to the dstQ
* insert all the entries in the srcP queue list after
* the dstP queue entry
*
* INPUTS:
* srcQ == pointer to source queue list to move entries from
* srcP == pointer to source queue entry in the srcQ
* move this entry and all entries to the end of
* the srcQ to the end of dstQ
* dstQ == pointer to destination queue list to move the
* entries from the srcQ to the end of this queue
*********************************************************************/
extern void dlq_block_move (dlq_hdrT *srcQ, void *srcP, dlq_hdrT * dstQ);
/********************************************************************
* FUNCTION dlq_count
*
* get the number of queue entries in the listP queue list
*
* INPUTS:
* listP == pointer to queue list to check
*
* RETURNS:
* number of queue entries found in listP queue
*********************************************************************/
extern unsigned int dlq_count (const dlq_hdrT *listP);
#ifdef __cplusplus
} /* end extern 'C' */
#endif
#endif /* _H_dlq */
|