2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
19 #include <afs/tcdata.h>
21 #include "error_macros.h"
23 /*extern int debugLevel;*/
24 static struct dumpNode
*dumpQHeader
; /* ptr to head of the dumpNode list */
25 static struct dumpNode headNode
; /* the dummy header of the node list */
26 static afs_int32 maxTaskID
; /* the largest task Id allotted so far, this is never reused */
29 * allocate a dump (task) id
38 /* initialize the node list used to keep track of the active dumps */
40 InitNodeList(afs_int32 portOffset
)
42 maxTaskID
= (portOffset
* 1000) + 1; /* this is the first task id alotted */
45 headNode
.dumps
= (struct tc_dumpDesc
*)0;
46 headNode
.restores
= (struct tc_restoreDesc
*)0;
47 dumpQHeader
= &headNode
; /* noone in the list to start with */
51 * Create a <newNode> for the dump, put it in the list of active dumps
52 * and return a pointer to it
54 * newNode - for return ptr
56 * newNode ptr set to point to a node.
60 CreateNode(struct dumpNode
**newNode
)
63 *newNode
= calloc(1, sizeof(struct dumpNode
));
65 (*newNode
)->next
= dumpQHeader
->next
;
66 dumpQHeader
->next
= *newNode
;
67 (*newNode
)->taskID
= allocTaskId();
69 /* if (debugLevel) DisplayNode(*newNode); */
72 /* free the space allotted to the node with <taskID> */
74 FreeNode(afs_int32 taskID
)
76 struct dumpNode
*oldPtr
, *newPtr
, *curPtr
;
82 newPtr
= dumpQHeader
->next
;
86 while ((!done
) && (curPtr
!= NULL
)) {
87 if (curPtr
->taskID
== taskID
) {
89 oldPtr
->next
= newPtr
;
91 /* free the node and its structures */
93 free(curPtr
->dumpName
);
94 if (curPtr
->volumeSetName
)
95 free(curPtr
->volumeSetName
);
97 free(curPtr
->restores
);
105 newPtr
= newPtr
->next
;
114 GetNthNode(afs_int32 aindex
, afs_int32
*aresult
)
119 tn
= dumpQHeader
->next
;
123 /* see if this is the desired node ID */
125 *aresult
= tn
->taskID
;
128 /* otherwise, skip to next one and keep looking */
133 /* return the node with <taskID> into <resultNode> */
135 GetNode(afs_int32 taskID
, struct dumpNode
**resultNode
)
137 struct dumpNode
*tmpPtr
;
141 tmpPtr
= dumpQHeader
;
142 while ((!done
) && (tmpPtr
!= NULL
)) {
143 if (tmpPtr
->taskID
== taskID
) {
144 *resultNode
= tmpPtr
;
147 tmpPtr
= tmpPtr
->next
;
152 return TC_NODENOTFOUND
;