X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Flib%2Fqueue.c;h=137b7bb55bf54c7c4582d7603a1c31ac5d72fa14;hb=897707854a8240d026e933215009f931bb9c5762;hp=19fd12599e6e664d7108b984be8d24a46243a9b0;hpb=56bbed88464979b01f841bf1332c3b9cfa769654;p=bacula%2Fbacula diff --git a/bacula/src/lib/queue.c b/bacula/src/lib/queue.c index 19fd12599e..137b7bb55b 100644 --- a/bacula/src/lib/queue.c +++ b/bacula/src/lib/queue.c @@ -1,36 +1,43 @@ /* - Q U E U E - Queue Handling Routines + Q U E U E + Queue Handling Routines - Taken from smartall written by John Walker. + Taken from smartall written by John Walker. - http://www.fourmilab.ch/smartall/ + http://www.fourmilab.ch/smartall/ - - Version $Id$ -*/ + Version $Id$ +*/ /* - Copyright (C) 2000-2004 Kern Sibbald and John Walker + Bacula® - The Network Backup Solution - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + Copyright (C) 2000-2006 Free Software Foundation Europe e.V. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program 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 General Public License for more details. - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. - */ + Bacula® is a registered trademark of Kern Sibbald. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ #include "bacula.h" @@ -39,15 +46,15 @@ #ifdef REALLY_NEEDED struct b_queue { - struct b_queue *qnext, /* Next item in queue */ - *qprev; /* Previous item in queue */ + struct b_queue *qnext, /* Next item in queue */ + *qprev; /* Previous item in queue */ }; #endif -/* +/* * To define a queue, use the following * - * static BQUEUE xyz = { &xyz, &xyz }; + * static BQUEUE xyz = { &xyz, &xyz }; * * Also, note, that the only real requirement is that * the object that is passed to these routines contain @@ -55,56 +62,56 @@ struct b_queue { * rest of the structure may be anything. * * NOTE!!!! The casting here is REALLY painful, but this avoids - * doing ugly casting every where else in the code. + * doing ugly casting every where else in the code. */ /* Queue manipulation functions. */ -/* QINSERT -- Insert object at end of queue */ +/* QINSERT -- Insert object at end of queue */ void qinsert(BQUEUE *qhead, BQUEUE *object) { #define qh ((BQUEUE *)qhead) #define obj ((BQUEUE *)object) - ASSERT(qh->qprev->qnext == qh); - ASSERT(qh->qnext->qprev == qh); + ASSERT(qh->qprev->qnext == qh); + ASSERT(qh->qnext->qprev == qh); - obj->qnext = qh; - obj->qprev = qh->qprev; - qh->qprev = obj; - obj->qprev->qnext = obj; + obj->qnext = qh; + obj->qprev = qh->qprev; + qh->qprev = obj; + obj->qprev->qnext = obj; #undef qh #undef obj } /* QREMOVE -- Remove next object from the queue given - the queue head (or any item). + the queue head (or any item). Returns NULL if queue is empty */ BQUEUE *qremove(BQUEUE *qhead) { #define qh ((BQUEUE *)qhead) - BQUEUE *object; + BQUEUE *object; - ASSERT(qh->qprev->qnext == qh); - ASSERT(qh->qnext->qprev == qh); + ASSERT(qh->qprev->qnext == qh); + ASSERT(qh->qnext->qprev == qh); - if ((object = qh->qnext) == qh) - return NULL; - qh->qnext = object->qnext; - object->qnext->qprev = qh; - return object; + if ((object = qh->qnext) == qh) + return NULL; + qh->qnext = object->qnext; + object->qnext->qprev = qh; + return object; #undef qh } -/* QNEXT -- Return next item from the queue - * returns NULL at the end of the queue. - * If qitem is NULL, the first item from - * the queue is returned. +/* QNEXT -- Return next item from the queue + * returns NULL at the end of the queue. + * If qitem is NULL, the first item from + * the queue is returned. */ BQUEUE *qnext(BQUEUE *qhead, BQUEUE *qitem) @@ -112,31 +119,31 @@ BQUEUE *qnext(BQUEUE *qhead, BQUEUE *qitem) #define qh ((BQUEUE *)qhead) #define qi ((BQUEUE *)qitem) - BQUEUE *object; + BQUEUE *object; - if (qi == NULL) - qitem = qhead; - ASSERT(qi->qprev->qnext == qi); - ASSERT(qi->qnext->qprev == qi); - - if ((object = qi->qnext) == qh) - return NULL; - return object; + if (qi == NULL) + qitem = qhead; + ASSERT(qi->qprev->qnext == qi); + ASSERT(qi->qnext->qprev == qi); + + if ((object = qi->qnext) == qh) + return NULL; + return object; #undef qh #undef qi -} +} /* QDCHAIN -- Dequeue an item from the middle of a queue. Passed - the queue item, returns the (now dechained) queue item. */ + the queue item, returns the (now dechained) queue item. */ BQUEUE *qdchain(BQUEUE *qitem) { #define qi ((BQUEUE *)qitem) - ASSERT(qi->qprev->qnext == qi); - ASSERT(qi->qnext->qprev == qi); + ASSERT(qi->qprev->qnext == qi); + ASSERT(qi->qnext->qprev == qi); - return qremove(qi->qprev); + return qremove(qi->qprev); #undef qi }