home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: findDirectChildren.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:32 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include <stdio.h>
- #include "ess.h"
- #include "checking.h"
- #include "list.h"
- #include "io.h"
- #include "tid.h"
- #include "object.h"
- #include "bf.h"
- #include "chunk.h"
- #include "lgobject.h"
- #include "pool.h"
- #include "trace.h"
- #include "error.h"
- #include "version_graph.h"
- #include "version_funcs.h"
- #include "lg_extfuncs.h"
- #include "sm_macro.h"
-
- /*
- * FindDirectChildren() find all the direct children of a node.
- * If a child is a tombstone, then the children of the tombstone
- * are included as well, recursively.
- */
-
- int
- findDirectChildren(
- BUFGROUP *bufGroup,
- VERSIONGRAPH *graph, /* graph containing node */
- VHGNODEID nodeId, /* inspect children of this node */
- VHGNODEID ignoreId, /* do not include this child */
- LIST *childList, /* list of children */
- POOL *childListPool /* pool of list elements */
- )
- {
- VHGNODE *node;
- VHGNODELISTELEMENT *child;
- VHGNODE *childNode;
- LGNODELIST *childListElement;
-
- TRPRINT(TR_VERSION, TR_LEVEL_1,
- ("checking for working children: node %d \n", nodeId) );
-
- CHECK_VERSIONGRAPH_MAGIC(graph);
-
- /*
- * Validate nodeId
- */
- if (nodeId >= graph->nodeCount) {
- SM_ERROR(TYPE_WARNING, esmINTERNAL);
- return(esmFAILURE);
- }
-
- /*
- * Get a pointer to the node
- */
- node = &(graph->nodeArray[nodeId]);
-
- /*
- * Do some defensive error checking.
- */
- CHECK_VHGNODE_MAGIC(node);
-
- /*
- * Get a pointer to the first child
- */
- child = (VHGNODELISTELEMENT*) VHGDEREF(graph, node->children.succ);
- CHECK_VHGLIST_MAGIC(child);
-
- /*
- * Look at each child until a working version is found or
- * the end-of-list is reached
- */
- while ( child != &node->children ) {
-
- /*
- * get a pointer to the child node
- */
- childNode = (VHGNODE*) VHGDEREF(graph, child->item);
- CHECK_VHGNODE_MAGIC(childNode);
- SM_ASSERT(LEVEL_3, childNode->flags & V_frozen);
-
- /*
- * Make sure the child is not one to be ignored
- */
- if (childNode->id != ignoreId) {
- /*
- * If the child is a tombstone, then include its children
- * as well.
- */
- if (childNode->flags & V_tombstone) {
- findDirectChildren(bufGroup, graph, childNode->id, VHGNULLNODE,
- childList, childListPool);
- } else {
-
- /*
- * Include only the child
- */
-
- /*
- * First get a list element and initialize it
- */
- if ((childListElement = (LGNODELIST *) poolDeq( childListPool )) == NULL) {
- /*
- * set the error code and return
- */
- SM_ERROR(TYPE_WARNING, esmNOFREELGNODELIST);
- return(esmFAILURE);
- }
- if (lg_GetRootNodePid(bufGroup, &node->oid,
- &childListElement->pid,
- &childListElement->slot) ) {
- return(esmFAILURE);
- }
-
- /*
- * Add it to the list
- */
- listEnq(childList, &childListElement->list);
-
- }
- }
-
- /*
- * Get next child
- */
- child = (VHGNODELISTELEMENT*) VHGDEREF(graph, child->succ);
- CHECK_VHGLIST_MAGIC(child);
- }
-
- return(esmNOERROR);
- }
-