Index: trunk/src/emx/src/innidmdll/innidmdll.c
===================================================================
--- trunk/src/emx/src/innidmdll/innidmdll.c	(revision 562)
+++ trunk/src/emx/src/innidmdll/innidmdll.c	(revision 562)
@@ -0,0 +1,125 @@
+/* $Id$
+ *
+ * Innotek IDM DLL - demangler DLL for the linker.
+ *
+ * Copyright (c) 2003 InnoTek Systemberatung GmbH
+ * Author: knut st. osmundsen <bird-srcspam@anduin.net>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with This program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <string.h>
+#include <stdlib.h>
+#include <demangle.h>
+#include <stdio.h>
+
+extern char *cplus_demangle ();
+#include "demangle.h"
+
+
+/*******************************************************************************
+*   Defined Constants And Macros                                               *
+*******************************************************************************/
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+
+
+/**
+ * Initiate the demangler.
+ * @returns TRUE (success)
+ * @param   psInitParms     Initiations parameter string.
+ */
+unsigned long _System InitDemangleID32(const char * psInitParms)
+{
+    return TRUE;
+}
+
+
+/**
+ * Demangle name pointed to by pszMangledName.
+ *
+ * @returns TRUE/FALSE - Success indicator.
+ * @param   psMangledName   Symbol to demangle. Pascal string.
+ * @param   pszPrototype    Return buffer. (zero string)
+ * @param   cchPrototype    Size of the pszPrototype buffer.
+ */
+unsigned long _System DemangleID32(const char * psMangledName, char * pszPrototype, unsigned long cchPrototype)
+{
+    char *  pszWeak;
+    char *  pszProto;
+    char *  pszMang;
+    char *  pszMangFree;
+
+    /*
+     * Make zero terminated string output of the pascal string.
+     */
+    pszMang = malloc((unsigned char)*psMangledName + 1);
+    if (!pszMang)
+        return FALSE;
+    memcpy(pszMang, psMangledName + 1, (unsigned char)*psMangledName);
+    pszMang[(unsigned char)*psMangledName] = '\0';
+
+    /*
+     * Skip any leading underscore.
+     */
+    pszMangFree = pszMang;
+    if (*pszMang == '_')
+        pszMang++;
+
+    /*
+     * Check if weak, and if so we must
+     */
+    pszWeak = strstr(pszMang, "$w$");
+    if (pszWeak)
+        *pszWeak = '\0';
+
+    /*
+     * Call the demangler.
+     */
+    pszProto = cplus_demangle(pszMang, DMGL_PARAMS | DMGL_ANSI);
+    if (pszProto)
+    {
+        int cchProto = strlen(pszProto);
+        if (cchProto >= cchPrototype)
+        {
+            memcpy(pszPrototype, pszProto, cchPrototype - 1);
+            pszPrototype[cchPrototype - 1] = '\0';
+        }
+        else
+        {
+            memcpy(pszPrototype, pszProto, cchProto + 1);
+            if (pszWeak && cchProto + 6 < cchPrototype)
+                strcpy(pszPrototype + cchProto, " weak");
+        }
+        free(pszProto);
+    }
+
+    /*
+     * Free pszMang
+     */
+    free(pszMangFree);
+
+    return pszProto != NULL;
+}
+
+
Index: trunk/src/emx/src/innidmdll/innidmdll.def
===================================================================
--- trunk/src/emx/src/innidmdll/innidmdll.def	(revision 562)
+++ trunk/src/emx/src/innidmdll/innidmdll.def	(revision 562)
@@ -0,0 +1,38 @@
+; $Id$
+;
+; Innotek IDM DLL - demangler DLL for the linker.
+;
+; Copyright (c) 2003 InnoTek Systemberatung GmbH
+; Author: knut st. osmundsen <bird-srcspam@anduin.net>
+;
+;
+; This program is free software; you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation; either version 2 of the License, or
+; (at your option) any later version.
+;
+; This program 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 General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with This program; if not, write to the Free Software
+; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+;
+;
+
+LIBRARY INNIDM INITINSTANCE TERMINSTANCE
+DATA MULTIPLE NONSHARED
+
+EXPORTS
+;unsigned long _System InitDemangleID32(char * psInitParms);
+    InitDemangleID32    @1 RESIDENTNAME
+;unsigned long _System DemangleID32(char * psMangledName, char * pszPrototype, unsigned long BufferLen);
+    DemangleID32        @2 RESIDENTNAME
+
+;unsigned short pascal far INITDEMANGLEID(char far * psInitParms);
+    INITDEMANGLEID      @3 RESIDENTNAME
+;unsigned short pascal far DEMANGLEID(char far * psMangledName, char far * pszPrototype, unsigned long BufferLen);
+    DEMANGLEID          @4 RESIDENTNAME
+
Index: trunk/src/emx/src/innidmdll/innidmdll.smak
===================================================================
--- trunk/src/emx/src/innidmdll/innidmdll.smak	(revision 562)
+++ trunk/src/emx/src/innidmdll/innidmdll.smak	(revision 562)
@@ -0,0 +1,14 @@
+.MODULE	:= innidmdll
+.MDESC	:= Demangler DLL for the IBM Linkers.
+.INSDIR	:= lib/
+.MDEP	:=
+
+.TARGET	:= innidm.dll
+.TKIND	:= $(TOOLFMT)
+.TSRC	:= src/innidmdll/innidmdll.c src/innidmdll/innidmdllthunks.asm
+.TCF	:= $(CFLAGS.DEF.VERSION)
+.TLDF	:= -liberty
+.TDEP	:=
+.TDEF	:= src/innidmdll/innidmdll.def
+include mkdll.smak
+
Index: trunk/src/emx/src/innidmdll/innidmdllthunks.asm
===================================================================
--- trunk/src/emx/src/innidmdll/innidmdllthunks.asm	(revision 561)
+++ trunk/src/emx/src/innidmdll/innidmdllthunks.asm	(revision 562)
@@ -29,9 +29,9 @@
 extrn DemangleID32:near
 
-CODE16 segment use16 public 'CODE' dword
+CODE16 segment dword use16 public 'CODE'
 CODE16 ends
-CODE32 segment use32 public 'CODE' para
+CODE32 segment para use32 public 'CODE'
 CODE32 ends
-DATA32 segment use32 public 'DATA' para
+DATA32 segment para use32 public 'DATA'
 DATA32 ends
 
@@ -42,5 +42,5 @@
 ;;
 ; Init stuff.
-; @cproto   unsigned short pascal far INITDEMANGLEID(char far * pszInitParms);
+; @cproto   unsigned short pascal far INITDEMANGLEID(char far * psInitParms);
 INITDEMANGLEID proc far
     push    ebp
@@ -74,5 +74,5 @@
     ; Thunk parameters and call the 32bit version.
     ;
-    mov     eax, [ebp + 08h]            ; pszInitParms
+    mov     eax, [ebp + 08h]            ; psInitParms
     mov     eax, edx
     shr     eax, 3
@@ -140,5 +140,5 @@
     push    eax
 
-    mov     eax, [ebp + 10h]            ; pszMangledName
+    mov     eax, [ebp + 10h]            ; psMangledName
     mov     eax, edx
     shr     eax, 3
