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>
22 #include <afs/tcdata.h>
24 #include "error_macros.h"
26 /*extern int debugLevel;*/
27 static struct dumpNode *dumpQHeader; /* ptr to head of the dumpNode list */
28 static struct dumpNode headNode; /* the dummy header of the node list */
29 static afs_int32 maxTaskID; /* the largest task Id allotted so far, this is never reused */
32 * allocate a dump (task) id
41 /* initialize the node list used to keep track of the active dumps */
43 InitNodeList(afs_int32 portOffset)
45 maxTaskID = (portOffset * 1000) + 1; /* this is the first task id alotted */
48 headNode.dumps = (struct tc_dumpDesc *)0;
49 headNode.restores = (struct tc_restoreDesc *)0;
50 dumpQHeader = &headNode; /* noone in the list to start with */
54 * Create a <newNode> for the dump, put it in the list of active dumps
55 * and return a pointer to it
57 * newNode - for return ptr
59 * newNode ptr set to point to a node.
63 CreateNode(struct dumpNode **newNode)
66 *newNode = (struct dumpNode *)(malloc(sizeof(struct dumpNode)));
68 memset(*newNode, 0, sizeof(struct dumpNode));
70 (*newNode)->next = dumpQHeader->next;
71 dumpQHeader->next = *newNode;
72 (*newNode)->taskID = allocTaskId();
74 /* if (debugLevel) DisplayNode(*newNode); */
77 /* free the space allotted to the node with <taskID> */
79 FreeNode(afs_int32 taskID)
81 struct dumpNode *oldPtr, *newPtr, *curPtr;
87 newPtr = dumpQHeader->next;
91 while ((!done) && (curPtr != NULL)) {
92 if (curPtr->taskID == taskID) {
94 oldPtr->next = newPtr;
96 /* free the node and its structures */
98 free(curPtr->dumpName);
99 if (curPtr->volumeSetName)
100 free(curPtr->volumeSetName);
101 if (curPtr->restores)
102 free(curPtr->restores);
110 newPtr = newPtr->next;
119 GetNthNode(afs_int32 aindex, afs_int32 *aresult)
124 tn = dumpQHeader->next;
128 /* see if this is the desired node ID */
130 *aresult = tn->taskID;
133 /* otherwise, skip to next one and keep looking */
138 /* return the node with <taskID> into <resultNode> */
140 GetNode(afs_int32 taskID, struct dumpNode **resultNode)
142 struct dumpNode *tmpPtr;
146 tmpPtr = dumpQHeader;
147 while ((!done) && (tmpPtr != NULL)) {
148 if (tmpPtr->taskID == taskID) {
149 *resultNode = tmpPtr;
152 tmpPtr = tmpPtr->next;
157 return TC_NODENOTFOUND;