Adding new files, not part of the build.

This commit is contained in:
nhotta%netscape.com 1999-09-09 19:23:41 +00:00
Родитель 6d7af31eb2
Коммит d6bb1e43f2
8 изменённых файлов: 483 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,30 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
MODULE=intlcmpt
DEPTH=..\..\..
XPIDLSRCS = \
.\nsII18nCompatibility.idl \
$(NULL)
include <$(DEPTH)/config/rules.mak>

Просмотреть файл

@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsISupports.idl"
%{C++
// Define Progid and CID
// {93941450-664A-11d3-9151-006008A6EDF6}
#define NS_I18NCOMPATIBILITY_CID \
{ 0x93941450, 0x664a, 0x11d3, { 0x91, 0x51, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
#define NS_I18NCOMPATIBILITY_PROGID "component://netscape/intl/compatibility"
%}
[scriptable, uuid(93941450-664A-11d3-9151-006008A6EDF6)]
interface nsII18nCompatibility : nsISupports {
// convert 4.x charset id (csid) to charset name
wstring CSIDtoCharsetName(in unsigned short csid);
};

Просмотреть файл

@ -0,0 +1,24 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..
DIRS= \
idl \
src
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -0,0 +1,59 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
LCFLAGS= $(LCFLAGS) -D__STDC__
DEFINES= -DWIN32_LEAN_AND_MEAN
LIBRARY_NAME= intlcmpt
CPPSRCS= \
nsI18nCompatibility.cpp \
nsCSIDtoCharsetName.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsI18nCompatibility.obj \
.\$(OBJDIR)\nsCSIDtoCharsetName.obj \
$(NULL)
MODULE=intlcmpt
REQUIRES=xpcom
INCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor
MAKE_OBJ_TYPE=DLL
DLLNAME=intlcmpt
DLL=.\$(OBJDIR)\$(DLLNAME).dll
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR)
include <$(DEPTH)\config\rules.mak>
libs:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber::
rm -f $(DIST)\bin\components\$(DLLNAME).dll
rm -f $(DIST)\bin\$(DLLNAME).lib

Просмотреть файл

@ -0,0 +1,27 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsCRT.h"
char * I18N_CSIDtoCharsetName(PRUint16 csid)
{
return "ISO-8859-1";
}

Просмотреть файл

@ -0,0 +1,183 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "pratom.h"
#include "nsISupports.h"
#include "nsIComponentManager.h"
#include "nsCOMPtr.h"
#include "nsIFactory.h"
#include "nsIServiceManager.h"
#include "nsII18nCompatibility.h"
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kI18nCompatibilityCID, NS_I18NCOMPATIBILITY_CID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
///////////////////////////////////////////////////////////////////////////////////////////
extern char * I18N_CSIDtoCharsetName(PRUint16 csid);
class nsI18nCompatibility : public nsII18nCompatibility {
public:
NS_DECL_ISUPPORTS
/* wstring CSIDtoCharsetName (in unsigned short csid); */
NS_IMETHOD CSIDtoCharsetName(PRUint16 csid, PRUnichar **_retval);
nsI18nCompatibility() {NS_INIT_REFCNT();}
virtual ~nsI18nCompatibility() {}
};
NS_IMPL_ISUPPORTS(nsI18nCompatibility, nsII18nCompatibility::GetIID());
NS_IMETHODIMP nsI18nCompatibility::CSIDtoCharsetName(PRUint16 csid, PRUnichar **_retval)
{
nsString charsetname(I18N_CSIDtoCharsetName(csid));
*_retval = charsetname.ToNewUnicode();
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////////////////
PRInt32 g_InstanceCount = 0;
PRInt32 g_LockCount = 0;
class nsI18nCompatibilityFactory : public nsIFactory {
NS_DECL_ISUPPORTS
nsI18nCompatibilityFactory() {
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
};
virtual ~nsI18nCompatibilityFactory() {
PR_AtomicDecrement(&g_InstanceCount);
};
NS_IMETHOD CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock) {
if (aLock) {
PR_AtomicIncrement(&g_LockCount);
} else {
PR_AtomicDecrement(&g_LockCount);
}
return NS_OK;
};
};
NS_IMPL_ISUPPORTS(nsI18nCompatibilityFactory, kIFactoryIID);
nsresult nsI18nCompatibilityFactory::CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult)
{
if(NULL == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
nsI18nCompatibility *imp = new nsI18nCompatibility();
if(NULL == imp)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = imp->QueryInterface(aIID, aResult);
if(NS_FAILED(rv)) {
delete imp;
}
return rv;
}
///////////////////////////////////////////////////////////////////////////////////////////
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (aFactory == NULL) {
return NS_ERROR_NULL_POINTER;
}
if (aClass.Equals(kI18nCompatibilityCID)) {
*aFactory = NULL;
nsI18nCompatibilityFactory *factory = new nsI18nCompatibilityFactory();
if(nsnull == factory)
return NS_ERROR_OUT_OF_MEMORY;
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
if (NS_FAILED(res)) {
*aFactory = NULL;
delete factory;
}
return res;
}
return NS_NOINTERFACE;
}
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) {
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
}
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *path)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
rv = compMgr->RegisterComponent(kI18nCompatibilityCID,
"I18n compatibility",
NS_I18NCOMPATIBILITY_PROGID,
path,
PR_TRUE, PR_TRUE);
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterComponent(kI18nCompatibilityCID, path);
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}

Просмотреть файл

@ -0,0 +1,78 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <iostream.h>
#include "nsIComponentManager.h"
#include "nsISupports.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsII18nCompatibility.h"
static NS_DEFINE_CID(kI18nCompatibilityCID, NS_I18NCOMPATIBILITY_CID);
#ifdef XP_PC
#define DLL_NAME "intlcmpt.dll"
#else
#ifdef XP_MAC
#define DLL_NAME "INTLCMPT_DLL"
#else
#endif
#define DLL_NAME "intlcmpt"MOZ_DLL_SUFFIX
#endif
extern "C" void NS_SetupRegistry()
{
nsComponentManager::RegisterComponent(kI18nCompatibilityCID, NULL, NULL, DLL_NAME, PR_FALSE, PR_FALSE);
}
#undef DLL_NAME
int main(int argc, char** argv) {
nsresult rv;
NS_SetupRegistry();
nsCOMPtr <nsII18nCompatibility> I18nCompatibility;
rv = nsComponentManager::CreateInstance(kI18nCompatibilityCID, NULL,
nsII18nCompatibility::GetIID(), getter_AddRefs(I18nCompatibility));
if (NS_SUCCEEDED(rv)) {
PRUint16 csid = 0;
PRUnichar *charsetUni = NULL;
rv = I18nCompatibility->CSIDtoCharsetName(csid, &charsetUni);
if (NS_SUCCEEDED(rv) && NULL != charsetUni) {
nsString tempStr(charsetUni);
char *tempCstr = tempStr.ToNewCString();
nsAllocator::Free(charsetUni);
if (NULL != tempCstr) {
cout << csid << " " << tempCstr << "\n";
delete [] tempCstr;
}
}
}
else {
cout << "error: CreateInstance\n";
}
cout << "done\n";
return 0;
}

Просмотреть файл

@ -0,0 +1,44 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ..\..\..
MAKE_OBJ_TYPE = EXE
PROG1 = .\$(OBJDIR)\TestI18nCompatibility.exe
PROGRAMS = $(PROG1)
LCFLAGS=-DUSE_NSREG
REQUIRES=libreg
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\lwbrk -I$(PUBLIC)\raptor
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR)
include <$(DEPTH)\config\rules.mak>
install:: $(PROGRAMS)
-for %p in ($(PROGRAMS)) do $(MAKE_INSTALL) %p $(DIST)\bin
clobber::
-for %p in ($(PROGRAMS)) do $(RM) %p $(DIST)\bin\%p
$(PROG1): $(OBJDIR) TestI18nCompatibility.cpp