Landed raptor modular netlib stuff

This commit is contained in:
scullin 1998-05-22 23:38:40 +00:00
Родитель 2c5a97d973
Коммит 213aa607f0
47 изменённых файлов: 5782 добавлений и 54 удалений

2
network/cache/makefile.win поставляемый
Просмотреть файл

@ -90,8 +90,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib

2
network/cache/mkcache.c поставляемый
Просмотреть файл

@ -1802,7 +1802,7 @@ NET_CacheConverter (FO_Present_Types format_out,
*/
for(i=0; *cp && i < 4; i++)
{
*cp = XP_TO_UPPER(*cp);
*cp = NET_TO_UPPER(*cp);
cp++;
}
*cp = '\0'; /* make sure it's terminated */

16
network/cache/mkmemcac.c поставляемый
Просмотреть файл

@ -39,7 +39,9 @@
#include "mkstream.h"
#include "extcache.h"
#include "mkmemcac.h"
#ifndef MODULAR_NETLIB
#include "libimg.h" /* Image Lib public API. */
#endif
#include "prclist.h"
#include "prmem.h"
#include "plstr.h"
@ -375,8 +377,8 @@ PRIVATE int net_CacheHashComp(net_MemoryCacheObject * obj1,
* so that "news:MSGID" and "news:MSGID?headers=all" share the same cache
* file.
*/
if((XP_TO_UPPER(obj1->cache_obj.address[0]) == 'N'
|| XP_TO_UPPER(obj1->cache_obj.address[0]) == 'S')
if((NET_TO_UPPER(obj1->cache_obj.address[0]) == 'N'
|| NET_TO_UPPER(obj1->cache_obj.address[0]) == 'S')
&& NET_URL_Type(obj1->cache_obj.address) == NEWS_TYPE_URL)
{
ques1 = PL_strchr(obj1->cache_obj.address, '?');
@ -384,8 +386,8 @@ PRIVATE int net_CacheHashComp(net_MemoryCacheObject * obj1,
*ques1 = '\0';
}
if((XP_TO_UPPER(obj2->cache_obj.address[0]) == 'N'
|| XP_TO_UPPER(obj2->cache_obj.address[0]) == 'S')
if((NET_TO_UPPER(obj2->cache_obj.address[0]) == 'N'
|| NET_TO_UPPER(obj2->cache_obj.address[0]) == 'S')
&& NET_URL_Type(obj2->cache_obj.address) == NEWS_TYPE_URL)
{
ques2 = PL_strchr(obj2->cache_obj.address, '?');
@ -481,12 +483,12 @@ PRIVATE uint32 net_CacheHashFunc(net_MemoryCacheObject * obj1)
x = (unsigned const char *) obj1->cache_obj.address;
/* figure out if it's a news type URL */
if((XP_TO_UPPER(obj1->cache_obj.address[0]) == 'N'
|| XP_TO_UPPER(obj1->cache_obj.address[0]) == 'S')
if((NET_TO_UPPER(obj1->cache_obj.address[0]) == 'N'
|| NET_TO_UPPER(obj1->cache_obj.address[0]) == 'S')
&& NET_URL_Type(obj1->cache_obj.address) == NEWS_TYPE_URL)
news_type_url = TRUE;
/* figure out if it's an IMAP type URL */
else if (XP_TO_UPPER(obj1->cache_obj.address[0]) == 'M' &&
else if (NET_TO_UPPER(obj1->cache_obj.address[0]) == 'M' &&
!PL_strncasecmp(obj1->cache_obj.address,"Mailbox://",10))
imap_type_url = TRUE;

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

@ -81,8 +81,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -41,10 +41,12 @@ MISCDEP=$(LLIBS)
OBJS= \
.\$(OBJDIR)\cvactive.obj \
.\$(OBJDIR)\cvchunk.obj \
!ifndef MODULAR_NETLIB
.\$(OBJDIR)\cvcolor.obj \
.\$(OBJDIR)\cvdisk.obj \
.\$(OBJDIR)\cvmime.obj \
.\$(OBJDIR)\cvpics.obj \
!endif
.\$(OBJDIR)\cvdisk.obj \
.\$(OBJDIR)\cvsimple.obj \
.\$(OBJDIR)\cvunzip.obj \
.\$(OBJDIR)\cvjscfg.obj \
@ -55,10 +57,12 @@ OBJS= \
TMP_CSRCS = \
cvactive.c \
cvchunk.c \
!ifndef MODULAR_NETLIB
cvcolor.c \
cvdisk.c \
cvmime.c \
cvpics.c \
!endif
cvdisk.c \
cvsimple.c \
cvunzip.c \
cvjscfg.c \
@ -109,8 +113,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -79,8 +79,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib

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

@ -33,7 +33,6 @@
#include "xp_mcom.h"
#include "jscookie.h"
#include "ds.h"
#include "htmldlgs.h"
#include "xpgetstr.h"
extern int MK_ACCESS_JAVASCRIPT_COOKIE_FILTER;

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

@ -139,8 +139,6 @@ LINCS=-I$(PUBLIC)\jtools \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib

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

@ -32,7 +32,7 @@
#include "prefapi.h"
#include "mkpadpac.h"
#if defined(XP_WIN)
#if defined(XP_WIN) && !defined(MODULAR_NETLIB)
#define ASYNC_DNS
#endif

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

@ -77,11 +77,15 @@
#include "jspubtd.h"
#endif
#ifndef MODULAR_NETLIB
#include "libimg.h" /* Image Lib public API. */
#include "il_strm.h" /* Image Lib public API. */
#endif
#include "libi18n.h"
#ifndef MODULAR_NETLIB
#include "htmldlgs.h"
#endif
#include "np.h"
#include "prefapi.h"
@ -115,7 +119,9 @@
#include "xplocale.h"
/* This is only until all platforms have libfont/ checked in */
#ifndef MODULAR_NETLIB
#define WEBFONTS
#endif
#ifdef WEBFONTS
#include "nf.h"

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

@ -21,6 +21,7 @@
*/
#include "mkutils.h"
#include "netutils.h"
#include "xp.h"
#include "mkparse.h"
#include "mkhelp.h"
@ -350,7 +351,7 @@ NET_ParseNetHelpURL(URL_Struct *URL_s)
while (*pCharacter)
{
*pCharacter = (char) XP_TO_LOWER((unsigned int) *pCharacter);
*pCharacter = (char) NET_TO_LOWER((unsigned int) *pCharacter);
pCharacter++;
}

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

@ -20,6 +20,7 @@
*/
#include "mkutils.h"
#include "netutils.h"
#include "xp.h"
#include "mkparse.h"
#include "xp_time.h"
@ -1241,7 +1242,7 @@ int NET_MakeRelativeURL( char *base_url,
/* Case-sensitive for UNIX */
*(url_ptr-1) != *(base_ptr-1) )
#else
XP_TO_LOWER(*(url_ptr-1)) != XP_TO_LOWER(*(base_ptr-1)) )
NET_TO_LOWER(*(url_ptr-1)) != NET_TO_LOWER(*(base_ptr-1)) )
#endif
{
Result = NET_URL_NOT_ON_SAME_DEVICE;
@ -1268,7 +1269,7 @@ int NET_MakeRelativeURL( char *base_url,
/* Case-sensitive for UNIX */
*base_ptr == *url_ptr &&
#else
XP_TO_LOWER(*base_ptr) == XP_TO_LOWER(*url_ptr) &&
NET_TO_LOWER(*base_ptr) == NET_TO_LOWER(*url_ptr) &&
#endif
*base_ptr != '\0' && *url_ptr != '\0' ){
base_ptr++;

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

@ -73,6 +73,9 @@ NET_WritePostData(MWContext *context,
extern int NET_UUEncode(unsigned char *src, unsigned char *dst, int srclen);
#define NET_TO_UPPER(x) ((((unsigned int) (x)) > 0x7f) ? x : toupper(x))
#define NET_TO_LOWER(x) ((((unsigned int) (x)) > 0x7f) ? x : tolower(x))
PR_END_EXTERN_C
#endif /* NETUTILS_H */

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

@ -51,8 +51,8 @@
<STYLE SRC=?>
$Revision: 1.2 $
$Date: 1998/05/19 00:53:36 $
$Revision: 1.3 $
$Date: 1998/05/22 23:38:14 $
*********************************************************************/
@ -382,7 +382,7 @@ void crawl_destroyPage(CRAWL_PageInfo page) {
*/
static CRAWL_TagError
crawl_processURL(CRAWL_PageInfo page, char *url, CRAWL_LinkContext context) {
/* XP_TO_LOWER(url); */
/* NET_TO_LOWER(url); */
if (crawl_startsWith("mailto:", url)) return(CRAWL_TAG_NO_ERR);
else if (crawl_startsWith("mailbox:", url)) return(CRAWL_TAG_NO_ERR);
else if (crawl_startsWith("news:", url)) return(CRAWL_TAG_NO_ERR);

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

@ -21,8 +21,8 @@
/********************************************************************
$Revision: 1.2 $
$Date: 1998/05/19 00:53:36 $
$Revision: 1.3 $
$Date: 1998/05/22 23:38:14 $
*********************************************************************/
@ -155,7 +155,7 @@ crawl_unescape (char *str, char *reserved, int numReserved)
return (int)(dst - str);
}
#define CHAR_CMP(x, y) ((x == y) || (XP_TO_LOWER(x) == XP_TO_LOWER(y)))
#define CHAR_CMP(x, y) ((x == y) || (NET_TO_LOWER(x) == NET_TO_LOWER(y)))
PRBool crawl_startsWith (char *pattern, char *uuid) {
short l1 = strlen(pattern);

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

@ -25,7 +25,17 @@ IGNORE_MANIFEST=1
#------------------------------------------------------------------------
DEPTH=..
DIRS=main cache protocol cnvts client
DIRS= \
main \
cache \
protocol \
cnvts \
!ifdef MODULAR_NETLIB
module \
!else
client \
!endif
$(NULL)
include <$(DEPTH)\config\rules.mak>

132
network/module/makefile.win Normal file
Просмотреть файл

@ -0,0 +1,132 @@
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
NODEPEND=1
IGNORE_MANIFEST = 1
#//------------------------------------------------------------------------
#//
# New build system where zip dll is build indepenant of java stubs.
#//
#//------------------------------------------------------------------------
MODULE = netlib
EXPORTS = nsIStreamListener.h \
nsINetService.h \
nsIURL.h \
nsIPostToServer.h \
nsIHttpUrl.h \
$(NULL)
#//------------------------------------------------------------------------
#//
#// Specify the depth of the current directory relative to the
#// root of NS
#//
#//------------------------------------------------------------------------
DEPTH= ..\..\
MAKE_OBJ_TYPE=DLL
#//------------------------------------------------------------------------
#//
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
#//
#//------------------------------------------------------------------------
DLLNAME=netlib.dll
PDBFILE=netlib.pdb
MAPFILE=netlib.map
DEFFILE=net.def
#//------------------------------------------------------------------------
#//
#// Define the files necessary to build the target (ie. OBJS)
#//
#//------------------------------------------------------------------------
OBJS= \
.\$(OBJDIR)\nsNetService.obj \
.\$(OBJDIR)\nsNetStream.obj \
.\$(OBJDIR)\nsURL.obj \
.\$(OBJDIR)\nsHttpUrl.obj \
.\$(OBJDIR)\nsStubContext.obj \
.\$(OBJDIR)\nsNetStubs.obj \
$(NULL)
#//------------------------------------------------------------------------
#//
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
#// (these must be defined before the common makefiles are included)
#//
#//------------------------------------------------------------------------
DLL=.\$(OBJDIR)\$(DLLNAME)
#//------------------------------------------------------------------------
#//
#// Define any local options for the make tools
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
#//
#//------------------------------------------------------------------------
LCFLAGS=-DNETSCAPE -DB1M -D_IMPL_NS_NET
LLIBS=$(LLIBS) $(LIBNSPR) \
$(DIST)\lib\libplc21.lib \
$(DIST)\lib\js3240.lib \
$(DIST)\lib\xppref32.lib \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\xplib.lib \
$(DIST)\lib\abouturl.lib \
$(DIST)\lib\fileurl.lib \
$(DIST)\lib\ftpurl.lib \
$(DIST)\lib\gophurl.lib \
$(DIST)\lib\httpurl.lib \
$(DIST)\lib\remoturl.lib \
$(DIST)\lib\netcache.lib \
$(DIST)\lib\netcnvts.lib \
$(DIST)\lib\network.lib \
$(DIST)\lib\raptorbase.lib \
$(NULL)
LINCS=$(LINCS) -I. \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\security \
-I$(PUBLIC)\pref \
-I$(PUBLIC)\js \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\httpurl \
-I$(PUBLIC)\netcache \
-I$(PUBLIC)\network \
-I$(PUBLIC)\netcnvts \
-I$(PUBLIC)\abouturl \
-I$(PUBLIC)\fileurl \
-I$(PUBLIC)\ftpurl \
-I$(PUBLIC)\gophurl \
-I$(PUBLIC)\httpurl \
-I$(PUBLIC)\remoturl \
$(NULL)
# clobber and clobber_all will remove the following garbage:
GARBAGE = $(GARBAGE) _gen
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
libs:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME) $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\netlib.lib $(DIST)\lib

21
network/module/net.def Normal file
Просмотреть файл

@ -0,0 +1,21 @@
; The contents of this file are subject to the Netscape Public License
; Version 1.0 (the "NPL"); you may not use this file except in
; compliance with the NPL. You may obtain a copy of the NPL at
; http://www.mozilla.org/NPL/
;
; Software distributed under the NPL is distributed on an "AS IS" basis,
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
; for the specific language governing rights and limitations under the
; NPL.
;
; The Initial Developer of this code under the NPL is Netscape
; Communications Corporation. Portions created by Netscape are
; Copyright (C) 1998 Netscape Communications Corporation. All Rights
; Reserved.
LIBRARY netlib.dll
EXPORTS
NS_NewINetService
NET_ToggleTrace
NET_PollSockets

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

@ -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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsAgg.h"
#include "nsIProtocolConnection.h"
#include "nsIHttpUrl.h"
#include "nsIPostToServer.h"
#include "nsINetService.h" /* XXX: NS_FALSE */
#include "nsNetStream.h"
#include "net.h"
#include "prmem.h"
#include "plstr.h"
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
class nsHttpUrlImpl : public nsIProtocolConnection,
public nsIPostToServer,
public nsIHttpUrl
{
public:
typedef enum {
Send_None,
Send_File,
Send_Data,
Send_DataFromFile,
} SendType;
public:
nsHttpUrlImpl(nsISupports* outer);
/* Aggregated nsISupports interface... */
NS_DECL_AGGREGATED
/* nsIProtocolConnection interface... */
NS_IMETHOD InitializeURLInfo(URL_Struct_ *URL_s);
/* nsIPostToServer interface... */
NS_IMETHOD SendFile(const char *aFile);
NS_IMETHOD SendData(const char *aBuffer, PRInt32 aLength);
NS_IMETHOD SendDataFromFile(const char *aFile);
/* nsIHttpUrl interface... */
static nsISupports* NewHttpUrlImpl(nsISupports *outer);
protected:
virtual ~nsHttpUrlImpl();
nsresult PostFile(const char *aFile);
SendType m_PostType;
char *m_PostBuffer;
PRInt32 m_PostBufferLength;
};
nsHttpUrlImpl::nsHttpUrlImpl(nsISupports* outer)
{
NS_INIT_AGGREGATED(outer);
m_PostType = Send_None;
m_PostBuffer = nsnull;
m_PostBufferLength = 0;
}
nsHttpUrlImpl::~nsHttpUrlImpl()
{
if (nsnull != m_PostBuffer) PR_Free(m_PostBuffer);
}
NS_IMPL_AGGREGATED(nsHttpUrlImpl)
nsresult nsHttpUrlImpl::AggregatedQueryInterface(const nsIID &aIID,
void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIProtocolConnectionIID, NS_IPROTOCOLCONNECTION_IID);
static NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID);
static NS_DEFINE_IID(kIHttpUrlIID, NS_IHTTPURL_IID);
if (aIID.Equals(kIProtocolConnectionIID)) {
*aInstancePtr = (void*) ((nsIProtocolConnection*)this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kIHttpUrlIID)) {
*aInstancePtr = (void*) ((nsIHttpUrl*)this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kIPostToServerIID)) {
*aInstancePtr = (void*) ((nsIPostToServer*)this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports *)&fAggregated);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_METHOD nsHttpUrlImpl::InitializeURLInfo(URL_Struct *URL_s)
{
nsresult result = NS_OK;
if (Send_None != m_PostType) {
/* Free any existing POST data hanging off the URL_Struct */
if (nsnull != URL_s->post_data) {
PR_Free(URL_s->post_data);
}
/*
* Store the new POST data into the URL_Struct
*/
URL_s->post_data = m_PostBuffer;
URL_s->post_data_size = m_PostBufferLength;
URL_s->post_data_is_file = (Send_Data == m_PostType) ? FALSE : TRUE;
/*
* Is the request a POST or PUT
*/
URL_s->method = (Send_File == m_PostType) ? URL_PUT_METHOD : URL_POST_METHOD;
/* Reset the local post state... */
m_PostType = Send_None;
m_PostBuffer = nsnull; /* The URL_Struct owns the memory now... */
m_PostBufferLength = 0;
}
return result;
}
NS_METHOD nsHttpUrlImpl::SendFile(const char *aFile)
{
nsresult result;
result = PostFile(aFile);
if (NS_OK == result) {
m_PostType = Send_File;
}
return result;
}
NS_METHOD nsHttpUrlImpl::SendDataFromFile(const char *aFile)
{
nsresult result;
result = PostFile(aFile);
if (NS_OK == result) {
m_PostType = Send_DataFromFile;
}
return result;
}
NS_METHOD nsHttpUrlImpl::SendData(const char *aBuffer, PRInt32 aLength)
{
nsresult result = NS_OK;
/* Deal with error conditions... */
if (nsnull == aBuffer) {
result = NS_ERROR_ILLEGAL_VALUE;
goto done;
}
else if (Send_None != m_PostType) {
result = NS_IPOSTTOSERVER_ALREADY_POSTING;
goto done;
}
/* Copy the post data... */
m_PostBuffer = (char *)PR_Malloc(aLength);
if (nsnull == m_PostBuffer) {
result = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
memcpy(m_PostBuffer, aBuffer, aLength);
m_PostBufferLength = aLength;
m_PostType = Send_Data;
done:
return result;
}
nsresult nsHttpUrlImpl::PostFile(const char *aFile)
{
nsresult result = NS_OK;
/* Deal with error conditions... */
if (nsnull == aFile) {
result = NS_ERROR_ILLEGAL_VALUE;
goto done;
}
else if (Send_None != m_PostType) {
result = NS_IPOSTTOSERVER_ALREADY_POSTING;
goto done;
}
/* Copy the post data... */
m_PostBuffer = PL_strdup(aFile);
if (nsnull == m_PostBuffer) {
result = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
m_PostBufferLength = PL_strlen(aFile);
done:
return result;
}
nsISupports* nsHttpUrlImpl::NewHttpUrlImpl(nsISupports* aOuter)
{
nsHttpUrlImpl* it;
nsISupports *result;
it = new nsHttpUrlImpl(aOuter);
if (nsnull != it) {
if (nsnull != aOuter) {
result = &it->fAggregated;
} else {
result = (nsIProtocolConnection *)it;
}
result->AddRef();
}
return result;
}
extern "C" NS_NET nsresult NS_NewHttpUrl(nsISupports** aInstancePtrResult,
nsISupports* aOuter)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtrResult = nsHttpUrlImpl::NewHttpUrlImpl(aOuter);
if (nsnull == *aInstancePtrResult) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}

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

@ -0,0 +1,47 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIHttpUrl_h___
#define nsIHttpUrl_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nspr.h"
/* 1A0B6FA1-EA25-11d1-BEAE-00805F8A66DC */
#define NS_IHTTPURL_IID \
{ 0x1a0b6fa1, 0xea25, 0x11d1, \
{ 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } }
struct nsIHttpUrl : public nsISupports
{
};
/** Create a new HttpUrl. */
extern "C" NS_NET nsresult NS_NewHttpUrl(nsISupports** aInstancePtrResult,
nsISupports* aOuter);
#endif /* nsIHttpUrl_h___ */

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

@ -0,0 +1,80 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsINetService_h___
#define nsINetService_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsIURL.h"
#include "nsIStreamListener.h"
/* XXX: This should be moved to ns/xpcom/src/nserror.h */
#define NS_OK 0
#define NS_FALSE 1
/* cfb1a480-c78f-11d1-bea2-00805f8a66dc */
#define NS_INETSERVICE_IID \
{ 0xcfb1a480, 0xc78f, 0x11d1, \
{0xbe, 0xa2, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
/**
* The nsINetService interface provides an API to the networking service.
* This is a preliminary interface which <B>will</B> change over time!
*
*/
struct nsINetService : public nsISupports
{
/**
* Initiate an asynchronous URL load.<BR><BR>
*
* @param aUrl The URL to load.
* @param aConsumer An object that will receive notifications during the
* URL loading. This parameter cannot be NULL.
* @return Returns NS_OK if successful, or NS_FALSE if an error occurred.
*/
NS_IMETHOD OpenStream(nsIURL *aUrl,
nsIStreamListener *aConsumer) = 0;
/**
* Initiate a synchronous URL load.<BR><BR>
*
* @param aUrl The URL to load.
* @param aConsumer An object that will receive notifications during the
* URL loading. This parameter can be NULL if
* notifications are not required.
* @param aNewStream An output parameter to recieve the blocking stream
* created for this URL load.
* @return Returns NS_OK if successful, or NS_FALSE if an error occurred.
*/
NS_IMETHOD OpenBlockingStream(nsIURL *aUrl,
nsIStreamListener *aConsumer,
nsIInputStream **aNewStream) = 0;
};
/**
* Create an instance of the INetService
*
*/
extern "C" NS_NET nsresult NS_NewINetService(nsINetService** aInstancePtrResult,
nsISupports* aOuter);
#endif /* nsINetService_h___ */

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

@ -0,0 +1,45 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIPostToServer_h___
#define nsIPostToServer_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nspr.h"
/* EADF7B41-EBC0-11d1-BEAE-00805F8A66DC */
#define NS_IPOSTTOSERVER_IID \
{ 0xeadf7b41, 0xebc0, 0x11d1, \
{ 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } }
struct nsIPostToServer : public nsISupports
{
NS_IMETHOD SendFile(const char *aFile) = 0;
NS_IMETHOD SendData(const char *aBuffer, PRInt32 aLength) = 0;
NS_IMETHOD SendDataFromFile(const char *aFile) = 0;
};
#define NS_IPOSTTOSERVER_ALREADY_POSTING 1
#endif /* nsIPostToServer_h___ */

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

@ -0,0 +1,41 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIProtocolConnection_h___
#define nsIProtocolConnection_h___
#include "nscore.h"
#include "nsISupports.h"
/* forward declaration */
struct URL_Struct_;
/* 121CC0F1-EA26-11d1-BEAE-00805F8A66DC */
#define NS_IPROTOCOLCONNECTION_IID \
{ 0x121cc0f1, 0xea26, 0x11d1, \
{ 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } }
struct nsIProtocolConnection : public nsISupports
{
NS_IMETHOD InitializeURLInfo(URL_Struct_ *URL_s) = 0;
};
#endif /* nsIHttpUrl_h___ */

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

@ -0,0 +1,100 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIStreamListener_h___
#define nsIStreamListener_h___
#include "prtypes.h"
#include "nsISupports.h"
/* forward declaration */
class nsIInputStream;
/* 45d234d0-c6c9-11d1-bea2-00805f8a66dc */
#define NS_ISTREAMNOTIFICATION_IID \
{ 0x45d234d0, 0xc6c9, 0x11d1, \
{0xbe, 0xa2, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
/**
* The nsIStreamListener interface provides the necessary notifications
* during both synchronous and asynchronous URL loading.
* This is a preliminary interface which <B>will</B> change over time!
* <BR><BR>
* An instance of this interface is passed to nsINetService::Open(...) to
* allow the client to receive status and notifications during the loading
* of the URL.
* <BR><BR>
* Over time this interface will provide the same functionality as the
* IBindStatusCallback interface in the MS INET-SDK...
*/
struct nsIStreamListener : public nsISupports
{
/**
* Return information regarding the current URL load.<BR>
*
* This method is currently not called.
*/
NS_IMETHOD GetBindInfo(void) = 0;
/**
* Notify the client that progress as occurred for the URL load.<BR>
*/
NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) = 0;
/**
* Notify the client that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
NS_IMETHOD OnStartBinding(void) = 0;
/**
* Notify the client that data is available in the input stream. This
* method is called whenver data is written into the input stream by the
* networking library...<BR><BR>
*
* @param pIStream The input stream containing the data. This stream can
* be either a blocking or non-blocking stream.
* @param length The amount of data that was just pushed into the stream.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) = 0;
/**
* Notify the client that the URL has finished loading. This method is
* called once when the networking library has finished processing the
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
*
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
*
* @param status Status code for the URL load.
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg) = 0;
};
/* Generic status codes for OnStopBinding */
#define NS_BINDING_SUCCEEDED NS_OK
#define NS_BINDING_FAILED (-1)
#define NS_BINDING_ABORTED (-2)
#endif /* nsIStreamListener_h___ */

95
network/module/nsIURL.h Normal file
Просмотреть файл

@ -0,0 +1,95 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIURL_h___
#define nsIURL_h___
#include "nscore.h"
#include "nsISupports.h"
class nsIInputStream;
struct nsIStreamListener;
class nsString;
#define NS_IURL_IID \
{ 0x6ecb2900, 0x93b5, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
/**
* TEMPORARY INTERFACE; this <B><EM><STRONG>will</STRONG></EM></B> will be
* going away
*/
class nsIURL : public nsISupports {
public:
/** Open the url for reading and return a new input stream for the
* url. The caller must release the input stream when done with it.
*/
virtual nsIInputStream* Open(PRInt32* aErrorCode) = 0;
virtual nsresult Open(nsIStreamListener *) = 0;
/** Equality operator */
virtual PRBool operator==(const nsIURL& aURL) const = 0;
virtual nsresult Set(const char *aNewSpec) = 0;
/** Accessors */
//@{
/**
@return protocol part of the URL */
virtual const char* GetProtocol() const = 0;
/** @return host part of the URL */
virtual const char* GetHost() const = 0;
/** @return file part of the URL */
virtual const char* GetFile() const = 0;
/** @return ref part of the URL */
virtual const char* GetRef() const = 0;
/** @return string originally used to construct the URL */
virtual const char* GetSpec() const = 0;
/** @return ref part of the URL */
virtual PRInt32 GetPort() const = 0;
//@}
/** Write the URL to aString, overwriting previous contents. */
virtual void ToString(nsString& aString) const = 0;
};
/** Create a new URL from aSpec. */
extern NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
const nsString& aSpec);
/** Create a new URL, interpreting aSpec as relative to aURL. */
extern NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
const nsIURL* aURL,
const nsString& aSpec);
/**
* Utility routine to take a url (may be nsnull) and a base url (may
* be empty), and a url spec and combine them properly into a new
* absolute url.
*/
extern NS_NET nsresult NS_MakeAbsoluteURL(nsIURL* aURL,
const nsString& aBaseURL,
const nsString& aSpec,
nsString& aResult);
#endif /* nsIURL_h___ */

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

@ -0,0 +1,306 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsNetService.h"
#include "nsNetStream.h"
#include "net.h"
#include "mktrace.h"
#include "nsIProtocolConnection.h"
/* XXX: Legacy definitions... */
MWContext *new_stub_context();
void free_stub_context(MWContext *window_id);
void bam_exit_routine(URL_Struct *URL_s, int status, MWContext *window_id);
extern "C" {
extern char *XP_AppCodeName;
extern char *XP_AppVersion;
};
static NS_DEFINE_IID(kIProtocolConnectionIID, NS_IPROTOCOLCONNECTION_IID);
nsNetlibService::nsNetlibService()
{
NS_INIT_REFCNT();
m_stubContext = new_stub_context();
/* Initialize netlib with 32 sockets... */
NET_InitNetLib(0, 32);
/* XXX: How should the User Agent get initialized? */
XP_AppCodeName = strdup("Mozilla");
XP_AppVersion = strdup("5.0 Netscape/5.0 (Windows;I;x86;en)");
}
NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
NS_IMPL_ISUPPORTS(nsNetlibService,kINetServiceIID);
nsNetlibService::~nsNetlibService()
{
TRACEMSG(("nsNetlibService is being destroyed...\n"));
if (NULL != m_stubContext) {
free_stub_context((MWContext *)m_stubContext);
m_stubContext = NULL;
}
NET_ShutdownNetLib();
}
nsresult nsNetlibService::OpenStream(nsIURL *aUrl,
nsIStreamListener *aConsumer)
{
URL_Struct *URL_s;
nsConnectionInfo *pConn;
nsIProtocolConnection *pProtocol;
nsresult result;
if ((NULL == aConsumer) || (NULL == aUrl)) {
return NS_FALSE;
}
/* Create the nsConnectionInfo object... */
pConn = new nsConnectionInfo(aUrl, NULL, aConsumer);
if (NULL == pConn) {
return NS_FALSE;
}
pConn->AddRef();
/* Create the URLStruct... */
URL_s = NET_CreateURLStruct(aUrl->GetSpec(), NET_NORMAL_RELOAD);
if (NULL == URL_s) {
pConn->Release();
return NS_FALSE;
}
/*
* Mark the URL as background loading. This prevents many
* client upcall notifications...
*/
URL_s->load_background = TRUE;
/*
* Attach the Data Consumer to the URL_Struct.
*
* Both the Data Consumer and the URL_Struct are freed in the
* bam_exit_routine(...)
*
* The Reference count on pConn is already 1 so no AddRef() is necessary.
*/
URL_s->fe_data = pConn;
/*
* Give the protocol a chance to initialize any URL_Struct fields...
*
* XXX: Currently the return value form InitializeURLInfo(...) is
* ignored... Should the connection abort if it fails?
*/
result = aUrl->QueryInterface(kIProtocolConnectionIID, (void**)&pProtocol);
if (NS_OK == result) {
pProtocol->InitializeURLInfo(URL_s);
NS_RELEASE(pProtocol);
}
/* Start the URL load... */
NET_GetURL (URL_s, /* URL_Struct */
FO_CACHE_AND_PRESENT, /* FO_Present_type */
(MWContext *)m_stubContext, /* MWContext */
bam_exit_routine); /* Exit routine... */
/* Remember, the URL_s may have been freed ! */
return NS_OK;
}
nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl,
nsIStreamListener *aConsumer,
nsIInputStream **aNewStream)
{
URL_Struct *URL_s;
nsConnectionInfo *pConn;
nsNetlibStream *pBlockingStream;
nsIProtocolConnection *pProtocol;
nsresult result;
if (NULL == aNewStream) {
return NS_FALSE;
}
if (NULL != aUrl) {
/* Create the blocking stream... */
pBlockingStream = new nsBlockingStream();
if (NULL == pBlockingStream) {
goto loser;
}
/*
* AddRef the new stream in anticipation of returning it... This will
* keep it alive :-)
*/
pBlockingStream->AddRef();
/* Create the nsConnectionInfo object... */
pConn = new nsConnectionInfo(aUrl, pBlockingStream, aConsumer);
if (NULL == pConn) {
pBlockingStream->Release();
goto loser;
}
pConn->AddRef();
/* Create the URLStruct... */
URL_s = NET_CreateURLStruct(aUrl->GetSpec(), NET_NORMAL_RELOAD);
if (NULL == URL_s) {
pBlockingStream->Release();
pConn->Release();
goto loser;
}
/*
* Mark the URL as background loading. This prevents many
* client upcall notifications...
*/
URL_s->load_background = TRUE;
/*
* Attach the ConnectionInfo object to the URL_Struct.
*
* Both the ConnectionInfo and the URL_Struct are freed in the
* bam_exit_routine(...)
* The Reference count on pConn is already 1 so no AddRef() is
* necessary.
*/
URL_s->fe_data = pConn;
/*
* Give the protocol a chance to initialize any URL_Struct fields...
*
* XXX: Currently the return value form InitializeURLInfo(...) is
* ignored... Should the connection abort if it fails?
*/
result = aUrl->QueryInterface(kIProtocolConnectionIID, (void**)&pProtocol);
if (NS_OK == result) {
pProtocol->InitializeURLInfo(URL_s);
NS_RELEASE(pProtocol);
}
/* printf("+++ Loading %s\n", aUrl); */
/* Start the URL load... */
NET_GetURL (URL_s, /* URL_Struct */
FO_CACHE_AND_PRESENT, /* FO_Present_type */
(MWContext *)m_stubContext, /* MWContext */
bam_exit_routine); /* Exit routine... */
/* Remember, the URL_s may have been freed ! */
*aNewStream = pBlockingStream;
return NS_OK;
}
loser:
*aNewStream = NULL;
return NS_FALSE;
}
extern "C" {
/*
* Factory for creating instance of the NetlibService...
*/
NS_NET nsresult NS_NewINetService(nsINetService** aInstancePtrResult,
nsISupports* aOuter)
{
static nsNetlibService *pNetlib = NULL;
if (NULL != aOuter) {
return NS_ERROR_NO_AGGREGATION;
}
/* XXX: For now only allow a single instance of the Netlib Service */
if (NULL == pNetlib) {
pNetlib = new nsNetlibService();
}
if (NULL == pNetlib) {
return NS_ERROR_OUT_OF_MEMORY;
}
return pNetlib->QueryInterface(kINetServiceIID, (void**)aInstancePtrResult);
}
}; /* extern "C" */
/*
* This is the generic exit routine for all URLs loaded via the new
* BAM APIs...
*/
static void bam_exit_routine(URL_Struct *URL_s, int status, MWContext *window_id)
{
TRACEMSG(("bam_exit_routine was called...\n"));
if (NULL != URL_s) {
nsConnectionInfo *pConn = (nsConnectionInfo *)URL_s->fe_data;
printf("+++ Finished loading %s\n", URL_s->address);
PR_ASSERT(pConn);
/* Release the ConnectionInfo object held in the URL_Struct. */
if (pConn) {
/*
* Normally, the stream is closed when the connection has been
* completed. However, if the URL exit proc was called directly
* by NET_GetURL(...), then the stream may still be around...
*/
if (pConn->pNetStream) {
pConn->pNetStream->Close();
pConn->pNetStream->Release();
pConn->pNetStream = NULL;
}
/*
* Notify the Data Consumer that the Binding has completed...
* Since the Consumer is still available, the stream was never
* closed (or possibly created). So, the binding has failed...
*/
if (pConn->pConsumer) {
pConn->pConsumer->OnStopBinding(NS_BINDING_FAILED, nsnull);
pConn->pConsumer->Release();
pConn->pConsumer = NULL;
}
/* Release the nsConnectionInfo object hanging off of the fe_data */
URL_s->fe_data = NULL;
pConn->Release();
}
/* Delete the URL_Struct... */
NET_FreeURLStruct(URL_s);
}
}

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

@ -0,0 +1,47 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef net_serv_h___
#define net_serv_h___
#include "nspr.h"
#include "nsINetService.h"
class nsNetlibService : public nsINetService {
public:
NS_DECL_ISUPPORTS
nsNetlibService();
/* Implementation of the nsINetService interface */
NS_IMETHOD OpenStream(nsIURL *aUrl, nsIStreamListener *aConsumer);
NS_IMETHOD OpenBlockingStream(nsIURL *aUrl,
nsIStreamListener *aConsumer,
nsIInputStream **aNewStream);
protected:
virtual ~nsNetlibService();
private:
/* XXX: This is temporary until bamwrap.cpp is removed... */
void *m_stubContext;
};
#endif /* net_strm_h___ */

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

@ -0,0 +1,715 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsNetStream.h"
#include "net.h"
#include "mktrace.h"
/* XXX: Declare NET_PollSockets(...) for the blocking stream hack... */
extern "C" {
PRBool NET_PollSockets(void);
};
NS_DEFINE_IID(kIInputStreamIID, NS_IINPUTSTREAM_IID);
#define BUFFER_BLOCK_SIZE 8192
nsConnectionInfo::nsConnectionInfo(nsIURL *aURL,
nsNetlibStream *aStream,
nsIStreamListener *aNotify)
{
NS_INIT_REFCNT();
pURL = aURL;
pNetStream = aStream;
pConsumer = aNotify;
if (NULL != pURL) {
pURL->AddRef();
}
if (NULL != pNetStream) {
pNetStream->AddRef();
}
if (NULL != pConsumer) {
pConsumer->AddRef();
}
}
NS_IMPL_ISUPPORTS(nsConnectionInfo,kISupportsIID);
nsConnectionInfo::~nsConnectionInfo()
{
TRACEMSG(("nsConnectionInfo is being destroyed...\n"));
if (NULL != pURL) {
pURL->Release();
}
if (NULL != pNetStream) {
pNetStream->Close();
pNetStream->Release();
}
if (NULL != pConsumer) {
pConsumer->Release();
}
pURL = NULL;
pNetStream = NULL;
pConsumer = NULL;
}
nsNetlibStream::nsNetlibStream(void)
{
NS_INIT_REFCNT();
m_Lock = PR_NewMonitor();
m_bIsClosed = PR_FALSE;
}
NS_IMPL_ADDREF(nsNetlibStream)
NS_IMPL_RELEASE(nsNetlibStream)
nsresult nsNetlibStream::QueryInterface(const nsIID &aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIInputStreamIID, NS_IINPUTSTREAM_IID);
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
if (aIID.Equals(kIInputStreamIID)) {
*aInstancePtr = (void*) ((nsIInputStream*)this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kIOutputStreamIID)) {
*aInstancePtr = (void*) ((nsIOutputStream*)this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = ((nsISupports *)(nsIInputStream *)this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
nsNetlibStream::~nsNetlibStream()
{
if (m_Lock) {
PR_DestroyMonitor(m_Lock);
m_Lock = NULL;
}
}
void nsNetlibStream::Close()
{
LockStream();
m_bIsClosed = PR_TRUE;
UnlockStream();
}
nsBufferedStream::nsBufferedStream(void)
{
m_BufferLength = BUFFER_BLOCK_SIZE;
m_Buffer = new char[m_BufferLength];
/* If the allocation failed, mark the stream as closed... */
if (NULL == m_Buffer) {
m_bIsClosed = PR_TRUE;
m_BufferLength = 0;
}
m_DataLength = 0;
m_ReadOffset = m_WriteOffset = 0;
}
nsBufferedStream::~nsBufferedStream()
{
TRACEMSG(("nsBufferedStream is being destroyed...\n"));
if (m_Buffer) {
free(m_Buffer);
m_Buffer = NULL;
}
}
PRInt32 nsBufferedStream::GetAvailableSpace(PRInt32 *aErrorCode)
{
PRInt32 size = 0;
if (m_bIsClosed) {
*aErrorCode = NS_INPUTSTREAM_EOF;
} else {
*aErrorCode = 0;
LockStream();
size = m_BufferLength - m_WriteOffset;
UnlockStream();
}
return size;
}
PRInt32 nsBufferedStream::GetLength()
{
PRInt32 size;
LockStream();
size = m_WriteOffset;
UnlockStream();
return size;
}
PRInt32 nsBufferedStream::Write(PRInt32 *aErrorCode,
const char *aBuf,
PRInt32 aOffset,
PRInt32 aLen)
{
PRInt32 bytesWritten = 0;
PRInt32 bytesFree;
LockStream();
NS_PRECONDITION((m_Buffer || m_bIsClosed), "m_Buffer is NULL!");
NS_PRECONDITION((m_WriteOffset >= m_ReadOffset), "Read past the end of buffer.");
/* Check for initial error conditions... */
if (NULL == aBuf) {
*aErrorCode = NS_INPUTSTREAM_ILLEGAL_ARGS;
goto done;
} else if (m_bIsClosed) {
*aErrorCode = NS_INPUTSTREAM_EOF;
goto done;
} else {
*aErrorCode = 0;
}
if (!m_bIsClosed && aBuf) {
/* Grow the buffer if necessary */
bytesFree = m_BufferLength - m_WriteOffset;
if (aLen > bytesFree) {
char *newBuffer;
m_BufferLength += (((aLen - bytesFree) / BUFFER_BLOCK_SIZE)+1) * BUFFER_BLOCK_SIZE;
newBuffer = (char *)realloc(m_Buffer, m_BufferLength);
/* If the allocation failed, close the stream and free the buffer... */
if (NULL == newBuffer) {
m_bIsClosed = PR_TRUE;
free(m_Buffer);
m_Buffer = NULL;
m_BufferLength = 0;
goto done;
} else {
m_Buffer = newBuffer;
}
}
/* Skip the appropriate number of bytes in the input buffer... */
if (aOffset) {
aBuf += aOffset;
}
memcpy(&m_Buffer[m_WriteOffset], aBuf, aLen);
m_WriteOffset += aLen;
bytesWritten = aLen;
m_DataLength += aLen;
}
done:
UnlockStream();
return bytesWritten;
}
PRInt32 nsBufferedStream::Read(PRInt32 *aErrorCode,
char *aBuf,
PRInt32 aOffset,
PRInt32 aCount)
{
PRInt32 bytesRead = 0;
LockStream();
NS_PRECONDITION((m_Buffer || m_bIsClosed), "m_Buffer is NULL!");
NS_PRECONDITION((m_WriteOffset >= m_ReadOffset), "Read past the end of buffer.");
/* Check for initial error conditions... */
if (NULL == aBuf) {
*aErrorCode = NS_INPUTSTREAM_ILLEGAL_ARGS;
goto done;
} else if (m_bIsClosed && (0 == m_DataLength)) {
*aErrorCode = NS_INPUTSTREAM_EOF;
goto done;
} else {
*aErrorCode = 0;
}
if (m_Buffer && m_DataLength) {
/* Skip the appropriate number of bytes in the input buffer... */
if (aOffset) {
aBuf += aOffset;
}
/* Do not read more data than there is available... */
if (aCount > m_DataLength) {
aCount = m_DataLength;
}
memcpy(aBuf, &m_Buffer[m_ReadOffset], aCount);
m_ReadOffset += aCount;
bytesRead = aCount;
m_DataLength -= aCount;
}
done:
UnlockStream();
return bytesRead;
}
nsAsyncStream::nsAsyncStream(PRInt32 buffer_size)
{
m_BufferLength = buffer_size;
m_Buffer = (char *)malloc(m_BufferLength);
/* If the allocation failed, mark the stream as closed... */
if (NULL == m_Buffer) {
m_bIsClosed = PR_TRUE;
m_BufferLength = 0;
}
m_DataLength = 0;
m_ReadOffset = m_WriteOffset = 0;
}
nsAsyncStream::~nsAsyncStream()
{
TRACEMSG(("nsAsyncStream is being destroyed...\n"));
if (m_Buffer) {
free(m_Buffer);
m_Buffer = NULL;
}
}
PRInt32 nsAsyncStream::GetAvailableSpace(PRInt32 *aErrorCode)
{
PRInt32 size = 0;
if (m_bIsClosed) {
*aErrorCode = NS_INPUTSTREAM_EOF;
} else {
*aErrorCode = 0;
LockStream();
size = m_BufferLength - m_DataLength;
UnlockStream();
}
return size;
}
PRInt32 nsAsyncStream::GetLength()
{
PRInt32 size;
LockStream();
size = m_DataLength;
UnlockStream();
return size;
}
PRInt32 nsAsyncStream::Write(PRInt32 *aErrorCode,
const char *aBuf,
PRInt32 aOffset,
PRInt32 aLen)
{
PRInt32 bytesWritten = 0;
PRInt32 bytesFree;
LockStream();
NS_PRECONDITION((m_Buffer || m_bIsClosed), "m_Buffer is NULL!");
/* Check for initial error conditions... */
if (NULL == aBuf) {
*aErrorCode = NS_INPUTSTREAM_ILLEGAL_ARGS;
goto done;
} else if (m_bIsClosed) {
*aErrorCode = NS_INPUTSTREAM_EOF;
goto done;
} else {
*aErrorCode = 0;
}
if (!m_bIsClosed && aBuf) {
/* Skip the appropriate number of bytes in the input buffer... */
if (aOffset) {
aBuf += aOffset;
}
/* Do not store more data than there is space for... */
bytesFree = m_BufferLength - m_DataLength;
if (aLen > bytesFree) {
aLen = bytesFree;
}
/* Storing the data will cause m_WriteOffset to wrap */
if (m_WriteOffset + aLen > m_BufferLength) {
PRInt32 delta;
/* Store the first chunk through the end of the buffer */
delta = m_BufferLength - m_WriteOffset;
memcpy(&m_Buffer[m_WriteOffset], aBuf, delta);
/* Store the second chunk from the beginning of the buffer */
m_WriteOffset = aLen-delta;
memcpy(m_Buffer, &aBuf[delta], m_WriteOffset);
} else {
memcpy(&m_Buffer[m_WriteOffset], aBuf, aLen);
m_WriteOffset += aLen;
}
bytesWritten = aLen;
m_DataLength += aLen;
}
done:
UnlockStream();
return bytesWritten;
}
PRInt32 nsAsyncStream::Read(PRInt32 *aErrorCode,
char *aBuf,
PRInt32 aOffset,
PRInt32 aCount)
{
PRInt32 bytesRead = 0;
LockStream();
NS_PRECONDITION((m_Buffer || m_bIsClosed), "m_Buffer is NULL!");
/* Check for initial error conditions... */
if (NULL == aBuf) {
*aErrorCode = NS_INPUTSTREAM_ILLEGAL_ARGS;
goto done;
} else if (m_bIsClosed && (0 == m_DataLength)) {
*aErrorCode = NS_INPUTSTREAM_EOF;
goto done;
} else {
*aErrorCode = 0;
}
if (m_Buffer && m_DataLength) {
/* Skip the appropriate number of bytes in the input buffer... */
if (aOffset) {
aBuf += aOffset;
}
/* Do not read more data than there is available... */
if (aCount > m_DataLength) {
aCount = m_DataLength;
}
/* Reading the data will cause m_ReadOffset to wrap */
if (m_ReadOffset + aCount > m_BufferLength) {
PRInt32 delta;
/* Read the first chunk through the end of the buffer */
delta = m_BufferLength - m_ReadOffset;
memcpy(aBuf, &m_Buffer[m_ReadOffset], delta);
/* Read the second chunk from the beginning of the buffer */
m_ReadOffset = aCount-delta;
memcpy(&aBuf[delta], m_Buffer, m_ReadOffset);
} else {
memcpy(aBuf, &m_Buffer[m_ReadOffset], aCount);
m_ReadOffset += aCount;
}
bytesRead = aCount;
m_DataLength -= aCount;
}
done:
UnlockStream();
return bytesRead;
}
nsBlockingStream::nsBlockingStream()
{
m_BufferLength = BUFFER_BLOCK_SIZE;
m_Buffer = (char *)malloc(m_BufferLength);
/* If the allocation failed, mark the stream as closed... */
if (NULL == m_Buffer) {
m_bIsClosed = PR_TRUE;
m_BufferLength = 0;
}
m_DataLength = 0;
m_ReadOffset = m_WriteOffset = 0;
}
nsBlockingStream::~nsBlockingStream()
{
TRACEMSG(("nsBlockingStream is being destroyed...\n"));
if (m_Buffer) {
free(m_Buffer);
m_Buffer = NULL;
}
}
PRInt32 nsBlockingStream::GetAvailableSpace(PRInt32 *aErrorCode)
{
PRInt32 size = 0;
if (m_bIsClosed) {
*aErrorCode = NS_INPUTSTREAM_EOF;
} else {
*aErrorCode = 0;
LockStream();
size = m_BufferLength - m_DataLength;
UnlockStream();
}
return size;
}
PRInt32 nsBlockingStream::GetLength()
{
PRInt32 size;
LockStream();
size = m_DataLength;
UnlockStream();
return size;
}
PRInt32 nsBlockingStream::Write(PRInt32 *aErrorCode,
const char *aBuf,
PRInt32 aOffset,
PRInt32 aLen)
{
PRInt32 bytesWritten = 0;
PRInt32 bytesFree;
LockStream();
NS_PRECONDITION((m_Buffer || m_bIsClosed), "m_Buffer is NULL!");
/* Check for initial error conditions... */
if (NULL == aBuf) {
*aErrorCode = NS_INPUTSTREAM_ILLEGAL_ARGS;
goto done;
} else if (m_bIsClosed) {
*aErrorCode = NS_INPUTSTREAM_EOF;
goto done;
} else {
*aErrorCode = 0;
}
if (!m_bIsClosed && aBuf) {
/* Skip the appropriate number of bytes in the input buffer... */
if (aOffset) {
aBuf += aOffset;
}
/* Do not store more data than there is space for... */
bytesFree = m_BufferLength - m_DataLength;
if (aLen > bytesFree) {
aLen = bytesFree;
}
/* Storing the data will cause m_WriteOffset to wrap */
if (m_WriteOffset + aLen > m_BufferLength) {
PRInt32 delta;
/* Store the first chunk through the end of the buffer */
delta = m_BufferLength - m_WriteOffset;
memcpy(&m_Buffer[m_WriteOffset], aBuf, delta);
/* Store the second chunk from the beginning of the buffer */
m_WriteOffset = aLen-delta;
memcpy(m_Buffer, &aBuf[delta], m_WriteOffset);
} else {
memcpy(&m_Buffer[m_WriteOffset], aBuf, aLen);
m_WriteOffset += aLen;
}
bytesWritten = aLen;
m_DataLength += aLen;
}
done:
UnlockStream();
return bytesWritten;
}
PRInt32 nsBlockingStream::Read(PRInt32 *aErrorCode,
char *aBuf,
PRInt32 aOffset,
PRInt32 aCount)
{
PRInt32 bytesRead = 0;
LockStream();
NS_PRECONDITION((m_Buffer || m_bIsClosed), "m_Buffer is NULL!");
/* Check for initial error conditions... */
if (NULL == aBuf) {
*aErrorCode = NS_INPUTSTREAM_ILLEGAL_ARGS;
goto done;
} else if (m_bIsClosed && (0 == m_DataLength)) {
*aErrorCode = NS_INPUTSTREAM_EOF;
goto done;
} else {
*aErrorCode = 0;
}
if (m_Buffer) {
/* Skip the appropriate number of bytes in the input buffer... */
if (aOffset) {
aBuf += aOffset;
}
/* Not enough data is available... Must block. */
if (aCount > m_DataLength) {
UnlockStream();
do {
NET_PollSockets();
bytesRead += ReadBuffer(aBuf+bytesRead, aCount-bytesRead);
/* XXX m_bIsClosed is checked outside of the lock! */
} while ((aCount > bytesRead) && !m_bIsClosed);
LockStream();
/*
* It is possible that the stream was closed during
* NET_PollSockets(...)... In this case, return EOF if no data
* is available...
*/
if ((0 == bytesRead) && m_bIsClosed) {
*aErrorCode = NS_INPUTSTREAM_EOF;
}
} else {
bytesRead = ReadBuffer(aBuf, aCount);
}
}
done:
UnlockStream();
return bytesRead;
}
PRInt32 nsBlockingStream::ReadBuffer(char *aBuf, PRInt32 aCount)
{
PRInt32 bytesRead = 0;
LockStream();
/* Do not read more data than there is available... */
if (aCount > m_DataLength) {
aCount = m_DataLength;
}
/* Reading the data will cause m_ReadOffset to wrap */
if (m_ReadOffset + aCount > m_BufferLength) {
PRInt32 delta;
/* Read the first chunk through the end of the buffer */
delta = m_BufferLength - m_ReadOffset;
memcpy(aBuf, &m_Buffer[m_ReadOffset], delta);
/* Read the second chunk from the beginning of the buffer */
m_ReadOffset = aCount-delta;
memcpy(&aBuf[delta], m_Buffer, m_ReadOffset);
} else {
memcpy(aBuf, &m_Buffer[m_ReadOffset], aCount);
m_ReadOffset += aCount;
}
bytesRead = aCount;
m_DataLength -= aCount;
UnlockStream();
return bytesRead;
}

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

@ -0,0 +1,194 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef net_strm_h___
#define net_strm_h___
#include "nspr.h"
#include "nsIURL.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIStreamListener.h"
/* Forward declaration... */
class nsNetlibStream;
class nsConnectionInfo : public nsISupports
{
public:
NS_DECL_ISUPPORTS
nsConnectionInfo(nsIURL *aURL,
nsNetlibStream *aStream,
nsIStreamListener *aNotify);
protected:
virtual ~nsConnectionInfo();
public:
nsIURL *pURL;
nsNetlibStream *pNetStream;
nsIStreamListener *pConsumer;
};
class nsNetlibStream : public nsIInputStream,
public nsIOutputStream
{
public:
NS_DECL_ISUPPORTS
nsNetlibStream(void);
virtual PRInt32 GetAvailableSpace(PRInt32 *aErrorCode) = 0;
/* From nsIBaseStream interface */
virtual void Close(void);
protected:
virtual ~nsNetlibStream();
inline void LockStream (void) { if (m_Lock) PR_EnterMonitor(m_Lock); }
inline void UnlockStream(void) { if (m_Lock) PR_ExitMonitor (m_Lock); }
protected:
PRBool m_bIsClosed;
private:
PRMonitor *m_Lock;
};
/*
* Variable size, buffered stream...
*/
class nsBufferedStream : public nsNetlibStream {
public:
nsBufferedStream(void);
virtual PRInt32 GetAvailableSpace(PRInt32 *aErrorCode);
/* From nsIBaseStream interface */
virtual PRInt32 GetLength(void);
/* nsIInputStream interface */
virtual PRInt32 Read(PRInt32 *aErrorCode,
char *aBuf,
PRInt32 aOffset,
PRInt32 aCount);
/* nsIOutputStream interface */
virtual PRInt32 Write(PRInt32 *aErrorCode,
const char *aBuf,
PRInt32 aOffset,
PRInt32 aLen);
protected:
virtual ~nsBufferedStream();
private:
char *m_Buffer;
PRInt32 m_BufferLength;
PRInt32 m_DataLength;
PRInt32 m_ReadOffset;
PRInt32 m_WriteOffset;
};
/*
* Fixed size stream...
*/
class nsAsyncStream : public nsNetlibStream {
public:
nsAsyncStream(PRInt32 buffer_size);
virtual PRInt32 GetAvailableSpace(PRInt32 *aErrorCode);
/* From nsIBaseStream interface */
virtual PRInt32 GetLength(void);
/* nsIInputStream interface */
virtual PRInt32 Read(PRInt32 *aErrorCode,
char *aBuf,
PRInt32 aOffset,
PRInt32 aCount);
/* nsIOutputStream interface */
virtual PRInt32 Write(PRInt32 *aErrorCode,
const char *aBuf,
PRInt32 aOffset,
PRInt32 aLen);
protected:
virtual ~nsAsyncStream();
private:
char *m_Buffer;
PRInt32 m_BufferLength;
PRInt32 m_DataLength;
PRInt32 m_ReadOffset;
PRInt32 m_WriteOffset;
};
/*
* Fixed size, blocking stream...
*/
class nsBlockingStream : public nsNetlibStream {
public:
nsBlockingStream(void);
virtual PRInt32 GetAvailableSpace(PRInt32 *aErrorCode);
/* From nsIBaseStream interface */
virtual PRInt32 GetLength(void);
/* nsIInputStream interface */
virtual PRInt32 Read(PRInt32 *aErrorCode,
char *aBuf,
PRInt32 aOffset,
PRInt32 aCount);
/* nsIOutputStream interface */
virtual PRInt32 Write(PRInt32 *aErrorCode,
const char *aBuf,
PRInt32 aOffset,
PRInt32 aLen);
protected:
virtual ~nsBlockingStream();
PRInt32 ReadBuffer(char *aBuf, PRInt32 aCount);
private:
char *m_Buffer;
PRInt32 m_BufferLength;
PRInt32 m_DataLength;
PRInt32 m_ReadOffset;
PRInt32 m_WriteOffset;
};
#endif /* net_strm_h___ */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,24 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#if 0
#define MOZ_FUNCTION_STUB \
DebugBreak();
#else
#define MOZ_FUNCTION_STUB
#endif

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

@ -0,0 +1,429 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "net.h"
#include "mktrace.h"
#include "structs.h"
#include "ctxtfunc.h"
#include "nsIStreamListener.h"
#include "nsNetStream.h"
/****************************************************************************/
/* Beginning of MWContext Evil!!! */
/* ------------------------------- */
/* */
/* Define a dummy MWContext where all of the upcalls are stubbed out. */
/* */
/****************************************************************************/
PRIVATE int
stub_noop(int x, ...)
{
#ifdef XP_MAC
#pragma unused (x)
#endif
/* DebugBreak(); */
return 0;
}
PRIVATE void stub_GraphProgressInit(MWContext *context,
URL_Struct *URL_s,
int32 content_length)
{
nsConnectionInfo *pConn;
if (NULL != URL_s->fe_data) {
/*
* Retrieve the nsConnectionInfo object from the fe_data field
* of the URL_Struct...
*/
pConn = (nsConnectionInfo *)URL_s->fe_data;
if ((NULL != pConn) && (NULL != pConn->pConsumer)) {
pConn->pConsumer->OnProgress(0, content_length, NULL);
}
}
}
PRIVATE void stub_GraphProgress(MWContext *context,
URL_Struct *URL_s,
int32 bytes_received,
int32 bytes_since_last_time,
int32 content_length)
{
nsConnectionInfo *pConn;
if (NULL != URL_s->fe_data) {
/*
* Retrieve the nsConnectionInfo object from the fe_data field
* of the URL_Struct...
*/
pConn = (nsConnectionInfo *)URL_s->fe_data;
if ((NULL != pConn) && (NULL != pConn->pConsumer)) {
pConn->pConsumer->OnProgress(bytes_received, content_length, NULL);
}
}
}
PRIVATE void stub_GraphProgressDestroy(MWContext *context,
URL_Struct *URL_s,
int32 content_length,
int32 total_bytes_read)
{
nsConnectionInfo *pConn;
if (NULL != URL_s->fe_data) {
/*
* Retrieve the nsConnectionInfo object from the fe_data field
* of the URL_Struct...
*/
pConn = (nsConnectionInfo *)URL_s->fe_data;
if ((NULL != pConn) && (NULL != pConn->pConsumer)) {
pConn->pConsumer->OnProgress(total_bytes_read, content_length, NULL);
}
}
}
#define MAKE_FE_TYPES_PREFIX(func) func##_t
#define MAKE_FE_FUNCS_TYPES
#include "mk_cx_fn.h"
#undef MAKE_FE_FUNCS_TYPES
#define stub_CreateNewDocWindow (CreateNewDocWindow_t)stub_noop
#define stub_LayoutNewDocument (LayoutNewDocument_t)stub_noop
#define stub_SetDocTitle (SetDocTitle_t)stub_noop
#define stub_FinishedLayout (FinishedLayout_t)stub_noop
#define stub_TranslateISOText (TranslateISOText_t)stub_noop
#define stub_GetTextInfo (GetTextInfo_t)stub_noop
#define stub_MeasureText (MeasureText_t)stub_noop
#define stub_GetEmbedSize (GetEmbedSize_t)stub_noop
#define stub_GetJavaAppSize (GetJavaAppSize_t)stub_noop
#define stub_GetFormElementInfo (GetFormElementInfo_t)stub_noop
#define stub_GetFormElementValue (GetFormElementValue_t)stub_noop
#define stub_ResetFormElement (ResetFormElement_t)stub_noop
#define stub_SetFormElementToggle (SetFormElementToggle_t)stub_noop
#define stub_FreeFormElement (FreeFormElement_t)stub_noop
#define stub_FreeImageElement (FreeImageElement_t)stub_noop
#define stub_FreeEmbedElement (FreeEmbedElement_t)stub_noop
#define stub_FreeJavaAppElement (FreeJavaAppElement_t)stub_noop
#define stub_CreateEmbedWindow (CreateEmbedWindow_t)stub_noop
#define stub_SaveEmbedWindow (SaveEmbedWindow_t)stub_noop
#define stub_RestoreEmbedWindow (RestoreEmbedWindow_t)stub_noop
#define stub_DestroyEmbedWindow (DestroyEmbedWindow_t)stub_noop
#define stub_HideJavaAppElement (HideJavaAppElement_t)stub_noop
#define stub_FreeEdgeElement (FreeEdgeElement_t)stub_noop
#define stub_FormTextIsSubmit (FormTextIsSubmit_t)stub_noop
#define stub_DisplaySubtext (DisplaySubtext_t)stub_noop
#define stub_DisplayText (DisplayText_t)stub_noop
#define stub_DisplayImage (DisplayImage_t)stub_noop
#define stub_DisplayEmbed (DisplayEmbed_t)stub_noop
#define stub_DisplayJavaApp (DisplayJavaApp_t)stub_noop
#define stub_DisplaySubImage (DisplaySubImage_t)stub_noop
#define stub_DisplayEdge (DisplayEdge_t)stub_noop
#define stub_DisplayTable (DisplayTable_t)stub_noop
#define stub_DisplayCell (DisplayCell_t)stub_noop
#define stub_InvalidateEntireTableOrCell (InvalidateEntireTableOrCell_t)stub_noop
#define stub_DisplayAddRowOrColBorder (DisplayAddRowOrColBorder_t)stub_noop
#define stub_DisplaySubDoc (DisplaySubDoc_t)stub_noop
#define stub_DisplayLineFeed (DisplayLineFeed_t)stub_noop
#define stub_DisplayHR (DisplayHR_t)stub_noop
#define stub_DisplayBullet (DisplayBullet_t)stub_noop
#define stub_DisplayFormElement (DisplayFormElement_t)stub_noop
#define stub_DisplayBorder (DisplayBorder_t)stub_noop
#define stub_UpdateEnableStates (UpdateEnableStates_t)stub_noop
#define stub_DisplayFeedback (DisplayFeedback_t)stub_noop
#define stub_ClearView (ClearView_t)stub_noop
#define stub_SetDocDimension (SetDocDimension_t)stub_noop
#define stub_SetDocPosition (SetDocPosition_t)stub_noop
#define stub_GetDocPosition (GetDocPosition_t)stub_noop
#define stub_BeginPreSection (BeginPreSection_t)stub_noop
#define stub_EndPreSection (EndPreSection_t)stub_noop
#define stub_SetProgressBarPercent (SetProgressBarPercent_t)stub_noop
#define stub_SetBackgroundColor (SetBackgroundColor_t)stub_noop
#define stub_Progress (Progress_t)stub_noop
#define stub_Alert (Alert_t)stub_noop
#define stub_SetCallNetlibAllTheTime (SetCallNetlibAllTheTime_t)stub_noop
#define stub_ClearCallNetlibAllTheTime (ClearCallNetlibAllTheTime_t)stub_noop
#define stub_GraphProgressInit (GraphProgressInit_t)stub_GraphProgressInit
#define stub_GraphProgressDestroy (GraphProgressDestroy_t)stub_GraphProgressDestroy
#define stub_GraphProgress (GraphProgress_t)stub_GraphProgress
#define stub_UseFancyFTP (UseFancyFTP_t)stub_noop
#define stub_UseFancyNewsgroupListing (UseFancyNewsgroupListing_t)stub_noop
#define stub_FileSortMethod (FileSortMethod_t)stub_noop
#define stub_ShowAllNewsArticles (ShowAllNewsArticles_t)stub_noop
#define stub_Confirm (Confirm_t)stub_noop
#define stub_Prompt (Prompt_t)stub_noop
#define stub_PromptWithCaption (PromptWithCaption_t)stub_noop
#define stub_PromptUsernameAndPassword (PromptUsernameAndPassword_t)stub_noop
#define stub_PromptPassword (PromptPassword_t)stub_noop
#define stub_EnableClicking (EnableClicking_t)stub_noop
#define stub_AllConnectionsComplete (AllConnectionsComplete_t)stub_noop
#define stub_ImageSize (ImageSize_t)stub_noop
#define stub_ImageData (ImageData_t)stub_noop
#define stub_ImageIcon (ImageIcon_t)stub_noop
#define stub_ImageOnScreen (ImageOnScreen_t)stub_noop
#define stub_SetColormap (SetColormap_t)stub_noop
#ifdef LAYERS
#define stub_EraseBackground (EraseBackground_t)stub_noop
#define stub_SetDrawable (SetDrawable_t)stub_noop
#define stub_GetTextFrame (GetTextFrame_t)stub_noop
#define stub_SetClipRegion (SetClipRegion_t)stub_noop
#define stub_SetOrigin (SetOrigin_t)stub_noop
#define stub_GetOrigin (GetOrigin_t)stub_noop
#define stub_GetTextFrame (GetTextFrame_t)stub_noop
#endif
#define stub_GetDefaultBackgroundColor (GetDefaultBackgroundColor_t)stub_noop
#define stub_LoadFontResource (LoadFontResource_t)stub_noop
#define stub_DrawJavaApp (DrawJavaApp_t)stub_noop
#define stub_HandleClippingView (HandleClippingView_t)stub_noop
/* Just reuse the same set of context functions: */
ContextFuncs stub_context_funcs;
MWContext *new_stub_context()
{
static int funcsInitialized = 0;
MWContext *context;
if (!funcsInitialized) {
#define MAKE_FE_FUNCS_PREFIX(f) stub_##f
#define MAKE_FE_FUNCS_ASSIGN stub_context_funcs.
#include "mk_cx_fn.h"
funcsInitialized = 1;
}
context = (MWContext *)calloc(sizeof(struct MWContext_), 1);
context->funcs = &stub_context_funcs;
context->type = MWContextBrowser;
return context;
}
void free_stub_context(MWContext *window_id)
{
TRACEMSG(("Freeing stub context...\n"));
free(window_id);
}
/****************************************************************************/
/* End of MWContext Evil!!! */
/****************************************************************************/
nsConnectionInfo *GetConnectionInfoFromStream(NET_StreamClass *stream)
{
URL_Struct *URL_s = (URL_Struct *)stream->data_object;
return (URL_s) ? (nsConnectionInfo *)URL_s->fe_data : NULL;
}
/*
* Define a NET_StreamClass which pushes its data into an nsIStream
* and fires off notifications through the nsIStreamListener interface
*/
void stub_complete(NET_StreamClass *stream)
{
URL_Struct *URL_s = (URL_Struct *)stream->data_object;
nsConnectionInfo *pConn = GetConnectionInfoFromStream(stream);
TRACEMSG(("+++ stream complete.\n"));
/* Close the stream and remove it from the ConnectionInfo... */
pConn->pNetStream->Close();
pConn->pNetStream->Release();
pConn->pNetStream = NULL;
/* Notify the Data Consumer that the Binding has completed... */
if (pConn->pConsumer) {
pConn->pConsumer->OnStopBinding(NS_BINDING_SUCCEEDED, nsnull);
pConn->pConsumer->Release();
pConn->pConsumer = NULL;
}
/* Release the URL_Struct hanging off of the data_object */
stream->data_object = NULL;
NET_DropURLStruct(URL_s);
}
void stub_abort(NET_StreamClass *stream, int status)
{
URL_Struct *URL_s = (URL_Struct *)stream->data_object;
nsConnectionInfo *pConn = GetConnectionInfoFromStream(stream);
TRACEMSG(("+++ stream abort. Status = %d\n", status));
/* Close the stream and remove it from the ConnectionInfo... */
pConn->pNetStream->Close();
pConn->pNetStream->Release();
pConn->pNetStream = NULL;
/* Notify the Data Consumer that the Binding has completed... */
/*
* XXX: Currently, there is no difference between complete and
* abort...
*/
if (pConn->pConsumer) {
pConn->pConsumer->OnStopBinding(NS_BINDING_ABORTED, nsnull);
pConn->pConsumer->Release();
pConn->pConsumer = NULL;
}
/* Release the URL_Struct hanging off of the data_object */
stream->data_object = NULL;
NET_DropURLStruct(URL_s);
}
int stub_put_block(NET_StreamClass *stream, const char *buffer, int32 length)
{
PRInt32 bytesWritten, errorCode;
nsConnectionInfo *pConn = GetConnectionInfoFromStream(stream);
TRACEMSG(("+++ stream put_block. Length = %d\n", length));
/*
* XXX: Sometimes put_block(...) will be called without having
* called is_write_ready(...) first. Once case is when a stream
* is interrupted... In this case, Netlib will call put_block(...)
* with the string "Transfer Interrupted!"
*/
bytesWritten = pConn->pNetStream->Write(&errorCode, buffer, 0, length);
/* Abort the connection... */
if (NS_INPUTSTREAM_EOF == errorCode) {
return -1;
}
/* XXX: check return value to abort connection if necessary */
if (pConn->pConsumer && (0 < bytesWritten)) {
pConn->pConsumer->OnDataAvailable(pConn->pNetStream, bytesWritten);
}
return (bytesWritten == length);
}
unsigned int stub_is_write_ready(NET_StreamClass *stream)
{
PRInt32 errorCode;
unsigned int free_space = 0;
URL_Struct *URL_s = (URL_Struct *)stream->data_object;
nsConnectionInfo *pConn = GetConnectionInfoFromStream(stream);
free_space = (unsigned int)pConn->pNetStream->GetAvailableSpace(&errorCode);
/*
* If the InputStream has been closed... Return 1 byte available so
* Netlib will call put_block(...) one more time...
*/
if (NS_INPUTSTREAM_EOF == errorCode) {
free_space = 1;
}
TRACEMSG(("+++ stream is_write_ready. Returning %d\n", free_space));
return free_space;
}
extern "C" {
/*
*Find a converter routine to create a stream and return the stream struct
*/
PUBLIC NET_StreamClass *
NET_StreamBuilder (FO_Present_Types format_out,
URL_Struct *URL_s,
MWContext *context)
{
// MOZ_FUNCTION_STUB;
NET_StreamClass *stream = NULL;
PRBool bSuccess = PR_TRUE;
/*
* Only create a stream if an nsConnectionInfo object is
* available from the fe_data...
*/
if (NULL != URL_s->fe_data) {
stream = (NET_StreamClass *)calloc(sizeof(NET_StreamClass), 1);
if (NULL != stream) {
nsConnectionInfo *pConn;
/*
* Initialize the NET_StreamClass instance...
*/
stream->name = "Stub Stream";
stream->window_id = context;
stream->complete = stub_complete;
stream->abort = stub_abort;
stream->put_block = stub_put_block;
stream->is_write_ready = stub_is_write_ready;
/*
* Retrieve the nsConnectionInfo object from the fe_data field
* of the URL_Struct...
*/
pConn = (nsConnectionInfo *)URL_s->fe_data;
/*
* If the URL address has been rewritten by netlib then update
* the cached info in the URL object...
*/
if ((URL_s->address_modified) && (NULL != pConn->pURL)) {
pConn->pURL->Set(NET_URLStruct_Address(URL_s));
}
/*
* Create an Async stream unless a blocking stream is already
* available in the ConnectionInfo...
*/
if (NULL == pConn->pNetStream) {
pConn->pNetStream = new nsAsyncStream(8192);
if (NULL == pConn->pNetStream) {
free(stream);
return NULL;
}
pConn->pNetStream->AddRef();
}
/* Hang the URL_Struct off of the NET_StreamClass */
NET_HoldURLStruct(URL_s);
stream->data_object = URL_s;
/* Notify the data consumer that Binding is beginning...*/
/* XXX: check result to terminate connection if necessary */
printf("+++ Created a stream for %s\n", URL_s->address);
if (pConn->pConsumer) {
pConn->pConsumer->OnStartBinding();
}
}
}
return stream;
}
}; /* extern "C" */

485
network/module/nsURL.cpp Normal file
Просмотреть файл

@ -0,0 +1,485 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIURL.h"
#include "nsIInputStream.h"
#include "nsINetService.h"
#include "nsIHttpUrl.h" /* NS_NewHttpUrl(...) */
#include "nsString.h"
#include <stdlib.h>
#include <stdio.h>/* XXX */
#include "plstr.h"
#include "prprf.h" /* PR_snprintf(...) */
#include "prmem.h" /* PR_Malloc(...) / PR_Free(...) */
#ifdef XP_PC
#include <windows.h>
#endif
char *mangleResourceIntoFileURL(const char* aResourceFileName);
class URLImpl : public nsIURL {
public:
URLImpl(const nsString& aSpec);
URLImpl(const nsIURL* aURL, const nsString& aSpec);
~URLImpl();
NS_DECL_ISUPPORTS
virtual nsIInputStream* Open(PRInt32* aErrorCode);
virtual nsresult Open(nsIStreamListener *aListener);
virtual PRBool operator==(const nsIURL& aURL) const;
virtual nsresult Set(const char *aNewSpec);
virtual const char* GetProtocol() const;
virtual const char* GetHost() const;
virtual const char* GetFile() const;
virtual const char* GetRef() const;
virtual const char* GetSpec() const;
virtual PRInt32 GetPort() const;
virtual void ToString(nsString& aString) const;
char* mSpec;
char* mProtocol;
char* mHost;
char* mFile;
char* mRef;
PRInt32 mPort;
PRBool mOK;
nsISupports* mProtocolUrl;
nsresult ParseURL(const nsIURL* aURL, const nsString& aSpec);
void CreateProtocolURL();
};
URLImpl::URLImpl(const nsString& aSpec)
{
NS_INIT_REFCNT();
mProtocolUrl = nsnull;
ParseURL(nsnull, aSpec);
}
URLImpl::URLImpl(const nsIURL* aURL, const nsString& aSpec)
{
NS_INIT_REFCNT();
mProtocolUrl = nsnull;
ParseURL(aURL, aSpec);
}
NS_IMPL_ADDREF(URLImpl)
NS_IMPL_RELEASE(URLImpl)
NS_DEFINE_IID(kURLIID, NS_IURL_IID);
nsresult URLImpl::QueryInterface(const nsIID &aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kURLIID)) {
*aInstancePtr = (void*) ((nsIURL*)this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports *)this);
AddRef();
return NS_OK;
}
if (nsnull == mProtocolUrl) {
CreateProtocolURL();
}
if (nsnull != mProtocolUrl) {
return mProtocolUrl->QueryInterface(aIID, aInstancePtr);
}
return NS_NOINTERFACE;
}
URLImpl::~URLImpl()
{
NS_IF_RELEASE(mProtocolUrl);
free(mSpec);
free(mProtocol);
free(mHost);
free(mFile);
free(mRef);
}
nsresult URLImpl::Set(const char *aNewSpec)
{
return ParseURL(nsnull, aNewSpec);
}
PRBool URLImpl::operator==(const nsIURL& aURL) const
{
URLImpl& other = (URLImpl&)aURL; // XXX ?
return PRBool((0 == PL_strcmp(mProtocol, other.mProtocol)) &&
(0 == PL_strcasecmp(mHost, other.mHost)) &&
(0 == PL_strcmp(mFile, other.mFile)));
}
const char* URLImpl::GetProtocol() const
{
return mProtocol;
}
const char* URLImpl::GetHost() const
{
return mHost;
}
const char* URLImpl::GetFile() const
{
return mFile;
}
const char* URLImpl::GetSpec() const
{
return mSpec;
}
const char* URLImpl::GetRef() const
{
return mRef;
}
PRInt32 URLImpl::GetPort() const
{
return mPort;
}
void URLImpl::ToString(nsString& aString) const
{
aString.SetLength(0);
aString.Append(mProtocol);
aString.Append("://");
if (nsnull != mHost) {
aString.Append(mHost);
if (0 < mPort) {
aString.Append(':');
aString.Append(mPort, 10);
}
}
aString.Append(mFile);
if (nsnull != mRef) {
aString.Append('#');
aString.Append(mRef);
}
}
// XXX recode to use nsString api's
// XXX don't bother with port numbers
// XXX don't bother with ref's
// XXX null pointer checks are incomplete
nsresult URLImpl::ParseURL(const nsIURL* aURL, const nsString& aSpec)
{
// XXX hack!
char* cSpec = aSpec.ToNewCString();
const char* uProtocol = nsnull;
const char* uHost = nsnull;
const char* uFile = nsnull;
PRInt32 uPort = -1;
if (nsnull != aURL) {
uProtocol = aURL->GetProtocol();
uHost = aURL->GetHost();
uFile = aURL->GetFile();
uPort = aURL->GetPort();
}
mProtocol = nsnull;
mHost = nsnull;
mFile = nsnull;
mRef = nsnull;
mPort = -1;
mSpec = nsnull;
if (nsnull == cSpec) {
delete cSpec;
if (nsnull == aURL) {
delete cSpec;
return NS_ERROR_ILLEGAL_VALUE;
}
mProtocol = (nsnull != uProtocol) ? PL_strdup(uProtocol) : nsnull;
mHost = (nsnull != uHost) ? PL_strdup(uHost) : nsnull;
mPort = uPort;
mFile = (nsnull != uFile) ? PL_strdup(uFile) : nsnull;
delete cSpec;
return NS_OK;
}
mSpec = PL_strdup(cSpec);
const char* cp = PL_strchr(cSpec, ':');
if (nsnull == cp) {
// relative spec
if (nsnull == aURL) {
delete cSpec;
return NS_ERROR_ILLEGAL_VALUE;
}
// keep protocol and host
mProtocol = (nsnull != uProtocol) ? PL_strdup(uProtocol) : nsnull;
mHost = (nsnull != uHost) ? PL_strdup(uHost) : nsnull;
mPort = uPort;
// figure out file name
PRInt32 len = PL_strlen(cSpec) + 1;
if ((len > 1) && (cSpec[0] == '/')) {
// Relative spec is absolute to the server
mFile = PL_strdup(cSpec);
} else {
char* dp = PL_strrchr(uFile, '/');
PRInt32 dirlen = (dp + 1) - uFile;
mFile = (char*) malloc(dirlen + len);
PL_strncpy(mFile, uFile, dirlen);
PL_strcpy(mFile + dirlen, cSpec);
}
} else {
// absolute spec
// get protocol first
PRInt32 plen = cp - cSpec;
mProtocol = (char*) malloc(plen + 1);
PL_strncpy(mProtocol, cSpec, plen);
mProtocol[plen] = 0;
cp++; // eat : in protocol
// skip over one, two or three slashes
if (*cp == '/') {
cp++;
if (*cp == '/') {
cp++;
if (*cp == '/') {
cp++;
}
}
} else {
delete cSpec;
return NS_ERROR_ILLEGAL_VALUE;
}
const char* cp0 = cp;
if ((PL_strcmp(mProtocol, "resource") == 0) ||
(PL_strcmp(mProtocol, "file") == 0)) {
// resource/file url's do not have host names.
// The remainder of the string is the file name
PRInt32 flen = PL_strlen(cp);
mFile = (char*) malloc(flen + 1);
PL_strcpy(mFile, cp);
#ifdef NS_WIN32
if (PL_strcmp(mProtocol, "file") == 0) {
// If the filename starts with a "x|" where is an single
// character then we assume it's a drive name and change the
// vertical bar back to a ":"
if ((flen >= 2) && (mFile[1] == '|')) {
mFile[1] = ':';
}
}
#endif
} else {
// Host name follows protocol for http style urls
cp = PL_strchr(cp, '/');
if (nsnull == cp) {
// There is no file name, only a host name
PRInt32 hlen = PL_strlen(cp0);
mHost = (char*) malloc(hlen + 1);
PL_strcpy(mHost, cp0);
// Set filename to "/"
mFile = (char*) malloc(2);
mFile[0] = '/';
mFile[1] = 0;
}
else {
PRInt32 hlen = cp - cp0;
mHost = (char*) malloc(hlen + 1);
PL_strncpy(mHost, cp0, hlen);
mHost[hlen] = 0;
// The rest is the file name
PRInt32 flen = PL_strlen(cp);
mFile = (char*) malloc(flen + 1);
PL_strcpy(mFile, cp);
}
}
}
//printf("protocol='%s' host='%s' file='%s'\n", mProtocol, mHost, mFile);
delete cSpec;
return NS_OK;
}
nsIInputStream* URLImpl::Open(PRInt32* aErrorCode)
{
nsresult rv;
nsIInputStream* in = nsnull;
nsINetService *inet;
// XXX: Rewrite the resource: URL into a file: URL
if (PL_strcmp(mProtocol, "resource") == 0) {
char* fileName;
fileName = mangleResourceIntoFileURL(mFile);
Set(fileName);
PR_Free(fileName);
}
rv = NS_NewINetService(&inet, nsnull);
if (NS_OK == rv) {
rv = inet->OpenBlockingStream(this, NULL, &in);
}
// XXX: The INetService should be released...
*aErrorCode = rv;
return in;
}
nsresult URLImpl::Open(nsIStreamListener *aListener)
{
nsINetService *inet;
nsresult rv;
// XXX: Rewrite the resource: URL into a file: URL
if (PL_strcmp(mProtocol, "resource") == 0) {
char *fileName;
fileName = mangleResourceIntoFileURL(mFile);
Set(fileName);
PR_Free(fileName);
}
rv = NS_NewINetService(&inet, nsnull);
if (NS_OK == rv) {
rv = inet->OpenStream(this, aListener);
}
// XXX: The INetService should be released...
return rv;
}
void URLImpl::CreateProtocolURL()
{
nsresult result;
result = NS_NewHttpUrl(&mProtocolUrl, this);
}
NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
const nsString& aSpec)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
URLImpl* it = new URLImpl(aSpec);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kURLIID, (void **) aInstancePtrResult);
}
NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
const nsIURL* aURL,
const nsString& aSpec)
{
URLImpl* it = new URLImpl(aURL, aSpec);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kURLIID, (void **) aInstancePtrResult);
}
NS_NET nsresult NS_MakeAbsoluteURL(nsIURL* aURL,
const nsString& aBaseURL,
const nsString& aSpec,
nsString& aResult)
{
if (0 < aBaseURL.Length()) {
URLImpl base(aBaseURL);
URLImpl url(&base, aSpec);
url.ToString(aResult);
} else {
URLImpl url(aURL, aSpec);
url.ToString(aResult);
}
return NS_OK;
}
char *mangleResourceIntoFileURL(const char* aResourceFileName)
{
// XXX For now, resources are not in jar files
// Find base path name to the resource file
char* resourceBase;
char* cp;
#ifdef XP_PC
// XXX For now, all resources are relative to the .exe file
resourceBase = (char *)PR_Malloc(2000);;
DWORD mfnLen = GetModuleFileName(NULL, resourceBase, 2000);
// Truncate the executable name from the rest of the path...
cp = strrchr(resourceBase, '\\');
if (nsnull != cp) {
*cp = '\0';
}
// Change the first ':' into a '|'
cp = strchr(resourceBase, ':');
if (nsnull != cp) {
*cp = '|';
}
#endif
#ifdef XP_UNIX
// FIX ME: write me!;
#endif
// Join base path to resource name
if (aResourceFileName[0] == '/') {
aResourceFileName++;
}
PRInt32 baseLen = strlen(resourceBase);
PRInt32 resLen = strlen(aResourceFileName);
PRInt32 totalLen = 8 + baseLen + 1 + resLen + 1;
char* fileName = (char *)PR_Malloc(totalLen);
PR_snprintf(fileName, totalLen, "file:///%s/%s", resourceBase, aResourceFileName);
#ifdef XP_PC
// Change any backslashes into foreward slashes...
while ((cp = strchr(fileName, '\\')) != 0) {
*cp = '/';
cp++;
}
#endif
#ifdef XP_PC
PR_Free(resourceBase);
#endif
return fileName;
}

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

@ -79,8 +79,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -9,7 +9,9 @@
#include "xplocale.h"
#include "prefapi.h"
#include "secnav.h"
#ifndef MODULAR_NETLIB
#include "libimg.h"
#endif
#include "il_strm.h"
#include "cookies.h"
#include "httpauth.h"

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

@ -76,8 +76,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -76,8 +76,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -76,8 +76,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -38,7 +38,13 @@
#include "glhist.h"
#include "il_strm.h" /* Image Lib stream converters. */
#ifndef MODULAR_NETLIB
#include "libimg.h" /* Image Lib public API. */
#else
#include "il_types.h"
IL_EXTERN(int)
IL_Type(const char *buf, int32 len);
#endif
#if defined(XP_WIN) || defined(XP_OS2)
#include "errno.h"

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

@ -76,8 +76,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -77,8 +77,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -79,8 +79,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -79,8 +79,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -26,7 +26,19 @@ IGNORE_MANIFEST=1
DEPTH=..\..
DIRS= about dataurl file ftp gopher http js marimba remote
DIRS= \
about \
file \
ftp \
gopher \
http \
remote \
!ifndef MODULAR_NETLIB
dataurl \
js \
marimba \
!endif
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -76,8 +76,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -76,8 +76,6 @@ LINCS= \
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
install::
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::

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

@ -509,7 +509,7 @@ HG85890
HG09714
ptr = PL_strcasestr(CD_RESPONSE_TXT, "DSN");
CD_EHLO_DSN_ENABLED = (ptr && XP_TO_UPPER(*(ptr-1)) != 'X');
CD_EHLO_DSN_ENABLED = (ptr && NET_TO_UPPER(*(ptr-1)) != 'X');
/* should we use auth login */
PREF_GetBoolPref("mail.auth_login", &(CD_AUTH_LOGIN_ENABLED));
if (CD_AUTH_LOGIN_ENABLED) {