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 = (struct dumpNode *)(malloc(sizeof(struct dumpNode)));
65 memset(*newNode, 0, sizeof(struct dumpNode));
67 (*newNode)->next = dumpQHeader->next;
68 dumpQHeader->next = *newNode;
69 (*newNode)->taskID = allocTaskId();
71 /* if (debugLevel) DisplayNode(*newNode); */
74 /* free the space allotted to the node with <taskID> */
76 FreeNode(afs_int32 taskID)
78 struct dumpNode *oldPtr, *newPtr, *curPtr;
84 newPtr = dumpQHeader->next;
88 while ((!done) && (curPtr != NULL)) {
89 if (curPtr->taskID == taskID) {
91 oldPtr->next = newPtr;
93 /* free the node and its structures */
95 free(curPtr->dumpName);
96 if (curPtr->volumeSetName)
97 free(curPtr->volumeSetName);
99 free(curPtr->restores);
107 newPtr = newPtr->next;
116 GetNthNode(afs_int32 aindex, afs_int32 *aresult)
121 tn = dumpQHeader->next;
125 /* see if this is the desired node ID */
127 *aresult = tn->taskID;
130 /* otherwise, skip to next one and keep looking */
135 /* return the node with <taskID> into <resultNode> */
137 GetNode(afs_int32 taskID, struct dumpNode **resultNode)
139 struct dumpNode *tmpPtr;
143 tmpPtr = dumpQHeader;
144 while ((!done) && (tmpPtr != NULL)) {
145 if (tmpPtr->taskID == taskID) {
146 *resultNode = tmpPtr;
149 tmpPtr = tmpPtr->next;
154 return TC_NODENOTFOUND;