Not part of the build

This commit is contained in:
av%netscape.com 2000-05-05 05:33:18 +00:00
parent 281ec7bb69
commit 2284b35757
34 changed files with 6116 additions and 0 deletions

View File

@ -0,0 +1,55 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
/**********************************************************************
*
* dbg.cpp
*
* This is a helper utility which allows diagnostic info in the output
* window in debug project environment in more convenient way than
* printf or OutputDebugString
*
***********************************************************************/
#include "xp.h"
extern char szAppName[];
#ifdef _DEBUG
void __cdecl dbgOut(LPSTR format, ...)
{
#ifdef XP_PC
static char buf[1024];
strcpy(buf, szAppName);
strcat(buf, ": ");
va_list va;
va_start(va, format);
wvsprintf(&buf[lstrlen(buf)], format, va);
va_end(va);
strcat(buf, "\n");
OutputDebugString(buf);
#endif
}
#endif

View File

@ -0,0 +1,169 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
/**********************************************************************
*
* instbase.cpp
*
* Implementation of the platform independent part of the plugin instance
* Eventual implementation is expected to be derived from this class
*
***********************************************************************/
#include "xp.h"
#include "instbase.h"
#include "listener.h"
#include "dbg.h"
extern PRUint32 gPluginObjectCount;
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
CPluginInstance::CPluginInstance() :
fPeer(nsnull),
fWindow(nsnull),
fMode(nsPluginMode_Embedded)
{
NS_INIT_REFCNT();
gPluginObjectCount++;
dbgOut2("CPluginInstance::CPluginInstance(), gPluginObjectCount = %lu", gPluginObjectCount);
}
CPluginInstance::~CPluginInstance()
{
gPluginObjectCount--;
dbgOut2("CPluginInstance::~CPluginInstance(), gPluginObjectCount = %lu", gPluginObjectCount);
}
NS_IMPL_QUERY_INTERFACE(CPluginInstance, kIPluginInstanceIID);
NS_IMPL_ADDREF(CPluginInstance);
NS_IMPL_RELEASE(CPluginInstance);
NS_METHOD CPluginInstance::Initialize(nsIPluginInstancePeer* peer)
{
dbgOut1("CPluginInstance::Initialize");
if(peer == nsnull)
return NS_ERROR_NULL_POINTER;
fPeer = peer;
peer->AddRef();
nsresult rv;
rv = peer->GetMode(&fMode);
if(NS_FAILED(rv))
return rv;
nsIPluginTagInfo* taginfo;
const char* const* names = nsnull;
const char* const* values = nsnull;
PRUint16 count = 0;
rv = peer->QueryInterface(NS_GET_IID(nsIPluginTagInfo), (void **)&taginfo);
if(!NS_FAILED(rv))
{
taginfo->GetAttributes(count, names, values);
NS_IF_RELEASE(taginfo);
}
PlatformNew();
return NS_OK;
}
NS_METHOD CPluginInstance::GetPeer(nsIPluginInstancePeer* *result)
{
dbgOut1("CPluginInstance::GetPeer");
fPeer->AddRef();
*result = fPeer;
return NS_OK;
}
NS_METHOD CPluginInstance::Start()
{
dbgOut1("CPluginInstance::Start");
return NS_OK;
}
NS_METHOD CPluginInstance::Stop()
{
dbgOut1("CPluginInstance::Stop");
return NS_OK;
}
NS_METHOD CPluginInstance::Destroy()
{
dbgOut1("CPluginInstance::Destroy");
PlatformDestroy();
return NS_OK;
}
NS_METHOD CPluginInstance::SetWindow(nsPluginWindow* window)
{
dbgOut1("CPluginInstance::SetWindow");
nsresult rv;
rv = PlatformSetWindow(window);
fWindow = window;
return rv;
}
NS_METHOD CPluginInstance::NewStream(nsIPluginStreamListener** result)
{
dbgOut1("CPluginInstance::NewStream");
if(result == nsnull)
return NS_ERROR_NULL_POINTER;
CPluginStreamListener * listener = new CPluginStreamListener(this, "http://warp");
if(listener == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
*result = listener;
NS_ADDREF(listener);
return NS_OK;
}
NS_METHOD CPluginInstance::Print(nsPluginPrint* printInfo)
{
dbgOut1("CPluginInstance::Print");
return NS_OK;
}
NS_METHOD CPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled)
{
dbgOut1("CPluginInstance::HandleEvent");
*handled = (PRBool)PlatformHandleEvent(event);
return NS_OK;
}
NS_METHOD CPluginInstance::GetValue(nsPluginInstanceVariable variable, void *value)
{
dbgOut1("CPluginInstance::GetValue");
return NS_ERROR_FAILURE;
}

View File

@ -0,0 +1,117 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
/**********************************************************************
*
* listener.cpp
*
* Implementation of the plugin stream listener class
*
***********************************************************************/
#include "xp.h"
#include "listener.h"
#include "dbg.h"
extern PRUint32 gPluginObjectCount;
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
CPluginStreamListener::CPluginStreamListener(CPluginInstance* inst, const char* msgName) :
fMessageName(msgName)
{
gPluginObjectCount++;
NS_INIT_REFCNT();
dbgOut3("CPluginStreamListener::CPluginStreamListener, message '%s', gPluginObjectCount = %lu",
fMessageName, gPluginObjectCount);
}
CPluginStreamListener::~CPluginStreamListener()
{
gPluginObjectCount--;
dbgOut2("CPluginStreamListener::~CPluginStreamListener, gPluginObjectCount = %lu", gPluginObjectCount);
}
NS_IMPL_QUERY_INTERFACE(CPluginStreamListener, kIPluginStreamListenerIID)
NS_IMPL_ADDREF(CPluginStreamListener)
NS_IMPL_RELEASE(CPluginStreamListener)
NS_METHOD CPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* streamInfo)
{
dbgOut1("CPluginStreamListener::OnStartBinding");
return NS_OK;
}
NS_METHOD CPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* streamInfo,
nsIInputStream* inputStream,
PRUint32 length)
{
dbgOut1("CPluginStreamListener::OnDataAvailable");
char* buffer = new char[length];
if(buffer == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32 amountRead = 0;
nsresult rv = inputStream->Read(buffer, length, &amountRead);
if(rv == NS_OK)
{
dbgOut2("\t\tReceived %lu bytes", length);
}
delete buffer;
return rv;
}
NS_METHOD CPluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* streamInfo, const char* fileName)
{
dbgOut1("CPluginStreamListener::OnFileAvailable");
return NS_OK;
}
NS_METHOD CPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* streamInfo, nsresult status)
{
dbgOut1("CPluginStreamListener::OnStopBinding");
return NS_OK;
}
NS_METHOD CPluginStreamListener::OnNotify(const char* url, nsresult status)
{
dbgOut1("CPluginStreamListener::OnNotify");
return NS_OK;
}
NS_METHOD CPluginStreamListener::GetStreamType(nsPluginStreamType *result)
{
dbgOut1("CPluginStreamListener::GetStreamType");
*result = nsPluginStreamType_Normal;
return NS_OK;
}

View File

@ -0,0 +1,168 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
/**********************************************************************
*
* npentry.cpp
*
* Netscape entry points for XPCom registration
*
***********************************************************************/
#include "xp.h"
#include "plugin.h"
#include "nsString.h"
#include "dbg.h"
char szAppName[] = "*** Basic60";
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_CID(kPluginCID, NS_PLUGIN_CID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kBasicPluginCID, NS_BASICPLUGIN_CID);
extern PRUint32 gPluginObjectCount;
extern PRBool gPluginLocked;
extern "C" NS_EXPORT
nsresult NSGetFactory(nsISupports* serviceMgr,
const nsCID &aCID,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
dbgOut1("NSGetFactory");
if(aFactory == nsnull)
return NS_ERROR_NULL_POINTER;
*aFactory = nsnull;
CPlugin* inst;
if (aCID.Equals(kBasicPluginCID))
inst = new CPlugin();
else if (aCID.Equals(kPluginCID))
inst = new CPlugin();
else
return NS_NOINTERFACE;
if(inst == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = inst->QueryInterface(kIFactoryIID, (void **)aFactory);
if(NS_FAILED(rv))
delete inst;
return rv;
return 0;
}
extern "C" NS_EXPORT
PRBool NSCanUnload(nsISupports* serviceMgr)
{
dbgOut1("NSCanUnload");
return (gPluginObjectCount == 1 && !gPluginLocked);
}
extern "C" NS_EXPORT
nsresult NSRegisterSelf(nsISupports *serviceMgr, const char *path)
{
dbgOut1("NSRegisterSelf");
nsresult rv = NS_OK;
char buf[255];
nsString progID(NS_INLINE_PLUGIN_PROGID_PREFIX);
// We will use the service manager to obtain the component
// manager, which will enable us to register a component
// with a ProgID (text string) instead of just the CID.
nsIServiceManager *sm;
// We can get the IID of an interface with the static GetIID() method as well
rv = serviceMgr->QueryInterface(NS_GET_IID(nsIServiceManager), (void **)&sm);
if(NS_FAILED(rv))
return rv;
nsIComponentManager *cm;
rv = sm->GetService(kComponentManagerCID, NS_GET_IID(nsIComponentManager), (nsISupports **)&cm);
if(NS_FAILED(rv))
{
NS_RELEASE(sm);
return rv;
}
progID += PLUGIN_MIME_TYPE;
progID.ToCString(buf, 255);
rv = cm->RegisterComponent(kBasicPluginCID, PLUGIN_NAME, buf, path, PR_TRUE, PR_TRUE);
sm->ReleaseService(kComponentManagerCID, cm);
NS_RELEASE(sm);
return rv;
}
extern "C" NS_EXPORT
nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path)
{
dbgOut1("NSUnregisterSelf");
nsresult rv = NS_OK;
nsIServiceManager *sm;
rv = serviceMgr->QueryInterface(NS_GET_IID(nsIServiceManager), (void **)&sm);
if(NS_FAILED(rv))
return rv;
nsIComponentManager *cm;
rv = sm->GetService(kComponentManagerCID, NS_GET_IID(nsIComponentManager), (nsISupports **)&cm);
if(NS_FAILED(rv))
{
NS_RELEASE(sm);
return rv;
}
rv = cm->UnregisterComponent(kBasicPluginCID, path);
sm->ReleaseService(kComponentManagerCID, cm);
NS_RELEASE(sm);
return rv;
}

View File

@ -0,0 +1,174 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
/**********************************************************************
*
* plugin.cpp
*
* Implementation of the plugin class
*
***********************************************************************/
#include "xp.h"
#include "plugin.h"
#include "instbase.h"
#include "dbg.h"
PRUint32 gPluginObjectCount = 0;
PRBool gPluginLocked = PR_FALSE;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID);
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID);
static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
CPlugin::CPlugin() :
mPluginManager(NULL),
mServiceManager(NULL)
{
NS_INIT_REFCNT();
if(nsComponentManager::CreateInstance(kCPluginManagerCID, NULL, kIPluginManagerIID, (void**)&mPluginManager) != NS_OK)
return;
gPluginObjectCount++;
dbgOut2("CPlugin::CPlugin(), gPluginObjectCount = %lu", gPluginObjectCount);
}
CPlugin::~CPlugin()
{
if(mPluginManager)
mPluginManager->Release();
if(mServiceManager)
mServiceManager->Release();
gPluginObjectCount--;
dbgOut2("CPlugin::~CPlugin(), gPluginObjectCount = %lu", gPluginObjectCount);
}
NS_METHOD CPlugin::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
dbgOut1("CPlugin::QueryInterface");
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kISupportsIID))
*aInstancePtr = NS_STATIC_CAST(nsISupports*,this);
else if (aIID.Equals(kIFactoryIID))
*aInstancePtr = NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(nsIFactory*,this));
else if (aIID.Equals(kIPluginIID))
*aInstancePtr = NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(nsIPlugin*,this));
else
{
*aInstancePtr = nsnull;
return NS_ERROR_NO_INTERFACE;
}
NS_ADDREF(NS_REINTERPRET_CAST(nsISupports*,*aInstancePtr));
return NS_OK;
}
NS_IMPL_ADDREF(CPlugin);
NS_IMPL_RELEASE(CPlugin);
NS_METHOD CPlugin::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
dbgOut1("CPlugin::CreateInstance");
CPluginInstance * inst = Platform_CreatePluginInstance(aOuter, aIID, nsnull);
if (inst == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
inst->AddRef();
*aResult = (void *)inst;
return NS_OK;
}
NS_METHOD CPlugin::CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID, const char* aPluginMIMEType, void **aResult)
{
dbgOut1("CreatePluginInstance");
CPluginInstance * inst = Platform_CreatePluginInstance(aOuter, aIID, aPluginMIMEType);
if (inst == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
inst->AddRef();
*aResult = (void *)inst;
return NS_OK;
}
NS_METHOD CPlugin::LockFactory(PRBool aLock)
{
dbgOut1("CPlugin::LockFactory");
gPluginLocked = aLock;
return NS_OK;
}
NS_METHOD CPlugin::Initialize()
{
dbgOut1("CPlugin::Initialize");
return NS_OK;
}
NS_METHOD CPlugin::Shutdown(void)
{
dbgOut1("CPlugin::Shutdown");
return NS_OK;
}
NS_METHOD CPlugin::GetMIMEDescription(const char **result)
{
dbgOut1("CPlugin::GetMIMEDescription");
*result = PLUGIN_MIMEDESCRIPTION;
return NS_OK;
}
NS_METHOD CPlugin::GetValue(nsPluginVariable variable, void *value)
{
dbgOut1("");
nsresult rv = NS_OK;
if (variable == nsPluginVariable_NameString)
*((char **)value) = PLUGIN_NAME;
else if (variable == nsPluginVariable_DescriptionString)
*((char **)value) = PLUGIN_DESCRIPTION;
else
rv = NS_ERROR_FAILURE;
return rv;
}

View File

@ -0,0 +1,30 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef __BASICCID_H__
#define __BASICCID_H__
// {D8A32288-207E-11d4-9CC2-0060B0FBD8AC}
#define NS_BASICPLUGIN_CID { 0xd8a32288, 0x207e, 0x11d4, { 0x9c, 0xc2, 0x0, 0x60, 0xb0, 0xfb, 0xd8, 0xac } }
#endif

View File

@ -0,0 +1,51 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef __DBG_H_
#define __DBG_H_
#ifdef _DEBUG
void __cdecl dbgOut(LPSTR format, ...);
#define dbgOut1(x) dbgOut(x)
#define dbgOut2(x,y) dbgOut(x, y)
#define dbgOut3(x,y,z) dbgOut(x, y, z)
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
#else
#define dbgOut1(x) ((void)0)
#define dbgOut2(x,y) ((void)0)
#define dbgOut3(x,y,z) ((void)0)
#define dbgOut4(x,y,z,t) ((void)0)
#define dbgOut5(x,y,z,t,u) ((void)0)
#define dbgOut6(x,y,z,t,u,v) ((void)0)
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
#endif
#endif

View File

@ -0,0 +1,94 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef __INSTANCEBASE_H__
#define __INSTANCEBASE_H__
#include "nsplugin.h"
/*******************************************************************
*
* CPluginInstance class is the class for all our plugins our plugin
* instances. This is abstract class, platform specific method are
* to be implemented in derived class for a specific platform.
*
********************************************************************/
class CPluginInstance : public nsIPluginInstance
{
public:
NS_DECL_ISUPPORTS
// (Corresponds to NPP_HandleEvent.)
// Note that for Unix and Mac the nsPluginEvent structure is different
// from the old NPEvent structure -- it's no longer the native event
// record, but is instead a struct. This was done for future extensibility,
// and so that the Mac could receive the window argument too. For Windows
// and OS2, it's always been a struct, so there's no change for them.
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
NS_IMETHOD GetPeer(nsIPluginInstancePeer* *result);
// This method is called when the plugin instance is to be started.
// This happens in two circumstances: (1) after the plugin instance
// is first initialized, and (2) after a plugin instance is returned to
// (e.g. by going back in the window history) after previously being stopped
// by the Stop method.
NS_IMETHOD Start();
// This method is called when the plugin instance is to be stopped (e.g. by
// displaying another plugin manager window, causing the page containing
// the plugin to become removed from the display).
NS_IMETHOD Stop();
// This is called once, before the plugin instance peer is to be
// destroyed. This method is used to destroy the plugin instance.
NS_IMETHOD Destroy();
// (Corresponds to NPP_SetWindow.)
NS_IMETHOD SetWindow(nsPluginWindow* window);
NS_IMETHOD NewStream(nsIPluginStreamListener** result);
NS_IMETHOD Print(nsPluginPrint* platformPrint);
NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
CPluginInstance();
virtual ~CPluginInstance();
// Platrorm specific methods, which need to be implemented in the derived class
virtual nsresult PlatformNew() = 0;
virtual nsresult PlatformDestroy() = 0;
virtual nsresult PlatformSetWindow(nsPluginWindow* window) = 0;
virtual PRInt16 PlatformHandleEvent(nsPluginEvent* event) = 0;
protected:
nsIPluginInstancePeer* fPeer;
nsPluginWindow* fWindow;
nsPluginMode fMode;
};
CPluginInstance * Platform_CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID, const char* aPluginMIMEType);
#endif

View File

@ -0,0 +1,58 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef _LISTENER_H__
#define _LISTENER_H__
#include "plugin.h"
#include "instbase.h"
class CPluginStreamListener : public nsIPluginStreamListener
{
public:
NS_DECL_ISUPPORTS
//This method is called at the beginning of a URL load
NS_IMETHOD OnStartBinding(nsIPluginStreamInfo* streamInfo);
//This method is called when data is available in the input stream.
NS_IMETHOD OnDataAvailable(nsIPluginStreamInfo* streamInfo, nsIInputStream* inputStream, PRUint32 length);
NS_IMETHOD OnFileAvailable(nsIPluginStreamInfo* streamInfo, const char* fileName);
//This method is called when a URL has finished loading.
NS_IMETHOD OnStopBinding(nsIPluginStreamInfo* streamInfo, nsresult status);
NS_IMETHOD OnNotify(const char* url, nsresult status);
NS_IMETHOD GetStreamType(nsPluginStreamType *result);
CPluginStreamListener(CPluginInstance* inst, const char* url);
virtual ~CPluginStreamListener();
protected:
const char* fMessageName;
};
#endif // _LISTENER_H__

View File

@ -0,0 +1,79 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef __PLUGIN_HPP__
#define __PLUGIN_HPP__
#include "nsplugin.h"
#include "nsIServiceManager.h"
#include "basiccid.h"
/*******************************************************************
*
* CPlugin class is the class for all our plugins. We crteate all
* our plugin instances using one instance of this class.
*
********************************************************************/
class CPlugin : public nsIPlugin
{
protected:
nsIPluginManager* mPluginManager;
nsIServiceManager* mServiceManager;
public:
NS_IMETHOD CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID, const char* aPluginMIMEType, void **aResult);
NS_IMETHOD CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
// This call initializes the plugin and will be called before any new
// instances are created. It is passed browserInterfaces on which QueryInterface
// may be used to obtain an nsIPluginManager, and other interfaces.
NS_IMETHOD Initialize(void);
// (Corresponds to NPP_Shutdown.)
// Called when the browser is done with the plugin factory, or when
// the plugin is disabled by the user.
NS_IMETHOD Shutdown(void);
// (Corresponds to NPP_GetMIMEDescription.)
NS_IMETHOD GetMIMEDescription(const char* *result);
// (Corresponds to NPP_GetValue.)
NS_IMETHOD GetValue(nsPluginVariable variable, void *value);
CPlugin();
virtual ~CPlugin(void);
NS_DECL_ISUPPORTS
nsIPluginManager* GetPluginManager(void) { return mPluginManager; }
};
#define PLUGIN_NAME "Basic Plugin"
#define PLUGIN_DESCRIPTION "Basic Plugin Example"
#define PLUGIN_MIMEDESCRIPTION "application/basicplugin-test:bpl:Basic Plugin";
#define PLUGIN_MIME_TYPE "application/basicplugin-test"
#endif // __PLUGIN_HPP__

View File

@ -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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
/*****************************************************************
*
* This shoud contain platform specific system include files
*
******************************************************************/
#ifndef __XP_H__
#define __XP_H__
#ifdef WIN32
#include <windows.h>
#endif
#endif // __XP_H__

View File

@ -0,0 +1,220 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
/**********************************************************************
*
* instwin.cpp
*
* Implementation of the plugin instance class for Windows
*
***********************************************************************/
#include <windows.h>
#include <windowsx.h>
#include "instwin.h"
#include "dbg.h"
CPluginInstance * Platform_CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID, const char* aPluginMIMEType)
{
CPluginInstanceWin *inst = new CPluginInstanceWin();
return (CPluginInstance *)inst;
}
/*------------------------------------
* CPluginInstanceWin implementation
*-----------------------------------*/
CPluginInstanceWin::CPluginInstanceWin() : CPluginInstance()
{
dbgOut1("CPluginInstanceWin::CPluginInstanceWin");
platform = nsnull;
}
CPluginInstanceWin::~CPluginInstanceWin()
{
dbgOut1("CPluginInstanceWin::~CPluginInstanceWin");
}
nsresult CPluginInstanceWin::PlatformNew()
{
dbgOut1("CPluginInstanceWin::PlatformNew");
platform = new CPlatformWin();
if(platform == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
nsresult CPluginInstanceWin::PlatformDestroy()
{
dbgOut1("CPluginInstanceWin::PlatformDestroy");
if(platform != nsnull)
{
delete platform;
platform = nsnull;
}
return NS_OK;
}
nsresult CPluginInstanceWin::PlatformSetWindow(nsPluginWindow* window)
{
dbgOut1("CPluginInstanceWin::PlatformSetWindow");
if(fWindow == nsnull) // we do not have a window yet
{
// platform should not be initialized if(fWindow == nsnull) but...
if(platform->m_bInitialized)
platform->shut();
if(window == nsnull) // not very meaningful if(fWindow == nsnull)
return NS_OK;
if(window->window != nsnull) // spurious entry
return platform->init(window);
else // First time in
return NS_OK;
}
else // (fWindow != nsnull), we already have a window
{
if((window == nsnull) || (window->window == nsnull)) // window went away
{
if(platform->m_bInitialized)
platform->shut();
return NS_OK;
}
if(!platform->m_bInitialized) // First time in
return platform->init(window);
else
{ // Netscape window has been resized or changed
if(platform->m_hWnd != (HWND)window->window) // changed
{
platform->shut();
return platform->init(window);
}
else // resized?
return NS_OK;
}
}
return NS_OK;
}
PRInt16 CPluginInstanceWin::PlatformHandleEvent(nsPluginEvent* event)
{
dbgOut1("CPluginInstanceWin::PlatformHandleEvent");
return 0;
}
/*------------------------------------
* CPlatformWin implementation
*-----------------------------------*/
static LRESULT CALLBACK PluginWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
CPlatformWin::CPlatformWin() :
m_bInitialized(PR_FALSE),
m_hWnd(nsnull),
m_OldWindowProc(nsnull)
{
dbgOut1("CPlatformWin::CPlatformWin");
}
CPlatformWin::~CPlatformWin()
{
dbgOut1("CPlatformWin::~CPlatformWin");
}
nsresult CPlatformWin::init(nsPluginWindow * window)
{
dbgOut1("CPlatformWin::init");
m_hWnd = (HWND)window->window;
if(!IsWindow(m_hWnd))
return NS_ERROR_UNEXPECTED;
m_OldWindowProc = SubclassWindow(m_hWnd, (WNDPROC)PluginWindowProc);
m_bInitialized = PR_TRUE;
return NS_OK;
}
void CPlatformWin::shut()
{
dbgOut1("CPlatformWin::shut");
if(m_hWnd != nsnull)
{
SubclassWindow(m_hWnd, m_OldWindowProc);
m_OldWindowProc = nsnull;
m_hWnd = nsnull;
}
m_bInitialized = PR_FALSE;
}
/*------------------------------------
* Window message handlers
*-----------------------------------*/
static void onPaint(HWND hWnd)
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd, &ps);
HBRUSH hBrush = CreateSolidBrush(RGB(0,255,0));
HBRUSH hBrushOld = SelectBrush(hDC, hBrush);
RECT rc;
GetClientRect(hWnd, &rc);
FillRect(hDC, &rc, hBrush);
SelectBrush(hDC, hBrushOld);
DeleteBrush(hBrush);
EndPaint(hWnd, &ps);
}
static void onDestroyWindow(HWND hWnd)
{
dbgOut1("onDestroyWindow");
}
static LRESULT CALLBACK PluginWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_PAINT:
HANDLE_WM_PAINT(hWnd, wParam, lParam, onPaint);
return 0L;
case WM_DESTROY:
HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroyWindow);
break;
default:
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}

View File

@ -0,0 +1,57 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef __INSTWIN_H__
#define __INSTWIN_H__
#include "instbase.h"
class CPlatformWin
{
public:
nsresult init(nsPluginWindow * window);
void shut();
CPlatformWin();
~CPlatformWin();
HWND m_hWnd;
WNDPROC m_OldWindowProc;
PRBool m_bInitialized;
};
class CPluginInstanceWin : public CPluginInstance
{
nsresult PlatformNew();
nsresult PlatformDestroy();
nsresult PlatformSetWindow(nsPluginWindow* window);
PRInt16 PlatformHandleEvent(nsPluginEvent* event);
public:
CPluginInstanceWin();
~CPluginInstanceWin();
CPlatformWin * platform;
};
#endif //__INSTWIN_H__

View File

@ -0,0 +1,9 @@
<HTML><BODY>
<object type="application/basicplugin-test">alternative text </object>
</BODY></HTML>
<BR>

View File

@ -0,0 +1,70 @@
/* -*- 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.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.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
*/
/*
* Mainly for debug purposes and in case we need a handle
* to application Windows instance
*/
/**********************************************************************
*
* winentry.cpp
*
* Windows entry point. Mainly for debug purposes.
*
***********************************************************************/
#include <windows.h>
#include "dbg.h"
HINSTANCE hInst = NULL;
BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
{
#ifdef DEBUG
char szReason[80];
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
strcpy(szReason, "DLL_PROCESS_ATTACH");
break;
case DLL_THREAD_ATTACH:
strcpy(szReason, "DLL_THREAD_ATTACH");
break;
case DLL_PROCESS_DETACH:
strcpy(szReason, "DLL_PROCESS_DETACH");
break;
case DLL_THREAD_DETACH:
strcpy(szReason, "DLL_THREAD_DETACH");
break;
}
dbgOut2("DllMain -- %s", szReason);
#endif
hInst = hDLL;
return TRUE;
}

View File

@ -0,0 +1,167 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
* This section typedefs the old 'native' types to the new PR<type>s.
* These definitions are scheduled to be eliminated at the earliest
* possible time. The NSPR API is implemented and documented using
* the new definitions.
*/
#if !defined(PROTYPES_H)
#define PROTYPES_H
typedef PRUintn uintn;
#ifndef _XP_Core_
typedef PRIntn intn;
#endif
/*
* BeOS already defines the integer types below in its standard
* header file SupportDefs.h.
*/
#ifdef XP_BEOS
#include <support/SupportDefs.h>
#elif defined(VMS)
/*
* OpenVMS already defines the integer types below in its standard
* header files ints.h and types.h.
*/
#include <ints.h>
#include <types.h>
#else
/* SVR4 typedef of uint is commonly found on UNIX machines. */
#ifdef XP_UNIX
#include <sys/types.h>
#endif
#if !defined(XP_UNIX) || defined(NTO)
typedef PRUintn uint;
#endif
typedef PRUint64 uint64;
#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2)
typedef PRUint32 uint32;
#else
typedef unsigned long uint32;
#endif
typedef PRUint16 uint16;
typedef PRUint8 uint8;
/*
* On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very
* common header file) defines the types int8, int16, int32, and int64.
* So we don't define these four types here to avoid conflicts in case
* the code also includes sys/types.h.
*/
#if defined(_PR_AIX_HAVE_BSD_INT_TYPES)
/* <sys/types.h> is already included */
#else
typedef PRInt64 int64;
/* /usr/include/model.h on HP-UX defines int8, int16, and int32 */
#if defined(HPUX)
#include <model.h>
#else
#if !defined(WIN32) || !defined(_WINSOCK2API_) /* defines its own "int32" */
#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2)
typedef PRInt32 int32;
#else
typedef long int32;
#endif
#endif
typedef PRInt16 int16;
typedef PRInt8 int8;
#endif /* HPUX */
#endif /* _PR_AIX_HAVE_BSD_INT_TYPES */
#endif /* XP_BEOS VMS */
typedef PRFloat64 float64;
typedef PRUptrdiff uptrdiff_t;
typedef PRUword uprword_t;
typedef PRWord prword_t;
/* Re: prbit.h */
#define TEST_BIT PR_TEST_BIT
#define SET_BIT PR_SET_BIT
#define CLEAR_BIT PR_CLEAR_BIT
/* Re: prarena.h->plarena.h */
#define PRArena PLArena
#define PRArenaPool PLArenaPool
#define PRArenaStats PLArenaStats
#define PR_ARENA_ALIGN PL_ARENA_ALIGN
#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL
#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE
#define PR_ARENA_GROW PL_ARENA_GROW
#define PR_ARENA_MARK PL_ARENA_MARK
#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED
#define PR_CLEAR_ARENA PL_CLEAR_ARENA
#define PR_ARENA_RELEASE PL_ARENA_RELEASE
#define PR_COUNT_ARENA PL_COUNT_ARENA
#define PR_ARENA_DESTROY PL_ARENA_DESTROY
#define PR_InitArenaPool PL_InitArenaPool
#define PR_FreeArenaPool PL_FreeArenaPool
#define PR_FinishArenaPool PL_FinishArenaPool
#define PR_CompactArenaPool PL_CompactArenaPool
#define PR_ArenaFinish PL_ArenaFinish
#define PR_ArenaAllocate PL_ArenaAllocate
#define PR_ArenaGrow PL_ArenaGrow
#define PR_ArenaRelease PL_ArenaRelease
#define PR_ArenaCountAllocation PL_ArenaCountAllocation
#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth
#define PR_ArenaCountGrowth PL_ArenaCountGrowth
#define PR_ArenaCountRelease PL_ArenaCountRelease
#define PR_ArenaCountRetract PL_ArenaCountRetract
/* Re: prhash.h->plhash.h */
#define PRHashEntry PLHashEntry
#define PRHashTable PLHashTable
#define PRHashNumber PLHashNumber
#define PRHashFunction PLHashFunction
#define PRHashComparator PLHashComparator
#define PRHashEnumerator PLHashEnumerator
#define PRHashAllocOps PLHashAllocOps
#define PR_NewHashTable PL_NewHashTable
#define PR_HashTableDestroy PL_HashTableDestroy
#define PR_HashTableRawLookup PL_HashTableRawLookup
#define PR_HashTableRawAdd PL_HashTableRawAdd
#define PR_HashTableRawRemove PL_HashTableRawRemove
#define PR_HashTableAdd PL_HashTableAdd
#define PR_HashTableRemove PL_HashTableRemove
#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries
#define PR_HashTableLookup PL_HashTableLookup
#define PR_HashTableDump PL_HashTableDump
#define PR_HashString PL_HashString
#define PR_CompareStrings PL_CompareStrings
#define PR_CompareValues PL_CompareValues
#if defined(XP_MAC)
#ifndef TRUE /* Mac standard is lower case true */
#define TRUE 1
#endif
#ifndef FALSE /* Mac standard is lower case false */
#define FALSE 0
#endif
#endif
#endif /* !defined(PROTYPES_H) */

View File

@ -0,0 +1,139 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
#ifndef plhash_h___
#define plhash_h___
/*
* API to portable hash table code.
*/
#include <stdio.h>
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef struct PLHashEntry PLHashEntry;
typedef struct PLHashTable PLHashTable;
typedef PRUint32 PLHashNumber;
#define PL_HASH_BITS 32 /* Number of bits in PLHashNumber */
typedef PLHashNumber (PR_CALLBACK *PLHashFunction)(const void *key);
typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2);
#if defined(XP_OS2_VACPP) && defined(VACPP_FLIP) /* for nsSpaceManager.cpp */
PR_END_EXTERN_C /* and nsHTMLDocument.cpp */
#endif
typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg);
#if defined(XP_OS2_VACPP) && defined(VACPP_FLIP)
PR_BEGIN_EXTERN_C
#endif
/* Flag bits in PLHashEnumerator's return value */
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */
#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */
#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */
typedef struct PLHashAllocOps {
void * (PR_CALLBACK *allocTable)(void *pool, PRSize size);
void (PR_CALLBACK *freeTable)(void *pool, void *item);
PLHashEntry * (PR_CALLBACK *allocEntry)(void *pool, const void *key);
void (PR_CALLBACK *freeEntry)(void *pool, PLHashEntry *he, PRUintn flag);
} PLHashAllocOps;
#define HT_FREE_VALUE 0 /* just free the entry's value */
#define HT_FREE_ENTRY 1 /* free value and entire entry */
struct PLHashEntry {
PLHashEntry *next; /* hash chain linkage */
PLHashNumber keyHash; /* key hash function result */
const void *key; /* ptr to opaque key */
void *value; /* ptr to opaque value */
};
struct PLHashTable {
PLHashEntry **buckets; /* vector of hash buckets */
PRUint32 nentries; /* number of entries in table */
PRUint32 shift; /* multiplicative hash shift */
PLHashFunction keyHash; /* key hash function */
PLHashComparator keyCompare; /* key comparison function */
PLHashComparator valueCompare; /* value comparison function */
const PLHashAllocOps *allocOps; /* allocation operations */
void *allocPriv; /* allocation private data */
#ifdef HASHMETER
PRUint32 nlookups; /* total number of lookups */
PRUint32 nsteps; /* number of hash chains traversed */
PRUint32 ngrows; /* number of table expansions */
PRUint32 nshrinks; /* number of table contractions */
#endif
};
/*
* Create a new hash table.
* If allocOps is null, use default allocator ops built on top of malloc().
*/
PR_EXTERN(PLHashTable *)
PL_NewHashTable(PRUint32 numBuckets, PLHashFunction keyHash,
PLHashComparator keyCompare, PLHashComparator valueCompare,
const PLHashAllocOps *allocOps, void *allocPriv);
PR_EXTERN(void)
PL_HashTableDestroy(PLHashTable *ht);
/* Higher level access methods */
PR_EXTERN(PLHashEntry *)
PL_HashTableAdd(PLHashTable *ht, const void *key, void *value);
PR_EXTERN(PRBool)
PL_HashTableRemove(PLHashTable *ht, const void *key);
PR_EXTERN(void *)
PL_HashTableLookup(PLHashTable *ht, const void *key);
PR_EXTERN(PRIntn)
PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg);
/* General-purpose C string hash function. */
PR_EXTERN(PLHashNumber)
PL_HashString(const void *key);
/* Compare strings using strcmp(), return true if equal. */
PR_EXTERN(PRIntn)
PL_CompareStrings(const void *v1, const void *v2);
/* Stub function just returns v1 == v2 */
PR_EXTERN(PRIntn)
PL_CompareValues(const void *v1, const void *v2);
/* Low level access methods */
PR_EXTERN(PLHashEntry **)
PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key);
PR_EXTERN(PLHashEntry *)
PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash,
const void *key, void *value);
PR_EXTERN(void)
PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he);
/* This can be trivially implemented using PL_HashTableEnumerateEntries. */
PR_EXTERN(PRIntn)
PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp);
PR_END_EXTERN_C
#endif /* plhash_h___ */

View File

@ -0,0 +1,428 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
#ifndef _plstr_h
#define _plstr_h
/*
* plstr.h
*
* This header file exports the API to the NSPR portable library or string-
* handling functions.
*
* This API was not designed as an "optimal" or "ideal" string library; it
* was based on the good ol' unix string.3 functions, and was written to
*
* 1) replace the libc functions, for cross-platform consistancy,
* 2) complete the API on platforms lacking common functions (e.g.,
* strcase*), and
* 3) to implement some obvious "closure" functions that I've seen
* people hacking around in our code.
*
* Point number three largely means that most functions have an "strn"
* limited-length version, and all comparison routines have a non-case-
* sensitive version available.
*/
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
* PL_strlen
*
* Returns the length of the provided string, not including the trailing '\0'.
*/
PR_EXTERN(PRUint32)
PL_strlen(const char *str);
/*
* PL_strnlen
*
* Returns the length of the provided string, not including the trailing '\0',
* up to the indicated maximum. The string will not be examined beyond the
* maximum; if no terminating '\0' is found, the maximum will be returned.
*/
PR_EXTERN(PRUint32)
PL_strnlen(const char *str, PRUint32 max);
/*
* PL_strcpy
*
* Copies the source string, up to and including the trailing '\0', into the
* destination buffer. It does not (can not) verify that the destination
* buffer is large enough. It returns the "dest" argument.
*/
PR_EXTERN(char *)
PL_strcpy(char *dest, const char *src);
/*
* PL_strncpy
*
* Copies the source string into the destination buffer, up to and including
* the trailing '\0' or up to and including the max'th character, whichever
* comes first. It does not (can not) verify that the destination buffer is
* large enough. If the source string is longer than the maximum length,
* the result will *not* be null-terminated (JLRU).
*/
PR_EXTERN(char *)
PL_strncpy(char *dest, const char *src, PRUint32 max);
/*
* PL_strncpyz
*
* Copies the source string into the destination buffer, up to and including
* the trailing '\0' or up but not including the max'th character, whichever
* comes first. It does not (can not) verify that the destination buffer is
* large enough. The destination string is always terminated with a '\0',
* unlike the traditional libc implementation. It returns the "dest" argument.
*
* NOTE: If you call this with a source "abcdefg" and a max of 5, the
* destination will end up with "abcd\0" (i.e., it's strlen length will be 4)!
*
* This means you can do this:
*
* char buffer[ SOME_SIZE ];
* PL_strncpyz(buffer, src, sizeof(buffer));
*
* and the result will be properly terminated.
*/
PR_EXTERN(char *)
PL_strncpyz(char *dest, const char *src, PRUint32 max);
/*
* PL_strdup
*
* Returns a pointer to a malloc'd extent of memory containing a duplicate
* of the argument string. The size of the allocated extent is one greater
* than the length of the argument string, because of the terminator. A
* null argument, like a zero-length argument, will result in a pointer to
* a one-byte extent containing the null value. This routine returns null
* upon malloc failure.
*/
PR_EXTERN(char *)
PL_strdup(const char *s);
/*
* PL_strfree
*
* Free memory allocated by PL_strdup
*/
PR_EXTERN(void)
PL_strfree(char *s);
/*
* PL_strndup
*
* Returns a pointer to a malloc'd extent of memory containing a duplicate
* of the argument string, up to the maximum specified. If the argument
* string has a length greater than the value of the specified maximum, the
* return value will be a pointer to an extent of memory of length one
* greater than the maximum specified. A null string, a zero-length string,
* or a zero maximum will all result in a pointer to a one-byte extent
* containing the null value. This routine returns null upon malloc failure.
*/
PR_EXTERN(char *)
PL_strndup(const char *s, PRUint32 max);
/*
* PL_strcat
*
* Appends a copy of the string pointed to by the second argument to the
* end of the string pointed to by the first. The destination buffer is
* not (can not be) checked for sufficient size. A null destination
* argument returns null; otherwise, the first argument is returned.
*/
PR_EXTERN(char *)
PL_strcat(char *dst, const char *src);
/*
* PL_strncat
*
* Appends a copy of the string pointed to by the second argument, up to
* the maximum size specified, to the end of the string pointed to by the
* first. The destination buffer is not (can not be) checked for sufficient
* size. A null destination argument returns null; otherwise, the first
* argument is returned. If the maximum size limits the copy, then the
* result will *not* be null-terminated (JLRU). A null destination
* returns null; otherwise, the destination argument is returned.
*/
PR_EXTERN(char *)
PL_strncat(char *dst, const char *src, PRUint32 max);
/*
* PL_strcatn
*
* Appends a copy of the string pointed to by the third argument, to the
* end of the string pointed to by the first. The second argument specifies
* the maximum size of the destination buffer, including the null termination.
* If the existing string in dst is longer than the max, no action is taken.
* The resulting string will be null-terminated. A null destination returns
* null; otherwise, the destination argument is returned.
*/
PR_EXTERN(char *)
PL_strcatn(char *dst, PRUint32 max, const char *src);
/*
* PL_strcmp
*
* Returns an integer, the sign of which -- positive, zero, or negative --
* reflects the lexical sorting order of the two strings indicated. The
* result is positive if the first string comes after the second. The
* NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strcmp(const char *a, const char *b);
/*
* PL_strncmp
*
* Returns an integer, the sign of which -- positive, zero, or negative --
* reflects the lexical sorting order of the two strings indicated, up to
* the maximum specified. The result is positive if the first string comes
* after the second. The NSPR implementation is not i18n. If the maximum
* is zero, only the existance or non-existance (pointer is null) of the
* strings is compared.
*/
PR_EXTERN(PRIntn)
PL_strncmp(const char *a, const char *b, PRUint32 max);
/*
* PL_strcasecmp
*
* Returns an integer, the sign of which -- positive, zero or negative --
* reflects the case-insensitive lexical sorting order of the two strings
* indicated. The result is positive if the first string comes after the
* second. The NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strcasecmp(const char *a, const char *b);
/*
* PL_strncasecmp
*
* Returns an integer, the sign of which -- positive, zero or negative --
* reflects the case-insensitive lexical sorting order of the first n characters
* of the two strings indicated. The result is positive if the first string comes
* after the second. The NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strncasecmp(const char *a, const char *b, PRUint32 max);
/*
* PL_strchr
*
* Returns a pointer to the first instance of the specified character in the
* provided string. It returns null if the character is not found, or if the
* provided string is null. The character may be the null character.
*/
PR_EXTERN(char *)
PL_strchr(const char *s, char c);
/*
* PL_strrchr
*
* Returns a pointer to the last instance of the specified character in the
* provided string. It returns null if the character is not found, or if the
* provided string is null. The character may be the null character.
*/
PR_EXTERN(char *)
PL_strrchr(const char *s, char c);
/*
* PL_strnchr
*
* Returns a pointer to the first instance of the specified character within the
* first n characters of the provided string. It returns null if the character
* is not found, or if the provided string is null. The character may be the
* null character.
*/
PR_EXTERN(char *)
PL_strnchr(const char *s, char c, PRUint32 n);
/*
* PL_strnrchr
*
* Returns a pointer to the last instance of the specified character within the
* first n characters of the provided string. It returns null if the character is
* not found, or if the provided string is null. The character may be the null
* character.
*/
PR_EXTERN(char *)
PL_strnrchr(const char *s, char c, PRUint32 n);
/*
* NOTE: Looking for strcasechr, strcaserchr, strncasechr, or strncaserchr?
* Use strpbrk, strprbrk, strnpbrk or strnprbrk.
*/
/*
* PL_strpbrk
*
* Returns a pointer to the first instance in the first string of any character
* (not including the terminating null character) of the second string. It returns
* null if either string is null.
*/
PR_EXTERN(char *)
PL_strpbrk(const char *s, const char *list);
/*
* PL_strprbrk
*
* Returns a pointer to the last instance in the first string of any character
* (not including the terminating null character) of the second string. It returns
* null if either string is null.
*/
PR_EXTERN(char *)
PL_strprbrk(const char *s, const char *list);
/*
* PL_strnpbrk
*
* Returns a pointer to the first instance (within the first n characters) of any
* character (not including the terminating null character) of the second string.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strnpbrk(const char *s, const char *list, PRUint32 n);
/*
* PL_strnprbrk
*
* Returns a pointer to the last instance (within the first n characters) of any
* character (not including the terminating null character) of the second string.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strnprbrk(const char *s, const char *list, PRUint32 n);
/*
* PL_strstr
*
* Returns a pointer to the first instance of the little string within the
* big one. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strstr(const char *big, const char *little);
/*
* PL_strrstr
*
* Returns a pointer to the last instance of the little string within the big one.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strrstr(const char *big, const char *little);
/*
* PL_strnstr
*
* Returns a pointer to the first instance of the little string within the first
* n characters of the big one. It returns null if either string is null. It
* returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strnstr(const char *big, const char *little, PRUint32 n);
/*
* PL_strnrstr
*
* Returns a pointer to the last instance of the little string within the first
* n characters of the big one. It returns null if either string is null. It
* returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strnrstr(const char *big, const char *little, PRUint32 max);
/*
* PL_strcasestr
*
* Returns a pointer to the first instance of the little string within the big one,
* ignoring case. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strcasestr(const char *big, const char *little);
/*
* PL_strcaserstr
*
* Returns a pointer to the last instance of the little string within the big one,
* ignoring case. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strcaserstr(const char *big, const char *little);
/*
* PL_strncasestr
*
* Returns a pointer to the first instance of the listtle string within the first
* n characters of the big one, ignoring case. It returns null if either string is
* null. It returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strncasestr(const char *big, const char *little, PRUint32 max);
/*
* PL_strncaserstr
*
* Returns a pointer to the last instance of the little string within the first
* n characters of the big one, ignoring case. It returns null if either string is
* null. It returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strncaserstr(const char *big, const char *little, PRUint32 max);
/*
* Things not (yet?) included: strspn/strcspn, strtok/strtok_r, strsep.
* memchr, memcmp, memcpy, memccpy, index, rindex, bcmp, bcopy, bzero.
* Any and all i18n/l10n stuff.
*/
PR_END_EXTERN_C
#endif /* _plstr_h */

View File

@ -0,0 +1,142 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/* GLOBAL FUNCTIONS:
** DESCRIPTION:
** PR Atomic operations
*/
#ifndef pratom_h___
#define pratom_h___
#include "prtypes.h"
#include "prlock.h"
PR_BEGIN_EXTERN_C
/*
** FUNCTION: PR_AtomicIncrement
** DESCRIPTION:
** Atomically increment a 32 bit value.
** INPUTS:
** val: a pointer to the value to increment
** RETURN:
** the returned value is the result of the increment
*/
NSPR_API(PRInt32) PR_AtomicIncrement(PRInt32 *val);
/*
** FUNCTION: PR_AtomicDecrement
** DESCRIPTION:
** Atomically decrement a 32 bit value.
** INPUTS:
** val: a pointer to the value to decrement
** RETURN:
** the returned value is the result of the decrement
*/
NSPR_API(PRInt32) PR_AtomicDecrement(PRInt32 *val);
/*
** FUNCTION: PR_AtomicSet
** DESCRIPTION:
** Atomically set a 32 bit value.
** INPUTS:
** val: A pointer to a 32 bit value to be set
** newval: The newvalue to assign to val
** RETURN:
** Returns the prior value
*/
NSPR_API(PRInt32) PR_AtomicSet(PRInt32 *val, PRInt32 newval);
/*
** FUNCTION: PR_AtomicAdd
** DESCRIPTION:
** Atomically add a 32 bit value.
** INPUTS:
** ptr: a pointer to the value to increment
** val: value to be added
** RETURN:
** the returned value is the result of the addition
*/
NSPR_API(PRInt32) PR_AtomicAdd(PRInt32 *ptr, PRInt32 val);
/*
** LIFO linked-list (stack)
*/
typedef struct PRStackElemStr PRStackElem;
struct PRStackElemStr {
PRStackElem *prstk_elem_next; /* next pointer MUST be at offset 0;
assembly language code relies on this */
};
typedef struct PRStackStr PRStack;
/*
** FUNCTION: PR_CreateStack
** DESCRIPTION:
** Create a stack, a LIFO linked list
** INPUTS:
** stack_name: a pointer to string containing the name of the stack
** RETURN:
** A pointer to the created stack, if successful, else NULL.
*/
NSPR_API(PRStack *) PR_CreateStack(const char *stack_name);
/*
** FUNCTION: PR_StackPush
** DESCRIPTION:
** Push an element on the top of the stack
** INPUTS:
** stack: pointer to the stack
** stack_elem: pointer to the stack element
** RETURN:
** None
*/
NSPR_API(void) PR_StackPush(PRStack *stack, PRStackElem *stack_elem);
/*
** FUNCTION: PR_StackPop
** DESCRIPTION:
** Remove the element on the top of the stack
** INPUTS:
** stack: pointer to the stack
** RETURN:
** A pointer to the stack element removed from the top of the stack,
** if non-empty,
** else NULL
*/
NSPR_API(PRStackElem *) PR_StackPop(PRStack *stack);
/*
** FUNCTION: PR_DestroyStack
** DESCRIPTION:
** Destroy the stack
** INPUTS:
** stack: pointer to the stack
** RETURN:
** PR_SUCCESS - if successfully deleted
** PR_FAILURE - if the stack is not empty
** PR_GetError will return
** PR_INVALID_STATE_ERROR - stack is not empty
*/
NSPR_API(PRStatus) PR_DestroyStack(PRStack *stack);
PR_END_EXTERN_C
#endif /* pratom_h___ */

View File

@ -0,0 +1,181 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_PC
#define XP_PC
#endif
#ifndef WIN32
#define WIN32
#endif
#ifndef WIN95
#define WIN95
#endif
#define PR_AF_INET6 23 /* same as AF_INET6 */
#if defined(_M_IX86) || defined(_X86_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 2
#elif defined(_ALPHA_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#else /* defined(_M_IX86) || defined(_X86_) */
#error unknown processor architecture
#endif /* defined(_M_IX86) || defined(_X86_) */
#define HAVE_LONG_LONG
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@ -0,0 +1,102 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
** File: prlock.h
** Description: API to basic locking functions of NSPR.
**
**
** NSPR provides basic locking mechanisms for thread synchronization. Locks
** are lightweight resource contention controls that prevent multiple threads
** from accessing something (code/data) simultaneously.
**/
#ifndef prlock_h___
#define prlock_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
/*
* PRLock --
*
* NSPR represents the lock as an opaque entity to the client of the
* API. All routines operate on a pointer to this opaque entity.
*/
typedef struct PRLock PRLock;
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/***********************************************************************
** FUNCTION: PR_NewLock
** DESCRIPTION:
** Returns a pointer to a newly created opaque lock object.
** INPUTS: void
** OUTPUTS: void
** RETURN: PRLock*
** If the lock can not be created because of resource constraints, NULL
** is returned.
**
***********************************************************************/
NSPR_API(PRLock*) PR_NewLock(void);
/***********************************************************************
** FUNCTION: PR_DestroyLock
** DESCRIPTION:
** Destroys a given opaque lock object.
** INPUTS: PRLock *lock
** Lock to be freed.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_DestroyLock(PRLock *lock);
/***********************************************************************
** FUNCTION: PR_Lock
** DESCRIPTION:
** Lock a lock.
** INPUTS: PRLock *lock
** Lock to locked.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_Lock(PRLock *lock);
/***********************************************************************
** FUNCTION: PR_Unlock
** DESCRIPTION:
** Unlock a lock. Unlocking an unlocked lock has undefined results.
** INPUTS: PRLock *lock
** Lock to unlocked.
** OUTPUTS: void
** RETURN: PR_STATUS
** Returns PR_FAILURE if the caller does not own the lock.
***********************************************************************/
NSPR_API(PRStatus) PR_Unlock(PRLock *lock);
PR_END_EXTERN_C
#endif /* prlock_h___ */

View File

@ -0,0 +1,409 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
** File: prlong.h
** Description: Portable access to 64 bit numerics
**
** Long-long (64-bit signed integer type) support. Some C compilers
** don't support 64 bit integers yet, so we use these macros to
** support both machines that do and don't.
**/
#ifndef prlong_h___
#define prlong_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/***********************************************************************
** DEFINES: LL_MaxInt
** LL_MinInt
** LL_Zero
** DESCRIPTION:
** Various interesting constants and static variable
** initializer
***********************************************************************/
#if defined(HAVE_WATCOM_BUG_2)
PRInt64 __pascal __loadds __export
LL_MaxInt(void);
PRInt64 __pascal __loadds __export
LL_MinInt(void);
PRInt64 __pascal __loadds __export
LL_Zero(void);
#else
NSPR_API(PRInt64) LL_MaxInt(void);
NSPR_API(PRInt64) LL_MinInt(void);
NSPR_API(PRInt64) LL_Zero(void);
#endif
#define LL_MAXINT LL_MaxInt()
#define LL_MININT LL_MinInt()
#define LL_ZERO LL_Zero()
#if defined(HAVE_LONG_LONG)
#if PR_BYTES_PER_LONG == 8
#define LL_INIT(hi, lo) ((hi ## L << 32) + lo ## L)
#elif (defined(WIN32) || defined(WIN16)) && !defined(__GNUC__)
#define LL_INIT(hi, lo) ((hi ## i64 << 32) + lo ## i64)
#else
#define LL_INIT(hi, lo) ((hi ## LL << 32) + lo ## LL)
#endif
/***********************************************************************
** MACROS: LL_*
** DESCRIPTION:
** The following macros define portable access to the 64 bit
** math facilities.
**
***********************************************************************/
/***********************************************************************
** MACROS: LL_<relational operators>
**
** LL_IS_ZERO Test for zero
** LL_EQ Test for equality
** LL_NE Test for inequality
** LL_GE_ZERO Test for zero or positive
** LL_CMP Compare two values
***********************************************************************/
#define LL_IS_ZERO(a) ((a) == 0)
#define LL_EQ(a, b) ((a) == (b))
#define LL_NE(a, b) ((a) != (b))
#define LL_GE_ZERO(a) ((a) >= 0)
#define LL_CMP(a, op, b) ((PRInt64)(a) op (PRInt64)(b))
#define LL_UCMP(a, op, b) ((PRUint64)(a) op (PRUint64)(b))
/***********************************************************************
** MACROS: LL_<logical operators>
**
** LL_AND Logical and
** LL_OR Logical or
** LL_XOR Logical exclusion
** LL_OR2 A disgusting deviation
** LL_NOT Negation (one's complement)
***********************************************************************/
#define LL_AND(r, a, b) ((r) = (a) & (b))
#define LL_OR(r, a, b) ((r) = (a) | (b))
#define LL_XOR(r, a, b) ((r) = (a) ^ (b))
#define LL_OR2(r, a) ((r) = (r) | (a))
#define LL_NOT(r, a) ((r) = ~(a))
/***********************************************************************
** MACROS: LL_<mathematical operators>
**
** LL_NEG Negation (two's complement)
** LL_ADD Summation (two's complement)
** LL_SUB Difference (two's complement)
***********************************************************************/
#define LL_NEG(r, a) ((r) = -(a))
#define LL_ADD(r, a, b) ((r) = (a) + (b))
#define LL_SUB(r, a, b) ((r) = (a) - (b))
/***********************************************************************
** MACROS: LL_<mathematical operators>
**
** LL_MUL Product (two's complement)
** LL_DIV Quotient (two's complement)
** LL_MOD Modulus (two's complement)
***********************************************************************/
#define LL_MUL(r, a, b) ((r) = (a) * (b))
#define LL_DIV(r, a, b) ((r) = (a) / (b))
#define LL_MOD(r, a, b) ((r) = (a) % (b))
/***********************************************************************
** MACROS: LL_<shifting operators>
**
** LL_SHL Shift left [0..64] bits
** LL_SHR Shift right [0..64] bits with sign extension
** LL_USHR Unsigned shift right [0..64] bits
** LL_ISHL Signed shift left [0..64] bits
***********************************************************************/
#define LL_SHL(r, a, b) ((r) = (PRInt64)(a) << (b))
#define LL_SHR(r, a, b) ((r) = (PRInt64)(a) >> (b))
#define LL_USHR(r, a, b) ((r) = (PRUint64)(a) >> (b))
#define LL_ISHL(r, a, b) ((r) = (PRInt64)(a) << (b))
/***********************************************************************
** MACROS: LL_<conversion operators>
**
** LL_L2I Convert to signed 32 bit
** LL_L2UI Convert to unsigned 32 bit
** LL_L2F Convert to floating point
** LL_L2D Convert to floating point
** LL_I2L Convert signed to 64 bit
** LL_UI2L Convert unsigned to 64 bit
** LL_F2L Convert float to 64 bit
** LL_D2L Convert float to 64 bit
***********************************************************************/
#define LL_L2I(i, l) ((i) = (PRInt32)(l))
#define LL_L2UI(ui, l) ((ui) = (PRUint32)(l))
#define LL_L2F(f, l) ((f) = (PRFloat64)(l))
#define LL_L2D(d, l) ((d) = (PRFloat64)(l))
#define LL_I2L(l, i) ((l) = (PRInt64)(i))
#define LL_UI2L(l, ui) ((l) = (PRInt64)(ui))
#define LL_F2L(l, f) ((l) = (PRInt64)(f))
#define LL_D2L(l, d) ((l) = (PRInt64)(d))
/***********************************************************************
** MACROS: LL_UDIVMOD
** DESCRIPTION:
** Produce both a quotient and a remainder given an unsigned
** INPUTS: PRUint64 a: The dividend of the operation
** PRUint64 b: The quotient of the operation
** OUTPUTS: PRUint64 *qp: pointer to quotient
** PRUint64 *rp: pointer to remainder
***********************************************************************/
#define LL_UDIVMOD(qp, rp, a, b) \
(*(qp) = ((PRUint64)(a) / (b)), \
*(rp) = ((PRUint64)(a) % (b)))
#else /* !HAVE_LONG_LONG */
#ifdef IS_LITTLE_ENDIAN
#define LL_INIT(hi, lo) {PR_INT32(lo), PR_INT32(hi)}
#else
#define LL_INIT(hi, lo) {PR_INT32(hi), PR_INT32(lo)}
#endif
#define LL_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0))
#define LL_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo))
#define LL_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo))
#define LL_GE_ZERO(a) (((a).hi >> 31) == 0)
#define LL_CMP(a, op, b) (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \
((PRInt32)(a).hi op (PRInt32)(b).hi))
#define LL_UCMP(a, op, b) (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \
((a).hi op (b).hi))
#define LL_AND(r, a, b) ((r).lo = (a).lo & (b).lo, \
(r).hi = (a).hi & (b).hi)
#define LL_OR(r, a, b) ((r).lo = (a).lo | (b).lo, \
(r).hi = (a).hi | (b).hi)
#define LL_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, \
(r).hi = (a).hi ^ (b).hi)
#define LL_OR2(r, a) ((r).lo = (r).lo | (a).lo, \
(r).hi = (r).hi | (a).hi)
#define LL_NOT(r, a) ((r).lo = ~(a).lo, \
(r).hi = ~(a).hi)
#define LL_NEG(r, a) ((r).lo = -(PRInt32)(a).lo, \
(r).hi = -(PRInt32)(a).hi - ((r).lo != 0))
#define LL_ADD(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
(r).lo = _a.lo + _b.lo; \
(r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \
}
#define LL_SUB(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
(r).lo = _a.lo - _b.lo; \
(r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \
}
#define LL_MUL(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
LL_MUL32(r, _a.lo, _b.lo); \
(r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \
}
#define _lo16(a) ((a) & PR_BITMASK(16))
#define _hi16(a) ((a) >> 16)
#define LL_MUL32(r, a, b) { \
PRUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \
_a1 = _hi16(a), _a0 = _lo16(a); \
_b1 = _hi16(b), _b0 = _lo16(b); \
_y0 = _a0 * _b0; \
_y1 = _a0 * _b1; \
_y2 = _a1 * _b0; \
_y3 = _a1 * _b1; \
_y1 += _hi16(_y0); /* can't carry */ \
_y1 += _y2; /* might carry */ \
if (_y1 < _y2) \
_y3 += (PRUint32)(PR_BIT(16)); /* propagate */ \
(r).lo = (_lo16(_y1) << 16) + _lo16(_y0); \
(r).hi = _y3 + _hi16(_y1); \
}
#define LL_UDIVMOD(qp, rp, a, b) ll_udivmod(qp, rp, a, b)
NSPR_API(void) ll_udivmod(PRUint64 *qp, PRUint64 *rp, PRUint64 a, PRUint64 b);
#define LL_DIV(r, a, b) { \
PRInt64 _a, _b; \
PRUint32 _negative = (PRInt32)(a).hi < 0; \
if (_negative) { \
LL_NEG(_a, a); \
} else { \
_a = a; \
} \
if ((PRInt32)(b).hi < 0) { \
_negative ^= 1; \
LL_NEG(_b, b); \
} else { \
_b = b; \
} \
LL_UDIVMOD(&(r), 0, _a, _b); \
if (_negative) \
LL_NEG(r, r); \
}
#define LL_MOD(r, a, b) { \
PRInt64 _a, _b; \
PRUint32 _negative = (PRInt32)(a).hi < 0; \
if (_negative) { \
LL_NEG(_a, a); \
} else { \
_a = a; \
} \
if ((PRInt32)(b).hi < 0) { \
LL_NEG(_b, b); \
} else { \
_b = b; \
} \
LL_UDIVMOD(0, &(r), _a, _b); \
if (_negative) \
LL_NEG(r, r); \
}
#define LL_SHL(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = _a.lo << ((b) & 31); \
(r).hi = (_a.hi << ((b) & 31)) | (_a.lo >> (32 - (b))); \
} else { \
(r).lo = 0; \
(r).hi = _a.lo << ((b) & 31); \
} \
} else { \
(r) = (a); \
} \
}
/* a is an PRInt32, b is PRInt32, r is PRInt64 */
#define LL_ISHL(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a.lo = (a); \
_a.hi = 0; \
if ((b) < 32) { \
(r).lo = (a) << ((b) & 31); \
(r).hi = ((a) >> (32 - (b))); \
} else { \
(r).lo = 0; \
(r).hi = (a) << ((b) & 31); \
} \
} else { \
(r).lo = (a); \
(r).hi = 0; \
} \
}
#define LL_SHR(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \
(r).hi = (PRInt32)_a.hi >> ((b) & 31); \
} else { \
(r).lo = (PRInt32)_a.hi >> ((b) & 31); \
(r).hi = (PRInt32)_a.hi >> 31; \
} \
} else { \
(r) = (a); \
} \
}
#define LL_USHR(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \
(r).hi = _a.hi >> ((b) & 31); \
} else { \
(r).lo = _a.hi >> ((b) & 31); \
(r).hi = 0; \
} \
} else { \
(r) = (a); \
} \
}
#define LL_L2I(i, l) ((i) = (l).lo)
#define LL_L2UI(ui, l) ((ui) = (l).lo)
#define LL_L2F(f, l) { double _d; LL_L2D(_d, l); (f) = (PRFloat64)_d; }
#define LL_L2D(d, l) { \
int _negative; \
PRInt64 _absval; \
\
_negative = (l).hi >> 31; \
if (_negative) { \
LL_NEG(_absval, l); \
} else { \
_absval = l; \
} \
(d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \
if (_negative) \
(d) = -(d); \
}
#define LL_I2L(l, i) { PRInt32 _i = ((PRInt32)(i)) >> 31; (l).lo = (i); (l).hi = _i; }
#define LL_UI2L(l, ui) ((l).lo = (ui), (l).hi = 0)
#define LL_F2L(l, f) { double _d = (double)f; LL_D2L(l, _d); }
#define LL_D2L(l, d) { \
int _negative; \
double _absval, _d_hi; \
PRInt64 _lo_d; \
\
_negative = ((d) < 0); \
_absval = _negative ? -(d) : (d); \
\
(l).hi = _absval / 4.294967296e9; \
(l).lo = 0; \
LL_L2D(_d_hi, l); \
_absval -= _d_hi; \
_lo_d.hi = 0; \
if (_absval < 0) { \
_lo_d.lo = -_absval; \
LL_SUB(l, l, _lo_d); \
} else { \
_lo_d.lo = _absval; \
LL_ADD(l, l, _lo_d); \
} \
\
if (_negative) \
LL_NEG(l, l); \
}
#endif /* !HAVE_LONG_LONG */
PR_END_EXTERN_C
#endif /* prlong_h___ */

View File

@ -0,0 +1,279 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
*----------------------------------------------------------------------
*
* prtime.h --
*
* NSPR date and time functions
*
*-----------------------------------------------------------------------
*/
#ifndef prtime_h___
#define prtime_h___
#include "prlong.h"
PR_BEGIN_EXTERN_C
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
#define PR_MSEC_PER_SEC 1000UL
#define PR_USEC_PER_SEC 1000000UL
#define PR_NSEC_PER_SEC 1000000000UL
#define PR_USEC_PER_MSEC 1000UL
#define PR_NSEC_PER_MSEC 1000000UL
/*
* PRTime --
*
* NSPR represents basic time as 64-bit signed integers relative
* to midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).
* (GMT is also known as Coordinated Universal Time, UTC.)
* The units of time are in microseconds. Negative times are allowed
* to represent times prior to the January 1970 epoch. Such values are
* intended to be exported to other systems or converted to human
* readable form.
*
* Notes on porting: PRTime corresponds to time_t in ANSI C. NSPR 1.0
* simply uses PRInt64.
*/
typedef PRInt64 PRTime;
/*
* Time zone and daylight saving time corrections applied to GMT to
* obtain the local time of some geographic location
*/
typedef struct PRTimeParameters {
PRInt32 tp_gmt_offset; /* the offset from GMT in seconds */
PRInt32 tp_dst_offset; /* contribution of DST in seconds */
} PRTimeParameters;
/*
* PRExplodedTime --
*
* Time broken down into human-readable components such as year, month,
* day, hour, minute, second, and microsecond. Time zone and daylight
* saving time corrections may be applied. If they are applied, the
* offsets from the GMT must be saved in the 'tm_params' field so that
* all the information is available to reconstruct GMT.
*
* Notes on porting: PRExplodedTime corrresponds to struct tm in
* ANSI C, with the following differences:
* - an additional field tm_usec;
* - replacing tm_isdst by tm_params;
* - the month field is spelled tm_month, not tm_mon;
* - we use absolute year, AD, not the year since 1900.
* The corresponding type in NSPR 1.0 is called PRTime. Below is
* a table of date/time type correspondence in the three APIs:
* API time since epoch time in components
* ANSI C time_t struct tm
* NSPR 1.0 PRInt64 PRTime
* NSPR 2.0 PRTime PRExplodedTime
*/
typedef struct PRExplodedTime {
PRInt32 tm_usec; /* microseconds past tm_sec (0-99999) */
PRInt32 tm_sec; /* seconds past tm_min (0-61, accomodating
up to two leap seconds) */
PRInt32 tm_min; /* minutes past tm_hour (0-59) */
PRInt32 tm_hour; /* hours past tm_day (0-23) */
PRInt32 tm_mday; /* days past tm_mon (1-31, note that it
starts from 1) */
PRInt32 tm_month; /* months past tm_year (0-11, Jan = 0) */
PRInt16 tm_year; /* absolute year, AD (note that we do not
count from 1900) */
PRInt8 tm_wday; /* calculated day of the week
(0-6, Sun = 0) */
PRInt16 tm_yday; /* calculated day of the year
(0-365, Jan 1 = 0) */
PRTimeParameters tm_params; /* time parameters used by conversion */
} PRExplodedTime;
/*
* PRTimeParamFn --
*
* A function of PRTimeParamFn type returns the time zone and
* daylight saving time corrections for some geographic location,
* given the current time in GMT. The input argument gmt should
* point to a PRExplodedTime that is in GMT, i.e., whose
* tm_params contains all 0's.
*
* For any time zone other than GMT, the computation is intended to
* consist of two steps:
* - Figure out the time zone correction, tp_gmt_offset. This number
* usually depends on the geographic location only. But it may
* also depend on the current time. For example, all of China
* is one time zone right now. But this situation may change
* in the future.
* - Figure out the daylight saving time correction, tp_dst_offset.
* This number depends on both the geographic location and the
* current time. Most of the DST rules are expressed in local
* current time. If so, one should apply the time zone correction
* to GMT before applying the DST rules.
*/
typedef PRTimeParameters (PR_CALLBACK_DECL *PRTimeParamFn)(const PRExplodedTime *gmt);
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/*
* The PR_Now routine returns the current time relative to the
* epoch, midnight, January 1, 1970 UTC. The units of the returned
* value are microseconds since the epoch.
*
* The values returned are not guaranteed to advance in a linear fashion
* due to the application of time correction protocols which synchronize
* computer clocks to some external time source. Consequently it should
* not be depended on for interval timing.
*
* The implementation is machine dependent.
* Cf. time_t time(time_t *tp) in ANSI C.
*/
#if defined(HAVE_WATCOM_BUG_2)
PRTime __pascal __export __loadds
#else
NSPR_API(PRTime)
#endif
PR_Now(void);
/*
* Expand time binding it to time parameters provided by PRTimeParamFn.
* The calculation is envisoned to proceed in the following steps:
* - From given PRTime, calculate PRExplodedTime in GMT
* - Apply the given PRTimeParamFn to the GMT that we just calculated
* to obtain PRTimeParameters.
* - Add the PRTimeParameters offsets to GMT to get the local time
* as PRExplodedTime.
*/
NSPR_API(void) PR_ExplodeTime(
PRTime usecs, PRTimeParamFn params, PRExplodedTime *exploded);
/* Reverse operation of PR_ExplodeTime */
#if defined(HAVE_WATCOM_BUG_2)
PRTime __pascal __export __loadds
#else
NSPR_API(PRTime)
#endif
PR_ImplodeTime(const PRExplodedTime *exploded);
/*
* Adjust exploded time to normalize field overflows after manipulation.
* Note that the following fields of PRExplodedTime should not be
* manipulated:
* - tm_month and tm_year: because the number of days in a month and
* number of days in a year are not constant, it is ambiguous to
* manipulate the month and year fields, although one may be tempted
* to. For example, what does "a month from January 31st" mean?
* - tm_wday and tm_yday: these fields are calculated by NSPR. Users
* should treat them as "read-only".
*/
NSPR_API(void) PR_NormalizeTime(
PRExplodedTime *exploded, PRTimeParamFn params);
/**********************************************************************/
/*********************** TIME PARAMETER FUNCTIONS *********************/
/**********************************************************************/
/* Time parameters that suit current host machine */
NSPR_API(PRTimeParameters) PR_LocalTimeParameters(const PRExplodedTime *gmt);
/* Time parameters that represent Greenwich Mean Time */
NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt);
/*
* Time parameters that represent the US Pacific Time Zone, with the
* current daylight saving time rules (for testing only)
*/
NSPR_API(PRTimeParameters) PR_USPacificTimeParameters(const PRExplodedTime *gmt);
/*
* This parses a time/date string into a PRTime
* (microseconds after "1-Jan-1970 00:00:00 GMT").
* It returns PR_SUCCESS on success, and PR_FAILURE
* if the time/date string can't be parsed.
*
* Many formats are handled, including:
*
* 14 Apr 89 03:20:12
* 14 Apr 89 03:20 GMT
* Fri, 17 Mar 89 4:01:33
* Fri, 17 Mar 89 4:01 GMT
* Mon Jan 16 16:12 PDT 1989
* Mon Jan 16 16:12 +0130 1989
* 6 May 1992 16:41-JST (Wednesday)
* 22-AUG-1993 10:59:12.82
* 22-AUG-1993 10:59pm
* 22-AUG-1993 12:59am
* 22-AUG-1993 12:59 PM
* Friday, August 04, 1995 3:54 PM
* 06/21/95 04:24:34 PM
* 20/06/95 21:07
* 95-06-08 19:32:48 EDT
*
* If the input string doesn't contain a description of the timezone,
* we consult the `default_to_gmt' to decide whether the string should
* be interpreted relative to the local time zone (PR_FALSE) or GMT (PR_TRUE).
* The correct value for this argument depends on what standard specified
* the time string which you are parsing.
*/
NSPR_API(PRStatus) PR_ParseTimeString (
const char *string,
PRBool default_to_gmt,
PRTime *result);
/*
* FIXME: should we also have a formatting function, such as asctime, ctime,
* and strftime in standard C library? But this would involve
* internationalization issues. Might want to provide a US English version.
*/
/**********************************************************************/
/*********************** OLD COMPATIBILITYFUNCTIONS *******************/
/**********************************************************************/
#ifndef NO_NSPR_10_SUPPORT
/* Format a time value into a buffer. Same semantics as strftime() */
NSPR_API(PRUint32) PR_FormatTime(char *buf, int buflen, const char *fmt,
const PRExplodedTime *tm);
/* Format a time value into a buffer. Time is always in US English format, regardless
* of locale setting.
*/
NSPR_API(PRUint32)
PR_FormatTimeUSEnglish( char* buf, PRUint32 bufSize,
const char* format, const PRExplodedTime* tm );
#endif /* NO_NSPR_10_SUPPORT */
PR_END_EXTERN_C
#endif /* prtime_h___ */

View File

@ -0,0 +1,475 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
** File: prtypes.h
** Description: Definitions of NSPR's basic types
**
** Prototypes and macros used to make up for deficiencies in ANSI environments
** that we have found.
**
** Since we do not wrap <stdlib.h> and all the other standard headers, authors
** of portable code will not know in general that they need these definitions.
** Instead of requiring these authors to find the dependent uses in their code
** and take the following steps only in those C files, we take steps once here
** for all C files.
**/
#ifndef prtypes_h___
#define prtypes_h___
#ifdef MDCPUCFG
#include MDCPUCFG
#else
#include "prcpucfg.h"
#endif
#include <stddef.h>
/***********************************************************************
** MACROS: PR_EXTERN
** PR_IMPLEMENT
** DESCRIPTION:
** These are only for externally visible routines and globals. For
** internal routines, just use "extern" for type checking and that
** will not export internal cross-file or forward-declared symbols.
** Define a macro for declaring procedures return types. We use this to
** deal with windoze specific type hackery for DLL definitions. Use
** PR_EXTERN when the prototype for the method is declared. Use
** PR_IMPLEMENT for the implementation of the method.
**
** Example:
** in dowhim.h
** PR_EXTERN( void ) DoWhatIMean( void );
** in dowhim.c
** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
**
**
***********************************************************************/
#if defined(WIN32)
#if defined(__GNUC__)
#undef _declspec
#define _declspec(x) __declspec(x)
#endif
#define PR_EXPORT(__type) extern _declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern _declspec(dllexport) __type
#define PR_IMPORT(__type) _declspec(dllimport) __type
#define PR_IMPORT_DATA(__type) _declspec(dllimport) __type
#define PR_EXTERN(__type) extern _declspec(dllexport) __type
#define PR_IMPLEMENT(__type) _declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern _declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) _declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(XP_BEOS)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPORT(__type) extern __declspec(dllexport) __type
#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_EXTERN(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(WIN16)
#define PR_CALLBACK_DECL __cdecl
#if defined(_WINDLL)
#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
#define PR_EXPORT_DATA(__type) extern __type _export
#define PR_IMPORT_DATA(__type) extern __type _export
#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
#define PR_EXTERN_DATA(__type) extern __type _export
#define PR_IMPLEMENT_DATA(__type) __type _export
#define PR_CALLBACK __cdecl __loadds
#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
#else /* this must be .EXE */
#define PR_EXPORT(__type) extern __type _cdecl _export
#define PR_IMPORT(__type) extern __type _cdecl _export
#define PR_EXPORT_DATA(__type) extern __type _export
#define PR_IMPORT_DATA(__type) extern __type _export
#define PR_EXTERN(__type) extern __type _cdecl _export
#define PR_IMPLEMENT(__type) __type _cdecl _export
#define PR_EXTERN_DATA(__type) extern __type _export
#define PR_IMPLEMENT_DATA(__type) __type _export
#define PR_CALLBACK __cdecl __loadds
#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
#endif /* _WINDLL */
#elif defined(XP_MAC)
#define PR_EXPORT(__type) extern __declspec(export) __type
#define PR_EXPORT_DATA(__type) extern __declspec(export) __type
#define PR_IMPORT(__type) extern __declspec(export) __type
#define PR_IMPORT_DATA(__type) extern __declspec(export) __type
#define PR_EXTERN(__type) extern __declspec(export) __type
#define PR_IMPLEMENT(__type) __declspec(export) __type
#define PR_EXTERN_DATA(__type) extern __declspec(export) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(XP_OS2_VACPP)
#define PR_EXPORT(__type) extern __type
#define PR_EXPORT_DATA(__type) extern __type
#define PR_IMPORT(__type) extern __type
#define PR_IMPORT_DATA(__type) extern __type
#define PR_EXTERN(__type) extern __type
#define PR_IMPLEMENT(__type) __type
#define PR_EXTERN_DATA(__type) extern __type
#define PR_IMPLEMENT_DATA(__type) __type
#define PR_CALLBACK _Optlink
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
#else /* Unix */
#define PR_EXPORT(__type) extern __type
#define PR_EXPORT_DATA(__type) extern __type
#define PR_IMPORT(__type) extern __type
#define PR_IMPORT_DATA(__type) extern __type
#define PR_EXTERN(__type) extern __type
#define PR_IMPLEMENT(__type) __type
#define PR_EXTERN_DATA(__type) extern __type
#define PR_IMPLEMENT_DATA(__type) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#endif
#if defined(_NSPR_BUILD_)
#define NSPR_API(__type) PR_EXPORT(__type)
#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
#else
#define NSPR_API(__type) PR_IMPORT(__type)
#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
#endif
/***********************************************************************
** MACROS: PR_BEGIN_MACRO
** PR_END_MACRO
** DESCRIPTION:
** Macro body brackets so that macros with compound statement definitions
** behave syntactically more like functions when called.
***********************************************************************/
#define PR_BEGIN_MACRO do {
#define PR_END_MACRO } while (0)
/***********************************************************************
** MACROS: PR_BEGIN_EXTERN_C
** PR_END_EXTERN_C
** DESCRIPTION:
** Macro shorthands for conditional C++ extern block delimiters.
***********************************************************************/
#ifdef __cplusplus
#define PR_BEGIN_EXTERN_C extern "C" {
#define PR_END_EXTERN_C }
#else
#define PR_BEGIN_EXTERN_C
#define PR_END_EXTERN_C
#endif
/***********************************************************************
** MACROS: PR_BIT
** PR_BITMASK
** DESCRIPTION:
** Bit masking macros. XXX n must be <= 31 to be portable
***********************************************************************/
#define PR_BIT(n) ((PRUint32)1 << (n))
#define PR_BITMASK(n) (PR_BIT(n) - 1)
/***********************************************************************
** MACROS: PR_ROUNDUP
** PR_MIN
** PR_MAX
** DESCRIPTION:
** Commonly used macros for operations on compatible types.
***********************************************************************/
#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
#define PR_MIN(x,y) ((x)<(y)?(x):(y))
#define PR_MAX(x,y) ((x)>(y)?(x):(y))
PR_BEGIN_EXTERN_C
/************************************************************************
** TYPES: PRUint8
** PRInt8
** DESCRIPTION:
** The int8 types are known to be 8 bits each. There is no type that
** is equivalent to a plain "char".
************************************************************************/
#if PR_BYTES_PER_BYTE == 1
typedef unsigned char PRUint8;
/*
** Some cfront-based C++ compilers do not like 'signed char' and
** issue the warning message:
** warning: "signed" not implemented (ignored)
** For these compilers, we have to define PRInt8 as plain 'char'.
** Make sure that plain 'char' is indeed signed under these compilers.
*/
#if (defined(HPUX) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus < 199707L) \
|| (defined(SCO) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus == 1L)
typedef char PRInt8;
#else
typedef signed char PRInt8;
#endif
#else
#error No suitable type for PRInt8/PRUint8
#endif
/************************************************************************
** TYPES: PRUint16
** PRInt16
** DESCRIPTION:
** The int16 types are known to be 16 bits each.
************************************************************************/
#if PR_BYTES_PER_SHORT == 2
typedef unsigned short PRUint16;
typedef short PRInt16;
#else
#error No suitable type for PRInt16/PRUint16
#endif
/************************************************************************
** TYPES: PRUint32
** PRInt32
** DESCRIPTION:
** The int32 types are known to be 32 bits each.
************************************************************************/
#if PR_BYTES_PER_INT == 4
typedef unsigned int PRUint32;
typedef int PRInt32;
#define PR_INT32(x) x
#define PR_UINT32(x) x ## U
#elif PR_BYTES_PER_LONG == 4
typedef unsigned long PRUint32;
typedef long PRInt32;
#define PR_INT32(x) x ## L
#define PR_UINT32(x) x ## UL
#else
#error No suitable type for PRInt32/PRUint32
#endif
/************************************************************************
** TYPES: PRUint64
** PRInt64
** DESCRIPTION:
** The int64 types are known to be 64 bits each. Care must be used when
** declaring variables of type PRUint64 or PRInt64. Different hardware
** architectures and even different compilers have varying support for
** 64 bit values. The only guaranteed portability requires the use of
** the LL_ macros (see prlong.h).
************************************************************************/
#ifdef HAVE_LONG_LONG
#if PR_BYTES_PER_LONG == 8
typedef long PRInt64;
typedef unsigned long PRUint64;
#elif defined(WIN16)
typedef __int64 PRInt64;
typedef unsigned __int64 PRUint64;
#elif defined(WIN32) && !defined(__GNUC__)
typedef __int64 PRInt64;
typedef unsigned __int64 PRUint64;
#else
typedef long long PRInt64;
typedef unsigned long long PRUint64;
#endif /* PR_BYTES_PER_LONG == 8 */
#else /* !HAVE_LONG_LONG */
typedef struct {
#ifdef IS_LITTLE_ENDIAN
PRUint32 lo, hi;
#else
PRUint32 hi, lo;
#endif
} PRInt64;
typedef PRInt64 PRUint64;
#endif /* !HAVE_LONG_LONG */
/************************************************************************
** TYPES: PRUintn
** PRIntn
** DESCRIPTION:
** The PRIntn types are most appropriate for automatic variables. They are
** guaranteed to be at least 16 bits, though various architectures may
** define them to be wider (e.g., 32 or even 64 bits). These types are
** never valid for fields of a structure.
************************************************************************/
#if PR_BYTES_PER_INT >= 2
typedef int PRIntn;
typedef unsigned int PRUintn;
#else
#error 'sizeof(int)' not sufficient for platform use
#endif
/************************************************************************
** TYPES: PRFloat64
** DESCRIPTION:
** NSPR's floating point type is always 64 bits.
************************************************************************/
typedef double PRFloat64;
/************************************************************************
** TYPES: PRSize
** DESCRIPTION:
** A type for representing the size of objects.
************************************************************************/
typedef size_t PRSize;
/************************************************************************
** TYPES: PROffset32, PROffset64
** DESCRIPTION:
** A type for representing byte offsets from some location.
************************************************************************/
typedef PRInt32 PROffset32;
typedef PRInt64 PROffset64;
/************************************************************************
** TYPES: PRPtrDiff
** DESCRIPTION:
** A type for pointer difference. Variables of this type are suitable
** for storing a pointer or pointer sutraction.
************************************************************************/
typedef ptrdiff_t PRPtrdiff;
/************************************************************************
** TYPES: PRUptrdiff
** DESCRIPTION:
** A type for pointer difference. Variables of this type are suitable
** for storing a pointer or pointer sutraction.
************************************************************************/
typedef unsigned long PRUptrdiff;
/************************************************************************
** TYPES: PRBool
** DESCRIPTION:
** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
** for clarity of target type in assignments and actual arguments. Use
** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
** juast as you would C int-valued conditions.
************************************************************************/
typedef PRIntn PRBool;
#define PR_TRUE 1
#define PR_FALSE 0
/************************************************************************
** TYPES: PRPackedBool
** DESCRIPTION:
** Use PRPackedBOol within structs where bitfields are not desireable
** but minimum and consistant overhead matters.
************************************************************************/
typedef PRUint8 PRPackedBool;
/*
** Status code used by some routines that have a single point of failure or
** special status return.
*/
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
/*
** WARNING: The undocumented data types PRWord and PRUword are
** only used in the garbage collection and arena code. Do not
** use PRWord and PRUword in new code.
**
** A PRWord is an integer that is the same size as a void*.
** It implements the notion of a "word" in the Java Virtual
** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine
** Specification, Addison-Wesley, September 1996.
** http://java.sun.com/docs/books/vmspec/index.html.)
*/
typedef long PRWord;
typedef unsigned long PRUword;
#if defined(NO_NSPR_10_SUPPORT)
#else
/********* ???????????????? FIX ME ??????????????????????????? *****/
/********************** Some old definitions until pr=>ds transition is done ***/
/********************** Also, we are still using NSPR 1.0. GC ******************/
/*
** Fundamental NSPR macros, used nearly everywhere.
*/
#define PR_PUBLIC_API PR_IMPLEMENT
/*
** Macro body brackets so that macros with compound statement definitions
** behave syntactically more like functions when called.
*/
#define NSPR_BEGIN_MACRO do {
#define NSPR_END_MACRO } while (0)
/*
** Macro shorthands for conditional C++ extern block delimiters.
*/
#ifdef NSPR_BEGIN_EXTERN_C
#undef NSPR_BEGIN_EXTERN_C
#endif
#ifdef NSPR_END_EXTERN_C
#undef NSPR_END_EXTERN_C
#endif
#ifdef __cplusplus
#define NSPR_BEGIN_EXTERN_C extern "C" {
#define NSPR_END_EXTERN_C }
#else
#define NSPR_BEGIN_EXTERN_C
#define NSPR_END_EXTERN_C
#endif
#ifdef XP_MAC
#include "protypes.h"
#else
#include "obsolete/protypes.h"
#endif
/********* ????????????? End Fix me ?????????????????????????????? *****/
#endif /* NO_NSPR_10_SUPPORT */
PR_END_EXTERN_C
#endif /* prtypes_h___ */

View File

@ -0,0 +1,167 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
* This section typedefs the old 'native' types to the new PR<type>s.
* These definitions are scheduled to be eliminated at the earliest
* possible time. The NSPR API is implemented and documented using
* the new definitions.
*/
#if !defined(PROTYPES_H)
#define PROTYPES_H
typedef PRUintn uintn;
#ifndef _XP_Core_
typedef PRIntn intn;
#endif
/*
* BeOS already defines the integer types below in its standard
* header file SupportDefs.h.
*/
#ifdef XP_BEOS
#include <support/SupportDefs.h>
#elif defined(VMS)
/*
* OpenVMS already defines the integer types below in its standard
* header files ints.h and types.h.
*/
#include <ints.h>
#include <types.h>
#else
/* SVR4 typedef of uint is commonly found on UNIX machines. */
#ifdef XP_UNIX
#include <sys/types.h>
#endif
#if !defined(XP_UNIX) || defined(NTO)
typedef PRUintn uint;
#endif
typedef PRUint64 uint64;
#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2)
typedef PRUint32 uint32;
#else
typedef unsigned long uint32;
#endif
typedef PRUint16 uint16;
typedef PRUint8 uint8;
/*
* On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very
* common header file) defines the types int8, int16, int32, and int64.
* So we don't define these four types here to avoid conflicts in case
* the code also includes sys/types.h.
*/
#if defined(_PR_AIX_HAVE_BSD_INT_TYPES)
/* <sys/types.h> is already included */
#else
typedef PRInt64 int64;
/* /usr/include/model.h on HP-UX defines int8, int16, and int32 */
#if defined(HPUX)
#include <model.h>
#else
#if !defined(WIN32) || !defined(_WINSOCK2API_) /* defines its own "int32" */
#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2)
typedef PRInt32 int32;
#else
typedef long int32;
#endif
#endif
typedef PRInt16 int16;
typedef PRInt8 int8;
#endif /* HPUX */
#endif /* _PR_AIX_HAVE_BSD_INT_TYPES */
#endif /* XP_BEOS VMS */
typedef PRFloat64 float64;
typedef PRUptrdiff uptrdiff_t;
typedef PRUword uprword_t;
typedef PRWord prword_t;
/* Re: prbit.h */
#define TEST_BIT PR_TEST_BIT
#define SET_BIT PR_SET_BIT
#define CLEAR_BIT PR_CLEAR_BIT
/* Re: prarena.h->plarena.h */
#define PRArena PLArena
#define PRArenaPool PLArenaPool
#define PRArenaStats PLArenaStats
#define PR_ARENA_ALIGN PL_ARENA_ALIGN
#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL
#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE
#define PR_ARENA_GROW PL_ARENA_GROW
#define PR_ARENA_MARK PL_ARENA_MARK
#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED
#define PR_CLEAR_ARENA PL_CLEAR_ARENA
#define PR_ARENA_RELEASE PL_ARENA_RELEASE
#define PR_COUNT_ARENA PL_COUNT_ARENA
#define PR_ARENA_DESTROY PL_ARENA_DESTROY
#define PR_InitArenaPool PL_InitArenaPool
#define PR_FreeArenaPool PL_FreeArenaPool
#define PR_FinishArenaPool PL_FinishArenaPool
#define PR_CompactArenaPool PL_CompactArenaPool
#define PR_ArenaFinish PL_ArenaFinish
#define PR_ArenaAllocate PL_ArenaAllocate
#define PR_ArenaGrow PL_ArenaGrow
#define PR_ArenaRelease PL_ArenaRelease
#define PR_ArenaCountAllocation PL_ArenaCountAllocation
#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth
#define PR_ArenaCountGrowth PL_ArenaCountGrowth
#define PR_ArenaCountRelease PL_ArenaCountRelease
#define PR_ArenaCountRetract PL_ArenaCountRetract
/* Re: prhash.h->plhash.h */
#define PRHashEntry PLHashEntry
#define PRHashTable PLHashTable
#define PRHashNumber PLHashNumber
#define PRHashFunction PLHashFunction
#define PRHashComparator PLHashComparator
#define PRHashEnumerator PLHashEnumerator
#define PRHashAllocOps PLHashAllocOps
#define PR_NewHashTable PL_NewHashTable
#define PR_HashTableDestroy PL_HashTableDestroy
#define PR_HashTableRawLookup PL_HashTableRawLookup
#define PR_HashTableRawAdd PL_HashTableRawAdd
#define PR_HashTableRawRemove PL_HashTableRawRemove
#define PR_HashTableAdd PL_HashTableAdd
#define PR_HashTableRemove PL_HashTableRemove
#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries
#define PR_HashTableLookup PL_HashTableLookup
#define PR_HashTableDump PL_HashTableDump
#define PR_HashString PL_HashString
#define PR_CompareStrings PL_CompareStrings
#define PR_CompareValues PL_CompareValues
#if defined(XP_MAC)
#ifndef TRUE /* Mac standard is lower case true */
#define TRUE 1
#endif
#ifndef FALSE /* Mac standard is lower case false */
#define FALSE 0
#endif
#endif
#endif /* !defined(PROTYPES_H) */

View File

@ -0,0 +1,139 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
#ifndef plhash_h___
#define plhash_h___
/*
* API to portable hash table code.
*/
#include <stdio.h>
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef struct PLHashEntry PLHashEntry;
typedef struct PLHashTable PLHashTable;
typedef PRUint32 PLHashNumber;
#define PL_HASH_BITS 32 /* Number of bits in PLHashNumber */
typedef PLHashNumber (PR_CALLBACK *PLHashFunction)(const void *key);
typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2);
#if defined(XP_OS2_VACPP) && defined(VACPP_FLIP) /* for nsSpaceManager.cpp */
PR_END_EXTERN_C /* and nsHTMLDocument.cpp */
#endif
typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg);
#if defined(XP_OS2_VACPP) && defined(VACPP_FLIP)
PR_BEGIN_EXTERN_C
#endif
/* Flag bits in PLHashEnumerator's return value */
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */
#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */
#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */
typedef struct PLHashAllocOps {
void * (PR_CALLBACK *allocTable)(void *pool, PRSize size);
void (PR_CALLBACK *freeTable)(void *pool, void *item);
PLHashEntry * (PR_CALLBACK *allocEntry)(void *pool, const void *key);
void (PR_CALLBACK *freeEntry)(void *pool, PLHashEntry *he, PRUintn flag);
} PLHashAllocOps;
#define HT_FREE_VALUE 0 /* just free the entry's value */
#define HT_FREE_ENTRY 1 /* free value and entire entry */
struct PLHashEntry {
PLHashEntry *next; /* hash chain linkage */
PLHashNumber keyHash; /* key hash function result */
const void *key; /* ptr to opaque key */
void *value; /* ptr to opaque value */
};
struct PLHashTable {
PLHashEntry **buckets; /* vector of hash buckets */
PRUint32 nentries; /* number of entries in table */
PRUint32 shift; /* multiplicative hash shift */
PLHashFunction keyHash; /* key hash function */
PLHashComparator keyCompare; /* key comparison function */
PLHashComparator valueCompare; /* value comparison function */
const PLHashAllocOps *allocOps; /* allocation operations */
void *allocPriv; /* allocation private data */
#ifdef HASHMETER
PRUint32 nlookups; /* total number of lookups */
PRUint32 nsteps; /* number of hash chains traversed */
PRUint32 ngrows; /* number of table expansions */
PRUint32 nshrinks; /* number of table contractions */
#endif
};
/*
* Create a new hash table.
* If allocOps is null, use default allocator ops built on top of malloc().
*/
PR_EXTERN(PLHashTable *)
PL_NewHashTable(PRUint32 numBuckets, PLHashFunction keyHash,
PLHashComparator keyCompare, PLHashComparator valueCompare,
const PLHashAllocOps *allocOps, void *allocPriv);
PR_EXTERN(void)
PL_HashTableDestroy(PLHashTable *ht);
/* Higher level access methods */
PR_EXTERN(PLHashEntry *)
PL_HashTableAdd(PLHashTable *ht, const void *key, void *value);
PR_EXTERN(PRBool)
PL_HashTableRemove(PLHashTable *ht, const void *key);
PR_EXTERN(void *)
PL_HashTableLookup(PLHashTable *ht, const void *key);
PR_EXTERN(PRIntn)
PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg);
/* General-purpose C string hash function. */
PR_EXTERN(PLHashNumber)
PL_HashString(const void *key);
/* Compare strings using strcmp(), return true if equal. */
PR_EXTERN(PRIntn)
PL_CompareStrings(const void *v1, const void *v2);
/* Stub function just returns v1 == v2 */
PR_EXTERN(PRIntn)
PL_CompareValues(const void *v1, const void *v2);
/* Low level access methods */
PR_EXTERN(PLHashEntry **)
PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key);
PR_EXTERN(PLHashEntry *)
PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash,
const void *key, void *value);
PR_EXTERN(void)
PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he);
/* This can be trivially implemented using PL_HashTableEnumerateEntries. */
PR_EXTERN(PRIntn)
PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp);
PR_END_EXTERN_C
#endif /* plhash_h___ */

View File

@ -0,0 +1,428 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
#ifndef _plstr_h
#define _plstr_h
/*
* plstr.h
*
* This header file exports the API to the NSPR portable library or string-
* handling functions.
*
* This API was not designed as an "optimal" or "ideal" string library; it
* was based on the good ol' unix string.3 functions, and was written to
*
* 1) replace the libc functions, for cross-platform consistancy,
* 2) complete the API on platforms lacking common functions (e.g.,
* strcase*), and
* 3) to implement some obvious "closure" functions that I've seen
* people hacking around in our code.
*
* Point number three largely means that most functions have an "strn"
* limited-length version, and all comparison routines have a non-case-
* sensitive version available.
*/
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
* PL_strlen
*
* Returns the length of the provided string, not including the trailing '\0'.
*/
PR_EXTERN(PRUint32)
PL_strlen(const char *str);
/*
* PL_strnlen
*
* Returns the length of the provided string, not including the trailing '\0',
* up to the indicated maximum. The string will not be examined beyond the
* maximum; if no terminating '\0' is found, the maximum will be returned.
*/
PR_EXTERN(PRUint32)
PL_strnlen(const char *str, PRUint32 max);
/*
* PL_strcpy
*
* Copies the source string, up to and including the trailing '\0', into the
* destination buffer. It does not (can not) verify that the destination
* buffer is large enough. It returns the "dest" argument.
*/
PR_EXTERN(char *)
PL_strcpy(char *dest, const char *src);
/*
* PL_strncpy
*
* Copies the source string into the destination buffer, up to and including
* the trailing '\0' or up to and including the max'th character, whichever
* comes first. It does not (can not) verify that the destination buffer is
* large enough. If the source string is longer than the maximum length,
* the result will *not* be null-terminated (JLRU).
*/
PR_EXTERN(char *)
PL_strncpy(char *dest, const char *src, PRUint32 max);
/*
* PL_strncpyz
*
* Copies the source string into the destination buffer, up to and including
* the trailing '\0' or up but not including the max'th character, whichever
* comes first. It does not (can not) verify that the destination buffer is
* large enough. The destination string is always terminated with a '\0',
* unlike the traditional libc implementation. It returns the "dest" argument.
*
* NOTE: If you call this with a source "abcdefg" and a max of 5, the
* destination will end up with "abcd\0" (i.e., it's strlen length will be 4)!
*
* This means you can do this:
*
* char buffer[ SOME_SIZE ];
* PL_strncpyz(buffer, src, sizeof(buffer));
*
* and the result will be properly terminated.
*/
PR_EXTERN(char *)
PL_strncpyz(char *dest, const char *src, PRUint32 max);
/*
* PL_strdup
*
* Returns a pointer to a malloc'd extent of memory containing a duplicate
* of the argument string. The size of the allocated extent is one greater
* than the length of the argument string, because of the terminator. A
* null argument, like a zero-length argument, will result in a pointer to
* a one-byte extent containing the null value. This routine returns null
* upon malloc failure.
*/
PR_EXTERN(char *)
PL_strdup(const char *s);
/*
* PL_strfree
*
* Free memory allocated by PL_strdup
*/
PR_EXTERN(void)
PL_strfree(char *s);
/*
* PL_strndup
*
* Returns a pointer to a malloc'd extent of memory containing a duplicate
* of the argument string, up to the maximum specified. If the argument
* string has a length greater than the value of the specified maximum, the
* return value will be a pointer to an extent of memory of length one
* greater than the maximum specified. A null string, a zero-length string,
* or a zero maximum will all result in a pointer to a one-byte extent
* containing the null value. This routine returns null upon malloc failure.
*/
PR_EXTERN(char *)
PL_strndup(const char *s, PRUint32 max);
/*
* PL_strcat
*
* Appends a copy of the string pointed to by the second argument to the
* end of the string pointed to by the first. The destination buffer is
* not (can not be) checked for sufficient size. A null destination
* argument returns null; otherwise, the first argument is returned.
*/
PR_EXTERN(char *)
PL_strcat(char *dst, const char *src);
/*
* PL_strncat
*
* Appends a copy of the string pointed to by the second argument, up to
* the maximum size specified, to the end of the string pointed to by the
* first. The destination buffer is not (can not be) checked for sufficient
* size. A null destination argument returns null; otherwise, the first
* argument is returned. If the maximum size limits the copy, then the
* result will *not* be null-terminated (JLRU). A null destination
* returns null; otherwise, the destination argument is returned.
*/
PR_EXTERN(char *)
PL_strncat(char *dst, const char *src, PRUint32 max);
/*
* PL_strcatn
*
* Appends a copy of the string pointed to by the third argument, to the
* end of the string pointed to by the first. The second argument specifies
* the maximum size of the destination buffer, including the null termination.
* If the existing string in dst is longer than the max, no action is taken.
* The resulting string will be null-terminated. A null destination returns
* null; otherwise, the destination argument is returned.
*/
PR_EXTERN(char *)
PL_strcatn(char *dst, PRUint32 max, const char *src);
/*
* PL_strcmp
*
* Returns an integer, the sign of which -- positive, zero, or negative --
* reflects the lexical sorting order of the two strings indicated. The
* result is positive if the first string comes after the second. The
* NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strcmp(const char *a, const char *b);
/*
* PL_strncmp
*
* Returns an integer, the sign of which -- positive, zero, or negative --
* reflects the lexical sorting order of the two strings indicated, up to
* the maximum specified. The result is positive if the first string comes
* after the second. The NSPR implementation is not i18n. If the maximum
* is zero, only the existance or non-existance (pointer is null) of the
* strings is compared.
*/
PR_EXTERN(PRIntn)
PL_strncmp(const char *a, const char *b, PRUint32 max);
/*
* PL_strcasecmp
*
* Returns an integer, the sign of which -- positive, zero or negative --
* reflects the case-insensitive lexical sorting order of the two strings
* indicated. The result is positive if the first string comes after the
* second. The NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strcasecmp(const char *a, const char *b);
/*
* PL_strncasecmp
*
* Returns an integer, the sign of which -- positive, zero or negative --
* reflects the case-insensitive lexical sorting order of the first n characters
* of the two strings indicated. The result is positive if the first string comes
* after the second. The NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strncasecmp(const char *a, const char *b, PRUint32 max);
/*
* PL_strchr
*
* Returns a pointer to the first instance of the specified character in the
* provided string. It returns null if the character is not found, or if the
* provided string is null. The character may be the null character.
*/
PR_EXTERN(char *)
PL_strchr(const char *s, char c);
/*
* PL_strrchr
*
* Returns a pointer to the last instance of the specified character in the
* provided string. It returns null if the character is not found, or if the
* provided string is null. The character may be the null character.
*/
PR_EXTERN(char *)
PL_strrchr(const char *s, char c);
/*
* PL_strnchr
*
* Returns a pointer to the first instance of the specified character within the
* first n characters of the provided string. It returns null if the character
* is not found, or if the provided string is null. The character may be the
* null character.
*/
PR_EXTERN(char *)
PL_strnchr(const char *s, char c, PRUint32 n);
/*
* PL_strnrchr
*
* Returns a pointer to the last instance of the specified character within the
* first n characters of the provided string. It returns null if the character is
* not found, or if the provided string is null. The character may be the null
* character.
*/
PR_EXTERN(char *)
PL_strnrchr(const char *s, char c, PRUint32 n);
/*
* NOTE: Looking for strcasechr, strcaserchr, strncasechr, or strncaserchr?
* Use strpbrk, strprbrk, strnpbrk or strnprbrk.
*/
/*
* PL_strpbrk
*
* Returns a pointer to the first instance in the first string of any character
* (not including the terminating null character) of the second string. It returns
* null if either string is null.
*/
PR_EXTERN(char *)
PL_strpbrk(const char *s, const char *list);
/*
* PL_strprbrk
*
* Returns a pointer to the last instance in the first string of any character
* (not including the terminating null character) of the second string. It returns
* null if either string is null.
*/
PR_EXTERN(char *)
PL_strprbrk(const char *s, const char *list);
/*
* PL_strnpbrk
*
* Returns a pointer to the first instance (within the first n characters) of any
* character (not including the terminating null character) of the second string.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strnpbrk(const char *s, const char *list, PRUint32 n);
/*
* PL_strnprbrk
*
* Returns a pointer to the last instance (within the first n characters) of any
* character (not including the terminating null character) of the second string.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strnprbrk(const char *s, const char *list, PRUint32 n);
/*
* PL_strstr
*
* Returns a pointer to the first instance of the little string within the
* big one. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strstr(const char *big, const char *little);
/*
* PL_strrstr
*
* Returns a pointer to the last instance of the little string within the big one.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strrstr(const char *big, const char *little);
/*
* PL_strnstr
*
* Returns a pointer to the first instance of the little string within the first
* n characters of the big one. It returns null if either string is null. It
* returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strnstr(const char *big, const char *little, PRUint32 n);
/*
* PL_strnrstr
*
* Returns a pointer to the last instance of the little string within the first
* n characters of the big one. It returns null if either string is null. It
* returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strnrstr(const char *big, const char *little, PRUint32 max);
/*
* PL_strcasestr
*
* Returns a pointer to the first instance of the little string within the big one,
* ignoring case. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strcasestr(const char *big, const char *little);
/*
* PL_strcaserstr
*
* Returns a pointer to the last instance of the little string within the big one,
* ignoring case. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strcaserstr(const char *big, const char *little);
/*
* PL_strncasestr
*
* Returns a pointer to the first instance of the listtle string within the first
* n characters of the big one, ignoring case. It returns null if either string is
* null. It returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strncasestr(const char *big, const char *little, PRUint32 max);
/*
* PL_strncaserstr
*
* Returns a pointer to the last instance of the little string within the first
* n characters of the big one, ignoring case. It returns null if either string is
* null. It returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strncaserstr(const char *big, const char *little, PRUint32 max);
/*
* Things not (yet?) included: strspn/strcspn, strtok/strtok_r, strsep.
* memchr, memcmp, memcpy, memccpy, index, rindex, bcmp, bcopy, bzero.
* Any and all i18n/l10n stuff.
*/
PR_END_EXTERN_C
#endif /* _plstr_h */

View File

@ -0,0 +1,142 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/* GLOBAL FUNCTIONS:
** DESCRIPTION:
** PR Atomic operations
*/
#ifndef pratom_h___
#define pratom_h___
#include "prtypes.h"
#include "prlock.h"
PR_BEGIN_EXTERN_C
/*
** FUNCTION: PR_AtomicIncrement
** DESCRIPTION:
** Atomically increment a 32 bit value.
** INPUTS:
** val: a pointer to the value to increment
** RETURN:
** the returned value is the result of the increment
*/
NSPR_API(PRInt32) PR_AtomicIncrement(PRInt32 *val);
/*
** FUNCTION: PR_AtomicDecrement
** DESCRIPTION:
** Atomically decrement a 32 bit value.
** INPUTS:
** val: a pointer to the value to decrement
** RETURN:
** the returned value is the result of the decrement
*/
NSPR_API(PRInt32) PR_AtomicDecrement(PRInt32 *val);
/*
** FUNCTION: PR_AtomicSet
** DESCRIPTION:
** Atomically set a 32 bit value.
** INPUTS:
** val: A pointer to a 32 bit value to be set
** newval: The newvalue to assign to val
** RETURN:
** Returns the prior value
*/
NSPR_API(PRInt32) PR_AtomicSet(PRInt32 *val, PRInt32 newval);
/*
** FUNCTION: PR_AtomicAdd
** DESCRIPTION:
** Atomically add a 32 bit value.
** INPUTS:
** ptr: a pointer to the value to increment
** val: value to be added
** RETURN:
** the returned value is the result of the addition
*/
NSPR_API(PRInt32) PR_AtomicAdd(PRInt32 *ptr, PRInt32 val);
/*
** LIFO linked-list (stack)
*/
typedef struct PRStackElemStr PRStackElem;
struct PRStackElemStr {
PRStackElem *prstk_elem_next; /* next pointer MUST be at offset 0;
assembly language code relies on this */
};
typedef struct PRStackStr PRStack;
/*
** FUNCTION: PR_CreateStack
** DESCRIPTION:
** Create a stack, a LIFO linked list
** INPUTS:
** stack_name: a pointer to string containing the name of the stack
** RETURN:
** A pointer to the created stack, if successful, else NULL.
*/
NSPR_API(PRStack *) PR_CreateStack(const char *stack_name);
/*
** FUNCTION: PR_StackPush
** DESCRIPTION:
** Push an element on the top of the stack
** INPUTS:
** stack: pointer to the stack
** stack_elem: pointer to the stack element
** RETURN:
** None
*/
NSPR_API(void) PR_StackPush(PRStack *stack, PRStackElem *stack_elem);
/*
** FUNCTION: PR_StackPop
** DESCRIPTION:
** Remove the element on the top of the stack
** INPUTS:
** stack: pointer to the stack
** RETURN:
** A pointer to the stack element removed from the top of the stack,
** if non-empty,
** else NULL
*/
NSPR_API(PRStackElem *) PR_StackPop(PRStack *stack);
/*
** FUNCTION: PR_DestroyStack
** DESCRIPTION:
** Destroy the stack
** INPUTS:
** stack: pointer to the stack
** RETURN:
** PR_SUCCESS - if successfully deleted
** PR_FAILURE - if the stack is not empty
** PR_GetError will return
** PR_INVALID_STATE_ERROR - stack is not empty
*/
NSPR_API(PRStatus) PR_DestroyStack(PRStack *stack);
PR_END_EXTERN_C
#endif /* pratom_h___ */

View File

@ -0,0 +1,181 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_PC
#define XP_PC
#endif
#ifndef WIN32
#define WIN32
#endif
#ifndef WIN95
#define WIN95
#endif
#define PR_AF_INET6 23 /* same as AF_INET6 */
#if defined(_M_IX86) || defined(_X86_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 2
#elif defined(_ALPHA_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#else /* defined(_M_IX86) || defined(_X86_) */
#error unknown processor architecture
#endif /* defined(_M_IX86) || defined(_X86_) */
#define HAVE_LONG_LONG
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@ -0,0 +1,102 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
** File: prlock.h
** Description: API to basic locking functions of NSPR.
**
**
** NSPR provides basic locking mechanisms for thread synchronization. Locks
** are lightweight resource contention controls that prevent multiple threads
** from accessing something (code/data) simultaneously.
**/
#ifndef prlock_h___
#define prlock_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
/*
* PRLock --
*
* NSPR represents the lock as an opaque entity to the client of the
* API. All routines operate on a pointer to this opaque entity.
*/
typedef struct PRLock PRLock;
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/***********************************************************************
** FUNCTION: PR_NewLock
** DESCRIPTION:
** Returns a pointer to a newly created opaque lock object.
** INPUTS: void
** OUTPUTS: void
** RETURN: PRLock*
** If the lock can not be created because of resource constraints, NULL
** is returned.
**
***********************************************************************/
NSPR_API(PRLock*) PR_NewLock(void);
/***********************************************************************
** FUNCTION: PR_DestroyLock
** DESCRIPTION:
** Destroys a given opaque lock object.
** INPUTS: PRLock *lock
** Lock to be freed.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_DestroyLock(PRLock *lock);
/***********************************************************************
** FUNCTION: PR_Lock
** DESCRIPTION:
** Lock a lock.
** INPUTS: PRLock *lock
** Lock to locked.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_Lock(PRLock *lock);
/***********************************************************************
** FUNCTION: PR_Unlock
** DESCRIPTION:
** Unlock a lock. Unlocking an unlocked lock has undefined results.
** INPUTS: PRLock *lock
** Lock to unlocked.
** OUTPUTS: void
** RETURN: PR_STATUS
** Returns PR_FAILURE if the caller does not own the lock.
***********************************************************************/
NSPR_API(PRStatus) PR_Unlock(PRLock *lock);
PR_END_EXTERN_C
#endif /* prlock_h___ */

View File

@ -0,0 +1,409 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
** File: prlong.h
** Description: Portable access to 64 bit numerics
**
** Long-long (64-bit signed integer type) support. Some C compilers
** don't support 64 bit integers yet, so we use these macros to
** support both machines that do and don't.
**/
#ifndef prlong_h___
#define prlong_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/***********************************************************************
** DEFINES: LL_MaxInt
** LL_MinInt
** LL_Zero
** DESCRIPTION:
** Various interesting constants and static variable
** initializer
***********************************************************************/
#if defined(HAVE_WATCOM_BUG_2)
PRInt64 __pascal __loadds __export
LL_MaxInt(void);
PRInt64 __pascal __loadds __export
LL_MinInt(void);
PRInt64 __pascal __loadds __export
LL_Zero(void);
#else
NSPR_API(PRInt64) LL_MaxInt(void);
NSPR_API(PRInt64) LL_MinInt(void);
NSPR_API(PRInt64) LL_Zero(void);
#endif
#define LL_MAXINT LL_MaxInt()
#define LL_MININT LL_MinInt()
#define LL_ZERO LL_Zero()
#if defined(HAVE_LONG_LONG)
#if PR_BYTES_PER_LONG == 8
#define LL_INIT(hi, lo) ((hi ## L << 32) + lo ## L)
#elif (defined(WIN32) || defined(WIN16)) && !defined(__GNUC__)
#define LL_INIT(hi, lo) ((hi ## i64 << 32) + lo ## i64)
#else
#define LL_INIT(hi, lo) ((hi ## LL << 32) + lo ## LL)
#endif
/***********************************************************************
** MACROS: LL_*
** DESCRIPTION:
** The following macros define portable access to the 64 bit
** math facilities.
**
***********************************************************************/
/***********************************************************************
** MACROS: LL_<relational operators>
**
** LL_IS_ZERO Test for zero
** LL_EQ Test for equality
** LL_NE Test for inequality
** LL_GE_ZERO Test for zero or positive
** LL_CMP Compare two values
***********************************************************************/
#define LL_IS_ZERO(a) ((a) == 0)
#define LL_EQ(a, b) ((a) == (b))
#define LL_NE(a, b) ((a) != (b))
#define LL_GE_ZERO(a) ((a) >= 0)
#define LL_CMP(a, op, b) ((PRInt64)(a) op (PRInt64)(b))
#define LL_UCMP(a, op, b) ((PRUint64)(a) op (PRUint64)(b))
/***********************************************************************
** MACROS: LL_<logical operators>
**
** LL_AND Logical and
** LL_OR Logical or
** LL_XOR Logical exclusion
** LL_OR2 A disgusting deviation
** LL_NOT Negation (one's complement)
***********************************************************************/
#define LL_AND(r, a, b) ((r) = (a) & (b))
#define LL_OR(r, a, b) ((r) = (a) | (b))
#define LL_XOR(r, a, b) ((r) = (a) ^ (b))
#define LL_OR2(r, a) ((r) = (r) | (a))
#define LL_NOT(r, a) ((r) = ~(a))
/***********************************************************************
** MACROS: LL_<mathematical operators>
**
** LL_NEG Negation (two's complement)
** LL_ADD Summation (two's complement)
** LL_SUB Difference (two's complement)
***********************************************************************/
#define LL_NEG(r, a) ((r) = -(a))
#define LL_ADD(r, a, b) ((r) = (a) + (b))
#define LL_SUB(r, a, b) ((r) = (a) - (b))
/***********************************************************************
** MACROS: LL_<mathematical operators>
**
** LL_MUL Product (two's complement)
** LL_DIV Quotient (two's complement)
** LL_MOD Modulus (two's complement)
***********************************************************************/
#define LL_MUL(r, a, b) ((r) = (a) * (b))
#define LL_DIV(r, a, b) ((r) = (a) / (b))
#define LL_MOD(r, a, b) ((r) = (a) % (b))
/***********************************************************************
** MACROS: LL_<shifting operators>
**
** LL_SHL Shift left [0..64] bits
** LL_SHR Shift right [0..64] bits with sign extension
** LL_USHR Unsigned shift right [0..64] bits
** LL_ISHL Signed shift left [0..64] bits
***********************************************************************/
#define LL_SHL(r, a, b) ((r) = (PRInt64)(a) << (b))
#define LL_SHR(r, a, b) ((r) = (PRInt64)(a) >> (b))
#define LL_USHR(r, a, b) ((r) = (PRUint64)(a) >> (b))
#define LL_ISHL(r, a, b) ((r) = (PRInt64)(a) << (b))
/***********************************************************************
** MACROS: LL_<conversion operators>
**
** LL_L2I Convert to signed 32 bit
** LL_L2UI Convert to unsigned 32 bit
** LL_L2F Convert to floating point
** LL_L2D Convert to floating point
** LL_I2L Convert signed to 64 bit
** LL_UI2L Convert unsigned to 64 bit
** LL_F2L Convert float to 64 bit
** LL_D2L Convert float to 64 bit
***********************************************************************/
#define LL_L2I(i, l) ((i) = (PRInt32)(l))
#define LL_L2UI(ui, l) ((ui) = (PRUint32)(l))
#define LL_L2F(f, l) ((f) = (PRFloat64)(l))
#define LL_L2D(d, l) ((d) = (PRFloat64)(l))
#define LL_I2L(l, i) ((l) = (PRInt64)(i))
#define LL_UI2L(l, ui) ((l) = (PRInt64)(ui))
#define LL_F2L(l, f) ((l) = (PRInt64)(f))
#define LL_D2L(l, d) ((l) = (PRInt64)(d))
/***********************************************************************
** MACROS: LL_UDIVMOD
** DESCRIPTION:
** Produce both a quotient and a remainder given an unsigned
** INPUTS: PRUint64 a: The dividend of the operation
** PRUint64 b: The quotient of the operation
** OUTPUTS: PRUint64 *qp: pointer to quotient
** PRUint64 *rp: pointer to remainder
***********************************************************************/
#define LL_UDIVMOD(qp, rp, a, b) \
(*(qp) = ((PRUint64)(a) / (b)), \
*(rp) = ((PRUint64)(a) % (b)))
#else /* !HAVE_LONG_LONG */
#ifdef IS_LITTLE_ENDIAN
#define LL_INIT(hi, lo) {PR_INT32(lo), PR_INT32(hi)}
#else
#define LL_INIT(hi, lo) {PR_INT32(hi), PR_INT32(lo)}
#endif
#define LL_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0))
#define LL_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo))
#define LL_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo))
#define LL_GE_ZERO(a) (((a).hi >> 31) == 0)
#define LL_CMP(a, op, b) (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \
((PRInt32)(a).hi op (PRInt32)(b).hi))
#define LL_UCMP(a, op, b) (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \
((a).hi op (b).hi))
#define LL_AND(r, a, b) ((r).lo = (a).lo & (b).lo, \
(r).hi = (a).hi & (b).hi)
#define LL_OR(r, a, b) ((r).lo = (a).lo | (b).lo, \
(r).hi = (a).hi | (b).hi)
#define LL_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, \
(r).hi = (a).hi ^ (b).hi)
#define LL_OR2(r, a) ((r).lo = (r).lo | (a).lo, \
(r).hi = (r).hi | (a).hi)
#define LL_NOT(r, a) ((r).lo = ~(a).lo, \
(r).hi = ~(a).hi)
#define LL_NEG(r, a) ((r).lo = -(PRInt32)(a).lo, \
(r).hi = -(PRInt32)(a).hi - ((r).lo != 0))
#define LL_ADD(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
(r).lo = _a.lo + _b.lo; \
(r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \
}
#define LL_SUB(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
(r).lo = _a.lo - _b.lo; \
(r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \
}
#define LL_MUL(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
LL_MUL32(r, _a.lo, _b.lo); \
(r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \
}
#define _lo16(a) ((a) & PR_BITMASK(16))
#define _hi16(a) ((a) >> 16)
#define LL_MUL32(r, a, b) { \
PRUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \
_a1 = _hi16(a), _a0 = _lo16(a); \
_b1 = _hi16(b), _b0 = _lo16(b); \
_y0 = _a0 * _b0; \
_y1 = _a0 * _b1; \
_y2 = _a1 * _b0; \
_y3 = _a1 * _b1; \
_y1 += _hi16(_y0); /* can't carry */ \
_y1 += _y2; /* might carry */ \
if (_y1 < _y2) \
_y3 += (PRUint32)(PR_BIT(16)); /* propagate */ \
(r).lo = (_lo16(_y1) << 16) + _lo16(_y0); \
(r).hi = _y3 + _hi16(_y1); \
}
#define LL_UDIVMOD(qp, rp, a, b) ll_udivmod(qp, rp, a, b)
NSPR_API(void) ll_udivmod(PRUint64 *qp, PRUint64 *rp, PRUint64 a, PRUint64 b);
#define LL_DIV(r, a, b) { \
PRInt64 _a, _b; \
PRUint32 _negative = (PRInt32)(a).hi < 0; \
if (_negative) { \
LL_NEG(_a, a); \
} else { \
_a = a; \
} \
if ((PRInt32)(b).hi < 0) { \
_negative ^= 1; \
LL_NEG(_b, b); \
} else { \
_b = b; \
} \
LL_UDIVMOD(&(r), 0, _a, _b); \
if (_negative) \
LL_NEG(r, r); \
}
#define LL_MOD(r, a, b) { \
PRInt64 _a, _b; \
PRUint32 _negative = (PRInt32)(a).hi < 0; \
if (_negative) { \
LL_NEG(_a, a); \
} else { \
_a = a; \
} \
if ((PRInt32)(b).hi < 0) { \
LL_NEG(_b, b); \
} else { \
_b = b; \
} \
LL_UDIVMOD(0, &(r), _a, _b); \
if (_negative) \
LL_NEG(r, r); \
}
#define LL_SHL(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = _a.lo << ((b) & 31); \
(r).hi = (_a.hi << ((b) & 31)) | (_a.lo >> (32 - (b))); \
} else { \
(r).lo = 0; \
(r).hi = _a.lo << ((b) & 31); \
} \
} else { \
(r) = (a); \
} \
}
/* a is an PRInt32, b is PRInt32, r is PRInt64 */
#define LL_ISHL(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a.lo = (a); \
_a.hi = 0; \
if ((b) < 32) { \
(r).lo = (a) << ((b) & 31); \
(r).hi = ((a) >> (32 - (b))); \
} else { \
(r).lo = 0; \
(r).hi = (a) << ((b) & 31); \
} \
} else { \
(r).lo = (a); \
(r).hi = 0; \
} \
}
#define LL_SHR(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \
(r).hi = (PRInt32)_a.hi >> ((b) & 31); \
} else { \
(r).lo = (PRInt32)_a.hi >> ((b) & 31); \
(r).hi = (PRInt32)_a.hi >> 31; \
} \
} else { \
(r) = (a); \
} \
}
#define LL_USHR(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \
(r).hi = _a.hi >> ((b) & 31); \
} else { \
(r).lo = _a.hi >> ((b) & 31); \
(r).hi = 0; \
} \
} else { \
(r) = (a); \
} \
}
#define LL_L2I(i, l) ((i) = (l).lo)
#define LL_L2UI(ui, l) ((ui) = (l).lo)
#define LL_L2F(f, l) { double _d; LL_L2D(_d, l); (f) = (PRFloat64)_d; }
#define LL_L2D(d, l) { \
int _negative; \
PRInt64 _absval; \
\
_negative = (l).hi >> 31; \
if (_negative) { \
LL_NEG(_absval, l); \
} else { \
_absval = l; \
} \
(d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \
if (_negative) \
(d) = -(d); \
}
#define LL_I2L(l, i) { PRInt32 _i = ((PRInt32)(i)) >> 31; (l).lo = (i); (l).hi = _i; }
#define LL_UI2L(l, ui) ((l).lo = (ui), (l).hi = 0)
#define LL_F2L(l, f) { double _d = (double)f; LL_D2L(l, _d); }
#define LL_D2L(l, d) { \
int _negative; \
double _absval, _d_hi; \
PRInt64 _lo_d; \
\
_negative = ((d) < 0); \
_absval = _negative ? -(d) : (d); \
\
(l).hi = _absval / 4.294967296e9; \
(l).lo = 0; \
LL_L2D(_d_hi, l); \
_absval -= _d_hi; \
_lo_d.hi = 0; \
if (_absval < 0) { \
_lo_d.lo = -_absval; \
LL_SUB(l, l, _lo_d); \
} else { \
_lo_d.lo = _absval; \
LL_ADD(l, l, _lo_d); \
} \
\
if (_negative) \
LL_NEG(l, l); \
}
#endif /* !HAVE_LONG_LONG */
PR_END_EXTERN_C
#endif /* prlong_h___ */

View File

@ -0,0 +1,279 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
*----------------------------------------------------------------------
*
* prtime.h --
*
* NSPR date and time functions
*
*-----------------------------------------------------------------------
*/
#ifndef prtime_h___
#define prtime_h___
#include "prlong.h"
PR_BEGIN_EXTERN_C
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
#define PR_MSEC_PER_SEC 1000UL
#define PR_USEC_PER_SEC 1000000UL
#define PR_NSEC_PER_SEC 1000000000UL
#define PR_USEC_PER_MSEC 1000UL
#define PR_NSEC_PER_MSEC 1000000UL
/*
* PRTime --
*
* NSPR represents basic time as 64-bit signed integers relative
* to midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).
* (GMT is also known as Coordinated Universal Time, UTC.)
* The units of time are in microseconds. Negative times are allowed
* to represent times prior to the January 1970 epoch. Such values are
* intended to be exported to other systems or converted to human
* readable form.
*
* Notes on porting: PRTime corresponds to time_t in ANSI C. NSPR 1.0
* simply uses PRInt64.
*/
typedef PRInt64 PRTime;
/*
* Time zone and daylight saving time corrections applied to GMT to
* obtain the local time of some geographic location
*/
typedef struct PRTimeParameters {
PRInt32 tp_gmt_offset; /* the offset from GMT in seconds */
PRInt32 tp_dst_offset; /* contribution of DST in seconds */
} PRTimeParameters;
/*
* PRExplodedTime --
*
* Time broken down into human-readable components such as year, month,
* day, hour, minute, second, and microsecond. Time zone and daylight
* saving time corrections may be applied. If they are applied, the
* offsets from the GMT must be saved in the 'tm_params' field so that
* all the information is available to reconstruct GMT.
*
* Notes on porting: PRExplodedTime corrresponds to struct tm in
* ANSI C, with the following differences:
* - an additional field tm_usec;
* - replacing tm_isdst by tm_params;
* - the month field is spelled tm_month, not tm_mon;
* - we use absolute year, AD, not the year since 1900.
* The corresponding type in NSPR 1.0 is called PRTime. Below is
* a table of date/time type correspondence in the three APIs:
* API time since epoch time in components
* ANSI C time_t struct tm
* NSPR 1.0 PRInt64 PRTime
* NSPR 2.0 PRTime PRExplodedTime
*/
typedef struct PRExplodedTime {
PRInt32 tm_usec; /* microseconds past tm_sec (0-99999) */
PRInt32 tm_sec; /* seconds past tm_min (0-61, accomodating
up to two leap seconds) */
PRInt32 tm_min; /* minutes past tm_hour (0-59) */
PRInt32 tm_hour; /* hours past tm_day (0-23) */
PRInt32 tm_mday; /* days past tm_mon (1-31, note that it
starts from 1) */
PRInt32 tm_month; /* months past tm_year (0-11, Jan = 0) */
PRInt16 tm_year; /* absolute year, AD (note that we do not
count from 1900) */
PRInt8 tm_wday; /* calculated day of the week
(0-6, Sun = 0) */
PRInt16 tm_yday; /* calculated day of the year
(0-365, Jan 1 = 0) */
PRTimeParameters tm_params; /* time parameters used by conversion */
} PRExplodedTime;
/*
* PRTimeParamFn --
*
* A function of PRTimeParamFn type returns the time zone and
* daylight saving time corrections for some geographic location,
* given the current time in GMT. The input argument gmt should
* point to a PRExplodedTime that is in GMT, i.e., whose
* tm_params contains all 0's.
*
* For any time zone other than GMT, the computation is intended to
* consist of two steps:
* - Figure out the time zone correction, tp_gmt_offset. This number
* usually depends on the geographic location only. But it may
* also depend on the current time. For example, all of China
* is one time zone right now. But this situation may change
* in the future.
* - Figure out the daylight saving time correction, tp_dst_offset.
* This number depends on both the geographic location and the
* current time. Most of the DST rules are expressed in local
* current time. If so, one should apply the time zone correction
* to GMT before applying the DST rules.
*/
typedef PRTimeParameters (PR_CALLBACK_DECL *PRTimeParamFn)(const PRExplodedTime *gmt);
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/*
* The PR_Now routine returns the current time relative to the
* epoch, midnight, January 1, 1970 UTC. The units of the returned
* value are microseconds since the epoch.
*
* The values returned are not guaranteed to advance in a linear fashion
* due to the application of time correction protocols which synchronize
* computer clocks to some external time source. Consequently it should
* not be depended on for interval timing.
*
* The implementation is machine dependent.
* Cf. time_t time(time_t *tp) in ANSI C.
*/
#if defined(HAVE_WATCOM_BUG_2)
PRTime __pascal __export __loadds
#else
NSPR_API(PRTime)
#endif
PR_Now(void);
/*
* Expand time binding it to time parameters provided by PRTimeParamFn.
* The calculation is envisoned to proceed in the following steps:
* - From given PRTime, calculate PRExplodedTime in GMT
* - Apply the given PRTimeParamFn to the GMT that we just calculated
* to obtain PRTimeParameters.
* - Add the PRTimeParameters offsets to GMT to get the local time
* as PRExplodedTime.
*/
NSPR_API(void) PR_ExplodeTime(
PRTime usecs, PRTimeParamFn params, PRExplodedTime *exploded);
/* Reverse operation of PR_ExplodeTime */
#if defined(HAVE_WATCOM_BUG_2)
PRTime __pascal __export __loadds
#else
NSPR_API(PRTime)
#endif
PR_ImplodeTime(const PRExplodedTime *exploded);
/*
* Adjust exploded time to normalize field overflows after manipulation.
* Note that the following fields of PRExplodedTime should not be
* manipulated:
* - tm_month and tm_year: because the number of days in a month and
* number of days in a year are not constant, it is ambiguous to
* manipulate the month and year fields, although one may be tempted
* to. For example, what does "a month from January 31st" mean?
* - tm_wday and tm_yday: these fields are calculated by NSPR. Users
* should treat them as "read-only".
*/
NSPR_API(void) PR_NormalizeTime(
PRExplodedTime *exploded, PRTimeParamFn params);
/**********************************************************************/
/*********************** TIME PARAMETER FUNCTIONS *********************/
/**********************************************************************/
/* Time parameters that suit current host machine */
NSPR_API(PRTimeParameters) PR_LocalTimeParameters(const PRExplodedTime *gmt);
/* Time parameters that represent Greenwich Mean Time */
NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt);
/*
* Time parameters that represent the US Pacific Time Zone, with the
* current daylight saving time rules (for testing only)
*/
NSPR_API(PRTimeParameters) PR_USPacificTimeParameters(const PRExplodedTime *gmt);
/*
* This parses a time/date string into a PRTime
* (microseconds after "1-Jan-1970 00:00:00 GMT").
* It returns PR_SUCCESS on success, and PR_FAILURE
* if the time/date string can't be parsed.
*
* Many formats are handled, including:
*
* 14 Apr 89 03:20:12
* 14 Apr 89 03:20 GMT
* Fri, 17 Mar 89 4:01:33
* Fri, 17 Mar 89 4:01 GMT
* Mon Jan 16 16:12 PDT 1989
* Mon Jan 16 16:12 +0130 1989
* 6 May 1992 16:41-JST (Wednesday)
* 22-AUG-1993 10:59:12.82
* 22-AUG-1993 10:59pm
* 22-AUG-1993 12:59am
* 22-AUG-1993 12:59 PM
* Friday, August 04, 1995 3:54 PM
* 06/21/95 04:24:34 PM
* 20/06/95 21:07
* 95-06-08 19:32:48 EDT
*
* If the input string doesn't contain a description of the timezone,
* we consult the `default_to_gmt' to decide whether the string should
* be interpreted relative to the local time zone (PR_FALSE) or GMT (PR_TRUE).
* The correct value for this argument depends on what standard specified
* the time string which you are parsing.
*/
NSPR_API(PRStatus) PR_ParseTimeString (
const char *string,
PRBool default_to_gmt,
PRTime *result);
/*
* FIXME: should we also have a formatting function, such as asctime, ctime,
* and strftime in standard C library? But this would involve
* internationalization issues. Might want to provide a US English version.
*/
/**********************************************************************/
/*********************** OLD COMPATIBILITYFUNCTIONS *******************/
/**********************************************************************/
#ifndef NO_NSPR_10_SUPPORT
/* Format a time value into a buffer. Same semantics as strftime() */
NSPR_API(PRUint32) PR_FormatTime(char *buf, int buflen, const char *fmt,
const PRExplodedTime *tm);
/* Format a time value into a buffer. Time is always in US English format, regardless
* of locale setting.
*/
NSPR_API(PRUint32)
PR_FormatTimeUSEnglish( char* buf, PRUint32 bufSize,
const char* format, const PRExplodedTime* tm );
#endif /* NO_NSPR_10_SUPPORT */
PR_END_EXTERN_C
#endif /* prtime_h___ */

View File

@ -0,0 +1,475 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (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.
*/
/*
** File: prtypes.h
** Description: Definitions of NSPR's basic types
**
** Prototypes and macros used to make up for deficiencies in ANSI environments
** that we have found.
**
** Since we do not wrap <stdlib.h> and all the other standard headers, authors
** of portable code will not know in general that they need these definitions.
** Instead of requiring these authors to find the dependent uses in their code
** and take the following steps only in those C files, we take steps once here
** for all C files.
**/
#ifndef prtypes_h___
#define prtypes_h___
#ifdef MDCPUCFG
#include MDCPUCFG
#else
#include "prcpucfg.h"
#endif
#include <stddef.h>
/***********************************************************************
** MACROS: PR_EXTERN
** PR_IMPLEMENT
** DESCRIPTION:
** These are only for externally visible routines and globals. For
** internal routines, just use "extern" for type checking and that
** will not export internal cross-file or forward-declared symbols.
** Define a macro for declaring procedures return types. We use this to
** deal with windoze specific type hackery for DLL definitions. Use
** PR_EXTERN when the prototype for the method is declared. Use
** PR_IMPLEMENT for the implementation of the method.
**
** Example:
** in dowhim.h
** PR_EXTERN( void ) DoWhatIMean( void );
** in dowhim.c
** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
**
**
***********************************************************************/
#if defined(WIN32)
#if defined(__GNUC__)
#undef _declspec
#define _declspec(x) __declspec(x)
#endif
#define PR_EXPORT(__type) extern _declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern _declspec(dllexport) __type
#define PR_IMPORT(__type) _declspec(dllimport) __type
#define PR_IMPORT_DATA(__type) _declspec(dllimport) __type
#define PR_EXTERN(__type) extern _declspec(dllexport) __type
#define PR_IMPLEMENT(__type) _declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern _declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) _declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(XP_BEOS)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPORT(__type) extern __declspec(dllexport) __type
#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_EXTERN(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(WIN16)
#define PR_CALLBACK_DECL __cdecl
#if defined(_WINDLL)
#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
#define PR_EXPORT_DATA(__type) extern __type _export
#define PR_IMPORT_DATA(__type) extern __type _export
#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
#define PR_EXTERN_DATA(__type) extern __type _export
#define PR_IMPLEMENT_DATA(__type) __type _export
#define PR_CALLBACK __cdecl __loadds
#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
#else /* this must be .EXE */
#define PR_EXPORT(__type) extern __type _cdecl _export
#define PR_IMPORT(__type) extern __type _cdecl _export
#define PR_EXPORT_DATA(__type) extern __type _export
#define PR_IMPORT_DATA(__type) extern __type _export
#define PR_EXTERN(__type) extern __type _cdecl _export
#define PR_IMPLEMENT(__type) __type _cdecl _export
#define PR_EXTERN_DATA(__type) extern __type _export
#define PR_IMPLEMENT_DATA(__type) __type _export
#define PR_CALLBACK __cdecl __loadds
#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
#endif /* _WINDLL */
#elif defined(XP_MAC)
#define PR_EXPORT(__type) extern __declspec(export) __type
#define PR_EXPORT_DATA(__type) extern __declspec(export) __type
#define PR_IMPORT(__type) extern __declspec(export) __type
#define PR_IMPORT_DATA(__type) extern __declspec(export) __type
#define PR_EXTERN(__type) extern __declspec(export) __type
#define PR_IMPLEMENT(__type) __declspec(export) __type
#define PR_EXTERN_DATA(__type) extern __declspec(export) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(XP_OS2_VACPP)
#define PR_EXPORT(__type) extern __type
#define PR_EXPORT_DATA(__type) extern __type
#define PR_IMPORT(__type) extern __type
#define PR_IMPORT_DATA(__type) extern __type
#define PR_EXTERN(__type) extern __type
#define PR_IMPLEMENT(__type) __type
#define PR_EXTERN_DATA(__type) extern __type
#define PR_IMPLEMENT_DATA(__type) __type
#define PR_CALLBACK _Optlink
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
#else /* Unix */
#define PR_EXPORT(__type) extern __type
#define PR_EXPORT_DATA(__type) extern __type
#define PR_IMPORT(__type) extern __type
#define PR_IMPORT_DATA(__type) extern __type
#define PR_EXTERN(__type) extern __type
#define PR_IMPLEMENT(__type) __type
#define PR_EXTERN_DATA(__type) extern __type
#define PR_IMPLEMENT_DATA(__type) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#endif
#if defined(_NSPR_BUILD_)
#define NSPR_API(__type) PR_EXPORT(__type)
#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
#else
#define NSPR_API(__type) PR_IMPORT(__type)
#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
#endif
/***********************************************************************
** MACROS: PR_BEGIN_MACRO
** PR_END_MACRO
** DESCRIPTION:
** Macro body brackets so that macros with compound statement definitions
** behave syntactically more like functions when called.
***********************************************************************/
#define PR_BEGIN_MACRO do {
#define PR_END_MACRO } while (0)
/***********************************************************************
** MACROS: PR_BEGIN_EXTERN_C
** PR_END_EXTERN_C
** DESCRIPTION:
** Macro shorthands for conditional C++ extern block delimiters.
***********************************************************************/
#ifdef __cplusplus
#define PR_BEGIN_EXTERN_C extern "C" {
#define PR_END_EXTERN_C }
#else
#define PR_BEGIN_EXTERN_C
#define PR_END_EXTERN_C
#endif
/***********************************************************************
** MACROS: PR_BIT
** PR_BITMASK
** DESCRIPTION:
** Bit masking macros. XXX n must be <= 31 to be portable
***********************************************************************/
#define PR_BIT(n) ((PRUint32)1 << (n))
#define PR_BITMASK(n) (PR_BIT(n) - 1)
/***********************************************************************
** MACROS: PR_ROUNDUP
** PR_MIN
** PR_MAX
** DESCRIPTION:
** Commonly used macros for operations on compatible types.
***********************************************************************/
#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
#define PR_MIN(x,y) ((x)<(y)?(x):(y))
#define PR_MAX(x,y) ((x)>(y)?(x):(y))
PR_BEGIN_EXTERN_C
/************************************************************************
** TYPES: PRUint8
** PRInt8
** DESCRIPTION:
** The int8 types are known to be 8 bits each. There is no type that
** is equivalent to a plain "char".
************************************************************************/
#if PR_BYTES_PER_BYTE == 1
typedef unsigned char PRUint8;
/*
** Some cfront-based C++ compilers do not like 'signed char' and
** issue the warning message:
** warning: "signed" not implemented (ignored)
** For these compilers, we have to define PRInt8 as plain 'char'.
** Make sure that plain 'char' is indeed signed under these compilers.
*/
#if (defined(HPUX) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus < 199707L) \
|| (defined(SCO) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus == 1L)
typedef char PRInt8;
#else
typedef signed char PRInt8;
#endif
#else
#error No suitable type for PRInt8/PRUint8
#endif
/************************************************************************
** TYPES: PRUint16
** PRInt16
** DESCRIPTION:
** The int16 types are known to be 16 bits each.
************************************************************************/
#if PR_BYTES_PER_SHORT == 2
typedef unsigned short PRUint16;
typedef short PRInt16;
#else
#error No suitable type for PRInt16/PRUint16
#endif
/************************************************************************
** TYPES: PRUint32
** PRInt32
** DESCRIPTION:
** The int32 types are known to be 32 bits each.
************************************************************************/
#if PR_BYTES_PER_INT == 4
typedef unsigned int PRUint32;
typedef int PRInt32;
#define PR_INT32(x) x
#define PR_UINT32(x) x ## U
#elif PR_BYTES_PER_LONG == 4
typedef unsigned long PRUint32;
typedef long PRInt32;
#define PR_INT32(x) x ## L
#define PR_UINT32(x) x ## UL
#else
#error No suitable type for PRInt32/PRUint32
#endif
/************************************************************************
** TYPES: PRUint64
** PRInt64
** DESCRIPTION:
** The int64 types are known to be 64 bits each. Care must be used when
** declaring variables of type PRUint64 or PRInt64. Different hardware
** architectures and even different compilers have varying support for
** 64 bit values. The only guaranteed portability requires the use of
** the LL_ macros (see prlong.h).
************************************************************************/
#ifdef HAVE_LONG_LONG
#if PR_BYTES_PER_LONG == 8
typedef long PRInt64;
typedef unsigned long PRUint64;
#elif defined(WIN16)
typedef __int64 PRInt64;
typedef unsigned __int64 PRUint64;
#elif defined(WIN32) && !defined(__GNUC__)
typedef __int64 PRInt64;
typedef unsigned __int64 PRUint64;
#else
typedef long long PRInt64;
typedef unsigned long long PRUint64;
#endif /* PR_BYTES_PER_LONG == 8 */
#else /* !HAVE_LONG_LONG */
typedef struct {
#ifdef IS_LITTLE_ENDIAN
PRUint32 lo, hi;
#else
PRUint32 hi, lo;
#endif
} PRInt64;
typedef PRInt64 PRUint64;
#endif /* !HAVE_LONG_LONG */
/************************************************************************
** TYPES: PRUintn
** PRIntn
** DESCRIPTION:
** The PRIntn types are most appropriate for automatic variables. They are
** guaranteed to be at least 16 bits, though various architectures may
** define them to be wider (e.g., 32 or even 64 bits). These types are
** never valid for fields of a structure.
************************************************************************/
#if PR_BYTES_PER_INT >= 2
typedef int PRIntn;
typedef unsigned int PRUintn;
#else
#error 'sizeof(int)' not sufficient for platform use
#endif
/************************************************************************
** TYPES: PRFloat64
** DESCRIPTION:
** NSPR's floating point type is always 64 bits.
************************************************************************/
typedef double PRFloat64;
/************************************************************************
** TYPES: PRSize
** DESCRIPTION:
** A type for representing the size of objects.
************************************************************************/
typedef size_t PRSize;
/************************************************************************
** TYPES: PROffset32, PROffset64
** DESCRIPTION:
** A type for representing byte offsets from some location.
************************************************************************/
typedef PRInt32 PROffset32;
typedef PRInt64 PROffset64;
/************************************************************************
** TYPES: PRPtrDiff
** DESCRIPTION:
** A type for pointer difference. Variables of this type are suitable
** for storing a pointer or pointer sutraction.
************************************************************************/
typedef ptrdiff_t PRPtrdiff;
/************************************************************************
** TYPES: PRUptrdiff
** DESCRIPTION:
** A type for pointer difference. Variables of this type are suitable
** for storing a pointer or pointer sutraction.
************************************************************************/
typedef unsigned long PRUptrdiff;
/************************************************************************
** TYPES: PRBool
** DESCRIPTION:
** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
** for clarity of target type in assignments and actual arguments. Use
** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
** juast as you would C int-valued conditions.
************************************************************************/
typedef PRIntn PRBool;
#define PR_TRUE 1
#define PR_FALSE 0
/************************************************************************
** TYPES: PRPackedBool
** DESCRIPTION:
** Use PRPackedBOol within structs where bitfields are not desireable
** but minimum and consistant overhead matters.
************************************************************************/
typedef PRUint8 PRPackedBool;
/*
** Status code used by some routines that have a single point of failure or
** special status return.
*/
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
/*
** WARNING: The undocumented data types PRWord and PRUword are
** only used in the garbage collection and arena code. Do not
** use PRWord and PRUword in new code.
**
** A PRWord is an integer that is the same size as a void*.
** It implements the notion of a "word" in the Java Virtual
** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine
** Specification, Addison-Wesley, September 1996.
** http://java.sun.com/docs/books/vmspec/index.html.)
*/
typedef long PRWord;
typedef unsigned long PRUword;
#if defined(NO_NSPR_10_SUPPORT)
#else
/********* ???????????????? FIX ME ??????????????????????????? *****/
/********************** Some old definitions until pr=>ds transition is done ***/
/********************** Also, we are still using NSPR 1.0. GC ******************/
/*
** Fundamental NSPR macros, used nearly everywhere.
*/
#define PR_PUBLIC_API PR_IMPLEMENT
/*
** Macro body brackets so that macros with compound statement definitions
** behave syntactically more like functions when called.
*/
#define NSPR_BEGIN_MACRO do {
#define NSPR_END_MACRO } while (0)
/*
** Macro shorthands for conditional C++ extern block delimiters.
*/
#ifdef NSPR_BEGIN_EXTERN_C
#undef NSPR_BEGIN_EXTERN_C
#endif
#ifdef NSPR_END_EXTERN_C
#undef NSPR_END_EXTERN_C
#endif
#ifdef __cplusplus
#define NSPR_BEGIN_EXTERN_C extern "C" {
#define NSPR_END_EXTERN_C }
#else
#define NSPR_BEGIN_EXTERN_C
#define NSPR_END_EXTERN_C
#endif
#ifdef XP_MAC
#include "protypes.h"
#else
#include "obsolete/protypes.h"
#endif
/********* ????????????? End Fix me ?????????????????????????????? *****/
#endif /* NO_NSPR_10_SUPPORT */
PR_END_EXTERN_C
#endif /* prtypes_h___ */

View File

@ -0,0 +1,83 @@
rem common include files
rem --------------------
copy ..\..\..\dist\include\nsCOMPtr.h mozilla\include
copy ..\..\..\dist\include\nsCRT.h mozilla\include
copy ..\..\..\dist\include\nsCom.h mozilla\include
copy ..\..\..\dist\include\nsComponentManagerUtils.h mozilla\include
copy ..\..\..\dist\include\nsCppSharedAllocator.h mozilla\include
copy ..\..\..\dist\include\nsDebug.h mozilla\include
copy ..\..\..\dist\include\nsError.h mozilla\include
copy ..\..\..\dist\include\nsIAllocator.h mozilla\include
copy ..\..\..\dist\include\nsIAtom.h mozilla\include
copy ..\..\..\dist\include\nsIBaseStream.h mozilla\include
copy ..\..\..\dist\include\nsIComponentManager.h mozilla\include
copy ..\..\..\dist\include\nsID.h mozilla\include
copy ..\..\..\dist\include\nsIEnumerator.h mozilla\include
copy ..\..\..\dist\include\nsIFactory.h mozilla\include
copy ..\..\..\dist\include\nsIFileUtilities.h mozilla\include
copy ..\..\..\dist\include\nsIID.h mozilla\include
copy ..\..\..\dist\include\nsIInputStream.h mozilla\include
copy ..\..\..\dist\include\nsIOutputStream.h mozilla\include
copy ..\..\..\dist\include\nsIPlugin.h mozilla\include
copy ..\..\..\dist\include\nsIPluginInputStream.h mozilla\include
copy ..\..\..\dist\include\nsIPluginInputStream2.h mozilla\include
copy ..\..\..\dist\include\nsIPluginInstance.h mozilla\include
copy ..\..\..\dist\include\nsIPluginInstancePeer.h mozilla\include
copy ..\..\..\dist\include\nsIPluginManager.h mozilla\include
copy ..\..\..\dist\include\nsIPluginManager2.h mozilla\include
copy ..\..\..\dist\include\nsIPluginStreamInfo.h mozilla\include
copy ..\..\..\dist\include\nsIPluginStreamListener.h mozilla\include
copy ..\..\..\dist\include\nsIPluginTagInfo.h mozilla\include
copy ..\..\..\dist\include\nsIPluginTagInfo2.h mozilla\include
copy ..\..\..\dist\include\nsIServiceManager.h mozilla\include
copy ..\..\..\dist\include\nsISupports.h mozilla\include
copy ..\..\..\dist\include\nsISupportsUtils.h mozilla\include
copy ..\..\..\dist\include\nsIWindowlessPlugInstPeer.h mozilla\include
copy ..\..\..\dist\include\nsRepository.h mozilla\include
copy ..\..\..\dist\include\nsStr.h mozilla\include
copy ..\..\..\dist\include\nsString.h mozilla\include
copy ..\..\..\dist\include\nsString2.h mozilla\include
copy ..\..\..\dist\include\nsTraceRefcnt.h mozilla\include
copy ..\..\..\dist\include\nscore.h mozilla\include
copy ..\..\..\dist\include\nsplugin.h mozilla\include
copy ..\..\..\dist\include\nsplugindefs.h mozilla\include
copy ..\..\..\dist\include\nsrootidl.h mozilla\include
rem debug specific include files
rem ----------------------------
copy ..\..\..\dist\Win32_d.obj\include\plhash.h mozilla\debug\include
copy ..\..\..\dist\Win32_d.obj\include\plstr.h mozilla\debug\include
copy ..\..\..\dist\Win32_d.obj\include\pratom.h mozilla\debug\include
copy ..\..\..\dist\Win32_d.obj\include\prcpucfg.h mozilla\debug\include
copy ..\..\..\dist\Win32_d.obj\include\prlock.h mozilla\debug\include
copy ..\..\..\dist\Win32_d.obj\include\prlong.h mozilla\debug\include
copy ..\..\..\dist\Win32_d.obj\include\prtime.h mozilla\debug\include
copy ..\..\..\dist\Win32_d.obj\include\prtypes.h mozilla\debug\include
copy ..\..\..\dist\Win32_d.obj\include\obsolete\protypes.h mozilla\debug\include\obsolete
rem release specific include files
rem ------------------------------
copy ..\..\..\dist\Win32_o.obj\include\plhash.h mozilla\release\include
copy ..\..\..\dist\Win32_o.obj\include\plstr.h mozilla\release\include
copy ..\..\..\dist\Win32_o.obj\include\pratom.h mozilla\release\include
copy ..\..\..\dist\Win32_o.obj\include\prcpucfg.h mozilla\release\include
copy ..\..\..\dist\Win32_o.obj\include\prlock.h mozilla\release\include
copy ..\..\..\dist\Win32_o.obj\include\prlong.h mozilla\release\include
copy ..\..\..\dist\Win32_o.obj\include\prtime.h mozilla\release\include
copy ..\..\..\dist\Win32_o.obj\include\prtypes.h mozilla\release\include
copy ..\..\..\dist\Win32_o.obj\include\obsolete\protypes.h mozilla\release\include\obsolete
rem debug specific libs
rem -------------------
copy ..\..\..\dist\Win32_d.obj\lib\xpcom.lib mozilla\debug\lib
rem release specific libs
rem ---------------------
copy ..\..\..\dist\Win32_o.obj\lib\xpcom.lib mozilla\release\lib