summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Fuhrmann <nf@openoffice.org>2001-04-11 08:52:27 +0000
committerNils Fuhrmann <nf@openoffice.org>2001-04-11 08:52:27 +0000
commit53adf7cac0cf63bd4eefe04add60c897047d8fd4 (patch)
tree7b351365f0b8290836f23fa107ba94b15b568f18
parentbf483b816251187276c53d4812732d9e14a2e096 (diff)
Initial import, replacement of solenv/wnti/ldump
-rw-r--r--soltools/ldump/hashtbl.cxx489
-rw-r--r--soltools/ldump/hashtbl.hxx223
-rw-r--r--soltools/ldump/ldump.cxx747
-rw-r--r--soltools/ldump/ldump.hxx110
-rw-r--r--soltools/ldump/makefile.mk88
-rw-r--r--soltools/prj/d.lst0
6 files changed, 1657 insertions, 0 deletions
diff --git a/soltools/ldump/hashtbl.cxx b/soltools/ldump/hashtbl.cxx
new file mode 100644
index 000000000000..383c2be56b91
--- /dev/null
+++ b/soltools/ldump/hashtbl.cxx
@@ -0,0 +1,489 @@
+/*************************************************************************
+ *
+ * $RCSfile: hashtbl.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nf $ $Date: 2001-04-11 09:52:26 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "hashtbl.hxx"
+#include <string.h>
+
+// -------------------------------------------------------------
+// class HashItem
+//
+class HashItem
+{
+ enum ETag { TAG_EMPTY, TAG_USED, TAG_DELETED };
+
+ void* m_pObject;
+ ETag m_Tag;
+ char* m_Key;
+
+public:
+ HashItem() { m_Tag = TAG_EMPTY; m_Key = NULL; m_pObject = NULL; }
+ ~HashItem() { delete [] m_Key; }
+
+ bool IsDeleted() const
+ { return m_Tag == TAG_DELETED; }
+
+ bool IsEmpty() const
+ { return m_Tag == TAG_DELETED || m_Tag == TAG_EMPTY; }
+
+ bool IsFree() const
+ { return m_Tag == TAG_EMPTY; }
+
+ bool IsUsed() const
+ { return m_Tag == TAG_USED; }
+
+ void Delete()
+ { m_Tag = TAG_DELETED; delete [] m_Key; m_Key = new char[ 1 ]; m_Key[ 0 ] = 0; m_pObject = NULL; }
+
+ const char *GetKey() const
+ { return m_Key; }
+
+ void* GetObject() const
+ { return m_pObject; }
+
+ void SetObject(const char * Key, void *pObject)
+ { m_Tag = TAG_USED; delete [] m_Key; m_Key = new char[ strlen( Key ) + 1 ]; strcpy( m_Key, Key ); m_pObject = pObject; }
+};
+
+#define MIN(a,b) (a)<(b)?(a):(b)
+#define MAX(a,b) (a)>(b)?(a):(b)
+
+// -------------------------------------------------------------
+// class HashTable
+//
+
+/*static*/ double HashTable::m_defMaxLoadFactor = 0.8;
+/*static*/ double HashTable::m_defDefGrowFactor = 2.0;
+
+HashTable::HashTable(unsigned long lSize, bool bOwner, double dMaxLoadFactor, double dGrowFactor)
+{
+ m_lSize = lSize;
+ m_bOwner = bOwner;
+ m_lElem = 0;
+ m_dMaxLoadFactor = MAX(0.5,MIN(1.0,dMaxLoadFactor)); // 0.5 ... 1.0
+ m_dGrowFactor = MAX(1.3,(5.0,dGrowFactor)); // 1.3 ... 5.0
+ m_pData = new HashItem [lSize];
+}
+
+HashTable::~HashTable()
+{
+ // Wenn die HashTable der Owner der Objecte ist,
+ // mssen die Destruktoren separat gerufen werden.
+ // Dies geschieht ber die virtuelle Methode OnDeleteObject()
+ //
+ // Problem: Virtuelle Funktionen sind im Destructor nicht virtuell!!
+ // Der Code mu deshalb ins Macro
+
+ /*
+ if (m_bOwner)
+ {
+ for (ULONG i=0; i<GetSize(); i++)
+ {
+ void *pObject = GetObjectAt(i);
+
+ if (pObject != NULL)
+ OnDeleteObject(pObject());
+ }
+ }
+ */
+
+ // Speicher fr HashItems freigeben
+ delete [] m_pData;
+}
+
+void* HashTable::GetObjectAt(unsigned long lPos) const
+// Gibt Objekt zurck, wenn es eines gibt, sonst NULL;
+{
+ HashItem *pItem = &m_pData[lPos];
+
+ return pItem->IsUsed() ? pItem->GetObject() : NULL;
+}
+
+void HashTable::OnDeleteObject(void*)
+{
+}
+
+unsigned long HashTable::Hash(const char *Key) const
+{
+ // Hashfunktion von P.J. Weinberger
+ // aus dem "Drachenbuch" von Aho/Sethi/Ullman
+ unsigned long i,n;
+ unsigned long h = 0;
+ unsigned long g = 0;
+
+ for (i=0,n=strlen( Key ); i<n; i++)
+ {
+ h = (h<<4) + (unsigned long)(unsigned short)Key[i];
+ g = h & 0xf0000000;
+
+ if (g != 0)
+ {
+ h = h ^ (g >> 24);
+ h = h ^ g;
+ }
+ }
+
+ return h % m_lSize;
+}
+
+unsigned long HashTable::DHash(const char* Key, unsigned long lOldHash) const
+{
+ unsigned long lHash = lOldHash;
+ unsigned long i,n;
+
+ for (i=0,n=strlen( Key ); i<n; i++)
+ {
+ lHash *= 256L;
+ lHash += (unsigned long)(unsigned short)Key[i];
+ lHash %= m_lSize;
+ }
+ return lHash;
+}
+
+unsigned long HashTable::Probe(unsigned long lPos) const
+// gibt den Folgewert von lPos zurck
+{
+ lPos++; if (lPos==m_lSize) lPos=0;
+ return lPos;
+}
+
+bool HashTable::IsFull() const
+{
+ return m_lElem>=m_lSize;
+}
+
+bool HashTable::Insert(const char * Key, void* pObject)
+// pre: Key ist nicht im Dictionary enthalten, sonst return FALSE
+// Dictionary ist nicht voll, sonst return FALSE
+// post: pObject ist unter Key im Dictionary; m_nElem wurde erhht
+{
+ SmartGrow();
+
+ if (IsFull())
+ {
+ return false;
+ }
+
+ if (FindPos(Key) != NULL )
+ return false;
+
+ unsigned long lPos = Hash(Key);
+ HashItem *pItem = &m_pData[lPos];
+
+ // first hashing
+ //
+ if (pItem->IsEmpty())
+ {
+ pItem->SetObject(Key, pObject);
+ m_lElem++;
+
+ return true;
+ }
+
+ // double hashing
+ //
+ lPos = DHash(Key,lPos);
+ pItem = &m_pData[lPos];
+
+ if (pItem->IsEmpty())
+ {
+ pItem->SetObject(Key, pObject);
+ m_lElem++;
+
+ return true;
+ }
+
+ // linear probing
+ //
+ do
+ {
+ lPos = Probe(lPos);
+ pItem = &m_pData[lPos];
+ }
+ while(!pItem->IsEmpty());
+
+ pItem->SetObject(Key, pObject);
+ m_lElem++;
+ return true;
+}
+
+HashItem* HashTable::FindPos(const char * Key) const
+// sucht den Key; gibt Refrenz auf den Eintrag (gefunden)
+// oder NULL (nicht gefunden) zurck
+//
+// pre: -
+// post: -
+{
+ // first hashing
+ //
+ unsigned long lPos = Hash(Key);
+ HashItem *pItem = &m_pData[lPos];
+
+ if (pItem->IsUsed()
+ && !(strcmp( pItem->GetKey(), Key )))
+ {
+ return pItem;
+ }
+
+ // double hashing
+ //
+ if (pItem->IsDeleted() || pItem->IsUsed())
+ {
+ lPos = DHash(Key,lPos);
+ pItem = &m_pData[lPos];
+
+ if (pItem->IsUsed()
+ && (!strcmp( pItem->GetKey(), Key)))
+ {
+ return pItem;
+ }
+
+ // linear probing
+ //
+ if (pItem->IsDeleted() || pItem->IsUsed())
+ {
+ unsigned long n = 0;
+ bool bFound = false;
+ bool bEnd = false;
+
+ do
+ {
+ n++;
+ lPos = Probe(lPos);
+ pItem = &m_pData[lPos];
+
+ bFound = pItem->IsUsed()
+ && !( strcmp( pItem->GetKey(), Key ));
+
+ bEnd = !(n<m_lSize || pItem->IsFree());
+ }
+ while(!bFound && !bEnd);
+
+ return bFound ? pItem : NULL;
+ }
+ }
+
+ // nicht gefunden
+ //
+ return NULL;
+}
+
+void* HashTable::Find(const char *Key) const
+// Gibt Verweis des Objektes zurck, das unter Key abgespeichert ist,
+// oder NULL wenn nicht vorhanden.
+//
+// pre: -
+// post: -
+{
+ HashItem *pItem = FindPos(Key);
+
+ if (pItem != NULL
+ && ( !strcmp( pItem->GetKey(), Key )))
+ return pItem->GetObject();
+ else
+ return NULL;
+}
+
+void* HashTable::Delete( const char * Key)
+// Lscht Objekt, das unter Key abgespeichert ist und gibt Verweis
+// darauf zurck.
+// Gibt NULL zurck, wenn Key nicht vorhanden ist.
+//
+// pre: -
+// post: Objekt ist nicht mehr enthalten; m_lElem dekrementiert
+// Wenn die HashTable der Owner ist, wurde das Object gelscht
+{
+ HashItem *pItem = FindPos(Key);
+
+ if (pItem != NULL
+ && ( !strcmp( pItem->GetKey(), Key )))
+ {
+ void* pObject = pItem->GetObject();
+
+ if (m_bOwner)
+ OnDeleteObject(pObject);
+
+ pItem->Delete();
+ m_lElem--;
+ return pObject;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+double HashTable::CalcLoadFactor() const
+// prozentuale Belegung der Hashtabelle berechnen
+{
+ return double(m_lElem) / double(m_lSize);
+}
+
+void HashTable::SmartGrow()
+// Achtung: da die Objekte umkopiert werden, darf die OnDeleteObject-Methode
+// nicht gerufen werden
+{
+ double dLoadFactor = CalcLoadFactor();
+
+ if (dLoadFactor <= m_dMaxLoadFactor)
+ return; // nothing to grow
+
+ unsigned long lOldSize = m_lSize; // alte Daten sichern
+ HashItem* pOldData = m_pData;
+
+ m_lSize = unsigned long (m_dGrowFactor * m_lSize); // neue Gre
+ m_pData = new HashItem[m_lSize]; // neue Daten holen
+
+ // kein Speicher:
+ // Zustand "Tabelle voll" wird in Insert abgefangen
+ //
+ if (m_pData == NULL)
+ {
+ m_lSize = lOldSize;
+ m_pData = pOldData;
+ return;
+ }
+
+ m_lElem = 0; // noch keine neuen Daten
+
+ // Umkopieren der Daten
+ //
+ for (unsigned long i=0; i<lOldSize; i++)
+ {
+ HashItem *pItem = &pOldData[i];
+
+ if (pItem->IsUsed())
+ Insert(pItem->GetKey(),pItem->GetObject());
+ }
+
+ delete [] pOldData;
+}
+
+// Iterator ---------------------------------------------------------
+//
+
+HashTableIterator::HashTableIterator(HashTable const& aTable)
+: m_aTable(aTable)
+{
+ m_lAt = 0;
+}
+
+void* HashTableIterator::GetFirst()
+{
+ m_lAt = 0;
+ return FindValidObject(true /* forward */);
+}
+
+void* HashTableIterator::GetLast()
+{
+ m_lAt = m_aTable.GetSize() -1;
+ return FindValidObject(false /* backward */);
+}
+
+void* HashTableIterator::GetNext()
+{
+ if (m_lAt+1 >= m_aTable.GetSize())
+ return NULL;
+
+ m_lAt++;
+ return FindValidObject(true /* forward */);
+}
+
+void* HashTableIterator::GetPrev()
+{
+ if (m_lAt <= 0)
+ return NULL;
+
+ m_lAt--;
+ return FindValidObject(false /* backward */);
+}
+
+void* HashTableIterator::FindValidObject(bool bForward)
+// Sucht nach einem vorhandenen Objekt ab der aktuellen
+// Position.
+//
+// pre: ab inkl. m_lAt soll die Suche beginnen
+// post: if not found then
+// if bForward == TRUE then
+// m_lAt == m_aTable.GetSize() -1
+// else
+// m_lAt == 0
+// else
+// m_lAt ist die gefundene Position
+{
+ void *pObject = m_aTable.GetObjectAt(m_lAt);
+
+ if (pObject != NULL)
+ return pObject;
+
+ while (pObject == NULL
+ && (bForward ? ((m_lAt+1) < m_aTable.GetSize())
+ : m_lAt > 0))
+ {
+ if (bForward)
+ m_lAt++;
+ else
+ m_lAt--;
+
+ pObject = m_aTable.GetObjectAt(m_lAt);
+ }
+
+ return pObject;
+}
diff --git a/soltools/ldump/hashtbl.hxx b/soltools/ldump/hashtbl.hxx
new file mode 100644
index 000000000000..85123873a44f
--- /dev/null
+++ b/soltools/ldump/hashtbl.hxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * $RCSfile: hashtbl.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nf $ $Date: 2001-04-11 09:52:26 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _HASHTBL_HXX
+#define _HASHTBL_HXX
+
+// ADT hash table
+//
+// Invariante:
+// 1. m_lElem < m_lSize
+// 2. die Elemente in m_Array wurden double-hashed erzeugt
+//
+class HashItem;
+
+class HashTable
+{
+ unsigned long m_lSize;
+ unsigned long m_lElem;
+ HashItem *m_pData;
+ double m_dMaxLoadFactor;
+ double m_dGrowFactor;
+ bool m_bOwner;
+
+ unsigned long Hash(const char *cKey) const;
+ unsigned long DHash(const char *cKey , unsigned long lHash) const;
+ unsigned long Probe(unsigned long lPos) const;
+
+ HashItem* FindPos(const char *cKey) const;
+ void SmartGrow();
+ double CalcLoadFactor() const;
+
+protected:
+ friend class HashTableIterator;
+
+ virtual void OnDeleteObject(void* pObject);
+
+ void* GetObjectAt(unsigned long lPos) const;
+
+// Default-Werte
+public:
+ static double m_defMaxLoadFactor;
+ static double m_defDefGrowFactor;
+
+public:
+ HashTable
+ (
+ unsigned long lSize,
+ bool bOwner,
+ double dMaxLoadFactor = HashTable::m_defMaxLoadFactor /* 0.8 */,
+ double dGrowFactor = HashTable::m_defDefGrowFactor /* 2.0 */
+ );
+
+ ~HashTable();
+
+ bool IsFull() const;
+ unsigned long GetSize() const { return m_lSize; }
+
+ void* Find (const char *cKey ) const;
+ bool Insert (const char *cKey , void* pObject);
+ void* Delete (const char *cKey);
+};
+
+// ADT hash table iterator
+//
+// Invariante: 0 <= m_lAt < m_aTable.GetCount()
+//
+class HashTableIterator
+{
+ unsigned long m_lAt;
+ HashTable const& m_aTable;
+
+ void* FindValidObject(bool bForward);
+
+protected:
+ void* GetFirst(); // Interation _ohne_ Sortierung
+ void* GetNext();
+ void* GetLast();
+ void* GetPrev();
+
+public:
+ HashTableIterator(HashTable const&);
+};
+
+// typsichere Makros ---------------------------------------------------
+
+#define DECLARE_HASHTABLE_INTERN(ClassName,Owner,KeyType,ObjType) \
+ class ClassName : public HashTable \
+ { \
+ public: \
+ ClassName \
+ ( \
+ unsigned long lSize, \
+ double dMaxLoadFactor = HashTable::m_defMaxLoadFactor, \
+ double dGrowFactor = HashTable::m_defDefGrowFactor \
+ ) \
+ : HashTable(lSize,Owner,dMaxLoadFactor,dGrowFactor) {} \
+ \
+ ObjType Find (KeyType const& Key) const \
+ { return (ObjType) HashTable::Find((char *) Key); } \
+ \
+ bool Insert (KeyType const& Key, ObjType Object) \
+ { return HashTable::Insert((char *) Key, (void*) Object); } \
+ \
+ ObjType Delete (KeyType const&Key) \
+ { return (ObjType) HashTable::Delete ((char *) Key); } \
+ };
+
+// HashTable OHNE Owner-Verhalten
+#define DECLARE_HASHTABLE(ClassName,KeyType,ObjType) \
+ DECLARE_HASHTABLE_INTERN(ClassName,false,KeyType,ObjType)
+
+// HashTable MIT Owner-Verhalten
+#define DECLARE_HASHTABLE_OWNER(ClassName,KeyType,ObjType) \
+ DECLARE_HASHTABLE_INTERN(ClassName##2,true,KeyType,ObjType) \
+ class ClassName : public ClassName##2 \
+ { \
+ protected: \
+ virtual void OnDeleteObject(void* pObject); \
+ public: \
+ ClassName \
+ ( \
+ unsigned long lSize, \
+ double dMaxLoadFactor = HashTable::m_defMaxLoadFactor, \
+ double dGrowFactor = HashTable::m_defDefGrowFactor \
+ ) \
+ : ClassName##2(lSize,dMaxLoadFactor,dGrowFactor) {} \
+ ~ClassName(); \
+ };
+
+#define IMPLEMENT_HASHTABLE_OWNER(ClassName,KeyType,ObjType) \
+ void ClassName::OnDeleteObject(void* pObject) \
+ { delete (ObjType) pObject; } \
+ \
+ ClassName::~ClassName() \
+ { \
+ for (unsigned long i=0; i<GetSize(); i++) \
+ { \
+ void *pObject = GetObjectAt(i); \
+ if (pObject != NULL) \
+ OnDeleteObject(pObject); \
+ } \
+ }
+
+// Iterator-Makros --------------------------------------------------
+
+#define DECLARE_HASHTABLE_ITERATOR(ClassName,ObjType) \
+ class ClassName : public HashTableIterator \
+ { \
+ public: \
+ ClassName(HashTable const& aTable) \
+ : HashTableIterator(aTable) {} \
+ \
+ ObjType GetFirst() \
+ { return (ObjType)HashTableIterator::GetFirst(); } \
+ ObjType GetNext() \
+ { return (ObjType)HashTableIterator::GetNext(); } \
+ ObjType GetLast() \
+ { return (ObjType)HashTableIterator::GetLast(); } \
+ ObjType GetPrev() \
+ { return (ObjType)HashTableIterator::GetPrev(); } \
+ };
+
+
+#endif // _HASHTBL_HXX
+
diff --git a/soltools/ldump/ldump.cxx b/soltools/ldump/ldump.cxx
new file mode 100644
index 000000000000..99c982018b8d
--- /dev/null
+++ b/soltools/ldump/ldump.cxx
@@ -0,0 +1,747 @@
+/*************************************************************************
+ *
+ * $RCSfile: ldump.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nf $ $Date: 2001-04-11 09:52:26 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <string.h>
+#include <direct.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "ldump.hxx"
+#include "hashtbl.hxx"
+
+#define MAXSYM 32768
+#define MAXBASE 49152
+#ifdef WNT
+#define MAX_MAN 4096
+#else
+#define MAX_MAN 4095
+#endif
+
+int bFilter = 0;
+int bLdump3 = 0;
+
+DECLARE_HASHTABLE( ExportSet, char *, LibExport*)
+
+LibDump::LibDump( char *cFileName )
+ : cBName( NULL ),
+ cAPrefix( NULL ),
+ cLibName( NULL ),
+ cFilterName( NULL ),
+ cModName( NULL )
+{
+ fprintf( stderr, "LIB-NT File Dumper v4.00 (C) 2000 Sun Microsystems, Inc.\n\n" );
+ fprintf( stderr, "%s ", cFileName );
+
+ int nSlots = 63997;
+ pBaseTab = new ExportSet( nSlots );
+ pIndexTab = new ExportSet( nSlots );
+ pFilterLines = new char * [MAXFILT];
+ CheckLibrary(cFileName);
+ bBase = 0;
+ bAll = false;
+ nDefStart = 0;
+ nBaseLines = 0;
+ nFilterLines = 0;
+ bDef = true;
+ cAPrefix = new char[ 1 ];
+ cAPrefix[ 0 ] = 0;
+ CheckDataBase();
+}
+
+bool LibDump::Dump()
+{
+ FILE *pList;
+ char aBuf[MAX_MAN];
+ int nLen;
+ char aName[MAX_MAN];
+
+#ifndef ICC
+ pList = fopen( cLibName, "rb");
+ if (!pList)
+ DumpError(10);
+
+ // berechnug des offsets fuer anfang der gemangelten namen
+ unsigned char TmpBuffer[4];
+ fread( TmpBuffer, 1, 4, pList);
+ // anzahl bigendian mal laenge + ueberspringen der naechsten laengenangabe
+ unsigned long nOffSet = ( TmpBuffer[2] * 256 + TmpBuffer[3] ) * 4 + 4;
+ fseek( pList, nOffSet, 0);
+
+ char c;
+ char aTmpBuf[4096];
+ // Einlesen der .exp-Datei
+ while( !feof( pList ) )
+ {
+ int i = 0;
+ // symbol komplett einlesen
+ while ( (c = fgetc( pList )) != '\0' )
+ {
+ if ( ((c >= 33) && (c <= 126)) && ( c!=40 && c!=41) )
+ aBuf[i] = c;
+ else
+ {
+ aBuf[0] = '\0';
+ break;
+ }
+ i++;
+ }
+ // Namen gefunden
+ aBuf[i] = '\0';
+
+ int n_is_ct;
+ if ((aBuf[0] =='?') || ( n_is_ct = !strncmp(aBuf, "__CT",4)))
+ {
+ nLen = strlen(aBuf);
+ memset( aName, 0, sizeof( aName ) );
+ int nName = 0;
+ for( i = 0; i < nLen; i++ )
+ {
+ if ( (aBuf[i] != '\n') && (aBuf[i] != '\r') )
+ {
+ aName[nName] = aBuf[i];
+ nName++;
+ }
+ }
+ // und raus damit
+ PrintSym( aName );
+ }
+ else if ( bAll == true )
+ {
+ int nPreLen = strlen( cAPrefix );
+
+ nLen = strlen(aBuf);
+ memset( aName, 0, sizeof( aName ) );
+ int nName = 0;
+
+ for( i = 0; i < nLen; i++ )
+ {
+ if ( (aBuf[i] != '\n') && (aBuf[i] != '\r') )
+ {
+ aName[nName] = aBuf[i];
+ nName++;
+ }
+ }
+ //fprintf( stderr, "Gefundenen Prefix : %s %d \n", aTmpBuf, nPreLen );
+ // den ersten _ raus
+ nLen = strlen(aName);
+ if (aName[0] == '_')
+ strcpy( aBuf , &aName[1] );
+ strncpy ( aTmpBuf, aBuf, nPreLen );
+ aTmpBuf[nPreLen] = '\0';
+ if ( !strcmp( aTmpBuf, cAPrefix ))
+ {
+ if ( bLdump3 ) {
+ int nChar = '@';
+ char *pNeu = strchr( aBuf, nChar );
+ int nPos = pNeu - aBuf + 1;
+ if ( nPos > 0 )
+ {
+ char aOldBuf[MAX_MAN];
+ strcpy( aOldBuf, aBuf );
+ char pChar[MAX_MAN];
+ strncpy( pChar, aBuf, nPos -1 );
+ pChar[nPos-1] = '\0';
+ strcpy( aBuf, pChar );
+ strcat( aBuf, "=" );
+ strcat( aBuf, aOldBuf );
+ strcpy( pChar, "" );
+ }
+ }
+ // und raus damit
+ PrintSym( aBuf, false );
+ }
+ }
+ }
+#else
+ pList = fopen( sLibName.GetBuffer(), "rb");
+ if (!pList)
+ DumpError(10);
+
+ char c = fgetc( pList );
+
+ while( !feof( pList ) )
+ {
+ int bBreakOut = 0;
+
+ int i=0;
+ bool bStop = false;
+
+ while ( c != '\0' )
+ {
+ if(c == 0x0d || c == 0x20)
+ {
+ c = fgetc( pList );
+ continue;
+ }
+
+ if(c == '@')
+ {
+ bStop = true;
+ c = fgetc( pList );
+ continue;
+ }
+
+ if(c != 0x0a)
+ {
+ if(!bStop)
+ aBuf[i++] = c;
+ }
+ else
+ {
+ aBuf[i] = '\0';
+ c = fgetc( pList );
+ break;
+ }
+
+ c = fgetc( pList );
+ }
+
+
+ //wenn erstes Zeichen kein Semikolon ist, wird die Zeile bernommen
+ if(aBuf[0] != ';' && aBuf[0] != 0)
+ {
+ //cdecl Methoden werden ohne NONAME expotiert
+ if(aBuf[0] == '_' && aBuf[1] != '_' && sAPrefix.Len())
+ PrintSym( aBuf, false );
+ else if(ByteString(aBuf).Search(sAPrefix) == 0)
+ PrintSym( aBuf, false );
+ else
+ PrintSym( aBuf );
+ }
+ }
+#endif
+ fclose(pList);
+ return true;
+}
+
+bool LibDump::ReadFilter( char * cFilterName )
+{
+ FILE* pfFilter = 0;
+ char aBuf[MAX_MAN];
+ char* pStr;
+ int nLen;
+
+ pfFilter = fopen( cFilterName, "r" );
+
+ if ( !pfFilter )
+ {
+ ::bFilter = 0;
+ DumpError( 500 );
+ return true;
+ }
+
+ while( fgets( aBuf, MAX_MAN, pfFilter ) != 0 )
+ {
+ nLen = strlen(aBuf);
+ pStr = new char[nLen];
+ if ( !pStr )
+ DumpError( 98 );
+ memcpy( pStr, aBuf, nLen );
+ if ( *(pStr+nLen-1) == '\n' )
+ *(pStr+nLen-1) = '\0';
+ pFilterLines[nFilterLines] = pStr;
+ nFilterLines++;
+ if ( nFilterLines >= MAXFILT )
+ DumpError( 510 );
+ }
+
+ fclose( pfFilter );
+ return true;
+}
+
+bool LibDump::PrintSym(char *pName, bool bName )
+{
+ int nTreffer = 0;
+ int bTreffer = false;
+ LibExport *pData;
+
+
+ // Filter auswerten
+ if ( Filter( pName ) )
+ {
+ if ( strlen( pName ) > 3 )
+ {
+ if ( bDef )
+ {
+ if (!bBase)
+ {
+ fprintf( stdout, "\t%s\t\t@%lu\n", pName, nDefStart );
+ }
+ else
+ {
+ pData = pBaseTab->Find( pName );
+ if ( pData )
+ {
+ pData->bExport = true;
+ if ( bName )
+ pData->bByName = true;
+ else
+ pData->bByName = false;
+ fprintf(stderr,".");
+ }
+ else
+ {
+ // neuen Export eintragen
+ pData = new LibExport;
+ pData->cExportName = new char[ strlen( pName ) + 1 ];
+ strcpy( pData->cExportName, pName );
+ pData->nOrdinal = nBaseLines++;
+ pData->bExport = true;
+ if ( bName )
+ pData->bByName = true;
+ else
+ pData->bByName = false;
+ pBaseTab->Insert( pData->cExportName, pData );
+ char *cBuffer = new char[ 30 ];
+ sprintf( cBuffer, "%lu", pData->nOrdinal );
+ pIndexTab->Insert( cBuffer, pData );
+ delete [] cBuffer;
+ fprintf(stderr,"n");
+ }
+ }
+ }
+ else
+ printf( "%s\n", pName );
+ nDefStart++;
+ }
+ }
+ return true;
+}
+
+bool LibDump::Filter(char *pExportName)
+{
+ unsigned long i;
+ char pTest[256];
+
+ // Kein Filter gesetzt
+ if ( ::bFilter == 0 )
+ return true;
+
+ // die Imports bleiben drin !
+ if ( strstr ( pExportName, "mport"))
+ return true;
+
+ if( strstr ( pExportName, "getImpl"))
+ i= 5;
+
+ for ( i=0; i<nFilterLines; i++ )
+ {
+ //Zum vergleichen mu das Plus abgeschnitteb werden
+ if(pFilterLines[i][0] != '+')
+ {
+ if ( strstr( pExportName, pFilterLines[i]))
+ return false;
+ }
+ else
+ {
+ strcpy(pTest,&pFilterLines[i][1]);
+ if ( strstr( pExportName, pTest))
+ return true;
+ }
+ }
+ return true;
+}
+
+bool LibDump::SetFilter(char * cFilterName)
+{
+ ReadFilter( cFilterName );
+ return true;
+}
+
+bool LibDump::CheckLibrary(char * cName)
+{
+ delete [] cLibName;
+ cLibName = new char[ strlen( cName ) + 1 ];
+ strcpy( cLibName, cName );
+ return true;
+}
+
+bool LibDump::ReadDataBase()
+{
+ FILE* pfBase = 0;
+ char aBuf[MAX_MAN];
+ char* pStr;
+ int nLen;
+ LibExport *pData;
+
+ pfBase = fopen( cBName, "r" );
+
+ if ( !pfBase )
+ {
+ bBase = 0;
+ DumpError( 600 );
+ return false;
+ }
+
+ bool bRet = true;
+ while( fgets( aBuf, MAX_MAN, pfBase ) != 0 )
+ {
+ nLen = strlen(aBuf);
+ pStr = new char[nLen];
+ if ( !pStr )
+ DumpError( 98 );
+ memcpy( pStr, aBuf, nLen );
+ if ( *(pStr+nLen-1) == '\n' )
+ *(pStr+nLen-1) = '\0';
+ pData = new LibExport;
+ pData->cExportName = new char[ strlen( pStr ) + 1 ];
+ strcpy( pData->cExportName, pStr );
+ pData->nOrdinal = nBaseLines;
+ pData->bExport=false;
+
+ if (pBaseTab->Insert(pData->cExportName, pData ) == NULL)
+ bRet = false;
+ char *cBuffer = new char[ 30 ];
+ sprintf( cBuffer, "%lu", pData->nOrdinal );
+ if (pIndexTab->Insert( cBuffer, pData ) == NULL)
+ bRet = false;
+ delete [] cBuffer;
+ nBaseLines++;
+ if ( nBaseLines >= MAXBASE )
+ DumpError( 610 );
+ }
+ //nNumber = nBaseLines-1;
+ fclose( pfBase );
+ return bRet;
+}
+
+DECLARE_HASHTABLE_ITERATOR( ExportSetIter, LibExport* )
+
+bool LibDump::PrintDataBase()
+{
+ FILE *pFp;
+ pFp = fopen (cBName,"w+");
+ if (!pFp)
+ fprintf( stderr, "Error opening DataBase File\n" );
+
+ LibExport *pData;
+ for ( unsigned long i=0; i < nBaseLines+10; i++ )
+ {
+ char * cBuffer = new char[ 30 ];
+ sprintf( cBuffer, "%lu", i );
+ pData = pIndexTab->Find( cBuffer );
+ delete [] cBuffer;
+ if ( pData )
+ fprintf(pFp,"%s\n",pData->cExportName);
+ }
+ fclose(pFp);
+ return true;
+}
+
+bool LibDump::PrintDefFile()
+{
+#ifdef FAST
+ ExportSetIter aIterator( *pBaseTab );
+ for ( LibExport *pData = aIterator.GetFirst(); pData != NULL;
+ pData = aIterator.GetNext() )
+ {
+ if ( pData->bExport )
+ {
+ if ( pData->bByName )
+ {
+ fprintf(stdout,"\t%s\t\t@%d NONAME\n",
+ pData->sExportName.GetBuffer(), pData->nOrdinal+nBegin);
+ }
+ else
+ {
+ fprintf(stdout,"\t%s\t\t@%d\n",
+ pData->sExportName.GetBuffer(), pData->nOrdinal+nBegin);
+ }
+ }
+ }
+#else
+ // sortiert nach Ordinals;
+ LibExport *pData;
+ for ( unsigned long i=0; i<nBaseLines+1; i++)
+ {
+ char * cBuffer = new char[ 30 ];
+ sprintf( cBuffer, "%lu", i );
+ pData = pIndexTab->Find( cBuffer );
+ delete [] cBuffer;
+ if ( pData )
+ if ( pData->bExport )
+ {
+ if ( pData->bByName )
+ {
+ if ( strlen( pData->cExportName ))
+ fprintf(stdout,"\t%s\t\t@%d NONAME\n",
+ pData->cExportName, pData->nOrdinal+nBegin);
+ }
+ else
+ {
+ if ( strlen( pData->cExportName ))
+ fprintf(stdout,"\t%s\t\t@%d\n",
+ pData->cExportName, pData->nOrdinal+nBegin);
+ }
+ }
+ }
+#endif
+ return true;
+}
+
+bool LibDump::CheckDataBase()
+{
+ // existiert eine Datenbasis ?
+ if (!bBase)
+ {
+ cBName = new char[ 2048 ];
+ char *pTmp = "defs\\";
+
+ FILE *fp;
+ _mkdir ("defs");
+ strcpy(cBName,pTmp);
+ strcat(cBName,getenv ("COMP_ENV"));
+
+ fp = fopen (cBName,"r");
+ if (fp)
+ {
+ bBase = true;
+ }
+ else
+ {
+ fp = fopen (cBName,"w+");
+ bBase = true;
+ }
+ fclose (fp);
+ }
+ // lese Datenbasis !
+ if (bBase)
+ {
+ ReadDataBase();
+ }
+ return true;
+}
+
+LibDump::~LibDump()
+{
+ delete [] cBName;
+ delete [] cAPrefix;
+// delete [] cLibName;
+ delete [] cFilterName;
+ delete [] cModName;
+}
+
+void LibDump::SetCExport( char* pName )
+{
+ delete [] cAPrefix;
+ cAPrefix = new char[ strlen( pName ) + 1 ];
+ strcpy( cAPrefix, pName );bAll = true;
+}
+
+//******************************************************************
+//* Error() - Gibt Fehlermeldumg aus
+//******************************************************************
+
+bool LibDump::DumpError( unsigned long n )
+{
+ char *p;
+
+ switch (n)
+ {
+ case 1: p = "Input error in library file"; break;
+ case 2: p = "Position error in library file (no THEADR set)"; break;
+ case 3: p = "Overflow of symbol table"; break;
+#ifdef WNT
+ case 10: p = "EXP file not found"; break;
+ case 11: p = "No valid EXP file"; break;
+#else
+ case 10: p = "Library file not found"; break;
+ case 11: p = "No valid library file"; break;
+#endif
+ case 98: p = "Out of memory"; break;
+ case 99: p = "LDUMP [-LD3] [-A] [-E nn] [-F name] Filename[.LIB]\n"
+ "-LD3 : Supports feature set of ldump3 (default: ldump/ldump2)\n"
+ "-A : all symbols (default: only C++)\n"
+ "-E nn : gerenration of export table beginning with number nn\n"
+ "-F name: Filter file\n"; break;
+ case 500: p = "Unable to open filter file\n"; break;
+ case 510: p = "Overflow of filter table\n"; break;
+ case 600: p = "Unable to open base database file\n"; break;
+ case 610: p = "Overflow in base database table\n"; break;
+ default: p = "Unspecified error";
+ }
+ fprintf( stdout, "%s\n", p );
+ exit (1);
+ return false;
+}
+
+/*********************************************************************
+ Test Funktionen
+*********************************************************************/
+
+
+usage()
+{
+ LibDump::DumpError(99);
+ exit(0);
+ return 0;
+}
+
+#define STATE_NON 0x0000
+#define STATE_BEGIN 0x0001
+#define STATE_FILTER 0x0002
+#define STATE_CEXPORT 0x0003
+
+#ifdef WNT
+int __cdecl
+#endif
+main( int argc, char **argv )
+{
+ char *pLibName = NULL, *pFilterName, *pCExport= NULL;
+ int nBegin=1;
+
+ unsigned short nState = STATE_NON;
+
+ if ( argc == 1 ) {
+ usage();
+ return 0;
+ }
+
+ for ( int i = 1; i < argc; i++ ) {
+ if (( !strcmp( argv[ i ], "-H" )) ||
+ ( !strcmp( argv[ i ], "-h" )) ||
+ ( !strcmp( argv[ i ], "-?" )))
+ {
+ usage();
+ return 0;
+ }
+ else if (( !strcmp( argv[ i ], "-LD3" )) ||
+ ( !strcmp( argv[ i ], "-Ld3" )) ||
+ ( !strcmp( argv[ i ], "-ld3" )) ||
+ ( !strcmp( argv[ i ], "-lD3" )))
+ {
+ if ( nState != STATE_NON ) {
+ usage();
+ return 0;
+ }
+ bLdump3 = 1;
+ }
+ else if (( !strcmp( argv[ i ], "-E" )) || ( !strcmp( argv[ i ], "-e" ))) {
+ if ( nState != STATE_NON ) {
+ usage();
+ return 0;
+ }
+ nState = STATE_BEGIN;
+ }
+ else if (( !strcmp( argv[ i ], "-F" )) || ( !strcmp( argv[ i ], "-f" ))) {
+ if ( nState != STATE_NON ) {
+ usage();
+ return 0;
+ }
+ nState = STATE_FILTER;
+ }
+ else if (( !strcmp( argv[ i ], "-A" )) || ( !strcmp( argv[ i ], "-a" ))) {
+ if ( nState != STATE_NON ) {
+ usage();
+ return 0;
+ }
+ nState = STATE_CEXPORT;
+ pCExport = new char[ 1 ];
+ pCExport[ 0 ] = 0;
+ }
+ else {
+ switch ( nState ) {
+ case STATE_BEGIN:
+ nBegin = atoi( argv[ i ] );
+ nState = STATE_NON;
+ break;
+ case STATE_FILTER:
+ pFilterName = new char[ strlen( argv[ i ] ) + 1 ];
+ strcpy( pFilterName, argv[ i ] );
+ bFilter = 1;
+ nState = STATE_NON;
+ break;
+ case STATE_CEXPORT:
+ delete [] pCExport;
+ pCExport = new char[ strlen( argv[ i ] ) + 1 ];
+ strcpy( pCExport, argv[ i ] );
+ nState = STATE_NON;
+ break;
+ default:
+ pLibName = new char[ strlen( argv[ i ] ) + 1 ];
+ strcpy( pLibName, argv[ i ] );
+ break;
+ }
+ }
+ }
+
+ if ( !pLibName ) {
+ usage();
+ return 0;
+ }
+
+ LibDump *pDump = new LibDump( pLibName );
+ pDump->SetBeginExport(nBegin);
+ if ( bFilter != 0 )
+ pDump->SetFilter( pFilterName );
+ if ( pCExport )
+ pDump->SetCExport( pCExport );
+ else {
+ char *pEmpty = "";
+ pDump->SetCExport( pEmpty );
+ }
+ pDump->Dump();
+ pDump->PrintDefFile();
+ pDump->PrintDataBase();
+ delete pDump;
+ return 0;
+}
+
diff --git a/soltools/ldump/ldump.hxx b/soltools/ldump/ldump.hxx
new file mode 100644
index 000000000000..a818e6622843
--- /dev/null
+++ b/soltools/ldump/ldump.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * $RCSfile: ldump.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nf $ $Date: 2001-04-11 09:52:26 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "hashtbl.hxx"
+
+#define MAXFILT 200
+
+struct LibExport
+{
+ char *cExportName; // zu exportierende Fkt.
+ unsigned long nOrdinal; // Nummer der zu export. Fkt.
+ bool bByName; // NONAME anhaengen
+ bool bExport; // exportieren oder nicht ?
+};
+
+class ExportSet;
+class LibDump
+{
+ ExportSet *pBaseTab; // Zugriff auf gemangelte Namen
+ ExportSet *pIndexTab; // Zugriff auf die Ordinals
+ char *cBName; // Name der Datenbasis
+ char *cAPrefix; // Prefix fuer C-Fkts.
+ char *cLibName; // Name der zu untersuchenden Lib
+ char *cFilterName; // Name der Filterdatei
+ char *cModName; // Modulname
+ unsigned short nBegin; // Nummer des ersten Exports
+ unsigned long nBaseLines; // Line in Datenbasis
+ unsigned long nFilterLines; // Line in FilterTabelle
+ char **pFilterLines; // Filtertabelle
+ unsigned long nDefStart;
+ bool bBase; // Existenz der DatenBasis;
+ bool bAll; // Alle Fkts exportieren
+ bool bDef; // DefFile schreiben ( bei -E )
+
+ bool CheckDataBase();
+ bool CheckLibrary(char * cName);
+ bool ReadDataBase();
+ bool ReadFilter(char *);
+ bool PrintSym(char *, bool bName = true );
+public:
+ LibDump( char *cFileName );
+ ~LibDump();
+ bool Dump();
+ bool SetFilter(char *cFilterName);
+ void SetBeginExport(unsigned short nVal){nBegin = nVal;}
+ void SetCExport( char* pName );
+ bool Filter(char *pName);
+ bool PrintDefFile();
+ bool PrintDataBase();
+ static bool DumpError(unsigned long nError);
+};
+
diff --git a/soltools/ldump/makefile.mk b/soltools/ldump/makefile.mk
new file mode 100644
index 000000000000..872e21da2094
--- /dev/null
+++ b/soltools/ldump/makefile.mk
@@ -0,0 +1,88 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: nf $ $Date: 2001-04-11 09:52:26 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=ldump
+TARGET=ldump
+TARGETTYPE=CUI
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+# ldump only supports windows environment
+.IF "$(GUI)"=="WNT"
+
+#ldump4 reimplements feature set of ldump2 and ldump3
+APP1TARGET= ldump4
+APP1STACK= 16000
+APP1OBJS= $(OBJ)$/ldump.obj $(OBJ)$/hashtbl.obj
+
+.ENDIF #"$(GUI)"=="WNT"
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/soltools/prj/d.lst b/soltools/prj/d.lst
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/soltools/prj/d.lst