Пример #1
0
void
btreeDestroyNode(BTreeNode *node)
{
    if (node != NULL)
    {
        gdbDestroyBlock(node->block);
    }
    return;
}
void
dbGetRequiredDeps(PmDatabase *db, PmPackage *pkg)
{
	GdbHashTable *table;
	offset_t      depsOffset, nextOffset;
	DbData       *data;
	char         *str;
	long          l;

	table = (GdbHashTable *)PM_PACKAGE_DB_DATA(pkg);

	if (table == NULL)
	{
		pmError(PM_ERROR_WARNING,
				_("GNUpdate DB: "
				  "dbData == NULL. Unable to add reqDeps in %s, line %d\n"),
				__FILE__, __LINE__);
		return;
	}

	data = (DbData *)db->db;
	
	for (depsOffset = htGetOffset(table, GDBTAG_REQ_DEPS);
		 depsOffset != 0;
		 depsOffset = nextOffset)
	{
		GdbHashTable *depTable;
		PmDependency *dep;
		
		depTable = htOpen(data->packageDb, depsOffset);

		if (depTable == NULL)
		{
			pmError(PM_ERROR_FATAL,
					_("GNUpdate DB: "
					  "Unable to open reqdeps hashtable at %ld "
					  "in %s, line %d\n"),
					depsOffset, __FILE__, __LINE__);
			abort();
		}

		nextOffset = depTable->block->listNext;

		dep = pmNewDependency();
		
		if ((str = htGetString(depTable, GDBTAG_NAME)) != NULL)
		{
			pmSetDependencyName(dep, str);
			free(str);
		}

		if ((str = htGetString(depTable, GDBTAG_VERSION)) != NULL)
		{
			l = htGetLong(depTable, GDBTAG_VERSION_FLAGS);

			pmSetDependencyVersion(dep, str, l);

			free(str);
		}

		if ((str = htGetString(depTable, GDBTAG_OWNER)) != NULL)
		{
			pmSetDependencyOwner(dep, str);
			free(str);
		}

		if ((l = htGetLong(depTable, GDBTAG_TYPE)) != 0)
		{
			pmSetDependencyType(dep, l);
		}
		
		gdbDestroyBlock(depTable->block);

		pmPackageAddRequirement(pkg, dep);
	}
}