Compare commits
188 Commits
pre-5
...
HttpConnec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62260249d7 | ||
|
|
ef04ff435d | ||
|
|
3ee96f57b8 | ||
|
|
f26f30b4c5 | ||
|
|
ce3e6ddbf9 | ||
|
|
54d006d031 | ||
|
|
6d979a3f4b | ||
|
|
6795a88baf | ||
|
|
8be0416d54 | ||
|
|
93d7718522 | ||
|
|
e7457f6c5e | ||
|
|
3355b20538 | ||
|
|
e38c0729b3 | ||
|
|
54e8ca8f3b | ||
|
|
bf655521c6 | ||
|
|
4db19a052e | ||
|
|
80364fb1a4 | ||
|
|
8f7941b6f1 | ||
|
|
55e1ff9673 | ||
|
|
ab3135f787 | ||
|
|
52c9c730d8 | ||
|
|
b3956fe708 | ||
|
|
63d68c34fd | ||
|
|
96a41c2c14 | ||
|
|
08fd9995e0 | ||
|
|
2ca3743459 | ||
|
|
8a48845120 | ||
|
|
bc09fdf610 | ||
|
|
802b66d97d | ||
|
|
96083a1e49 | ||
|
|
31989208be | ||
|
|
29d9b38fe8 | ||
|
|
a8f751a9d9 | ||
|
|
81066b3e6e | ||
|
|
e462d551cb | ||
|
|
09b30c7d5a | ||
|
|
96b0c82bcf | ||
|
|
15ffdf8caa | ||
|
|
0262c5af7e | ||
|
|
01ca73096c | ||
|
|
dadf65501b | ||
|
|
348ee07541 | ||
|
|
dbe972baa8 | ||
|
|
f5d02b707a | ||
|
|
258f97e0cd | ||
|
|
95cdab9527 | ||
|
|
7a5dbad111 | ||
|
|
3e08b330b5 | ||
|
|
f058c57c79 | ||
|
|
b8032d0c21 | ||
|
|
4a6fc79ce2 | ||
|
|
0b5526cd2c | ||
|
|
03d7306f8b | ||
|
|
7ff9289c01 | ||
|
|
7fe1a07870 | ||
|
|
010c993ecc | ||
|
|
17fbfd000c | ||
|
|
cca34ca60b | ||
|
|
45374a5c34 | ||
|
|
17778cbb4a | ||
|
|
b757903490 | ||
|
|
341c5930e6 | ||
|
|
c8b278e410 | ||
|
|
e3e7aaa151 | ||
|
|
d1e31737be | ||
|
|
24ba71145e | ||
|
|
b3d65cb774 | ||
|
|
129ffc6314 | ||
|
|
b52ef0d361 | ||
|
|
a409e246b6 | ||
|
|
343e849a97 | ||
|
|
76e256eaa3 | ||
|
|
a7fdcf52fa | ||
|
|
cd099d2cbc | ||
|
|
f7deb0fa0b | ||
|
|
cd47bfdae2 | ||
|
|
f91fdf403e | ||
|
|
09f6fd004d | ||
|
|
ea9dbc1fa2 | ||
|
|
cde877f50f | ||
|
|
13aefaef6b | ||
|
|
498945875e | ||
|
|
2e0e94ae65 | ||
|
|
7b7422e29a | ||
|
|
d84a726e54 | ||
|
|
73880344b4 | ||
|
|
1b45fe664e | ||
|
|
2f6c90b945 | ||
|
|
644337e67b | ||
|
|
22654d4d46 | ||
|
|
34fba3d4c0 | ||
|
|
e693567a2e | ||
|
|
1c256a65b9 | ||
|
|
bfd50df9de | ||
|
|
edd4b252cd | ||
|
|
73ee7fdc9a | ||
|
|
96eeeb78af | ||
|
|
ea54c51a9d | ||
|
|
7dcb9cc71e | ||
|
|
aa97b1196f | ||
|
|
c85775f835 | ||
|
|
0c98acd0ca | ||
|
|
e928f09133 | ||
|
|
a392db3c90 | ||
|
|
4bae98b66c | ||
|
|
785b49036d | ||
|
|
2596789db7 | ||
|
|
407bbe2241 | ||
|
|
f35727b8ea | ||
|
|
dccd3fea0e | ||
|
|
75ece73a17 | ||
|
|
2ca018925a | ||
|
|
c913fbc495 | ||
|
|
f3fef266f1 | ||
|
|
22764d875c | ||
|
|
774f30876b | ||
|
|
700f64697f | ||
|
|
48e663acf8 | ||
|
|
52efc959be | ||
|
|
5920a24815 | ||
|
|
f67fb40d23 | ||
|
|
bd8bea34a9 | ||
|
|
d3a97bdb9e | ||
|
|
7b767f7ab5 | ||
|
|
59a0933f9d | ||
|
|
8e96dfd851 | ||
|
|
3d39ad60e2 | ||
|
|
7381c52b0f | ||
|
|
0cd86a0e53 | ||
|
|
66cd209313 | ||
|
|
9e5e3dc4f8 | ||
|
|
05af1518f0 | ||
|
|
faaeef8dd0 | ||
|
|
91a290a394 | ||
|
|
6c53a6fa81 | ||
|
|
c30d3dc75c | ||
|
|
0f93d336e4 | ||
|
|
e3451cffcc | ||
|
|
c0a2d2872c | ||
|
|
188591212e | ||
|
|
12228ebdea | ||
|
|
5cccdcfb92 | ||
|
|
1e12ea24d8 | ||
|
|
86bc259321 | ||
|
|
5f592da9ec | ||
|
|
88e1476dcc | ||
|
|
7401de36e0 | ||
|
|
fd3d77122b | ||
|
|
b5e422c515 | ||
|
|
f8b07e1d79 | ||
|
|
25b34db661 | ||
|
|
4ef5a05f6e | ||
|
|
72467e9543 | ||
|
|
5ad305a325 | ||
|
|
4ad5e810d4 | ||
|
|
e9295b308b | ||
|
|
e561e68462 | ||
|
|
ec68a17487 | ||
|
|
87d17ebb9b | ||
|
|
c871441282 | ||
|
|
8e676fcec9 | ||
|
|
01902287ba | ||
|
|
284de57c74 | ||
|
|
7defd5c982 | ||
|
|
196d5f01e3 | ||
|
|
e20d8aa5c0 | ||
|
|
50504e342c | ||
|
|
b841b1c329 | ||
|
|
3c3b40c6a4 | ||
|
|
420c4bdd1e | ||
|
|
32278d385e | ||
|
|
c3af281416 | ||
|
|
aeff9e633b | ||
|
|
29112c02e3 | ||
|
|
a80623ea05 | ||
|
|
252b1505d4 | ||
|
|
9604b2c9e7 | ||
|
|
dee90d33b6 | ||
|
|
e45e176315 | ||
|
|
8c6b501871 | ||
|
|
6ce46da402 | ||
|
|
6a81aac1ee | ||
|
|
efc73f0976 | ||
|
|
5438ed3f24 | ||
|
|
bc635e6b90 | ||
|
|
5b0ac3f43e | ||
|
|
48541d57ac | ||
|
|
a7d10a1cd7 |
27
mozilla/content/build/gbdate.pl
Executable file
27
mozilla/content/build/gbdate.pl
Executable file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
|
||||
# XP way of doing the build date.
|
||||
# 1998091509 = 1998, September, 15th, 9am local time zone
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
|
||||
# localtime returns year minus 1900
|
||||
$year = $year + 1900;
|
||||
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);
|
||||
90
mozilla/content/build/nsContentHTTPStartup.cpp
Normal file
90
mozilla/content/build/nsContentHTTPStartup.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- 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 Communicator client 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):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
|
||||
#define PRODUCT_NAME "Gecko"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::Observe( nsISupports *aSubject,
|
||||
const PRUnichar *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProduct(PRODUCT_NAME);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProductSub((char*) PRODUCT_VERSION);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::RegisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString previousEntry;
|
||||
rv = catMan->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY,
|
||||
"Content UserAgent Setter",
|
||||
NS_CONTENTHTTPSTARTUP_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE,
|
||||
getter_Copies(previousEntry));
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::UnregisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
5215
mozilla/content/html/document/src/nsHTMLContentSink.cpp
Normal file
5215
mozilla/content/html/document/src/nsHTMLContentSink.cpp
Normal file
File diff suppressed because it is too large
Load Diff
3513
mozilla/content/html/document/src/nsHTMLDocument.cpp
Normal file
3513
mozilla/content/html/document/src/nsHTMLDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1424
mozilla/content/xbl/src/nsXBLService.cpp
Normal file
1424
mozilla/content/xbl/src/nsXBLService.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1126
mozilla/content/xml/document/src/nsXMLDocument.cpp
Normal file
1126
mozilla/content/xml/document/src/nsXMLDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
121
mozilla/content/xml/document/src/nsXMLDocument.h
Normal file
121
mozilla/content/xml/document/src/nsXMLDocument.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/* -*- 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.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 Communicator client 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 nsXMLDocument_h___
|
||||
#define nsXMLDocument_h___
|
||||
|
||||
#include "nsMarkupDocument.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
|
||||
class nsIParser;
|
||||
class nsIDOMNode;
|
||||
class nsICSSLoader;
|
||||
class nsIURI;
|
||||
|
||||
class nsXMLDocument : public nsMarkupDocument,
|
||||
public nsIXMLDocument,
|
||||
public nsIHTMLContentContainer,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIHttpEventSink
|
||||
{
|
||||
public:
|
||||
nsXMLDocument();
|
||||
virtual ~nsXMLDocument();
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup);
|
||||
|
||||
NS_IMETHOD GetContentType(nsAWritableString& aContentType) const;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* channel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
NS_IMETHOD GetBaseTarget(nsAWritableString &aBaseTarget);
|
||||
NS_IMETHOD SetBaseTarget(const nsAReadableString &aBaseTarget);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType);
|
||||
NS_IMETHOD CreateCDATASection(const nsAReadableString& aData, nsIDOMCDATASection** aReturn);
|
||||
NS_IMETHOD CreateEntityReference(const nsAReadableString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD CreateProcessingInstruction(const nsAReadableString& aTarget, const nsAReadableString& aData, nsIDOMProcessingInstruction** aReturn);
|
||||
NS_IMETHOD CreateElement(const nsAReadableString& aTagName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD ImportNode(nsIDOMNode* aImportedNode,
|
||||
PRBool aDeep,
|
||||
nsIDOMNode** aReturn);
|
||||
NS_IMETHOD CreateElementNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aQualifiedName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateAttributeNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aQualifiedName,
|
||||
nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD GetElementById(const nsAReadableString& aElementId,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD Load(const nsAReadableString& aUrl);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHOD SetDefaultStylesheets(nsIURI* aUrl);
|
||||
NS_IMETHOD SetTitle(const PRUnichar *aTitle);
|
||||
|
||||
// nsIHTMLContentContainer
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
|
||||
NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader);
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_IMETHOD GetInterface(const nsIID& aIID, void** aSink);
|
||||
|
||||
// nsIHTTPEventSink
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
|
||||
protected:
|
||||
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet); // subclass hook for sheet ordering
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
|
||||
// For HTML elements in our content model
|
||||
// XXX This is not clean, but is there a better way?
|
||||
nsIHTMLStyleSheet* mAttrStyleSheet;
|
||||
nsIHTMLCSSStyleSheet* mInlineStyleSheet;
|
||||
nsString mBaseTarget;
|
||||
|
||||
nsIParser *mParser;
|
||||
nsICSSLoader* mCSSLoader;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsXMLDocument_h___
|
||||
4989
mozilla/docshell/base/nsDocShell.cpp
Normal file
4989
mozilla/docshell/base/nsDocShell.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1438
mozilla/docshell/base/nsWebShell.cpp
Normal file
1438
mozilla/docshell/base/nsWebShell.cpp
Normal file
File diff suppressed because it is too large
Load Diff
4555
mozilla/dom/src/base/nsGlobalWindow.cpp
Normal file
4555
mozilla/dom/src/base/nsGlobalWindow.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1210
mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp
Normal file
1210
mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp
Normal file
File diff suppressed because it is too large
Load Diff
250
mozilla/extensions/cookie/nsCookieHTTPNotify.cpp
Normal file
250
mozilla/extensions/cookie/nsCookieHTTPNotify.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_dp
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "nsCookieService.h" /* don't remove -- needed for mac build */
|
||||
#include "nsCookieHTTPNotify.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsCookie.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINetModuleMgr.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIHttpProtocolHandler.h" // for NS_HTTP_STARTUP_CATEGORY
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIPrompt.h"
|
||||
|
||||
static NS_DEFINE_CID(kINetModuleMgrCID, NS_NETMODULEMGR_CID);
|
||||
|
||||
///////////////////////////////////
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsCookieHTTPNotify, nsIHttpNotify, nsINetNotify);
|
||||
|
||||
///////////////////////////////////
|
||||
// nsCookieHTTPNotify Implementation
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCookieHTTPNotify, Init)
|
||||
|
||||
nsresult nsCookieHTTPNotify::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
return nsCookieHTTPNotifyConstructor(aOuter, aIID, aResult);
|
||||
}
|
||||
|
||||
NS_METHOD nsCookieHTTPNotify::RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
// Register ourselves into the NS_CATEGORY_HTTP_STARTUP
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString prevEntry;
|
||||
rv = catman->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY, "Http Cookie Notify", NS_COOKIEHTTPNOTIFY_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(prevEntry));
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_METHOD nsCookieHTTPNotify::UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString prevEntry;
|
||||
rv = catman->DeleteCategoryEntry(NS_HTTP_STARTUP_CATEGORY, NS_COOKIEHTTPNOTIFY_CONTRACTID, PR_TRUE,
|
||||
getter_Copies(prevEntry));
|
||||
|
||||
// Return value is not used from this function.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::Init()
|
||||
{
|
||||
// Register to handing http requests and responses
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsINetModuleMgr> pNetModuleMgr = do_GetService(kINetModuleMgrCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = pNetModuleMgr->RegisterModule(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_CONTRACTID,
|
||||
(nsIHttpNotify *)this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = pNetModuleMgr->RegisterModule(NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_CONTRACTID,
|
||||
(nsIHttpNotify *)this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCookieHTTPNotify::nsCookieHTTPNotify()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mCookieService = nsnull;
|
||||
#ifdef DEBUG_dp
|
||||
printf("CookieHTTPNotify Created.\n");
|
||||
#endif /* DEBUG_dp */
|
||||
}
|
||||
|
||||
nsCookieHTTPNotify::~nsCookieHTTPNotify()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::SetupCookieService()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!mCookieService)
|
||||
{
|
||||
mCookieService = do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// nsIHttpNotify
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::OnModifyRequest(nsIHttpChannel *aHttpChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
// Preconditions
|
||||
NS_ENSURE_ARG_POINTER(aHttpChannel);
|
||||
|
||||
// Get the url
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the original url that the user either typed in or clicked on
|
||||
nsCOMPtr<nsILoadGroup> pLoadGroup;
|
||||
rv = aHttpChannel->GetLoadGroup(getter_AddRefs(pLoadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
if (pLoadGroup) {
|
||||
nsCOMPtr<nsIRequest> pRequest;
|
||||
rv = pLoadGroup->GetDefaultLoadRequest(getter_AddRefs(pRequest));
|
||||
if (pRequest)
|
||||
pChannel = do_QueryInterface(pRequest);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> pFirstURL;
|
||||
if (pChannel) {
|
||||
rv = pChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
} else {
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Ensure that the cookie service exists
|
||||
rv = SetupCookieService();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char * cookie;
|
||||
rv = mCookieService->GetCookieStringFromHttp(pURL, pFirstURL, &cookie);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Set the cookie into the request headers
|
||||
if (cookie && *cookie)
|
||||
rv = aHttpChannel->SetRequestHeader("Cookie", cookie);
|
||||
nsMemory::Free((void *)cookie);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::OnExamineResponse(nsIHttpChannel *aHttpChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
// Preconditions
|
||||
NS_ENSURE_ARG_POINTER(aHttpChannel);
|
||||
|
||||
// Get the Cookie header
|
||||
nsXPIDLCString cookieHeader;
|
||||
rv = aHttpChannel->GetResponseHeader("Set-Cookie", getter_Copies(cookieHeader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!cookieHeader) return NS_OK; // not an error, there's just no header.
|
||||
|
||||
// Get the url
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the original url that the user either typed in or clicked on
|
||||
nsCOMPtr<nsILoadGroup> pLoadGroup;
|
||||
rv = aHttpChannel->GetLoadGroup(getter_AddRefs(pLoadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
if (pLoadGroup) {
|
||||
nsCOMPtr<nsIRequest> pRequest;
|
||||
rv = pLoadGroup->GetDefaultLoadRequest(getter_AddRefs(pRequest));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
pChannel = do_QueryInterface(pRequest);
|
||||
}
|
||||
nsCOMPtr<nsIURI> pFirstURL;
|
||||
if (pChannel) {
|
||||
rv = pChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
} else {
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the prompter
|
||||
nsCOMPtr<nsIInterfaceRequestor> pInterfaces;
|
||||
nsCOMPtr<nsIPrompt> pPrompter;
|
||||
if (pChannel) {
|
||||
pChannel->GetNotificationCallbacks(getter_AddRefs(pInterfaces));
|
||||
} else {
|
||||
aHttpChannel->GetNotificationCallbacks(getter_AddRefs(pInterfaces));
|
||||
}
|
||||
if (pInterfaces)
|
||||
pInterfaces->GetInterface(NS_GET_IID(nsIPrompt), getter_AddRefs(pPrompter));
|
||||
|
||||
// Get the expires
|
||||
nsXPIDLCString dateHeader;
|
||||
rv = aHttpChannel->GetResponseHeader("Date", getter_Copies(dateHeader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Ensure that we have the cookie service
|
||||
rv = SetupCookieService();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Save the cookie
|
||||
rv = mCookieService->SetCookieStringFromHttp(pURL, pFirstURL, pPrompter, cookieHeader, dateHeader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
71
mozilla/extensions/cookie/nsCookieHTTPNotify.h
Normal file
71
mozilla/extensions/cookie/nsCookieHTTPNotify.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 2; 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 nsCookieHTTPNotify_h___
|
||||
#define nsCookieHTTPNotify_h___
|
||||
|
||||
#include "nsIHttpNotify.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
// {6BC1F522-1F45-11d3-8AD4-00105A1B8860}
|
||||
#define NS_COOKIEHTTPNOTIFY_CID \
|
||||
{ 0x6bc1f522, 0x1f45, 0x11d3, { 0x8a, 0xd4, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
|
||||
|
||||
#define NS_COOKIEHTTPNOTIFY_CONTRACTID "@mozilla.org/cookie-notifier;1"
|
||||
#define NS_COOKIEHTTPNOTIFY_CLASSNAME "Cookie Notifier"
|
||||
|
||||
struct nsModuleComponentInfo; // forward declaration
|
||||
|
||||
class nsCookieHTTPNotify : public nsIHttpNotify {
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Init method
|
||||
NS_IMETHOD Init();
|
||||
|
||||
// nsIHttpNotify methods:
|
||||
NS_DECL_NSIHTTPNOTIFY
|
||||
|
||||
// nsCookieHTTPNotify methods:
|
||||
nsCookieHTTPNotify();
|
||||
virtual ~nsCookieHTTPNotify();
|
||||
|
||||
static nsresult Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
const nsModuleComponentInfo *info);
|
||||
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const nsModuleComponentInfo *info);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsICookieService> mCookieService;
|
||||
|
||||
NS_IMETHOD SetupCookieService();
|
||||
};
|
||||
#endif /* nsCookieHTTPNotify_h___ */
|
||||
43
mozilla/extensions/datetime/Makefile.in
Normal file
43
mozilla/extensions/datetime/Makefile.in
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = necko
|
||||
LIBRARY_NAME = nkdatetm_s
|
||||
REQUIRES = xpcom string
|
||||
|
||||
CPPSRCS = \
|
||||
nsDateTimeHandler.cpp \
|
||||
nsDateTimeChannel.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
327
mozilla/extensions/datetime/nsDateTimeChannel.cpp
Normal file
327
mozilla/extensions/datetime/nsDateTimeChannel.cpp
Normal file
@@ -0,0 +1,327 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
// datetime implementation
|
||||
|
||||
#include "nsDateTimeChannel.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
||||
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
||||
|
||||
// nsDateTimeChannel methods
|
||||
nsDateTimeChannel::nsDateTimeChannel() {
|
||||
NS_INIT_REFCNT();
|
||||
mContentLength = -1;
|
||||
mPort = -1;
|
||||
}
|
||||
|
||||
nsDateTimeChannel::~nsDateTimeChannel() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS4(nsDateTimeChannel,
|
||||
nsIChannel,
|
||||
nsIRequest,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver)
|
||||
|
||||
nsresult
|
||||
nsDateTimeChannel::Init(nsIURI* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ASSERTION(uri, "no uri");
|
||||
|
||||
mUrl = uri;
|
||||
|
||||
rv = mUrl->GetPort(&mPort);
|
||||
if (NS_FAILED(rv) || mPort < 1)
|
||||
mPort = DATETIME_PORT;
|
||||
|
||||
rv = mUrl->GetPath(getter_Copies(mHost));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!*(const char *)mHost) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsDateTimeChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
||||
{
|
||||
nsDateTimeChannel* dc = new nsDateTimeChannel();
|
||||
if (dc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(dc);
|
||||
nsresult rv = dc->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(dc);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequest methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetName(PRUnichar* *result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::IsPending(PRBool *result)
|
||||
{
|
||||
NS_NOTREACHED("nsDateTimeChannel::IsPending");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetStatus(nsresult *status)
|
||||
{
|
||||
*status = NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::Cancel(nsresult status)
|
||||
{
|
||||
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
||||
NS_NOTREACHED("nsDateTimeChannel::Cancel");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::Suspend(void)
|
||||
{
|
||||
NS_NOTREACHED("nsDateTimeChannel::Suspend");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::Resume(void)
|
||||
{
|
||||
NS_NOTREACHED("nsDateTimeChannel::Resume");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChannel methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetOriginalURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mOriginalURI ? mOriginalURI : mUrl;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetOriginalURI(nsIURI* aURI)
|
||||
{
|
||||
mOriginalURI = aURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mUrl;
|
||||
NS_IF_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::Open(nsIInputStream **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITransport> transport;
|
||||
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
transport->SetNotificationCallbacks(mCallbacks,
|
||||
(mLoadFlags & LOAD_BACKGROUND));
|
||||
|
||||
return transport->OpenInputStream(0, -1, 0, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITransport> transport;
|
||||
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
transport->SetNotificationCallbacks(mCallbacks,
|
||||
(mLoadFlags & LOAD_BACKGROUND));
|
||||
|
||||
mListener = aListener;
|
||||
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
return transport->AsyncRead(this, ctxt, 0, -1, 0, getter_AddRefs(request));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetLoadFlags(PRUint32 *aLoadFlags)
|
||||
{
|
||||
*aLoadFlags = mLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define DATETIME_TYPE "text/plain"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetContentType(char* *aContentType) {
|
||||
if (!aContentType) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aContentType = nsCRT::strdup(DATETIME_TYPE);
|
||||
if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetContentType(const char *aContentType)
|
||||
{
|
||||
//It doesn't make sense to set the content-type on this type
|
||||
// of channel...
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetContentLength(PRInt32 aContentLength)
|
||||
{
|
||||
NS_NOTREACHED("nsDateTimeChannel::SetContentLength");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
if (mLoadGroup) // if we already had a load group remove ourselves...
|
||||
(void)mLoadGroup->RemoveRequest(this, nsnull, NS_OK);
|
||||
|
||||
mLoadGroup = aLoadGroup;
|
||||
if (mLoadGroup) {
|
||||
return mLoadGroup->AddRequest(this, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetSecurityInfo(nsISupports **sec)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(sec);
|
||||
*sec = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIRequestObserver methods
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) {
|
||||
return mListener->OnStartRequest(this, aContext);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext,
|
||||
nsresult aStatus) {
|
||||
if (mLoadGroup) {
|
||||
nsresult rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return mListener->OnStopRequest(this, aContext, aStatus);
|
||||
}
|
||||
|
||||
|
||||
// nsIStreamListener method
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext,
|
||||
nsIInputStream *aInputStream, PRUint32 aSourceOffset,
|
||||
PRUint32 aLength) {
|
||||
mContentLength = aLength;
|
||||
return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength);
|
||||
}
|
||||
|
||||
78
mozilla/extensions/datetime/nsDateTimeChannel.h
Normal file
78
mozilla/extensions/datetime/nsDateTimeChannel.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
// A datetime channel retrieves date time information from
|
||||
// RFC 867 compliant datetime servers. The date/time returned
|
||||
// to the caller is of MIME type "text/plain".
|
||||
|
||||
#ifndef nsDateTimeChannel_h___
|
||||
#define nsDateTimeChannel_h___
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsDateTimeHandler.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
|
||||
class nsDateTimeChannel
|
||||
: public nsIChannel,
|
||||
public nsIStreamListener {
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
// nsDateTimeChannel methods:
|
||||
nsDateTimeChannel();
|
||||
virtual ~nsDateTimeChannel();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init(nsIURI* uri);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mUrl;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
PRUint32 mLoadFlags;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCString mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
PRInt32 mPort;
|
||||
nsXPIDLCString mHost;
|
||||
};
|
||||
|
||||
#endif /* nsDateTimeChannel_h___ */
|
||||
117
mozilla/extensions/datetime/nsDateTimeHandler.cpp
Normal file
117
mozilla/extensions/datetime/nsDateTimeHandler.cpp
Normal 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):
|
||||
*/
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsDateTimeChannel.h"
|
||||
#include "nsDateTimeHandler.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsDateTimeHandler::nsDateTimeHandler() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsDateTimeHandler::~nsDateTimeHandler() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDateTimeHandler, nsIProtocolHandler)
|
||||
|
||||
NS_METHOD
|
||||
nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
|
||||
|
||||
nsDateTimeHandler* ph = new nsDateTimeHandler();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(ph);
|
||||
nsresult rv = ph->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(ph);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeHandler::GetScheme(char* *result) {
|
||||
*result = nsCRT::strdup("datetime");
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeHandler::GetDefaultPort(PRInt32 *result) {
|
||||
*result = DATETIME_PORT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
nsIURI **result) {
|
||||
nsresult rv;
|
||||
|
||||
// no concept of a relative datetime url
|
||||
NS_ASSERTION(!aBaseURI, "base url passed into datetime protocol handler");
|
||||
|
||||
nsIURI* url;
|
||||
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
|
||||
NS_GET_IID(nsIURI),
|
||||
(void**)&url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = url->SetSpec((char*)aSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = url;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsDateTimeChannel* channel;
|
||||
rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(url);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = channel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
51
mozilla/extensions/datetime/nsDateTimeHandler.h
Normal file
51
mozilla/extensions/datetime/nsDateTimeHandler.h
Normal 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):
|
||||
*/
|
||||
|
||||
// The datetime protocol handler creates "datetime" URIs of the form
|
||||
// "datetime:RFC867Server".
|
||||
|
||||
#ifndef nsDateTimeHandler_h___
|
||||
#define nsDateTimeHandler_h___
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
#define DATETIME_PORT 13
|
||||
|
||||
// {AA27D2A0-B71B-11d3-A1A0-0050041CAF44}
|
||||
#define NS_DATETIMEHANDLER_CID \
|
||||
{ 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } }
|
||||
|
||||
class nsDateTimeHandler : public nsIProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
|
||||
// nsDateTimeHandler methods:
|
||||
nsDateTimeHandler();
|
||||
virtual ~nsDateTimeHandler();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
};
|
||||
|
||||
#endif /* nsDateTimeHandler_h___ */
|
||||
34
mozilla/extensions/datetime/nsDateTimeModule.cpp
Normal file
34
mozilla/extensions/datetime/nsDateTimeModule.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsDateTimeHandler.h"
|
||||
|
||||
static nsModuleComponentInfo gResComponents[] = {
|
||||
{ "The DateTime Protocol Handler",
|
||||
NS_DATETIMEHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "datetime",
|
||||
nsDateTimeHandler::Create
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(datetime, gResComponents)
|
||||
42
mozilla/extensions/finger/Makefile.in
Normal file
42
mozilla/extensions/finger/Makefile.in
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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 Brian Ryner.
|
||||
# Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brian Ryner <bryner@uiuc.edu>
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = necko
|
||||
LIBRARY_NAME = nkfinger_s
|
||||
REQUIRES = xpcom string mimetype
|
||||
|
||||
CPPSRCS = \
|
||||
nsFingerHandler.cpp \
|
||||
nsFingerChannel.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
427
mozilla/extensions/finger/nsFingerChannel.cpp
Normal file
427
mozilla/extensions/finger/nsFingerChannel.cpp
Normal file
@@ -0,0 +1,427 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
// finger implementation
|
||||
|
||||
#include "nsFingerChannel.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsITXTToHTMLConv.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
|
||||
#define BUFFER_SEG_SIZE (4*1024)
|
||||
#define BUFFER_MAX_SIZE (64*1024)
|
||||
|
||||
// nsFingerChannel methods
|
||||
nsFingerChannel::nsFingerChannel()
|
||||
: mContentLength(-1),
|
||||
mActAsObserver(PR_TRUE),
|
||||
mPort(-1),
|
||||
mStatus(NS_OK)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsFingerChannel::~nsFingerChannel() {
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel,
|
||||
nsIChannel,
|
||||
nsIRequest,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver)
|
||||
|
||||
nsresult
|
||||
nsFingerChannel::Init(nsIURI* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString autoBuffer;
|
||||
|
||||
NS_ASSERTION(uri, "no uri");
|
||||
|
||||
mUrl = uri;
|
||||
|
||||
// For security reasons, we do not allow the user to specify a
|
||||
// non-default port for finger: URL's.
|
||||
|
||||
mPort = FINGER_PORT;
|
||||
|
||||
rv = mUrl->GetPath(getter_Copies(autoBuffer)); // autoBuffer = user@host
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Now parse out the user and host
|
||||
const char* buf = autoBuffer.get();
|
||||
const char* pos = PL_strchr(buf, '@');
|
||||
|
||||
// Catch the case of just the host being given
|
||||
if (!pos) {
|
||||
mHost.Assign(buf);
|
||||
} else {
|
||||
mUser.Assign(buf,pos-buf);
|
||||
mHost.Assign(pos+1); // ignore '@'
|
||||
}
|
||||
|
||||
if (mHost.IsEmpty()) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsFingerChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
||||
{
|
||||
nsFingerChannel* fc = new nsFingerChannel();
|
||||
if (fc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(fc);
|
||||
nsresult rv = fc->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(fc);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequest methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetName(PRUnichar* *result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::IsPending(PRBool *result)
|
||||
{
|
||||
NS_NOTREACHED("nsFingerChannel::IsPending");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetStatus(nsresult *status)
|
||||
{
|
||||
*status = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::Cancel(nsresult status)
|
||||
{
|
||||
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
mStatus = status;
|
||||
if (mTransportRequest) {
|
||||
rv = mTransportRequest->Cancel(status);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::Suspend(void)
|
||||
{
|
||||
NS_NOTREACHED("nsFingerChannel::Suspend");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::Resume(void)
|
||||
{
|
||||
NS_NOTREACHED("nsFingerChannel::Resume");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChannel methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetOriginalURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mOriginalURI ? mOriginalURI : mUrl;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetOriginalURI(nsIURI* aURI)
|
||||
{
|
||||
mOriginalURI = aURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mUrl;
|
||||
NS_IF_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::Open(nsIInputStream **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE,
|
||||
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mTransport->SetNotificationCallbacks(mCallbacks,
|
||||
(mLoadFlags & LOAD_BACKGROUND));
|
||||
|
||||
return mTransport->OpenInputStream(0, PRUint32(-1), 0, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE,
|
||||
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mTransport->SetNotificationCallbacks(mCallbacks,
|
||||
(mLoadFlags & LOAD_BACKGROUND));
|
||||
|
||||
mListener = aListener;
|
||||
mResponseContext = ctxt;
|
||||
|
||||
return SendRequest(mTransport);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetLoadFlags(PRUint32 *aLoadFlags)
|
||||
{
|
||||
*aLoadFlags = mLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define FINGER_TYPE TEXT_HTML
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetContentType(char* *aContentType) {
|
||||
if (!aContentType) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aContentType = nsCRT::strdup(FINGER_TYPE);
|
||||
if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetContentType(const char *aContentType)
|
||||
{
|
||||
//It doesn't make sense to set the content-type on this type
|
||||
// of channel...
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetContentLength(PRInt32 aContentLength)
|
||||
{
|
||||
NS_NOTREACHED("nsFingerChannel::SetContentLength");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
||||
{
|
||||
*aSecurityInfo = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIRequestObserver methods
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) {
|
||||
if (!mActAsObserver) {
|
||||
// acting as a listener
|
||||
return mListener->OnStartRequest(this, mResponseContext);
|
||||
} else {
|
||||
// we don't want to pass our AsyncWrite's OnStart through
|
||||
// we just ignore this
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (NS_FAILED(aStatus) || !mActAsObserver) {
|
||||
if (mLoadGroup) {
|
||||
rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = mListener->OnStopRequest(this, mResponseContext, aStatus);
|
||||
mTransport = 0;
|
||||
return rv;
|
||||
} else {
|
||||
// at this point we know the request has been sent.
|
||||
// we're no longer acting as an observer.
|
||||
|
||||
mActAsObserver = PR_FALSE;
|
||||
nsCOMPtr<nsIStreamListener> converterListener;
|
||||
|
||||
NS_WITH_SERVICE(nsIStreamConverterService, StreamConvService,
|
||||
kStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString fromStr; fromStr.AssignWithConversion("text/plain");
|
||||
nsAutoString toStr; toStr.AssignWithConversion("text/html");
|
||||
|
||||
rv = StreamConvService->AsyncConvertData(fromStr.GetUnicode(),
|
||||
toStr.GetUnicode(), this, mResponseContext,
|
||||
getter_AddRefs(converterListener));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITXTToHTMLConv> converter(do_QueryInterface(converterListener));
|
||||
if (converter) {
|
||||
nsAutoString title; title.AssignWithConversion("Finger information for ");
|
||||
nsXPIDLCString userHost;
|
||||
rv = mUrl->GetPath(getter_Copies(userHost));
|
||||
title.AppendWithConversion(userHost);
|
||||
converter->SetTitle(title.GetUnicode());
|
||||
converter->PreFormatHTML(PR_TRUE);
|
||||
}
|
||||
|
||||
return mTransport->AsyncRead(converterListener, mResponseContext, 0, PRUint32(-1), 0,
|
||||
getter_AddRefs(mTransportRequest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// nsIStreamListener method
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext,
|
||||
nsIInputStream *aInputStream, PRUint32 aSourceOffset,
|
||||
PRUint32 aLength) {
|
||||
mContentLength = aLength;
|
||||
return mListener->OnDataAvailable(this, mResponseContext, aInputStream, aSourceOffset, aLength);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFingerChannel::SendRequest(nsITransport* aTransport) {
|
||||
// The text to send should already be in mUser
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsISupports> result;
|
||||
nsCOMPtr<nsIInputStream> charstream;
|
||||
nsCString requestBuffer(mUser);
|
||||
|
||||
if (mLoadGroup) {
|
||||
mLoadGroup->AddRequest(this, nsnull);
|
||||
}
|
||||
|
||||
requestBuffer.Append(CRLF);
|
||||
|
||||
mRequest = requestBuffer.ToNewCString();
|
||||
|
||||
rv = NS_NewCharInputStream(getter_AddRefs(result), mRequest);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
charstream = do_QueryInterface(result, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = NS_AsyncWriteFromStream(getter_AddRefs(mTransportRequest),
|
||||
aTransport, charstream,
|
||||
0, requestBuffer.Length(), 0,
|
||||
this, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
88
mozilla/extensions/finger/nsFingerChannel.h
Normal file
88
mozilla/extensions/finger/nsFingerChannel.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
#ifndef nsFingerChannel_h___
|
||||
#define nsFingerChannel_h___
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsFingerHandler.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsITransport.h"
|
||||
|
||||
class nsFingerChannel
|
||||
: public nsIChannel,
|
||||
public nsIStreamListener {
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
// nsFingerChannel methods:
|
||||
nsFingerChannel();
|
||||
virtual ~nsFingerChannel();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init(nsIURI* uri);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mUrl;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
PRUint32 mLoadFlags;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCString mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
PRUint32 mBufferSegmentSize;
|
||||
PRUint32 mBufferMaxSize;
|
||||
PRBool mActAsObserver;
|
||||
|
||||
PRInt32 mPort;
|
||||
nsCString mHost;
|
||||
nsCString mUser;
|
||||
|
||||
nsXPIDLCString mRequest;
|
||||
|
||||
nsCOMPtr<nsISupports> mResponseContext;
|
||||
nsCOMPtr<nsITransport> mTransport;
|
||||
nsCOMPtr<nsIRequest> mTransportRequest;
|
||||
nsresult mStatus;
|
||||
|
||||
protected:
|
||||
nsresult SendRequest(nsITransport* aTransport);
|
||||
};
|
||||
|
||||
#endif /* nsFingerChannel_h___ */
|
||||
117
mozilla/extensions/finger/nsFingerHandler.cpp
Normal file
117
mozilla/extensions/finger/nsFingerHandler.cpp
Normal 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 Mozilla 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/MPL/
|
||||
*
|
||||
* 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 Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsFingerChannel.h"
|
||||
#include "nsFingerHandler.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsFingerHandler::nsFingerHandler() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsFingerHandler::~nsFingerHandler() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFingerHandler, nsIProtocolHandler)
|
||||
|
||||
NS_METHOD
|
||||
nsFingerHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
|
||||
|
||||
nsFingerHandler* ph = new nsFingerHandler();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(ph);
|
||||
nsresult rv = ph->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(ph);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerHandler::GetScheme(char* *result) {
|
||||
*result = nsCRT::strdup("finger");
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerHandler::GetDefaultPort(PRInt32 *result) {
|
||||
*result = FINGER_PORT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
nsIURI **result) {
|
||||
nsresult rv;
|
||||
|
||||
// no concept of a relative finger url
|
||||
NS_ASSERTION(!aBaseURI, "base url passed into finger protocol handler");
|
||||
|
||||
nsIURI* url;
|
||||
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
|
||||
NS_GET_IID(nsIURI),
|
||||
(void**)&url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = url->SetSpec((char*)aSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = url;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsFingerChannel* channel;
|
||||
rv = nsFingerChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(url);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = channel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
52
mozilla/extensions/finger/nsFingerHandler.h
Normal file
52
mozilla/extensions/finger/nsFingerHandler.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
// The finger protocol handler creates "finger" URIs of the form
|
||||
// "finger:user@host" or "finger:host".
|
||||
|
||||
#ifndef nsFingerHandler_h___
|
||||
#define nsFingerHandler_h___
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
#define FINGER_PORT 79
|
||||
|
||||
// {0x76d6d5d8-1dd2-11b2-b361-850ddf15ef07}
|
||||
#define NS_FINGERHANDLER_CID \
|
||||
{ 0x76d6d5d8, 0x1dd2, 0x11b2, \
|
||||
{0xb3, 0x61, 0x85, 0x0d, 0xdf, 0x15, 0xef, 0x07} }
|
||||
|
||||
class nsFingerHandler : public nsIProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
|
||||
// nsFingerHandler methods:
|
||||
nsFingerHandler();
|
||||
virtual ~nsFingerHandler();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
};
|
||||
|
||||
#endif /* nsFingerHandler_h___ */
|
||||
34
mozilla/extensions/finger/nsFingerModule.cpp
Normal file
34
mozilla/extensions/finger/nsFingerModule.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsFingerHandler.h"
|
||||
|
||||
static nsModuleComponentInfo gResComponents[] = {
|
||||
{ "The Finger Protocol Handler",
|
||||
NS_FINGERHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "finger",
|
||||
nsFingerHandler::Create
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(finger, gResComponents)
|
||||
180
mozilla/extensions/xmlextras/base/public/nsIXMLHttpRequest.idl
Normal file
180
mozilla/extensions/xmlextras/base/public/nsIXMLHttpRequest.idl
Normal file
@@ -0,0 +1,180 @@
|
||||
/* -*- 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.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):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIHttpChannel;
|
||||
|
||||
[scriptable, uuid(b7215e70-4157-11d4-9a42-000064657374)]
|
||||
interface nsIXMLHttpRequest : nsISupports {
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting a load event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the load event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
*/
|
||||
attribute nsISupports onload;
|
||||
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting an error event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the error event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
*/
|
||||
attribute nsISupports onerror;
|
||||
|
||||
/**
|
||||
* The HTTP request uses an HTTP channel in order to perform the
|
||||
* request. This attribute represents the HTTP channel used
|
||||
* for the request. NULL if the HTTP channel has not yet been
|
||||
* created.
|
||||
*/
|
||||
readonly attribute nsIHttpChannel channel;
|
||||
|
||||
/**
|
||||
* The response to the HTTP request is parsed as if it were a
|
||||
* text/xml stream. This attributes represents the response as
|
||||
* a DOM Document object. NULL if the request is unsuccessful or
|
||||
* has not yet been sent.
|
||||
*/
|
||||
readonly attribute nsIDOMDocument responseXML;
|
||||
|
||||
/**
|
||||
* The response to the HTTP request as text.
|
||||
* NULL if the request is unsuccessful or
|
||||
* has not yet been sent.
|
||||
*/
|
||||
readonly attribute wstring responseText;
|
||||
|
||||
|
||||
/**
|
||||
* The status of the response to the HTTP request.
|
||||
*/
|
||||
readonly attribute unsigned long status;
|
||||
|
||||
/**
|
||||
* The string representing the status of the response to the
|
||||
* HTTP request.
|
||||
*/
|
||||
readonly attribute string statusText;
|
||||
|
||||
/**
|
||||
* If the HTTP request has been sent already, this method will
|
||||
* abort the request.
|
||||
*/
|
||||
void abort();
|
||||
|
||||
/**
|
||||
* Returns all of the HTTP response headers as a string string.
|
||||
*
|
||||
* @returns A string containing all of the response headers.
|
||||
* NULL if the response has not yet been received.
|
||||
*/
|
||||
string getAllResponseHeaders();
|
||||
|
||||
/**
|
||||
* Returns the text of the header with the specified name.
|
||||
*
|
||||
* @param header The name of the header to retrieve
|
||||
* @returns A string containing the text of the header specified.
|
||||
* NULL if the response has not yet been received or the
|
||||
* header does not exist in the response.
|
||||
*/
|
||||
string getResponseHeader(in string header);
|
||||
|
||||
/**
|
||||
* Native (non-script) method to initialize a request. Note that
|
||||
* the HTTP request is not sent until the <code>send</code> method
|
||||
* is invoked.
|
||||
*
|
||||
* @param method The HTTP method - either "POST" or "GET".
|
||||
* @param url The URL to which to send the request.
|
||||
* @param async Whether the request is synchronous or asynchronous
|
||||
* i.e. whether send returns only after the response
|
||||
* is received or if it returns immediately after
|
||||
* sending the request. In the latter case, notification
|
||||
* of completion is sent through the event listeners.
|
||||
* @param user A username for authentication if necessary.
|
||||
* @param password A password for authentication if necessary.
|
||||
*/
|
||||
[noscript] void openRequest(in string method,
|
||||
in string url,
|
||||
in boolean async,
|
||||
in string user,
|
||||
in string password);
|
||||
|
||||
/**
|
||||
* Meant to be a script-only method for initializing a request.
|
||||
* The parameters are similar to the ones detailed in the
|
||||
* description of <code>openRequest</code>, but the last
|
||||
* 3 are optional.
|
||||
*
|
||||
* @param method The HTTP method - either "POST" or "GET".
|
||||
* @param url The URL to which to send the request.
|
||||
* @param async (optional) Whether the request is synchronous or
|
||||
* asynchronous i.e. whether send returns only after
|
||||
* the response is received or if it returns immediately after
|
||||
* sending the request. In the latter case, notification
|
||||
* of completion is sent through the event listeners.
|
||||
* The default value is true.
|
||||
* @param user (optional) A username for authentication if necessary.
|
||||
* The default value is the empty string
|
||||
* @param password (optional) A password for authentication if necessary.
|
||||
* The default value is the empty string
|
||||
*/
|
||||
void open(in string method, in string url);
|
||||
|
||||
/**
|
||||
* Sends the HTTP request. If the request is asynchronous, returns
|
||||
* immediately after sending the request. If it is synchronous
|
||||
* returns only after the response has been received.
|
||||
*
|
||||
* @param body Either an instance of nsIDOMDocument, nsIInputStream
|
||||
* or a string (nsISupportsWString in the native calling
|
||||
* case). This is used to populate the body of the
|
||||
* HTTP request if the HTTP request method is "POST".
|
||||
* If the parameter is a nsIDOMDocument, it is serialized.
|
||||
* If the parameter is a nsIInputStream, it is expected
|
||||
* to contain the ContentType: and ContentLength: headers
|
||||
* and trailing carriage-return/line-feed pairs.
|
||||
*/
|
||||
void send(in nsISupports body);
|
||||
|
||||
/**
|
||||
* Sets a HTTP request header.
|
||||
*
|
||||
* @param header The name of the header to set in the request.
|
||||
* @param value The body of the header.
|
||||
*/
|
||||
void setRequestHeader(in string header, in string value);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_XMLHTTPREQUEST_CID \
|
||||
{ /* d164e770-4157-11d4-9a42-000064657374 */ \
|
||||
0xd164e770, 0x4157, 0x11d4, \
|
||||
{0x9a, 0x42, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
|
||||
#define NS_XMLHTTPREQUEST_CONTRACTID \
|
||||
"@mozilla.org/xmlextras/xmlhttprequest;1"
|
||||
%}
|
||||
1459
mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp
Normal file
1459
mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
244
mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h
Normal file
244
mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h
Normal file
@@ -0,0 +1,244 @@
|
||||
/* -*- 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.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 nsXMLHttpRequest_h__
|
||||
#define nsXMLHttpRequest_h__
|
||||
|
||||
#define IMPLEMENT_SYNC_LOAD
|
||||
|
||||
#include "nsIXMLHttpRequest.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#ifdef IMPLEMENT_SYNC_LOAD
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#endif
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
enum {
|
||||
XML_HTTP_REQUEST_INITIALIZED,
|
||||
XML_HTTP_REQUEST_OPENED,
|
||||
XML_HTTP_REQUEST_SENT,
|
||||
XML_HTTP_REQUEST_COMPLETED,
|
||||
XML_HTTP_REQUEST_ABORTED
|
||||
};
|
||||
|
||||
class nsXMLHttpRequest : public nsIXMLHttpRequest,
|
||||
public nsIDOMLoadListener,
|
||||
public nsIDOMEventTarget,
|
||||
public nsISecurityCheckedComponent,
|
||||
public nsIStreamListener,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
nsXMLHttpRequest();
|
||||
virtual ~nsXMLHttpRequest();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIXMLHttpRequest
|
||||
NS_DECL_NSIXMLHTTPREQUEST
|
||||
|
||||
// nsIDOMEventTarget
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIDOMLoadListener
|
||||
NS_IMETHOD Load(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsISecurityCheckedComponent
|
||||
NS_DECL_NSISECURITYCHECKEDCOMPONENT
|
||||
|
||||
// nsIStreamListener
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
// nsIRequestObserver
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
protected:
|
||||
nsresult MakeScriptEventListener(nsISupports* aObject,
|
||||
nsIDOMEventListener** aListener);
|
||||
void GetScriptEventListener(nsISupportsArray* aList,
|
||||
nsIDOMEventListener** aListener);
|
||||
PRBool StuffReturnValue(nsIDOMEventListener* aListener);
|
||||
|
||||
|
||||
nsresult GetStreamForWString(const PRUnichar* aStr,
|
||||
PRInt32 aLength,
|
||||
nsIInputStream** aStream);
|
||||
|
||||
nsCOMPtr<nsISupports> mContext;
|
||||
nsCOMPtr<nsIHttpChannel> mChannel;
|
||||
nsCOMPtr<nsIRequest> mReadRequest;
|
||||
nsCOMPtr<nsIDOMDocument> mDocument;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsCOMPtr<nsIDocument> mBaseDocument;
|
||||
#ifdef IMPLEMENT_SYNC_LOAD
|
||||
nsCOMPtr<nsIWebBrowserChrome> mChromeWindow;
|
||||
#endif
|
||||
nsCOMPtr<nsISupportsArray> mLoadEventListeners;
|
||||
nsCOMPtr<nsISupportsArray> mErrorEventListeners;
|
||||
|
||||
nsresult DetectCharset(nsAWritableString& aCharset);
|
||||
nsresult ConvertBodyToText(PRUnichar **aOutBuffer);
|
||||
static NS_METHOD StreamReaderFunc(nsIInputStream* in,
|
||||
void* closure,
|
||||
const char* fromRawSegment,
|
||||
PRUint32 toOffset,
|
||||
PRUint32 count,
|
||||
PRUint32 *writeCount);
|
||||
|
||||
// used to implement getAllResponseHeaders()
|
||||
class nsHeaderVisitor : public nsIHttpHeaderVisitor {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIHTTPHEADERVISITOR
|
||||
nsHeaderVisitor() { NS_INIT_ISUPPORTS(); }
|
||||
virtual ~nsHeaderVisitor() {}
|
||||
const nsACString &Headers() { return mHeaders; }
|
||||
private:
|
||||
nsCString mHeaders;
|
||||
};
|
||||
|
||||
#if 1 // When nsCString::Append()/Length() works for strings that contain nulls, remove this buffer impl
|
||||
class ResponseBodyBuffer {
|
||||
public:
|
||||
ResponseBodyBuffer()
|
||||
: mBuffer(0),
|
||||
mBufferSize(0),
|
||||
mBufferFreeIndex(0),
|
||||
mCanBeString(PR_FALSE),
|
||||
mBufferChecked(PR_FALSE) {}
|
||||
~ResponseBodyBuffer() { nsMemory::Free(mBuffer); }
|
||||
void Truncate(void) {
|
||||
nsMemory::Free(mBuffer);
|
||||
mBuffer=nsnull;
|
||||
mBufferSize=mBufferFreeIndex=0;
|
||||
mCanBeString = PR_FALSE;
|
||||
mBufferChecked = PR_FALSE;
|
||||
}
|
||||
nsresult Append(const char* aBuffer, PRUint32 aBufferLen) {
|
||||
if (aBufferLen > (mBufferSize-mBufferFreeIndex)) {
|
||||
PRUint32 newBufferSize = (mBufferSize > aBufferLen ? mBufferSize : aBufferLen)<<1;
|
||||
char * newBuffer = NS_STATIC_CAST(char*,nsMemory::Realloc(mBuffer,newBufferSize));
|
||||
if (!newBuffer) {
|
||||
nsMemory::Free(mBuffer);
|
||||
mBuffer = nsnull;
|
||||
mBufferChecked = PR_FALSE;
|
||||
mCanBeString = PR_FALSE;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mBuffer = newBuffer;
|
||||
mBufferSize = newBufferSize;
|
||||
}
|
||||
memcpy(&mBuffer[mBufferFreeIndex],aBuffer,aBufferLen);
|
||||
mBufferFreeIndex += aBufferLen;
|
||||
mBufferChecked = PR_FALSE;
|
||||
mCanBeString = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
const char * GetBuffer(void) { return mBuffer; }
|
||||
PRUint32 GetBufferLength(void) { return mBufferFreeIndex; }
|
||||
PRBool CanBeString(void) {
|
||||
if (!mBufferFreeIndex)
|
||||
return PR_TRUE; // Perhaps this is a bit questionable...
|
||||
if (!mBufferChecked) {
|
||||
mBufferChecked = PR_TRUE;
|
||||
|
||||
mCanBeString = PR_TRUE;
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < mBufferFreeIndex; i++) {
|
||||
if (!mBuffer[i]) {
|
||||
mCanBeString = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mCanBeString;
|
||||
}
|
||||
private:
|
||||
char *mBuffer;
|
||||
PRUint32 mBufferSize;
|
||||
PRUint32 mBufferFreeIndex;
|
||||
PRPackedBool mCanBeString;
|
||||
PRPackedBool mBufferChecked;
|
||||
};
|
||||
ResponseBodyBuffer mResponseBody;
|
||||
#else
|
||||
nsCString mResponseBody;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;
|
||||
|
||||
PRInt32 mStatus;
|
||||
PRBool mAsync;
|
||||
};
|
||||
|
||||
#define NS_IPRIVATEJSEVENTLISTENER_IID \
|
||||
{ /* d47a6550-4327-11d4-9a45-000064657374 */ \
|
||||
0xd47a6550, 0x4327, 0x11d4, \
|
||||
{0x9a, 0x45, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
|
||||
|
||||
class nsIPrivateJSEventListener : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRIVATEJSEVENTLISTENER_IID)
|
||||
|
||||
NS_IMETHOD GetFunctionObj(JSObject** aObj) = 0;
|
||||
};
|
||||
|
||||
class nsXMLHttpRequestScriptListener : public nsIDOMEventListener,
|
||||
public nsIPrivateJSEventListener
|
||||
{
|
||||
public:
|
||||
nsXMLHttpRequestScriptListener(JSObject* aScopeObj, JSObject* aFunctionObj);
|
||||
virtual ~nsXMLHttpRequestScriptListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIPrivateJSEventListener
|
||||
NS_IMETHOD GetFunctionObj(JSObject** aObj);
|
||||
|
||||
protected:
|
||||
JSObject* mScopeObj;
|
||||
JSObject* mFunctionObj;
|
||||
};
|
||||
|
||||
#endif
|
||||
907
mozilla/gfx/src/nsImageNetContextAsync.cpp
Normal file
907
mozilla/gfx/src/nsImageNetContextAsync.cpp
Normal file
@@ -0,0 +1,907 @@
|
||||
/* -*- 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.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):
|
||||
*/
|
||||
|
||||
#include "libimg.h"
|
||||
#include "nsImageNet.h"
|
||||
#include "ilINetContext.h"
|
||||
#include "ilIURL.h"
|
||||
#include "ilINetReader.h"
|
||||
#include "ilErrors.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "prprf.h"
|
||||
|
||||
|
||||
#include "nsITimer.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_CID(kStreamConvServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
static NS_DEFINE_IID(kIURLIID, NS_IURL_IID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
PRLogModuleInfo *image_net_context_async_log_module = NULL;
|
||||
|
||||
#define IMAGE_BUF_SIZE 4096
|
||||
|
||||
class ImageConsumer;
|
||||
|
||||
class ImageNetContextImpl : public ilINetContext {
|
||||
public:
|
||||
ImageNetContextImpl(ImgCachePolicy aReloadPolicy,
|
||||
nsISupports * aLoadContext,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg);
|
||||
virtual ~ImageNetContextImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual ilINetContext* Clone();
|
||||
|
||||
virtual ImgCachePolicy GetReloadPolicy();
|
||||
virtual ImgCachePolicy SetReloadPolicy(ImgCachePolicy ReloadPolicy);
|
||||
|
||||
|
||||
virtual void AddReferer(ilIURL *aUrl);
|
||||
|
||||
virtual void Interrupt();
|
||||
|
||||
virtual ilIURL* CreateURL(const char *aUrl,
|
||||
ImgCachePolicy aReloadMethod);
|
||||
|
||||
virtual PRBool IsLocalFileURL(char *aAddress);
|
||||
#ifdef NU_CACHE
|
||||
virtual PRBool IsURLInCache(ilIURL *aUrl);
|
||||
#else /* NU_CACHE */
|
||||
virtual PRBool IsURLInMemCache(ilIURL *aUrl);
|
||||
|
||||
virtual PRBool IsURLInDiskCache(ilIURL *aUrl);
|
||||
#endif
|
||||
|
||||
virtual int GetURL (ilIURL * aUrl, ImgCachePolicy aLoadMethod,
|
||||
ilINetReader *aReader, PRBool IsAnimationLoop);
|
||||
|
||||
virtual int GetContentLength(ilIURL * aURL);
|
||||
|
||||
nsresult RemoveRequest(ImageConsumer *aConsumer);
|
||||
nsresult RequestDone(ImageConsumer *aConsumer, nsIRequest* request,
|
||||
nsISupports* ctxt, nsresult status, const PRUnichar* aMsg);
|
||||
|
||||
nsVoidArray *mRequests; // WEAK references to |ImageConsumer|s
|
||||
ImgCachePolicy mReloadPolicy;
|
||||
nsWeakPtr mLoadContext;
|
||||
nsReconnectCB mReconnectCallback;
|
||||
void* mReconnectArg;
|
||||
};
|
||||
|
||||
class ImageConsumer : public nsIStreamListener, public nsIURIContentListener, public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
ImageConsumer(ilIURL *aURL, ImageNetContextImpl *aContext);
|
||||
|
||||
// nsIRequestObserver methods:
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
void SetKeepPumpingData(nsIRequest* request, nsISupports* context) {
|
||||
NS_ADDREF(request);
|
||||
NS_IF_RELEASE(mRequest);
|
||||
mRequest = request;
|
||||
|
||||
NS_IF_ADDREF(context);
|
||||
NS_IF_RELEASE(mUserContext);
|
||||
mUserContext = context;
|
||||
}
|
||||
|
||||
void Interrupt();
|
||||
|
||||
static void KeepPumpingStream(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
protected:
|
||||
virtual ~ImageConsumer();
|
||||
ilIURL *mURL;
|
||||
PRBool mInterrupted;
|
||||
ImageNetContextImpl *mContext;
|
||||
nsIInputStream *mStream;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
PRBool mFirstRead;
|
||||
char *mBuffer;
|
||||
PRInt32 mStatus;
|
||||
nsIRequest* mRequest;
|
||||
nsISupports* mUserContext;
|
||||
PRBool mIsMulti;
|
||||
};
|
||||
|
||||
ImageConsumer::ImageConsumer(ilIURL *aURL, ImageNetContextImpl *aContext)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mURL = aURL;
|
||||
NS_ADDREF(mURL);
|
||||
mContext = aContext;
|
||||
NS_ADDREF(mContext);
|
||||
mInterrupted = PR_FALSE;
|
||||
mFirstRead = PR_TRUE;
|
||||
mStream = nsnull;
|
||||
mBuffer = nsnull;
|
||||
mStatus = 0;
|
||||
mRequest = nsnull;
|
||||
mUserContext = nsnull;
|
||||
mIsMulti = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(ImageConsumer)
|
||||
NS_IMPL_THREADSAFE_RELEASE(ImageConsumer)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(ImageConsumer)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP ImageConsumer::GetInterface(const nsIID & aIID, void * *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
// nsIURIContentListener support
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
||||
{
|
||||
*aProtocolHandler = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::GetParentContentListener(nsIURIContentListener** aParent)
|
||||
{
|
||||
*aParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::SetParentContentListener(nsIURIContentListener* aParent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::GetLoadCookie(nsISupports ** aLoadCookie)
|
||||
{
|
||||
nsCOMPtr<nsISupports> loadContext = do_QueryReferent(mContext->mLoadContext);
|
||||
*aLoadCookie = loadContext;
|
||||
NS_IF_ADDREF(*aLoadCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget,
|
||||
aDesiredContentType, aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
// if we had a webshell or doc shell around, we'd pass this call
|
||||
// through to it...but we don't =(
|
||||
if (!nsCRT::strcasecmp(aContentType, "message/rfc822"))
|
||||
*aDesiredContentType = nsCRT::strdup("application/vnd.mozilla.xul+xml");
|
||||
// since we explicilty loaded the url, we always want to handle it!
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest * aOpenedChannel,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aAbortProcess)
|
||||
*aAbortProcess = PR_FALSE;
|
||||
|
||||
nsAutoString contentType; contentType.AssignWithConversion(aContentType);
|
||||
|
||||
if (contentType.EqualsWithConversion("multipart/x-mixed-replace")
|
||||
|| contentType.EqualsWithConversion("multipart/mixed")) {
|
||||
// if we're getting multipart data, we have to convert it.
|
||||
// so wedge the converter inbetween us and the consumer.
|
||||
mIsMulti= PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIStreamConverterService> convServ = do_GetService(kStreamConvServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString astrix; astrix.AssignWithConversion("*/*");
|
||||
return convServ->AsyncConvertData(contentType.GetUnicode(),
|
||||
astrix.GetUnicode(),
|
||||
NS_STATIC_CAST(nsIStreamListener*, this),
|
||||
nsnull /*a context?*/, aContentHandler);
|
||||
}
|
||||
|
||||
QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
|
||||
{
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
|
||||
|
||||
PRUint32 httpStatus;
|
||||
if (mInterrupted) {
|
||||
mStatus = MK_INTERRUPTED;
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
mBuffer = (char *)PR_MALLOC(IMAGE_BUF_SIZE);
|
||||
if (mBuffer == nsnull) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(channel));
|
||||
if (pHTTPCon) {
|
||||
pHTTPCon->GetResponseStatus(&httpStatus);
|
||||
if (httpStatus == 404) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
ilINetReader *reader = mURL->GetReader(); //ptn test: nsCOMPtr??
|
||||
/*nsresult err=*/ reader->FlushImgBuffer(); //flush current data in buffer before starting
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
char* aContentType = NULL;
|
||||
rv = channel->GetContentType(&aContentType); //nsCRT alloc's str
|
||||
if (NS_FAILED(rv)) {
|
||||
if(aContentType){
|
||||
nsCRT::free(aContentType);
|
||||
}
|
||||
aContentType = nsCRT::strdup("unknown");
|
||||
}
|
||||
if(nsCRT::strlen(aContentType) > 50){
|
||||
//somethings wrong. mimetype string shouldn't be this big.
|
||||
//protect us from the user.
|
||||
nsCRT::free(aContentType);
|
||||
aContentType = nsCRT::strdup("unknown");
|
||||
}
|
||||
|
||||
if (reader->StreamCreated(mURL, aContentType) != PR_TRUE) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
reader->StreamAbort(mStatus);
|
||||
NS_RELEASE(reader);
|
||||
nsCRT::free(aContentType);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
nsCRT::free(aContentType);
|
||||
NS_RELEASE(reader);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define IMAGE_BUF_SIZE 4096
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnDataAvailable(nsIRequest* request, nsISupports* aContext,
|
||||
nsIInputStream *pIStream, PRUint32 offset, PRUint32 length)
|
||||
{
|
||||
PRUint32 max_read=0;
|
||||
PRUint32 bytes_read = 0;
|
||||
ilINetReader *reader = mURL->GetReader();
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
|
||||
if (mInterrupted || mStatus != 0) {
|
||||
mStatus = MK_INTERRUPTED;
|
||||
reader->StreamAbort(mStatus);
|
||||
NS_RELEASE(reader);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
nsresult err = 0;
|
||||
PRUint32 nb = 0;
|
||||
char* uriStr = NULL;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
err = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(err) && uri) {
|
||||
err = uri->GetSpec(&uriStr);
|
||||
if (NS_FAILED(err)){
|
||||
/* if we can't get a file spec, it is bad, very bad.*/
|
||||
mStatus = MK_INTERRUPTED;
|
||||
reader->StreamAbort(mStatus);
|
||||
NS_RELEASE(reader);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
err = reader->WriteReady(&max_read); //max read is most decoder can handle
|
||||
if(NS_FAILED(err)) //note length tells how much we already have.
|
||||
break;
|
||||
|
||||
if(max_read < 0){
|
||||
max_read = 128;
|
||||
}
|
||||
|
||||
if (max_read > (length - bytes_read)) {
|
||||
max_read = length - bytes_read;
|
||||
}
|
||||
|
||||
if (max_read > IMAGE_BUF_SIZE) {
|
||||
max_read = IMAGE_BUF_SIZE;
|
||||
}
|
||||
|
||||
// make sure there's enough data available to decode the image.
|
||||
// put test into WriteReady
|
||||
if (mFirstRead && length < 4)
|
||||
break;
|
||||
|
||||
err = pIStream->Read(mBuffer,
|
||||
max_read, &nb);
|
||||
|
||||
if (err == NS_BASE_STREAM_WOULD_BLOCK) {
|
||||
NS_ASSERTION(nb == 0, "Data will be lost.");
|
||||
err = NS_OK;
|
||||
break;
|
||||
}
|
||||
if (NS_FAILED(err) || nb == 0) {
|
||||
NS_ASSERTION(nb == 0, "Data will be lost.");
|
||||
break;
|
||||
}
|
||||
|
||||
bytes_read += nb;
|
||||
if (mFirstRead == PR_TRUE) {
|
||||
|
||||
err = reader->FirstWrite((const unsigned char *)mBuffer, nb, uriStr);
|
||||
mFirstRead = PR_FALSE; //? move after err chk?
|
||||
/*
|
||||
* If FirstWrite(...) fails then the image type
|
||||
* cannot be determined and the il_container
|
||||
* stream functions have not been initialized!
|
||||
*/
|
||||
if (NS_FAILED(err)) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
mInterrupted = PR_TRUE;
|
||||
if(uriStr)
|
||||
nsCRT::free(uriStr);
|
||||
NS_RELEASE(reader);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
err = reader->Write((const unsigned char *)mBuffer, (int32)nb);
|
||||
if(NS_FAILED(err)){
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
mInterrupted = PR_TRUE;
|
||||
if(uriStr)
|
||||
nsCRT::free(uriStr);
|
||||
NS_RELEASE(reader);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
} while(bytes_read < length);
|
||||
|
||||
if (uriStr) {
|
||||
nsCRT::free(uriStr);
|
||||
}
|
||||
|
||||
if (NS_FAILED(err)) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
mInterrupted = PR_TRUE;
|
||||
}
|
||||
|
||||
if (bytes_read < length) {
|
||||
// If we haven't emptied the stream, hold onto it, because
|
||||
// we will need to read from it subsequently and we don't
|
||||
// know if we'll get a OnDataAvailable call again.
|
||||
//
|
||||
// Addref the new stream before releasing the old one,
|
||||
// in case it is the same stream!
|
||||
NS_ADDREF(pIStream);
|
||||
NS_IF_RELEASE(mStream);
|
||||
mStream = pIStream;
|
||||
} else {
|
||||
NS_IF_RELEASE(mStream);
|
||||
}
|
||||
NS_RELEASE(reader);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
ImageConsumer::KeepPumpingStream(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
ImageConsumer *consumer = (ImageConsumer *)aClosure;
|
||||
|
||||
consumer->OnStopRequest(consumer->mRequest, consumer->mUserContext,
|
||||
NS_BINDING_SUCCEEDED);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnStopRequest(nsIRequest* request, nsISupports* aContext, nsresult status)
|
||||
{
|
||||
if (mTimer) {
|
||||
mTimer->Cancel();
|
||||
mTimer = nsnull;
|
||||
}
|
||||
|
||||
if (NS_BINDING_SUCCEEDED != status) {
|
||||
mStatus = MK_INTERRUPTED;
|
||||
}
|
||||
|
||||
|
||||
// Since we're still holding on to the stream, there's still data
|
||||
// that needs to be read. So, pump the stream ourselves.
|
||||
if((mStream != nsnull) && (status == NS_BINDING_SUCCEEDED)) {
|
||||
PRUint32 str_length;
|
||||
nsresult err = mStream->Available(&str_length);
|
||||
if (NS_SUCCEEDED(err)) {
|
||||
NS_ASSERTION((str_length > 0), "No data left in the stream!");
|
||||
err = OnDataAvailable(request, aContext, mStream, 0, str_length); // XXX fix offset
|
||||
if (NS_SUCCEEDED(err)) {
|
||||
// If we still have the stream, there's still data to be
|
||||
// pumped, so we set a timer to call us back again.
|
||||
if (mStream) {
|
||||
SetKeepPumpingData(request, aContext);
|
||||
|
||||
nsresult rv;
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
if (NS_FAILED(rv) ||
|
||||
(NS_OK != mTimer->Init(ImageConsumer::KeepPumpingStream, this, 0))) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
NS_RELEASE(mStream);
|
||||
}
|
||||
else {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
NS_IF_RELEASE(mStream);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
NS_IF_RELEASE(mStream);
|
||||
}
|
||||
}
|
||||
|
||||
ilINetReader *reader = mURL->GetReader();
|
||||
if (0 != mStatus) {
|
||||
reader->StreamAbort(mStatus);
|
||||
}
|
||||
else {
|
||||
reader->StreamComplete(mIsMulti);
|
||||
}
|
||||
|
||||
if(mIsMulti)
|
||||
mFirstRead = PR_TRUE; //reset to read new frame
|
||||
|
||||
reader->NetRequestDone(mURL, mStatus);
|
||||
NS_RELEASE(reader);
|
||||
|
||||
return mContext->RequestDone(this, request, aContext, status, nsnull);
|
||||
}
|
||||
|
||||
void
|
||||
ImageConsumer::Interrupt()
|
||||
{
|
||||
mInterrupted = PR_TRUE;
|
||||
}
|
||||
|
||||
ImageConsumer::~ImageConsumer()
|
||||
{
|
||||
if (mTimer) {
|
||||
mTimer->Cancel();
|
||||
mTimer = nsnull;
|
||||
}
|
||||
if (mContext) {
|
||||
nsresult res = mContext->RemoveRequest(this);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
// The load was canceled.
|
||||
mStatus = MK_INTERRUPTED;
|
||||
if (mURL) {
|
||||
nsCOMPtr<ilINetReader> reader( dont_AddRef( mURL->GetReader() ) );
|
||||
reader->StreamAbort(mStatus);
|
||||
reader->NetRequestDone(mURL, mStatus);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(mContext);
|
||||
}
|
||||
NS_IF_RELEASE(mURL);
|
||||
NS_IF_RELEASE(mStream);
|
||||
if (mBuffer != nsnull) {
|
||||
PR_DELETE(mBuffer);
|
||||
}
|
||||
NS_IF_RELEASE(mRequest);
|
||||
NS_IF_RELEASE(mUserContext);
|
||||
}
|
||||
|
||||
ImageNetContextImpl::ImageNetContextImpl(ImgCachePolicy aReloadPolicy,
|
||||
nsISupports * aLoadContext,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mRequests = nsnull;
|
||||
mLoadContext = getter_AddRefs(NS_GetWeakReference(aLoadContext));
|
||||
mReloadPolicy = aReloadPolicy;
|
||||
mReconnectCallback = aReconnectCallback;
|
||||
mReconnectArg = aReconnectArg;
|
||||
}
|
||||
|
||||
ImageNetContextImpl::~ImageNetContextImpl()
|
||||
{
|
||||
delete mRequests;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(ImageNetContextImpl, ilINetContext)
|
||||
|
||||
ilINetContext*
|
||||
ImageNetContextImpl::Clone()
|
||||
{
|
||||
ilINetContext *cx;
|
||||
nsCOMPtr<nsISupports> loadContext = do_QueryReferent(mLoadContext);
|
||||
|
||||
//mReconnectArg is ImageGroup. If GetURL is triggered
|
||||
//by timer for animation, ImageGroup may have been unloaded
|
||||
//before timer kicks off.
|
||||
//mReconnectCallback=nsnull; mReconnectArg=nsnull;
|
||||
|
||||
if (NS_NewImageNetContext(&cx, loadContext, mReconnectCallback, mReconnectArg) == NS_OK)
|
||||
{
|
||||
return cx;
|
||||
}
|
||||
else {
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
ImgCachePolicy
|
||||
ImageNetContextImpl::GetReloadPolicy()
|
||||
{
|
||||
return mReloadPolicy;
|
||||
}
|
||||
|
||||
ImgCachePolicy
|
||||
ImageNetContextImpl::SetReloadPolicy(ImgCachePolicy reloadpolicy)
|
||||
{
|
||||
mReloadPolicy=reloadpolicy;
|
||||
return mReloadPolicy;
|
||||
}
|
||||
|
||||
void
|
||||
ImageNetContextImpl::AddReferer(ilIURL *aUrl)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ImageNetContextImpl::Interrupt()
|
||||
{
|
||||
if (mRequests != nsnull) {
|
||||
int i, count = mRequests->Count();
|
||||
for (i=0; i < count; i++) {
|
||||
ImageConsumer *ic = (ImageConsumer *)mRequests->ElementAt(i);
|
||||
ic->Interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ilIURL*
|
||||
ImageNetContextImpl::CreateURL(const char *aURL,
|
||||
ImgCachePolicy aReloadMethod)
|
||||
{
|
||||
ilIURL *url;
|
||||
|
||||
nsCOMPtr<nsISupports> loadContext (do_QueryReferent(mLoadContext));
|
||||
nsCOMPtr<nsILoadGroup> group (do_GetInterface(loadContext));
|
||||
if (NS_NewImageURL(&url, aURL, group) == NS_OK)
|
||||
{
|
||||
return url;
|
||||
}
|
||||
else {
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
ImageNetContextImpl::IsLocalFileURL(char *aAddress)
|
||||
{
|
||||
if (PL_strncasecmp(aAddress, "file:", 5) == 0) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NU_CACHE
|
||||
PRBool
|
||||
ImageNetContextImpl::IsURLInCache(ilIURL *aUrl)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
#else /* NU_CACHE */
|
||||
PRBool
|
||||
ImageNetContextImpl::IsURLInMemCache(ilIURL *aUrl)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
ImageNetContextImpl::IsURLInDiskCache(ilIURL *aUrl)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif /* NU_CACHE */
|
||||
|
||||
int
|
||||
ImageNetContextImpl::GetContentLength (ilIURL * aURL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ImageNetContextImpl::GetURL (ilIURL * aURL,
|
||||
ImgCachePolicy aLoadMethod,
|
||||
ilINetReader *aReader,
|
||||
PRBool IsAnimationLoop)
|
||||
{
|
||||
|
||||
|
||||
NS_PRECONDITION(nsnull != aURL, "null URL");
|
||||
NS_PRECONDITION(nsnull != aReader, "null reader");
|
||||
if (aURL == nsnull || aReader == nsnull) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mRequests == nsnull) {
|
||||
mRequests = new nsVoidArray();
|
||||
if (mRequests == nsnull) {
|
||||
// XXX Should still call exit function
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int ret;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> nsurl = do_QueryInterface(aURL, &rv);
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
aURL->SetReader(aReader);
|
||||
SetReloadPolicy(aLoadMethod);
|
||||
|
||||
|
||||
// Find previously created ImageConsumer if possible
|
||||
ImageConsumer *ic = new ImageConsumer(aURL, this);
|
||||
if (ic == nsnull)
|
||||
return -1;
|
||||
NS_ADDREF(ic);
|
||||
|
||||
// See if a reconnect is being done...(XXX: hack!)
|
||||
if (mReconnectCallback == nsnull
|
||||
|| !(*mReconnectCallback)(mReconnectArg, ic)) {
|
||||
// first, create a channel for the protocol....
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsISupports> loadContext (do_QueryReferent(mLoadContext));
|
||||
nsCOMPtr<nsILoadGroup> group (do_GetInterface(loadContext));
|
||||
nsCOMPtr<nsIInterfaceRequestor> sink(do_QueryInterface(loadContext));
|
||||
|
||||
nsLoadFlags flags=0;
|
||||
if(IsAnimationLoop)
|
||||
flags |= nsIRequest::LOAD_FROM_CACHE;
|
||||
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), nsurl, nsnull, group, sink, flags);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel)
|
||||
{
|
||||
// Get the defloadRequest from the loadgroup-
|
||||
nsCOMPtr<nsIRequest> defLoadRequest;
|
||||
if (NS_SUCCEEDED(group->GetDefaultLoadRequest(
|
||||
getter_AddRefs(defLoadRequest))) && defLoadRequest)
|
||||
{
|
||||
nsCOMPtr<nsIChannel> reqchannel = do_QueryInterface(defLoadRequest);
|
||||
|
||||
// Get the referrer from the loadchannel-
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
if (NS_SUCCEEDED(reqchannel->GetURI(getter_AddRefs(referrer))))
|
||||
{
|
||||
// Set the referrer-
|
||||
httpChannel->SetReferrer(referrer, nsIHttpChannel::REFERRER_INLINES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rv = channel->GetLoadFlags(&flags);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
if (aURL->GetBackgroundLoad())
|
||||
flags |= nsIRequest::LOAD_BACKGROUND;
|
||||
|
||||
(void)channel->SetLoadFlags(flags);
|
||||
|
||||
nsCOMPtr<nsISupports> window (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, ic)));
|
||||
|
||||
// let's try uri dispatching...
|
||||
nsCOMPtr<nsIURILoader> pURILoader (do_GetService(NS_URI_LOADER_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsURILoadCommand loadCmd = nsIURILoader::viewNormal;
|
||||
PRBool bIsBackground = aURL->GetBackgroundLoad();
|
||||
if (bIsBackground) {
|
||||
loadCmd = nsIURILoader::viewNormalBackground;
|
||||
}
|
||||
|
||||
|
||||
rv = pURILoader->OpenURI(channel, loadCmd, nsnull /* window target */,
|
||||
window);
|
||||
}
|
||||
// rv = channel->AsyncOpen(ic, nsnull);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
}
|
||||
|
||||
ret = mRequests->AppendElement((void *)ic) ? 0 : -1;
|
||||
NS_RELEASE(ic); // if nothing else is holding onto it, it will remove
|
||||
// itself from mRequests
|
||||
return ret;
|
||||
|
||||
error:
|
||||
NS_RELEASE(ic);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nsresult
|
||||
ImageNetContextImpl::RemoveRequest(ImageConsumer *aConsumer)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mRequests) {
|
||||
rv = mRequests->RemoveElement((void *)aConsumer)?NS_OK:NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
ImageNetContextImpl::RequestDone(ImageConsumer *aConsumer, nsIRequest* request,
|
||||
nsISupports* ctxt, nsresult status, const PRUnichar* aMsg)
|
||||
{
|
||||
RemoveRequest(aConsumer);
|
||||
/// if (mLoadGroup)
|
||||
/// return mLoadGroup->RemoveChannel(channel, ctxt, status, aMsg);
|
||||
/// else
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" NS_GFX_(nsresult)
|
||||
NS_NewImageNetContext(ilINetContext **aInstancePtrResult,
|
||||
nsISupports * aLoadContext,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg)
|
||||
{
|
||||
|
||||
PRUint32 necko_attribs;
|
||||
ImgCachePolicy imglib_attribs = USE_IMG_CACHE;
|
||||
nsLoadFlags defchan_attribs = nsIRequest::LOAD_NORMAL;
|
||||
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if(aLoadContext){
|
||||
nsCOMPtr<nsILoadGroup> group (do_GetInterface(aLoadContext));
|
||||
/*nsresult rv = */group->GetLoadFlags(&necko_attribs);
|
||||
/*
|
||||
Need code to check freshness of necko cache.
|
||||
*/
|
||||
nsCOMPtr<nsIRequest> defLoadRequest;
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (NS_SUCCEEDED(group->GetDefaultLoadRequest(
|
||||
getter_AddRefs(defLoadRequest))) && defLoadRequest)
|
||||
{
|
||||
channel = do_QueryInterface(defLoadRequest);
|
||||
if (channel) channel->GetLoadFlags(&defchan_attribs);
|
||||
}
|
||||
|
||||
#if defined( DEBUG )
|
||||
if (image_net_context_async_log_module == NULL) {
|
||||
image_net_context_async_log_module = PR_NewLogModule("IMAGENETCTXASYNC");
|
||||
}
|
||||
#endif
|
||||
if((nsIRequest::VALIDATE_ALWAYS & defchan_attribs)||
|
||||
(nsIRequest::INHIBIT_PERSISTENT_CACHING & defchan_attribs)||
|
||||
(nsIRequest::LOAD_BYPASS_CACHE & defchan_attribs)) {
|
||||
imglib_attribs = DONT_USE_IMG_CACHE;
|
||||
#if defined( DEBUG )
|
||||
PR_LOG(image_net_context_async_log_module, 1, ("ImageNetContextAsync: NS_NewImageNetContext: DONT_USE_IMAGE_CACHE\n"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
ilINetContext *cx = new ImageNetContextImpl( imglib_attribs,
|
||||
aLoadContext,
|
||||
aReconnectCallback,
|
||||
aReconnectArg);
|
||||
if (cx == nsnull) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return cx->QueryInterface(NS_GET_IID(ilINetContext), (void **) aInstancePtrResult);
|
||||
|
||||
}
|
||||
106
mozilla/intl/chardet/src/nsObserverBase.cpp
Normal file
106
mozilla/intl/chardet/src/nsObserverBase.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/* -*- 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 "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) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
//#define DONT_INFORM_WEBSHELL
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIWebShellServices.h"
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsObserverBase.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
|
||||
static NS_DEFINE_IID(kIWebShellServicesIID, NS_IWEB_SHELL_SERVICES_IID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsObserverBase::NotifyWebShell(
|
||||
nsISupports* aParserBundle, const char* charset, nsCharsetSource source)
|
||||
{
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupportsParserBundle> bundle=do_QueryInterface(aParserBundle);
|
||||
|
||||
if (bundle) {
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// XXX - Make sure not to reload POST data to prevent bugs such as 27006
|
||||
nsAutoString theChannelKey;
|
||||
theChannelKey.AssignWithConversion("channel");
|
||||
|
||||
nsCOMPtr<nsIChannel> channel=nsnull;
|
||||
res=bundle->GetDataFromBundle(theChannelKey,getter_AddRefs(channel));
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel,&res));
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
nsXPIDLCString method;
|
||||
httpChannel->GetRequestMethod(getter_Copies(method));
|
||||
if(method) {
|
||||
if(!PL_strcasecmp(method, "POST"))
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString theDocShellKey;
|
||||
theDocShellKey.AssignWithConversion("docshell"); // Key to find docshell from the bundle.
|
||||
|
||||
nsCOMPtr<nsIDocShell> docshell=nsnull;
|
||||
|
||||
res=bundle->GetDataFromBundle(theDocShellKey,getter_AddRefs(docshell));
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIWebShellServices> wss=nsnull;
|
||||
wss=do_QueryInterface(docshell,&res); // Query webshell service through docshell.
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
|
||||
#ifndef DONT_INFORM_WEBSHELL
|
||||
// ask the webshellservice to load the URL
|
||||
if(NS_FAILED( res = wss->SetRendering(PR_FALSE) ))
|
||||
rv=res;
|
||||
|
||||
// XXX nisheeth, uncomment the following two line to see the reent problem
|
||||
|
||||
else if(NS_FAILED(res = wss->StopDocumentLoad())){
|
||||
rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
|
||||
}
|
||||
|
||||
else if(NS_FAILED(res = wss->ReloadDocument(charset, source))) {
|
||||
rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_HTMLPARSER_STOPPARSING; // We're reloading a new document...stop loading the current.
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
27
mozilla/layout/build/gbdate.pl
Executable file
27
mozilla/layout/build/gbdate.pl
Executable file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
|
||||
# XP way of doing the build date.
|
||||
# 1998091509 = 1998, September, 15th, 9am local time zone
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
|
||||
# localtime returns year minus 1900
|
||||
$year = $year + 1900;
|
||||
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);
|
||||
90
mozilla/layout/build/nsContentHTTPStartup.cpp
Normal file
90
mozilla/layout/build/nsContentHTTPStartup.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- 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 Communicator client 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):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
|
||||
#define PRODUCT_NAME "Gecko"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::Observe( nsISupports *aSubject,
|
||||
const PRUnichar *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProduct(PRODUCT_NAME);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProductSub((char*) PRODUCT_VERSION);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::RegisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString previousEntry;
|
||||
rv = catMan->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY,
|
||||
"Content UserAgent Setter",
|
||||
NS_CONTENTHTTPSTARTUP_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE,
|
||||
getter_Copies(previousEntry));
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::UnregisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
1813
mozilla/layout/html/forms/src/nsFormFrame.cpp
Normal file
1813
mozilla/layout/html/forms/src/nsFormFrame.cpp
Normal file
File diff suppressed because it is too large
Load Diff
864
mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp
Normal file
864
mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp
Normal file
@@ -0,0 +1,864 @@
|
||||
/* -*- 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.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):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "msgCore.h" // for pre-compiled headers
|
||||
#include "nsCOMPtr.h"
|
||||
#include <stdio.h>
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "comi18n.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAbSyncPostEngine.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIAbSync.h"
|
||||
#include "nsAbSyncCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCAbSyncMojoCID, NS_AB_SYNC_MOJO_CID);
|
||||
static NS_DEFINE_CID(kAbSync, NS_ABSYNC_SERVICE_CID);
|
||||
|
||||
/*
|
||||
* This function will be used by the factory to generate an
|
||||
* object class object....
|
||||
*/
|
||||
NS_METHOD
|
||||
nsAbSyncPostEngine::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsAbSyncPostEngine *ph = new nsAbSyncPostEngine();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return ph->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAbSyncPostEngine)
|
||||
NS_IMPL_RELEASE(nsAbSyncPostEngine)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsAbSyncPostEngine)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAbSyncPostEngine)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
/*
|
||||
* Inherited methods for nsMimeConverter
|
||||
*/
|
||||
nsAbSyncPostEngine::nsAbSyncPostEngine()
|
||||
{
|
||||
/* the following macro is used to initialize the ref counting data */
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// Init member variables...
|
||||
mTotalWritten = 0;
|
||||
mStillRunning = PR_TRUE;
|
||||
mContentType = nsnull;
|
||||
mCharset = nsnull;
|
||||
|
||||
mListenerArray = nsnull;
|
||||
mListenerArrayCount = 0;
|
||||
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostIdle;
|
||||
mTransactionID = 0;
|
||||
mMessageSize = 0;
|
||||
mAuthenticationRunning = PR_TRUE;
|
||||
mCookie = nsnull;
|
||||
mUser = nsnull;
|
||||
mSyncProtocolRequest = nsnull;
|
||||
mSyncProtocolRequestPrefix = nsnull;
|
||||
mChannel = nsnull;
|
||||
mMojoSyncSpec = nsnull;
|
||||
}
|
||||
|
||||
nsAbSyncPostEngine::~nsAbSyncPostEngine()
|
||||
{
|
||||
mStillRunning = PR_FALSE;
|
||||
PR_FREEIF(mContentType);
|
||||
PR_FREEIF(mCharset);
|
||||
|
||||
PR_FREEIF(mSyncProtocolRequest);
|
||||
PR_FREEIF(mSyncProtocolRequestPrefix);
|
||||
PR_FREEIF(mCookie);
|
||||
PR_FREEIF(mUser);
|
||||
PR_FREEIF(mMojoSyncSpec);
|
||||
DeleteListeners();
|
||||
}
|
||||
|
||||
PRInt32 Base64Decode_int(const char *in_str, unsigned char *out_str,
|
||||
PRUint32& decoded_len);
|
||||
/* ==================================================================
|
||||
* Base64Encode
|
||||
*
|
||||
* Returns number of bytes that were encoded.
|
||||
*
|
||||
* >0 -> OK
|
||||
* -1 -> BAD (output buffer not big enough).
|
||||
*
|
||||
* ==================================================================
|
||||
*/
|
||||
PRInt32 Base64Encode(const unsigned char *in_str, PRInt32 in_len, char *out_str,
|
||||
PRInt32 out_len)
|
||||
{
|
||||
static unsigned char base64[] =
|
||||
{
|
||||
/* 0 1 2 3 4 5 6 7 */
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', /* 0 */
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', /* 1 */
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', /* 2 */
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', /* 3 */
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', /* 4 */
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', /* 5 */
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', /* 6 */
|
||||
'4', '5', '6', '7', '8', '9', '+', '/' /* 7 */
|
||||
};
|
||||
PRInt32 curr_out_len = 0;
|
||||
|
||||
PRInt32 i = 0;
|
||||
unsigned char a, b, c;
|
||||
|
||||
out_str[0] = '\0';
|
||||
|
||||
if (in_len > 0)
|
||||
{
|
||||
|
||||
while (i < in_len)
|
||||
{
|
||||
a = in_str[i];
|
||||
b = (i + 1 >= in_len) ? 0 : in_str[i + 1];
|
||||
c = (i + 2 >= in_len) ? 0 : in_str[i + 2];
|
||||
|
||||
if (i + 2 < in_len)
|
||||
{
|
||||
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
|
||||
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
|
||||
+ ((b >> 4) & 0xf)]);
|
||||
out_str[curr_out_len++] = (base64[((b << 2) & 0x3c)
|
||||
+ ((c >> 6) & 0x3)]);
|
||||
out_str[curr_out_len++] = (base64[c & 0x3F]);
|
||||
}
|
||||
else if (i + 1 < in_len)
|
||||
{
|
||||
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
|
||||
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
|
||||
+ ((b >> 4) & 0xf)]);
|
||||
out_str[curr_out_len++] = (base64[((b << 2) & 0x3c)
|
||||
+ ((c >> 6) & 0x3)]);
|
||||
out_str[curr_out_len++] = '=';
|
||||
}
|
||||
else
|
||||
{
|
||||
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
|
||||
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
|
||||
+ ((b >> 4) & 0xf)]);
|
||||
out_str[curr_out_len++] = '=';
|
||||
out_str[curr_out_len++] = '=';
|
||||
}
|
||||
|
||||
i += 3;
|
||||
|
||||
if((curr_out_len + 4) > out_len)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
}
|
||||
out_str[curr_out_len] = '\0';
|
||||
}
|
||||
|
||||
return curr_out_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine decodes base64 string to a buffer.
|
||||
* Populates 'out_str' with b64 decoded data.
|
||||
*
|
||||
* Returns number of bytes that were decoded.
|
||||
* >0 -> OK
|
||||
* -1 -> BAD (output buffer not big enough).
|
||||
*/
|
||||
PRInt32 Base64Decode(const char *in_str, unsigned char *out_str,
|
||||
PRUint32* decoded_len)
|
||||
{
|
||||
return Base64Decode_int(in_str, out_str, *decoded_len);
|
||||
}
|
||||
|
||||
PRInt32 Base64Decode_int(const char *in_str, unsigned char *out_str,
|
||||
PRUint32& decoded_len)
|
||||
{
|
||||
PRInt32 in_len = strlen (/*(char *)*/ in_str);
|
||||
PRInt32 ii = 0;
|
||||
PRInt32 a = 0;
|
||||
char ch;
|
||||
PRInt32 b1 = 0;
|
||||
long b4 = 0;
|
||||
PRInt32 nn = 0;
|
||||
|
||||
/* Decode remainder of base 64 string */
|
||||
|
||||
while (ii < in_len)
|
||||
{
|
||||
ch = in_str[ii++];
|
||||
if (ch >= 'A' && ch <= 'Z') b1 = (ch - 'A');
|
||||
else if (ch >= 'a' && ch <= 'z') b1 = 26 + (ch - 'a');
|
||||
else if (ch >= '0' && ch <= '9') b1 = 52 + (ch - '0');
|
||||
else if (ch == '+') b1 = 62;
|
||||
else if (ch == '/') b1 = 63;
|
||||
else if (ch == '\r' || ch == '\n') continue;
|
||||
else
|
||||
{
|
||||
if (ch == '=')
|
||||
{
|
||||
if (nn == 3)
|
||||
{
|
||||
if ((a + 2) > (PRInt32) decoded_len)
|
||||
return (-1); /* Bail. Buffer overflow */
|
||||
b4 = (b4 << 6);
|
||||
out_str[a++] = (char) (0xff & (b4 >> 16));
|
||||
out_str[a++] = (char) (0xff & (b4 >> 8));
|
||||
}
|
||||
else if (nn == 2)
|
||||
{
|
||||
if ((a + 1) > (PRInt32) decoded_len)
|
||||
{
|
||||
return (-1); /* Bail. Buffer overflow */
|
||||
}
|
||||
b4 = (b4 << 12);
|
||||
out_str[a++] = (char) (0xff & (b4 >> 16));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
b4 = (b4 << 6) | (long) b1;
|
||||
nn++;
|
||||
if (nn == 4)
|
||||
{
|
||||
if ((a + 3) > (PRInt32) decoded_len)
|
||||
{
|
||||
return (-1); /* Bail. Buffer overflow */
|
||||
}
|
||||
out_str[a++] = (char) (0xff & (b4 >> 16));
|
||||
out_str[a++] = (char) (0xff & (b4 >> 8));
|
||||
out_str[a++] = (char) (0xff & (b4));
|
||||
nn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
out_str[a] = '\0';
|
||||
decoded_len = a;
|
||||
|
||||
return (a);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::GetInterface(const nsIID & aIID, void * *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
// nsIURIContentListener support
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
||||
{
|
||||
*aProtocolHandler = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
if (nsCRT::strcasecmp(aContentType, MESSAGE_RFC822) == 0)
|
||||
*aDesiredContentType = nsCRT::strdup("text/html");
|
||||
|
||||
// since we explicilty loaded the url, we always want to handle it!
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest *request,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aAbortProcess)
|
||||
*aAbortProcess = PR_FALSE;
|
||||
QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::GetParentContentListener(nsIURIContentListener** aParent)
|
||||
{
|
||||
*aParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::SetParentContentListener(nsIURIContentListener* aParent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::GetLoadCookie(nsISupports ** aLoadCookie)
|
||||
{
|
||||
*aLoadCookie = mLoadCookie;
|
||||
NS_IF_ADDREF(*aLoadCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
mLoadCookie = aLoadCookie;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::StillRunning(PRBool *running)
|
||||
{
|
||||
*running = mStillRunning;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Methods for nsIStreamListener...
|
||||
nsresult
|
||||
nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
|
||||
PRUint32 sourceOffset, PRUint32 aLength)
|
||||
{
|
||||
PRUint32 readLen = aLength;
|
||||
|
||||
char *buf = (char *)PR_Malloc(aLength);
|
||||
if (!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
|
||||
// read the data from the input stram...
|
||||
nsresult rv = aIStream->Read(buf, aLength, &readLen);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// write to the protocol response buffer...
|
||||
mProtocolResponse.Append(NS_ConvertASCIItoUCS2(buf, readLen));
|
||||
PR_FREEIF(buf);
|
||||
mTotalWritten += readLen;
|
||||
|
||||
if (!mAuthenticationRunning)
|
||||
NotifyListenersOnProgress(mTransactionID, mTotalWritten, 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Methods for nsIRequestObserver
|
||||
nsresult
|
||||
nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
{
|
||||
if (mAuthenticationRunning)
|
||||
NotifyListenersOnStartAuthOperation();
|
||||
else
|
||||
NotifyListenersOnStartSending(mTransactionID, mMessageSize);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus)
|
||||
{
|
||||
#ifdef NS_DEBUG_rhp
|
||||
printf("nsAbSyncPostEngine::OnStopRequest()\n");
|
||||
#endif
|
||||
|
||||
char *tProtResponse = nsnull;
|
||||
|
||||
//
|
||||
// Now complete the stream!
|
||||
//
|
||||
mStillRunning = PR_FALSE;
|
||||
|
||||
// Check the content type!
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
if (channel)
|
||||
{
|
||||
char *contentType = nsnull;
|
||||
char *charset = nsnull;
|
||||
|
||||
if (NS_SUCCEEDED(channel->GetContentType(&contentType)) && contentType)
|
||||
{
|
||||
if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE))
|
||||
{
|
||||
mContentType = contentType;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel)
|
||||
{
|
||||
if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset)
|
||||
{
|
||||
mCharset = charset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set the state...
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostIdle;
|
||||
|
||||
if (mAuthenticationRunning)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mSyncMojo)
|
||||
rv = mSyncMojo->GetAbSyncMojoResults(&mUser, &mCookie, &mMojoSyncSpec, &mMojoSyncPort);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// Before we really get started...lets let sync know who is doing this...
|
||||
NS_WITH_SERVICE(nsIAbSync, sync, kAbSync, &rv);
|
||||
if (NS_SUCCEEDED(rv) || sync)
|
||||
sync->SetAbSyncUser(mUser);
|
||||
|
||||
// Base64 encode then url encode it...
|
||||
//
|
||||
char tUser[256] = "";
|
||||
|
||||
if (Base64Encode((unsigned char *)mUser, nsCRT::strlen(mUser), tUser, sizeof(tUser)) < 0)
|
||||
{
|
||||
rv = NS_ERROR_FAILURE;
|
||||
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
|
||||
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *tUser2 = nsEscape(tUser, url_Path);
|
||||
if (!tUser2)
|
||||
{
|
||||
rv = NS_ERROR_FAILURE;
|
||||
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
|
||||
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSyncProtocolRequestPrefix = PR_smprintf("cn=%s&cc=%s&", tUser2, mCookie);
|
||||
PR_FREEIF(tUser2);
|
||||
NotifyListenersOnStopAuthOperation(aStatus, tProtResponse);
|
||||
KickTheSyncOperation();
|
||||
}
|
||||
}
|
||||
|
||||
// RICHIE - Special here to show the server we are hitting!
|
||||
// RICHIE - REMOVE THIS BEFORE SHIPPING!!!!
|
||||
#ifdef DEBUG
|
||||
PRUnichar *msgValue = nsnull;
|
||||
msgValue = nsTextFormatter::smprintf(nsString(NS_ConvertASCIItoUCS2("Server: %s - port %d")).GetUnicode(),
|
||||
mMojoSyncSpec, mMojoSyncPort);
|
||||
NotifyListenersOnStatus(mTransactionID, msgValue);
|
||||
PR_FREEIF(msgValue);
|
||||
// RICHIE
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
|
||||
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
|
||||
}
|
||||
|
||||
mSyncMojo = nsnull;
|
||||
}
|
||||
else
|
||||
{
|
||||
tProtResponse = mProtocolResponse.ToNewCString();
|
||||
NotifyListenersOnStopSending(mTransactionID, aStatus, tProtResponse);
|
||||
}
|
||||
|
||||
PR_FREEIF(tProtResponse);
|
||||
|
||||
// Time to return...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void AddSyncListener (in nsIAbSyncPostListener aListener); */
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::AddPostListener(nsIAbSyncPostListener *aListener)
|
||||
{
|
||||
if ( (mListenerArrayCount > 0) || mListenerArray )
|
||||
{
|
||||
++mListenerArrayCount;
|
||||
mListenerArray = (nsIAbSyncPostListener **)
|
||||
PR_Realloc(*mListenerArray, sizeof(nsIAbSyncPostListener *) * mListenerArrayCount);
|
||||
if (!mListenerArray)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
{
|
||||
mListenerArray[mListenerArrayCount - 1] = aListener;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mListenerArrayCount = 1;
|
||||
mListenerArray = (nsIAbSyncPostListener **) PR_Malloc(sizeof(nsIAbSyncPostListener *) * mListenerArrayCount);
|
||||
if (!mListenerArray)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCRT::memset(mListenerArray, 0, (sizeof(nsIAbSyncPostListener *) * mListenerArrayCount));
|
||||
|
||||
mListenerArray[0] = aListener;
|
||||
NS_ADDREF(mListenerArray[0]);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* void RemoveSyncListener (in nsIAbSyncPostListener aListener); */
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::RemovePostListener(nsIAbSyncPostListener *aListener)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] == aListener)
|
||||
{
|
||||
NS_RELEASE(mListenerArray[i]);
|
||||
mListenerArray[i] = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::DeleteListeners()
|
||||
{
|
||||
if ( (mListenerArray) && (*mListenerArray) )
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
{
|
||||
NS_RELEASE(mListenerArray[i]);
|
||||
}
|
||||
|
||||
PR_FREEIF(mListenerArray);
|
||||
}
|
||||
|
||||
mListenerArrayCount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStartAuthOperation(void)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStartAuthOperation();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStopAuthOperation(nsresult aStatus, const char *aCookie)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStopAuthOperation(aStatus, nsnull, aCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStartSending(PRInt32 aTransactionID, PRUint32 aMsgSize)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStartOperation(aTransactionID, aMsgSize);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnProgress(aTransactionID, aProgress, aProgressMax);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStatus(PRInt32 aTransactionID, PRUnichar *aMsg)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStatus(aTransactionID, aMsg);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStopSending(PRInt32 aTransactionID, nsresult aStatus,
|
||||
char *aProtocolResponse)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStopOperation(aTransactionID, aStatus, nsnull, aProtocolResponse);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Utility to create a nsIURI object...
|
||||
extern "C" nsresult
|
||||
nsEngineNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (nsnull == aInstancePtrResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_WITH_SERVICE(nsIIOService, pService, kIOServiceCID, &res);
|
||||
if (NS_FAILED(res))
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
|
||||
return pService->NewURI(aSpec, aBase, aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInputStream> postStream;
|
||||
|
||||
if (!postData)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(mChannel), aURL, nsnull), NS_ERROR_FAILURE);
|
||||
|
||||
// Tag the post stream onto the channel...but never seemed to work...so putting it
|
||||
// directly on the URL spec
|
||||
//
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
|
||||
if (!httpChannel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, postData, 0)))
|
||||
httpChannel->SetUploadStream(postStream);
|
||||
|
||||
httpChannel->AsyncOpen(this, nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRInt32 GetCurrentState (); */
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::GetCurrentState(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = mPostEngineState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is the implementation of the actual post driver.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::BuildMojoString(nsIDocShell *aRootDocShell, char **aID)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!aID)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Now, get the COMPtr to the Mojo!
|
||||
if (!mSyncMojo)
|
||||
{
|
||||
rv = nsComponentManager::CreateInstance(kCAbSyncMojoCID, NULL, NS_GET_IID(nsIAbSyncMojo), getter_AddRefs(mSyncMojo));
|
||||
if ( NS_FAILED(rv) || (!mSyncMojo) )
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = mSyncMojo->BuildMojoString(aRootDocShell, aID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::SendAbRequest(const char *aSpec, PRInt32 aPort, const char *aProtocolRequest, PRInt32 aTransactionID,
|
||||
nsIDocShell *aDocShell, const char *aUser)
|
||||
{
|
||||
nsresult rv;
|
||||
char *mojoUser = nsnull;
|
||||
char *mojoSnack = nsnull;
|
||||
|
||||
// Only try if we are not currently busy!
|
||||
if (mPostEngineState != nsIAbSyncPostEngineState::nsIAbSyncPostIdle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Now, get the COMPtr to the Mojo!
|
||||
if (!mSyncMojo)
|
||||
{
|
||||
rv = nsComponentManager::CreateInstance(kCAbSyncMojoCID, NULL, NS_GET_IID(nsIAbSyncMojo), getter_AddRefs(mSyncMojo));
|
||||
if ( NS_FAILED(rv) || (!mSyncMojo) )
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aUser)
|
||||
mUser = nsCRT::strdup(aUser);
|
||||
if (NS_FAILED(mSyncMojo->StartAbSyncMojo(this, aDocShell, mUser)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Set transaction ID and save/init Sync info...
|
||||
mTransactionID = aTransactionID;
|
||||
|
||||
// Init stuff we need....
|
||||
mSyncProtocolRequest = nsCRT::strdup(aProtocolRequest);
|
||||
mProtocolResponse = NS_ConvertASCIItoUCS2("");
|
||||
mTotalWritten = 0;
|
||||
|
||||
// The first thing we need to do is authentication so do it!
|
||||
mAuthenticationRunning = PR_TRUE;
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncAuthenticationRunning;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::KickTheSyncOperation(void)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIURI *workURI = nsnull;
|
||||
char *protString = nsnull;
|
||||
|
||||
// The first thing we need to do is authentication so do it!
|
||||
mAuthenticationRunning = PR_FALSE;
|
||||
mProtocolResponse = NS_ConvertASCIItoUCS2("");
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostRunning;
|
||||
|
||||
char *postHeader = "Content-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\nCookie: %s\r\n\r\n%s";
|
||||
protString = PR_smprintf("%s%s", mSyncProtocolRequestPrefix, mSyncProtocolRequest);
|
||||
if (protString)
|
||||
mMessageSize = nsCRT::strlen(protString);
|
||||
else
|
||||
mMessageSize = 0;
|
||||
|
||||
char *tCommand = PR_smprintf(postHeader, mMessageSize, mCookie, protString);
|
||||
PR_FREEIF(protString);
|
||||
|
||||
#ifdef DEBUG_rhp
|
||||
printf("COMMAND = %s\n", tCommand);
|
||||
#endif
|
||||
|
||||
if (!tCommand)
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY; // we couldn't allocate the string
|
||||
goto GetOuttaHere;
|
||||
}
|
||||
|
||||
rv = nsEngineNewURI(&workURI, mMojoSyncSpec, nsnull);
|
||||
if (NS_FAILED(rv) || (!workURI))
|
||||
{
|
||||
rv = NS_ERROR_FAILURE; // we couldn't allocate the string
|
||||
goto GetOuttaHere;
|
||||
}
|
||||
|
||||
if (mMojoSyncPort > 0)
|
||||
workURI->SetPort(mMojoSyncPort);
|
||||
|
||||
rv = FireURLRequest(workURI, tCommand);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
NotifyListenersOnStartSending(mTransactionID, mMessageSize);
|
||||
|
||||
GetOuttaHere:
|
||||
NS_IF_RELEASE(workURI);
|
||||
PR_FREEIF(tCommand);
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostRunning;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::CancelAbSync()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (mSyncMojo)
|
||||
{
|
||||
rv = mSyncMojo->CancelTheMojo();
|
||||
}
|
||||
else if (mChannel)
|
||||
{
|
||||
rv = mChannel->Cancel(NS_BINDING_ABORTED);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::GetMojoUserAndSnack(char **aMojoUser, char **aMojoSnack)
|
||||
{
|
||||
if ( (!mUser) || (!mCookie) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aMojoUser = nsCRT::strdup(mUser);
|
||||
*aMojoSnack = nsCRT::strdup(mCookie);
|
||||
|
||||
if ( (!*aMojoUser) || (!*aMojoSnack) )
|
||||
return NS_ERROR_FAILURE;
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
2107
mozilla/mailnews/compose/src/nsMsgCompUtils.cpp
Normal file
2107
mozilla/mailnews/compose/src/nsMsgCompUtils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
453
mozilla/mailnews/compose/src/nsURLFetcher.cpp
Normal file
453
mozilla/mailnews/compose/src/nsURLFetcher.cpp
Normal file
@@ -0,0 +1,453 @@
|
||||
/* -*- 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.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):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "nsURLFetcher.h"
|
||||
|
||||
#include "msgCore.h" // for pre-compiled headers
|
||||
#include "nsCOMPtr.h"
|
||||
#include <stdio.h>
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "comi18n.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsMsgAttachmentHandler.h"
|
||||
#include "nsMsgSend.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS7(nsURLFetcher, nsIURLFetcher, nsIStreamListener, nsIURIContentListener, nsIInterfaceRequestor, nsIWebProgressListener, nsIHttpEventSink, nsISupportsWeakReference)
|
||||
|
||||
|
||||
/*
|
||||
* Inherited methods for nsMimeConverter
|
||||
*/
|
||||
nsURLFetcher::nsURLFetcher()
|
||||
{
|
||||
#if defined(DEBUG_ducarroz)
|
||||
printf("CREATE nsURLFetcher: %x\n", this);
|
||||
#endif
|
||||
/* the following macro is used to initialize the ref counting data */
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// Init member variables...
|
||||
mOutStream = nsnull;
|
||||
mTotalWritten = 0;
|
||||
mStillRunning = PR_TRUE;
|
||||
mCallback = nsnull;
|
||||
mContentType = nsnull;
|
||||
mCharset = nsnull;
|
||||
mOnStopRequestProcessed = PR_FALSE;
|
||||
mRedirection = PR_FALSE;
|
||||
}
|
||||
|
||||
nsURLFetcher::~nsURLFetcher()
|
||||
{
|
||||
#if defined(DEBUG_ducarroz)
|
||||
printf("DISPOSE nsURLFetcher: %x\n", this);
|
||||
#endif
|
||||
mStillRunning = PR_FALSE;
|
||||
|
||||
PR_FREEIF(mContentType);
|
||||
PR_FREEIF(mCharset);
|
||||
// Remove the DocShell as a listener of the old WebProgress...
|
||||
if (mLoadCookie)
|
||||
{
|
||||
nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
|
||||
|
||||
if (webProgress)
|
||||
webProgress->RemoveProgressListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsURLFetcher::GetInterface(const nsIID & aIID, void * *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
// nsIURIContentListener support
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
||||
{
|
||||
*aProtocolHandler = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
if (nsCRT::strcasecmp(aContentType, MESSAGE_RFC822) == 0)
|
||||
*aDesiredContentType = nsCRT::strdup("text/html");
|
||||
|
||||
// since we explicilty loaded the url, we always want to handle it!
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest *request,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aAbortProcess)
|
||||
*aAbortProcess = PR_FALSE;
|
||||
QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::GetParentContentListener(nsIURIContentListener** aParent)
|
||||
{
|
||||
*aParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::SetParentContentListener(nsIURIContentListener* aParent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::GetLoadCookie(nsISupports ** aLoadCookie)
|
||||
{
|
||||
*aLoadCookie = mLoadCookie;
|
||||
NS_IF_ADDREF(*aLoadCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
// Remove the DocShell as a listener of the old WebProgress...
|
||||
if (mLoadCookie)
|
||||
{
|
||||
nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
|
||||
|
||||
if (webProgress)
|
||||
webProgress->RemoveProgressListener(this);
|
||||
}
|
||||
|
||||
mLoadCookie = aLoadCookie;
|
||||
|
||||
// Add the DocShell as a listener to the new WebProgress...
|
||||
if (mLoadCookie)
|
||||
{
|
||||
nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
|
||||
|
||||
if (webProgress)
|
||||
webProgress->AddProgressListener(this);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURLFetcher::StillRunning(PRBool *running)
|
||||
{
|
||||
*running = mStillRunning;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Methods for nsIStreamListener...
|
||||
nsresult
|
||||
nsURLFetcher::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
|
||||
PRUint32 sourceOffset, PRUint32 aLength)
|
||||
{
|
||||
PRUint32 readLen = aLength;
|
||||
PRUint32 wroteIt;
|
||||
|
||||
if (!mOutStream)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
char *buf = (char *)PR_Malloc(aLength);
|
||||
if (!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
|
||||
// read the data from the input stram...
|
||||
nsresult rv = aIStream->Read(buf, aLength, &readLen);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// write to the output file...
|
||||
wroteIt = mOutStream->write(buf, readLen);
|
||||
PR_FREEIF(buf);
|
||||
|
||||
if (wroteIt != readLen)
|
||||
return NS_ERROR_FAILURE;
|
||||
else
|
||||
{
|
||||
mTotalWritten += wroteIt;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methods for nsIStreamObserver
|
||||
nsresult
|
||||
nsURLFetcher::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
{
|
||||
mRedirection = PR_FALSE; // start a new request, reset mRedirection
|
||||
|
||||
nsMsgAttachmentHandler *attachmentHdl = (nsMsgAttachmentHandler *)mTagData;
|
||||
if (attachmentHdl)
|
||||
{
|
||||
nsCOMPtr<nsIMsgSend> sendPtr;
|
||||
attachmentHdl->GetMimeDeliveryState(getter_AddRefs(sendPtr));
|
||||
if (sendPtr)
|
||||
{
|
||||
nsCOMPtr<nsIMsgProgress> progress;
|
||||
sendPtr->GetProgress(getter_AddRefs(progress));
|
||||
if (progress)
|
||||
{
|
||||
PRBool cancel = PR_FALSE;
|
||||
progress->GetProcessCanceledByUser(&cancel);
|
||||
if (cancel)
|
||||
return request->Cancel(NS_ERROR_ABORT);
|
||||
}
|
||||
}
|
||||
attachmentHdl->mRequest = request;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus)
|
||||
{
|
||||
#if defined(DEBUG_ducarroz)
|
||||
printf("nsURLFetcher::OnStopRequest()\n");
|
||||
#endif
|
||||
|
||||
// it's possible we could get in here from the channel calling us with an OnStopRequest and from our
|
||||
// onStatusChange method (in the case of an error). So we should protect against this to make sure we
|
||||
// don't process the on stop request twice...
|
||||
|
||||
if (mOnStopRequestProcessed) return NS_OK;
|
||||
mOnStopRequestProcessed = PR_TRUE;
|
||||
|
||||
nsMsgAttachmentHandler *attachmentHdl = (nsMsgAttachmentHandler *)mTagData;
|
||||
if (attachmentHdl)
|
||||
attachmentHdl->mRequest = nsnull;
|
||||
|
||||
//
|
||||
// Now complete the stream!
|
||||
//
|
||||
mStillRunning = PR_FALSE;
|
||||
|
||||
// First close the output stream...
|
||||
if (mOutStream)
|
||||
{
|
||||
mOutStream->close();
|
||||
mOutStream = nsnull;
|
||||
}
|
||||
|
||||
|
||||
// Check the content type!
|
||||
char *contentType = nsnull;
|
||||
char *charset = nsnull;
|
||||
|
||||
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
|
||||
if(!aChannel) return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType)
|
||||
{
|
||||
if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE))
|
||||
{
|
||||
mContentType = contentType;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel)
|
||||
{
|
||||
if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset)
|
||||
{
|
||||
mCharset = charset;
|
||||
}
|
||||
}
|
||||
|
||||
// Now if there is a callback, we need to call it...
|
||||
if (mCallback)
|
||||
mCallback (aStatus, mContentType, mCharset, mTotalWritten, nsnull, mTagData);
|
||||
|
||||
// Time to return...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURLFetcher::Initialize(nsOutputFileStream *fOut,
|
||||
nsAttachSaveCompletionCallback cb,
|
||||
void *tagData)
|
||||
{
|
||||
if (!fOut)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (!fOut->is_open())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mOutStream = fOut;
|
||||
mCallback = cb; //JFD: Please, no more callback, use a listener...
|
||||
mTagData = tagData; //JFD: TODO, WE SHOULD USE A NSCOMPTR to hold this stuff!!!
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
|
||||
nsAttachSaveCompletionCallback cb, void *tagData)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if ( (!aURL) || (!fOut) )
|
||||
{
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!fOut->is_open())
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// we're about to fire a new url request so make sure the on stop request flag is cleared...
|
||||
mOnStopRequestProcessed = PR_FALSE;
|
||||
|
||||
// let's try uri dispatching...
|
||||
nsCOMPtr<nsIURILoader> pURILoader (do_GetService(NS_URI_LOADER_CONTRACTID));
|
||||
NS_ENSURE_TRUE(pURILoader, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsISupports> cntListener (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, this)));
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
pURILoader->GetLoadGroupForContext(cntListener, getter_AddRefs(loadGroup));
|
||||
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(channel), aURL, nsnull, loadGroup, this), NS_ERROR_FAILURE);
|
||||
|
||||
rv = pURILoader->OpenURI(channel, nsIURILoader::viewNormal, nsnull /* window target */,
|
||||
cntListener);
|
||||
|
||||
mOutStream = fOut;
|
||||
mCallback = cb;
|
||||
mTagData = tagData;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// web progress listener implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnProgressChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
|
||||
PRInt32 aStateFlags, nsresult aStatus)
|
||||
{
|
||||
// all we care about is the case where an error occurred (as in we were unable to locate the
|
||||
// the url....
|
||||
|
||||
if (NS_FAILED(aStatus))
|
||||
{
|
||||
//... but we must ignore abort message caused by a redirection!
|
||||
if (aStatus == NS_BINDING_ABORTED && mRedirection)
|
||||
return NS_OK;
|
||||
|
||||
OnStopRequest(aRequest, nsnull, aStatus);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnLocationChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
nsIURI *aURI)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnStatusChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* aMessage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 state)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnRedirect(nsIHttpChannel *aOldChannel, nsIChannel *aNewChannel)
|
||||
{
|
||||
mRedirection = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
88
mozilla/mailnews/compose/src/nsURLFetcher.h
Normal file
88
mozilla/mailnews/compose/src/nsURLFetcher.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- 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 "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 nsURLFetcher_h_
|
||||
#define nsURLFetcher_h_
|
||||
|
||||
#include "nsIURLFetcher.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
|
||||
class nsURLFetcher : public nsIURLFetcher,
|
||||
public nsIStreamListener,
|
||||
public nsIURIContentListener,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIWebProgressListener,
|
||||
public nsIHttpEventSink,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
nsURLFetcher();
|
||||
virtual ~nsURLFetcher();
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Methods for nsIURLFetcher
|
||||
NS_DECL_NSIURLFETCHER
|
||||
|
||||
// Methods for nsIStreamListener
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
// Methods for nsIRequestObserver
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
// Methods for nsIURICOntentListener
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
|
||||
// Methods for nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// Methods for nsIWebProgressListener
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
// Methods for nsIHttpEventSink
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
|
||||
private:
|
||||
nsOutputFileStream *mOutStream; // the output file stream
|
||||
PRBool mStillRunning; // Are we still running?
|
||||
PRInt32 mTotalWritten; // Size counter variable
|
||||
char *mContentType; // The content type retrieved from the server
|
||||
char *mCharset; // The charset retrieved from the server
|
||||
void *mTagData; // Tag data for callback...
|
||||
nsAttachSaveCompletionCallback mCallback; // Callback to call once the file is saved...
|
||||
nsCOMPtr<nsISupports> mLoadCookie; // load cookie used by the uri loader when we fetch the url
|
||||
PRBool mOnStopRequestProcessed; // used to prevent calling OnStopRequest multiple times
|
||||
PRBool mRedirection; // Set when we get a redirection, should ignore stop message.
|
||||
};
|
||||
|
||||
#endif /* nsURLFetcher_h_ */
|
||||
39
mozilla/modules/libjar/nsIJARChannel.idl
Normal file
39
mozilla/modules/libjar/nsIJARChannel.idl
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: IDL; 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):
|
||||
*/
|
||||
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
[scriptable, uuid(c7e410d1-85f2-11d3-9f63-006008a6efe9)]
|
||||
interface nsIJARChannel : nsIChannel
|
||||
{
|
||||
|
||||
/**
|
||||
* Enumerates all the entries in the JAR (the root URI).
|
||||
* ARGUMENTS:
|
||||
* aRoot - a string representing the root dir to enumerate from
|
||||
* or null to enumerate the whole thing.
|
||||
*/
|
||||
nsISimpleEnumerator EnumerateEntries(in string aRoot);
|
||||
|
||||
};
|
||||
34
mozilla/modules/libjar/nsIJARProtocolHandler.idl
Normal file
34
mozilla/modules/libjar/nsIJARProtocolHandler.idl
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C++; tab-width: 2; 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):
|
||||
*/
|
||||
|
||||
#include "nsIProtocolHandler.idl"
|
||||
|
||||
interface nsIZipReaderCache;
|
||||
|
||||
[scriptable, uuid(92c3b42c-98c4-11d3-8cd9-0060b0fc14a3)]
|
||||
interface nsIJARProtocolHandler : nsIProtocolHandler {
|
||||
|
||||
/**
|
||||
* JARCache contains the collection of open jar files.
|
||||
*/
|
||||
readonly attribute nsIZipReaderCache JARCache;
|
||||
};
|
||||
42
mozilla/modules/libjar/nsIJARURI.idl
Normal file
42
mozilla/modules/libjar/nsIJARURI.idl
Normal file
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: IDL; 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 "nsIURI.idl"
|
||||
|
||||
/**
|
||||
* JAR URLs have the following syntax
|
||||
*
|
||||
* jar:<jar-file-uri>!/<jar-entry>
|
||||
*
|
||||
* EXAMPLE: jar:http://www.big.com/blue.jar!/ocean.html
|
||||
*/
|
||||
[scriptable, uuid(c7e410d3-85f2-11d3-9f63-006008a6efe9)]
|
||||
interface nsIJARURI : nsIURI {
|
||||
|
||||
/**
|
||||
* Returns the root URI (the one for the actual JAR file) for this JAR.
|
||||
* eg http://www.big.com/blue.jar
|
||||
*/
|
||||
attribute nsIURI JARFile;
|
||||
|
||||
/**
|
||||
* Returns the entry specified for this JAR URI.
|
||||
* eg ocean.html
|
||||
*/
|
||||
attribute string JAREntry;
|
||||
};
|
||||
696
mozilla/modules/libjar/nsJARChannel.cpp
Normal file
696
mozilla/modules/libjar/nsJARChannel.cpp
Normal file
@@ -0,0 +1,696 @@
|
||||
/* -*- 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,2000 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsJARChannel.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFileTransportService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsIAggregatePrincipal.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIJAR.h"
|
||||
|
||||
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
static NS_DEFINE_CID(kScriptSecurityManagerCID, NS_SCRIPTSECURITYMANAGER_CID);
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
//
|
||||
// Log module for SocketTransport logging...
|
||||
//
|
||||
// To enable logging (see prlog.h for full details):
|
||||
//
|
||||
// set NSPR_LOG_MODULES=nsJarProtocol:5
|
||||
// set NSPR_LOG_FILE=nspr.log
|
||||
//
|
||||
// this enables PR_LOG_DEBUG level information and places all output in
|
||||
// the file nspr.log
|
||||
//
|
||||
PRLogModuleInfo* gJarProtocolLog = nsnull;
|
||||
|
||||
#endif /* PR_LOGGING */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_DEFAULT_JAR_BUFFER_SEGMENT_SIZE (16*1024)
|
||||
#define NS_DEFAULT_JAR_BUFFER_MAX_SIZE (256*1024)
|
||||
|
||||
nsJARChannel::nsJARChannel()
|
||||
: mLoadFlags(LOAD_NORMAL),
|
||||
mContentType(nsnull),
|
||||
mContentLength(-1),
|
||||
mJAREntry(nsnull),
|
||||
mStatus(NS_OK),
|
||||
mMonitor(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
//
|
||||
// Initialize the global PRLogModule for socket transport logging
|
||||
// if necessary...
|
||||
//
|
||||
if (nsnull == gJarProtocolLog) {
|
||||
gJarProtocolLog = PR_NewLogModule("nsJarProtocol");
|
||||
}
|
||||
#endif /* PR_LOGGING */
|
||||
}
|
||||
|
||||
nsJARChannel::~nsJARChannel()
|
||||
{
|
||||
if (mContentType)
|
||||
nsCRT::free(mContentType);
|
||||
if (mJAREntry)
|
||||
nsCRT::free(mJAREntry);
|
||||
if (mMonitor)
|
||||
PR_DestroyMonitor(mMonitor);
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS7(nsJARChannel,
|
||||
nsIJARChannel,
|
||||
nsIChannel,
|
||||
nsIRequest,
|
||||
nsIRequestObserver,
|
||||
nsIStreamListener,
|
||||
nsIStreamIO,
|
||||
nsIDownloadObserver)
|
||||
|
||||
NS_METHOD
|
||||
nsJARChannel::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsJARChannel* jarChannel = new nsJARChannel();
|
||||
if (jarChannel == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(jarChannel);
|
||||
rv = jarChannel->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(jarChannel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::Init(nsIJARProtocolHandler* aHandler, nsIURI* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
mURI = do_QueryInterface(uri, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mMonitor = PR_NewMonitor();
|
||||
if (mMonitor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mJARProtocolHandler = aHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequest methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetName(PRUnichar* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString urlStr;
|
||||
rv = mURI->GetSpec(getter_Copies(urlStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsString name;
|
||||
name.AppendWithConversion(urlStr);
|
||||
*result = name.ToNewUnicode();
|
||||
return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::IsPending(PRBool* result)
|
||||
{
|
||||
NS_NOTREACHED("nsJARChannel::IsPending");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetStatus(nsresult *status)
|
||||
{
|
||||
*status = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Cancel(nsresult status)
|
||||
{
|
||||
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoMonitor monitor(mMonitor);
|
||||
|
||||
if (mJarExtractionTransport) {
|
||||
rv = mJarExtractionTransport->Cancel(status);
|
||||
mJarExtractionTransport = nsnull;
|
||||
}
|
||||
|
||||
mStatus = status;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Suspend()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoMonitor monitor(mMonitor);
|
||||
|
||||
if (mJarExtractionTransport) {
|
||||
rv = mJarExtractionTransport->Suspend();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Resume()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoMonitor monitor(mMonitor);
|
||||
|
||||
if (mJarExtractionTransport) {
|
||||
rv = mJarExtractionTransport->Resume();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChannel methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetOriginalURI(nsIURI* *aOriginalURI)
|
||||
{
|
||||
if (mOriginalURI)
|
||||
*aOriginalURI = mOriginalURI;
|
||||
else
|
||||
*aOriginalURI = NS_STATIC_CAST(nsIURI*, mURI);
|
||||
|
||||
NS_IF_ADDREF(*aOriginalURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetOriginalURI(nsIURI* aOriginalURI)
|
||||
{
|
||||
mOriginalURI = aOriginalURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mURI;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::OpenJARElement()
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoCMonitor mon(this);
|
||||
rv = Open(nsnull, nsnull);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = GetInputStream(getter_AddRefs(mSynchronousInputStream));
|
||||
mon.Notify(); // wake up nsIChannel::Open
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Open(nsIInputStream* *result)
|
||||
{
|
||||
nsAutoCMonitor mon(this);
|
||||
nsresult rv;
|
||||
mSynchronousRead = PR_TRUE;
|
||||
rv = EnsureJARFileAvailable();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (mSynchronousInputStream == nsnull)
|
||||
mon.Wait();
|
||||
if (mSynchronousInputStream)
|
||||
{
|
||||
*result = mSynchronousInputStream; // Result of GetInputStream called on transport thread
|
||||
NS_ADDREF(*result);
|
||||
mSynchronousInputStream = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt)
|
||||
{
|
||||
nsresult rv;
|
||||
mUserContext = ctxt;
|
||||
mUserListener = listener;
|
||||
|
||||
if (mLoadGroup) {
|
||||
rv = mLoadGroup->AddRequest(this, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
mSynchronousRead = PR_FALSE;
|
||||
return EnsureJARFileAvailable();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::EnsureJARFileAvailable()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIChannel> jarBaseChannel;
|
||||
nsCOMPtr<nsIFile> jarCacheFile;
|
||||
nsCOMPtr<nsIChannel> jarCacheTransport;
|
||||
nsCOMPtr<nsIInputStream> jarBaseIn;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsXPIDLCString jarURLStr;
|
||||
mURI->GetSpec(getter_Copies(jarURLStr));
|
||||
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
||||
("nsJarProtocol: EnsureJARFileAvailable %s", (const char*)jarURLStr));
|
||||
#endif
|
||||
|
||||
rv = mURI->GetJARFile(getter_AddRefs(mJARBaseURI));
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
rv = mURI->GetJAREntry(&mJAREntry);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
rv = NS_NewDownloader(getter_AddRefs(mDownloader),
|
||||
mJARBaseURI, this, nsnull, mSynchronousRead, mLoadGroup, mCallbacks,
|
||||
mLoadFlags);
|
||||
|
||||
// if DownloadComplete() was called early, need to release the reference.
|
||||
if (mSynchronousRead && mSynchronousInputStream)
|
||||
mDownloader = null_nsCOMPtr();
|
||||
|
||||
error:
|
||||
if (NS_FAILED(rv) && mLoadGroup) {
|
||||
nsresult rv2 = mLoadGroup->RemoveRequest(this, nsnull, NS_OK);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed");
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::AsyncReadJARElement()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsAutoMonitor monitor(mMonitor);
|
||||
|
||||
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITransport> jarTransport;
|
||||
rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (mCallbacks) {
|
||||
nsCOMPtr<nsIProgressEventSink> sink = do_GetInterface(mCallbacks);
|
||||
if (sink) {
|
||||
// don't think that this is not needed anymore
|
||||
// jarTransport->SetProgressEventSink(sink);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsXPIDLCString jarURLStr;
|
||||
mURI->GetSpec(getter_Copies(jarURLStr));
|
||||
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
||||
("nsJarProtocol: AsyncRead jar entry %s", (const char*)jarURLStr));
|
||||
#endif
|
||||
|
||||
rv = jarTransport->AsyncRead(this, nsnull, 0, PRUint32(-1), 0,
|
||||
getter_AddRefs(mJarExtractionTransport));
|
||||
mJarExtractionTransport = 0;
|
||||
jarTransport = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetLoadFlags(PRUint32* aLoadFlags)
|
||||
{
|
||||
*aLoadFlags = mLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetContentType(char* *aContentType)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mContentType == nsnull) {
|
||||
if (!mJAREntry)
|
||||
return NS_ERROR_FAILURE;
|
||||
char* fileName = nsCRT::strdup(mJAREntry);
|
||||
if (fileName != nsnull) {
|
||||
PRInt32 len = nsCRT::strlen(fileName);
|
||||
const char* ext = nsnull;
|
||||
for (PRInt32 i = len-1; i >= 0; i--) {
|
||||
if (fileName[i] == '.') {
|
||||
ext = &fileName[i + 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ext) {
|
||||
nsCOMPtr<nsIMIMEService> mimeServ (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mimeServ->GetTypeFromExtension(ext, &mContentType);
|
||||
}
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCRT::free(fileName);
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
mContentType = nsCRT::strdup(UNKNOWN_CONTENT_TYPE);
|
||||
if (mContentType == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aContentType = nsCRT::strdup(mContentType);
|
||||
if (*aContentType == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetContentType(const char *aContentType)
|
||||
{
|
||||
if (mContentType) {
|
||||
nsCRT::free(mContentType);
|
||||
}
|
||||
|
||||
mContentType = nsCRT::strdup(aContentType);
|
||||
if (!mContentType) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetContentLength(PRInt32* aContentLength)
|
||||
{
|
||||
if (mContentLength == -1)
|
||||
return NS_ERROR_FAILURE;
|
||||
*aContentLength = mContentLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetContentLength(PRInt32 aContentLength)
|
||||
{
|
||||
NS_NOTREACHED("nsJARChannel::SetContentLength");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mOwner == nsnull) {
|
||||
//-- Verify signature, if one is present, and set owner accordingly
|
||||
rv = EnsureZipReader();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIJAR> jar = do_QueryInterface(mJAR, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Zip reader is not an nsIJAR");
|
||||
nsCOMPtr<nsIPrincipal> certificate;
|
||||
rv = jar->GetCertificatePrincipal(mJAREntry,
|
||||
getter_AddRefs(certificate));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (certificate)
|
||||
{ // Get the codebase principal
|
||||
NS_WITH_SERVICE(nsIScriptSecurityManager, secMan,
|
||||
kScriptSecurityManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPrincipal> codebase;
|
||||
rv = secMan->GetCodebasePrincipal(mJARBaseURI,
|
||||
getter_AddRefs(codebase));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Join the certificate and the codebase
|
||||
nsCOMPtr<nsIAggregatePrincipal> agg;
|
||||
agg = do_QueryInterface(certificate, &rv);
|
||||
rv = agg->SetCodebase(codebase);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mOwner = do_QueryInterface(agg, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
||||
{
|
||||
*aSecurityInfo = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIDownloadObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosure,
|
||||
nsresult aStatus, nsIFile* aFile)
|
||||
{
|
||||
nsresult rv=aStatus;
|
||||
if(NS_SUCCEEDED(aStatus)) {
|
||||
NS_ASSERTION(!mDownloader ||(aDownloader == mDownloader.get()), "wrong downloader");
|
||||
mDownloadedJARFile = aFile;
|
||||
// after successfully downloading the jar file to the cache,
|
||||
// start the extraction process:
|
||||
if (mSynchronousRead)
|
||||
rv = OpenJARElement();
|
||||
else
|
||||
rv = AsyncReadJARElement();
|
||||
}
|
||||
mDownloader = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequestObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::OnStartRequest(nsIRequest* jarExtractionTransport,
|
||||
nsISupports* context)
|
||||
{
|
||||
return mUserListener->OnStartRequest(this, mUserContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* context,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv;
|
||||
#ifdef PR_LOGGING
|
||||
nsCOMPtr<nsIURI> jarURI;
|
||||
nsXPIDLCString jarURLStr;
|
||||
rv = mURI->GetSpec(getter_Copies(jarURLStr));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
||||
("nsJarProtocol: jar extraction complete %s status=%x",
|
||||
(const char*)jarURLStr, aStatus));
|
||||
}
|
||||
#endif
|
||||
|
||||
rv = mUserListener->OnStopRequest(this, mUserContext, aStatus);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "OnStopRequest failed");
|
||||
|
||||
if (mLoadGroup)
|
||||
mLoadGroup->RemoveRequest(this, context, aStatus);
|
||||
|
||||
mUserListener = nsnull;
|
||||
mUserContext = nsnull;
|
||||
mJarExtractionTransport = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamListener methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::OnDataAvailable(nsIRequest* jarCacheTransport,
|
||||
nsISupports* context,
|
||||
nsIInputStream *inStr,
|
||||
PRUint32 sourceOffset,
|
||||
PRUint32 count)
|
||||
{
|
||||
return mUserListener->OnDataAvailable(this, mUserContext,
|
||||
inStr, sourceOffset, count);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamIO methods:
|
||||
|
||||
nsresult
|
||||
nsJARChannel::EnsureZipReader()
|
||||
{
|
||||
if (mJAR == nsnull) {
|
||||
nsresult rv;
|
||||
if (mDownloadedJARFile == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIZipReaderCache> jarCache;
|
||||
rv = mJARProtocolHandler->GetJARCache(getter_AddRefs(jarCache));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = jarCache->GetZip(mDownloadedJARFile, getter_AddRefs(mJAR));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Open(char* *contentType, PRInt32 *contentLength)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = EnsureZipReader();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIZipEntry> entry;
|
||||
rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (contentLength) {
|
||||
rv = entry->GetRealSize((PRUint32*)contentLength);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if (contentType) {
|
||||
rv = GetContentType(contentType);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Close(nsresult status)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetInputStream(nsIInputStream* *aInputStream)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
nsXPIDLCString jarURLStr;
|
||||
mURI->GetSpec(getter_Copies(jarURLStr));
|
||||
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
||||
("nsJarProtocol: GetInputStream jar entry %s", (const char*)jarURLStr));
|
||||
#endif
|
||||
NS_ENSURE_TRUE(mJAR, NS_ERROR_NULL_POINTER);
|
||||
return mJAR->GetInputStream(mJAREntry, aInputStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetOutputStream(nsIOutputStream* *aOutputStream)
|
||||
{
|
||||
NS_NOTREACHED("nsJARChannel::GetOutputStream");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetName(char* *aName)
|
||||
{
|
||||
return mURI->GetSpec(aName);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIJARChannel methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::EnumerateEntries(const char *aRoot, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
NS_NOTREACHED("nsJARChannel::EnumerateEntries");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
111
mozilla/modules/libjar/nsJARChannel.h
Normal file
111
mozilla/modules/libjar/nsJARChannel.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* -*- 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,2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsJARChannel_h__
|
||||
#define nsJARChannel_h__
|
||||
|
||||
#include "nsIJARChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIJARProtocolHandler.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsIStreamIO.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFile.h"
|
||||
#include "prmon.h"
|
||||
#include "nsIDownloader.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
class nsIFileChannel;
|
||||
class nsJARChannel;
|
||||
|
||||
#define NS_JARCHANNEL_CID \
|
||||
{ /* 0xc7e410d5-0x85f2-11d3-9f63-006008a6efe9 */ \
|
||||
0xc7e410d5, \
|
||||
0x85f2, \
|
||||
0x11d3, \
|
||||
{0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
|
||||
}
|
||||
|
||||
class nsJARChannel : public nsIJARChannel,
|
||||
public nsIStreamListener,
|
||||
public nsIStreamIO,
|
||||
public nsIDownloadObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSIJARCHANNEL
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSISTREAMIO
|
||||
NS_DECL_NSIDOWNLOADOBSERVER
|
||||
|
||||
nsJARChannel();
|
||||
virtual ~nsJARChannel();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
nsresult Init(nsIJARProtocolHandler* aHandler, nsIURI* uri);
|
||||
nsresult EnsureJARFileAvailable();
|
||||
nsresult OpenJARElement();
|
||||
nsresult AsyncReadJARElement();
|
||||
nsresult EnsureZipReader();
|
||||
|
||||
friend class nsJARDownloadObserver;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIJARProtocolHandler> mJARProtocolHandler;
|
||||
nsCOMPtr<nsIJARURI> mURI;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsLoadFlags mLoadFlags;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
nsCOMPtr<nsISupports> mUserContext;
|
||||
nsCOMPtr<nsIStreamListener> mUserListener;
|
||||
|
||||
char* mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsIURI> mJARBaseURI;
|
||||
char* mJAREntry;
|
||||
nsCOMPtr<nsIZipReader> mJAR;
|
||||
nsCOMPtr<nsIFile> mDownloadedJARFile;
|
||||
nsresult mStatus;
|
||||
PRBool mSynchronousRead;
|
||||
nsCOMPtr<nsIInputStream> mSynchronousInputStream;
|
||||
|
||||
PRMonitor* mMonitor;
|
||||
nsCOMPtr<nsIDownloader> mDownloader;
|
||||
nsCOMPtr<nsIRequest> mJarExtractionTransport;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsJARChannel_h__
|
||||
162
mozilla/modules/libjar/nsJARProtocolHandler.cpp
Normal file
162
mozilla/modules/libjar/nsJARProtocolHandler.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#include "nsJARProtocolHandler.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsJARURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsJARChannel.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID);
|
||||
static NS_DEFINE_CID(kZipReaderCacheCID, NS_ZIPREADERCACHE_CID);
|
||||
|
||||
#define NS_JAR_CACHE_SIZE 32
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsJARProtocolHandler::nsJARProtocolHandler()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARProtocolHandler::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsComponentManager::CreateInstance(kZipReaderCacheCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIZipReaderCache),
|
||||
getter_AddRefs(mJARCache));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mJARCache->Init(NS_JAR_CACHE_SIZE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsJARProtocolHandler::~nsJARProtocolHandler()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsJARProtocolHandler,
|
||||
nsIJARProtocolHandler,
|
||||
nsIProtocolHandler)
|
||||
|
||||
NS_METHOD
|
||||
nsJARProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsJARProtocolHandler* ph = new nsJARProtocolHandler();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(ph);
|
||||
nsresult rv = ph->Init();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = ph->QueryInterface(aIID, aResult);
|
||||
}
|
||||
NS_RELEASE(ph);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::GetJARCache(nsIZipReaderCache* *result)
|
||||
{
|
||||
*result = mJARCache;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::GetScheme(char* *result)
|
||||
{
|
||||
*result = nsCRT::strdup("jar");
|
||||
if (*result == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::GetDefaultPort(PRInt32 *result)
|
||||
{
|
||||
*result = -1; // no port for JAR: URLs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
nsIURI **result)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsIURI* url;
|
||||
|
||||
rv = nsJARURI::Create(nsnull, NS_GET_IID(nsIJARURI), (void**)&url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aBaseURI)
|
||||
{
|
||||
nsXPIDLCString aResolvedURI;
|
||||
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = url->SetSpec(aResolvedURI);
|
||||
} else {
|
||||
rv = url->SetSpec((char*)aSpec);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = url;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsJARChannel* channel;
|
||||
rv = nsJARChannel::Create(nsnull, NS_GET_IID(nsIJARChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(this, uri);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = channel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
61
mozilla/modules/libjar/nsJARProtocolHandler.h
Normal file
61
mozilla/modules/libjar/nsJARProtocolHandler.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- 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 nsJARProtocolHandler_h___
|
||||
#define nsJARProtocolHandler_h___
|
||||
|
||||
#include "nsIJARProtocolHandler.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_JARPROTOCOLHANDLER_CID \
|
||||
{ /* 0xc7e410d4-0x85f2-11d3-9f63-006008a6efe9 */ \
|
||||
0xc7e410d4, \
|
||||
0x85f2, \
|
||||
0x11d3, \
|
||||
{0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
|
||||
}
|
||||
|
||||
|
||||
class nsJARProtocolHandler : public nsIJARProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
NS_DECL_NSIJARPROTOCOLHANDLER
|
||||
|
||||
// nsJARProtocolHandler methods:
|
||||
nsJARProtocolHandler();
|
||||
virtual ~nsJARProtocolHandler();
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIZipReaderCache> mJARCache;
|
||||
};
|
||||
|
||||
#endif /* nsJARProtocolHandler_h___ */
|
||||
38
mozilla/modules/libjar/nsJARProtocolModule.cpp
Normal file
38
mozilla/modules/libjar/nsJARProtocolModule.cpp
Normal 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):
|
||||
*/
|
||||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsJARProtocolHandler.h"
|
||||
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "JAR Protocol Handler",
|
||||
NS_JARPROTOCOLHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar",
|
||||
nsJARProtocolHandler::Create
|
||||
},
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(nsJarProtocolModule, components);
|
||||
|
||||
|
||||
396
mozilla/modules/libjar/nsJARURI.cpp
Normal file
396
mozilla/modules/libjar/nsJARURI.cpp
Normal file
@@ -0,0 +1,396 @@
|
||||
/* -*- 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 "nsJARURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIZipReader.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsJARURI::nsJARURI()
|
||||
: mJAREntry(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsJARURI::~nsJARURI()
|
||||
{
|
||||
if (mJAREntry)
|
||||
nsMemory::Free(mJAREntry);
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsJARURI, nsIJARURI, nsIURI)
|
||||
|
||||
NS_METHOD
|
||||
nsJARURI::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsJARURI* uri = new nsJARURI();
|
||||
|
||||
if (uri == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(uri);
|
||||
nsresult rv = uri->Init();
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = uri->QueryInterface(aIID, aResult);
|
||||
}
|
||||
NS_RELEASE(uri);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARURI::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define NS_JAR_SCHEME "jar:"
|
||||
#define NS_JAR_DELIMITER "!/"
|
||||
|
||||
nsresult
|
||||
nsJARURI::FormatSpec(const char* entryPath, char* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
char* jarFileSpec;
|
||||
rv = mJARFile->GetSpec(&jarFileSpec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCString spec(NS_JAR_SCHEME);
|
||||
spec += jarFileSpec;
|
||||
nsCRT::free(jarFileSpec);
|
||||
spec += NS_JAR_DELIMITER;
|
||||
spec += entryPath;
|
||||
|
||||
*result = nsCRT::strdup(spec);
|
||||
return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsURI methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetSpec(char* *aSpec)
|
||||
{
|
||||
return FormatSpec(mJAREntry, aSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetSpec(const char * aSpec)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUint32 startPos, endPos;
|
||||
rv = serv->ExtractScheme(aSpec, &startPos, &endPos, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (nsCRT::strncmp("jar", &aSpec[startPos], endPos - startPos - 1) != 0)
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
||||
// Search backward from the end for the "!/" delimiter. Remember, jar URLs
|
||||
// can nest, e.g.:
|
||||
// jar:jar:http://www.foo.com/bar.jar!/a.jar!/b.html
|
||||
// This gets the b.html document from out of the a.jar file, that's
|
||||
// contained within the bar.jar file.
|
||||
|
||||
nsCAutoString jarPath(aSpec);
|
||||
PRInt32 pos = jarPath.RFind(NS_JAR_DELIMITER);
|
||||
if (pos == -1 || endPos + 1 > (PRUint32)pos)
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
||||
jarPath.Cut(pos, jarPath.Length());
|
||||
jarPath.Cut(0, endPos);
|
||||
|
||||
rv = serv->NewURI(jarPath, nsnull, getter_AddRefs(mJARFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString entry(aSpec);
|
||||
entry.Cut(0, pos + 2); // 2 == strlen(NS_JAR_DELIMITER)
|
||||
while (entry.CharAt(0) == '/')
|
||||
entry.Cut(0,1); // Strip any additional leading slashes from entry path
|
||||
|
||||
rv = serv->ResolveRelativePath(entry, nsnull, &mJAREntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPrePath(char* *prePath)
|
||||
{
|
||||
*prePath = nsCRT::strdup("jar:");
|
||||
return *prePath ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPrePath(const char* prePath)
|
||||
{
|
||||
NS_NOTREACHED("nsJARURI::SetPrePath");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetScheme(char * *aScheme)
|
||||
{
|
||||
*aScheme = nsCRT::strdup("jar");
|
||||
return *aScheme ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetScheme(const char * aScheme)
|
||||
{
|
||||
// doesn't make sense to set the scheme of a jar: URL
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetUsername(char * *aUsername)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetUsername(const char * aUsername)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPassword(char * *aPassword)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPassword(const char * aPassword)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPreHost(char * *aPreHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPreHost(const char * aPreHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetHost(char * *aHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetHost(const char * aHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPort(PRInt32 *aPort)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPort(PRInt32 aPort)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPath(char * *aPath)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPath(const char * aPath)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Equals(nsIURI *other, PRBool *result)
|
||||
{
|
||||
nsresult rv;
|
||||
*result = PR_FALSE;
|
||||
|
||||
if (other == nsnull)
|
||||
return NS_OK; // not equal
|
||||
|
||||
nsJARURI* otherJAR;
|
||||
rv = other->QueryInterface(NS_GET_IID(nsIJARURI), (void**)&otherJAR);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK; // not equal
|
||||
|
||||
nsCOMPtr<nsIURI> otherJARFile;
|
||||
rv = otherJAR->GetJARFile(getter_AddRefs(otherJARFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRBool equal;
|
||||
rv = mJARFile->Equals(otherJARFile, &equal);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!equal)
|
||||
return NS_OK; // not equal
|
||||
|
||||
char* otherJAREntry;
|
||||
rv = otherJAR->GetJAREntry(&otherJAREntry);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = nsCRT::strcmp(mJAREntry, otherJAREntry) == 0;
|
||||
nsCRT::free(otherJAREntry);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SchemeIs(const char *i_Scheme, PRBool *o_Equals)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(o_Equals);
|
||||
if (!i_Scheme) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (*i_Scheme == 'j' || *i_Scheme == 'J') {
|
||||
*o_Equals = PL_strcasecmp("jar", i_Scheme) ? PR_FALSE : PR_TRUE;
|
||||
} else {
|
||||
*o_Equals = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Clone(nsIURI **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIURI> newJARFile;
|
||||
rv = mJARFile->Clone(getter_AddRefs(newJARFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char* newJAREntry = nsCRT::strdup(mJAREntry);
|
||||
if (newJAREntry == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsJARURI* uri = new nsJARURI();
|
||||
if (uri == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(uri);
|
||||
uri->mJARFile = newJARFile;
|
||||
uri->mJAREntry = newJAREntry;
|
||||
*result = uri;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Resolve(const char *relativePath, char **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!relativePath) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString scheme;
|
||||
rv = serv->ExtractScheme(relativePath, nsnull, nsnull, getter_Copies(scheme));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// then aSpec is absolute
|
||||
*result = nsCRT::strdup(relativePath);
|
||||
if (*result == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCAutoString path(mJAREntry);
|
||||
PRInt32 pos = path.RFind("/");
|
||||
if (pos >= 0)
|
||||
path.Truncate(pos + 1);
|
||||
else
|
||||
path = "";
|
||||
|
||||
char* resolvedEntry;
|
||||
rv = serv->ResolveRelativePath(relativePath, path.get(),
|
||||
&resolvedEntry);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = FormatSpec(resolvedEntry, result);
|
||||
nsCRT::free(resolvedEntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIJARUri methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetJARFile(nsIURI* *jarFile)
|
||||
{
|
||||
*jarFile = mJARFile;
|
||||
NS_ADDREF(*jarFile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetJARFile(nsIURI* jarFile)
|
||||
{
|
||||
mJARFile = jarFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetJAREntry(char* *entryPath)
|
||||
{
|
||||
nsCAutoString entry(mJAREntry);
|
||||
PRInt32 pos = entry.RFindCharInSet("#?;");
|
||||
if (pos >= 0)
|
||||
entry.Truncate(pos);
|
||||
*entryPath = entry.ToNewCString();
|
||||
return *entryPath ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetJAREntry(const char* entryPath)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (mJAREntry)
|
||||
nsCRT::free(mJAREntry);
|
||||
|
||||
rv = serv->ResolveRelativePath(entryPath, nsnull, &mJAREntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
55
mozilla/modules/libjar/nsJARURI.h
Normal file
55
mozilla/modules/libjar/nsJARURI.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- Mode: IDL; 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.
|
||||
*/
|
||||
|
||||
#ifndef nsJARURI_h__
|
||||
#define nsJARURI_h__
|
||||
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_JARURI_CID \
|
||||
{ /* 0xc7e410d7-0x85f2-11d3-9f63-006008a6efe9 */ \
|
||||
0xc7e410d7, \
|
||||
0x85f2, \
|
||||
0x11d3, \
|
||||
{0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
|
||||
}
|
||||
|
||||
class nsJARURI : public nsIJARURI
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURI
|
||||
NS_DECL_NSIJARURI
|
||||
|
||||
// nsJARURI
|
||||
nsJARURI();
|
||||
virtual ~nsJARURI();
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
nsresult Init();
|
||||
nsresult FormatSpec(const char* entryPath, char* *result);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mJARFile;
|
||||
char *mJAREntry;
|
||||
};
|
||||
|
||||
#endif // nsJARURI_h__
|
||||
221
mozilla/modules/libpr0n/src/imgCache.cpp
Normal file
221
mozilla/modules/libpr0n/src/imgCache.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "imgCache.h"
|
||||
|
||||
#include "ImageLogging.h"
|
||||
|
||||
#include "imgRequest.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsICache.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsICacheSession.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(imgCache, imgICache)
|
||||
|
||||
imgCache::imgCache()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
imgCache::~imgCache()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* void clearCache (in boolean chrome); */
|
||||
NS_IMETHODIMP imgCache::ClearCache(PRBool chrome)
|
||||
{
|
||||
if (chrome)
|
||||
return imgCache::ClearChromeImageCache();
|
||||
else
|
||||
return imgCache::ClearImageCache();
|
||||
}
|
||||
|
||||
static nsCOMPtr<nsICacheSession> gSession = nsnull;
|
||||
static nsCOMPtr<nsICacheSession> gChromeSession = nsnull;
|
||||
|
||||
void GetCacheSession(nsIURI *aURI, nsICacheSession **_retval)
|
||||
{
|
||||
NS_ASSERTION(aURI, "Null URI!");
|
||||
|
||||
PRBool isChrome = PR_FALSE;
|
||||
aURI->SchemeIs("chrome", &isChrome);
|
||||
|
||||
if (gSession && !isChrome) {
|
||||
*_retval = gSession;
|
||||
NS_ADDREF(*_retval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gChromeSession && isChrome) {
|
||||
*_retval = gChromeSession;
|
||||
NS_ADDREF(*_retval);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICacheService> cacheService(do_GetService("@mozilla.org/network/cache-service;1"));
|
||||
if (!cacheService) {
|
||||
NS_WARNING("Unable to get the cache service");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICacheSession> newSession;
|
||||
cacheService->CreateSession(isChrome ? "image-chrome" : "image",
|
||||
nsICache::NOT_STREAM_BASED,
|
||||
PR_FALSE, getter_AddRefs(newSession));
|
||||
|
||||
if (!newSession) {
|
||||
NS_WARNING("Unable to create a cache session");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isChrome)
|
||||
gChromeSession = newSession;
|
||||
else
|
||||
gSession = newSession;
|
||||
|
||||
*_retval = newSession;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
|
||||
void imgCache::Shutdown()
|
||||
{
|
||||
gSession = nsnull;
|
||||
gChromeSession = nsnull;
|
||||
}
|
||||
|
||||
|
||||
nsresult imgCache::ClearChromeImageCache()
|
||||
{
|
||||
if (!gChromeSession)
|
||||
return NS_OK;
|
||||
|
||||
return gChromeSession->EvictEntries();
|
||||
}
|
||||
|
||||
nsresult imgCache::ClearImageCache()
|
||||
{
|
||||
if (!gSession)
|
||||
return NS_OK;
|
||||
|
||||
return gSession->EvictEntries();
|
||||
}
|
||||
|
||||
PRBool imgCache::Put(nsIURI *aKey, imgRequest *request, nsICacheEntryDescriptor **aEntry)
|
||||
{
|
||||
LOG_STATIC_FUNC(gImgLog, "imgCache::Put");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICacheSession> ses;
|
||||
GetCacheSession(aKey, getter_AddRefs(ses));
|
||||
if (!ses) return PR_FALSE;
|
||||
|
||||
nsXPIDLCString spec;
|
||||
aKey->GetSpec(getter_Copies(spec));
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
|
||||
rv = ses->OpenCacheEntry(spec, nsICache::ACCESS_WRITE, nsICache::BLOCKING, getter_AddRefs(entry));
|
||||
|
||||
if (NS_FAILED(rv) || !entry)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsISupports> sup(do_QueryInterface(NS_STATIC_CAST(imgIRequest*, request)));
|
||||
entry->SetCacheElement(sup);
|
||||
|
||||
entry->MarkValid();
|
||||
|
||||
*aEntry = entry;
|
||||
NS_ADDREF(*aEntry);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool imgCache::Get(nsIURI *aKey, imgRequest **aRequest, nsICacheEntryDescriptor **aEntry)
|
||||
{
|
||||
LOG_STATIC_FUNC(gImgLog, "imgCache::Get");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICacheSession> ses;
|
||||
GetCacheSession(aKey, getter_AddRefs(ses));
|
||||
if (!ses) return PR_FALSE;
|
||||
|
||||
nsXPIDLCString spec;
|
||||
aKey->GetSpec(getter_Copies(spec));
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
|
||||
rv = ses->OpenCacheEntry(spec, nsICache::ACCESS_READ, nsICache::BLOCKING, getter_AddRefs(entry));
|
||||
|
||||
if (NS_FAILED(rv) || !entry)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
entry->GetCacheElement(getter_AddRefs(sup));
|
||||
|
||||
nsCOMPtr<imgIRequest> req(do_QueryInterface(sup));
|
||||
*aRequest = NS_REINTERPRET_CAST(imgRequest*, req.get());
|
||||
NS_IF_ADDREF(*aRequest);
|
||||
|
||||
*aEntry = entry;
|
||||
NS_ADDREF(*aEntry);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
PRBool imgCache::Remove(nsIURI *aKey)
|
||||
{
|
||||
LOG_STATIC_FUNC(gImgLog, "imgCache::Remove");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICacheSession> ses;
|
||||
GetCacheSession(aKey, getter_AddRefs(ses));
|
||||
if (!ses) return PR_FALSE;
|
||||
|
||||
nsXPIDLCString spec;
|
||||
aKey->GetSpec(getter_Copies(spec));
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
|
||||
rv = ses->OpenCacheEntry(spec, nsICache::ACCESS_READ, nsICache::BLOCKING, getter_AddRefs(entry));
|
||||
|
||||
if (NS_FAILED(rv) || !entry)
|
||||
return PR_FALSE;
|
||||
|
||||
entry->Doom();
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
388
mozilla/modules/libpr0n/src/imgLoader.cpp
Normal file
388
mozilla/modules/libpr0n/src/imgLoader.cpp
Normal file
@@ -0,0 +1,388 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "imgLoader.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "imgCache.h"
|
||||
#include "imgRequest.h"
|
||||
#include "imgRequestProxy.h"
|
||||
|
||||
#include "ImageLogging.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(imgLoader, imgILoader)
|
||||
|
||||
imgLoader::imgLoader()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
imgLoader::~imgLoader()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* imgIRequest loadImage (in nsIURI uri, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports cx); */
|
||||
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver, nsISupports *cx, imgIRequest **_retval)
|
||||
{
|
||||
NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer");
|
||||
|
||||
if (!aURI)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
nsXPIDLCString spec;
|
||||
aURI->GetSpec(getter_Copies(spec));
|
||||
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::LoadImage", "aURI", spec.get());
|
||||
#endif
|
||||
|
||||
imgRequest *request = nsnull;
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
imgCache::Get(aURI, &request, getter_AddRefs(entry)); // addrefs request
|
||||
|
||||
if (request && entry && aLoadGroup) {
|
||||
/* this isn't exactly what I want here. This code will re-doom every
|
||||
cache hit in a document while it is force reloading. So for multiple
|
||||
copies of an image on a page, when you force reload, this will cause
|
||||
you to get seperate loads for each copy of the image... this sucks.
|
||||
*/
|
||||
PRUint32 flags = 0;
|
||||
PRBool doomRequest = PR_FALSE;
|
||||
aLoadGroup->GetLoadFlags(&flags);
|
||||
if (flags & nsIRequest::LOAD_BYPASS_CACHE)
|
||||
doomRequest = PR_TRUE;
|
||||
else {
|
||||
nsCOMPtr<nsIRequest> r;
|
||||
aLoadGroup->GetDefaultLoadRequest(getter_AddRefs(r));
|
||||
if (r) {
|
||||
r->GetLoadFlags(&flags);
|
||||
if (flags & nsIRequest::LOAD_BYPASS_CACHE)
|
||||
doomRequest = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (doomRequest) {
|
||||
entry->Doom(); // doom this thing.
|
||||
entry = nsnull;
|
||||
NS_RELEASE(request);
|
||||
request = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
if (!request) {
|
||||
/* no request from the cache. do a new load */
|
||||
LOG_SCOPE(gImgLog, "imgLoader::LoadImage |cache miss|");
|
||||
|
||||
nsCOMPtr<nsIIOService> ioserv(do_GetService("@mozilla.org/network/io-service;1"));
|
||||
if (!ioserv) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
ioserv->NewChannelFromURI(aURI, getter_AddRefs(newChannel));
|
||||
if (!newChannel) return NS_ERROR_FAILURE;
|
||||
|
||||
if (aLoadGroup) {
|
||||
PRUint32 flags;
|
||||
aLoadGroup->GetLoadFlags(&flags);
|
||||
newChannel->SetLoadFlags(flags);
|
||||
}
|
||||
|
||||
NS_NEWXPCOM(request, imgRequest);
|
||||
if (!request) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(request);
|
||||
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgLoader::LoadImage -- Created new imgRequest [request=%p]\n", this, request));
|
||||
|
||||
#ifdef MOZ_NEW_CACHE
|
||||
imgCache::Put(aURI, request, getter_AddRefs(entry));
|
||||
|
||||
request->Init(newChannel, entry);
|
||||
#else
|
||||
request->Init(newChannel, nsnull);
|
||||
#endif
|
||||
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgLoader::LoadImage -- Calling channel->AsyncOpen()\n", this));
|
||||
|
||||
// create the proxy listener
|
||||
ProxyListener *pl = new ProxyListener(NS_STATIC_CAST(nsIStreamListener *, request));
|
||||
if (!pl) {
|
||||
NS_RELEASE(request);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(pl);
|
||||
|
||||
// set the referrer if this is an HTTP request
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(newChannel));
|
||||
if (aLoadGroup && httpChannel) {
|
||||
nsresult rv;
|
||||
// Get the defloadRequest from the loadgroup
|
||||
nsCOMPtr<nsIRequest> defLoadRequest;
|
||||
rv = aLoadGroup->GetDefaultLoadRequest(getter_AddRefs(defLoadRequest));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && defLoadRequest) {
|
||||
nsCOMPtr<nsIChannel> reqChannel(do_QueryInterface(defLoadRequest));
|
||||
|
||||
if (reqChannel) {
|
||||
// Get the referrer from the loadchannel
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
rv = reqChannel->GetURI(getter_AddRefs(referrer));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Set the referrer
|
||||
httpChannel->SetReferrer(referrer, nsIHttpChannel::REFERRER_INLINES);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX Are we calling AsyncOpen() too early? Is it possible for
|
||||
AsyncOpen to result in an OnStartRequest to the channel before
|
||||
we call CreateNewProxyForRequest() ?
|
||||
*/
|
||||
nsresult asyncOpenResult = newChannel->AsyncOpen(NS_STATIC_CAST(nsIStreamListener *, pl), nsnull);
|
||||
|
||||
NS_RELEASE(pl);
|
||||
|
||||
if (NS_FAILED(asyncOpenResult)) {
|
||||
/* If AsyncOpen fails, then we want to hand back a request proxy
|
||||
object that has a canceled load.
|
||||
*/
|
||||
LOG_MSG(gImgLog, "imgLoader::LoadImage", "async open failed.");
|
||||
|
||||
nsresult rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
|
||||
cx, _retval);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
request->OnStartRequest(newChannel, nsnull);
|
||||
request->OnStopRequest(newChannel, nsnull, NS_BINDING_ABORTED);
|
||||
}
|
||||
|
||||
NS_RELEASE(request);
|
||||
|
||||
return asyncOpenResult;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* request found in cache. use it */
|
||||
LOG_MSG_WITH_PARAM(gImgLog, "imgLoader::LoadImage |cache hit|", "request", request);
|
||||
}
|
||||
|
||||
LOG_MSG(gImgLog, "imgLoader::LoadImage", "creating proxy request.");
|
||||
|
||||
nsresult rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver, cx, _retval);
|
||||
|
||||
NS_RELEASE(request);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* imgIRequest loadImageWithChannel(in nsIChannel, in imgIDecoderObserver aObserver, in nsISupports cx, out nsIStreamListener); */
|
||||
NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderObserver *aObserver, nsISupports *cx, nsIStreamListener **listener, imgIRequest **_retval)
|
||||
{
|
||||
NS_ASSERTION(channel, "imgLoader::LoadImageWithChannel -- NULL channel pointer");
|
||||
|
||||
imgRequest *request = nsnull;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetOriginalURI(getter_AddRefs(uri));
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
imgCache::Get(uri, &request, getter_AddRefs(entry)); // addrefs request
|
||||
|
||||
if (request) {
|
||||
// we have this in our cache already.. cancel the current (document) load
|
||||
|
||||
/* XXX If |*listener| is null when we return here, the caller should
|
||||
probably cancel the channel instead of us doing it here.
|
||||
*/
|
||||
channel->Cancel(NS_BINDING_ABORTED); // this should fire an OnStopRequest
|
||||
|
||||
*listener = nsnull; // give them back a null nsIStreamListener
|
||||
} else {
|
||||
NS_NEWXPCOM(request, imgRequest);
|
||||
if (!request) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(request);
|
||||
|
||||
imgCache::Put(uri, request, getter_AddRefs(entry));
|
||||
|
||||
request->Init(channel, entry);
|
||||
|
||||
ProxyListener *pl = new ProxyListener(NS_STATIC_CAST(nsIStreamListener *, request));
|
||||
if (!pl) {
|
||||
NS_RELEASE(request);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(pl);
|
||||
|
||||
*listener = NS_STATIC_CAST(nsIStreamListener*, pl);
|
||||
NS_ADDREF(*listener);
|
||||
|
||||
NS_RELEASE(pl);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
channel->GetLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
nsresult rv = CreateNewProxyForRequest(request, loadGroup, aObserver, cx, _retval);
|
||||
|
||||
NS_RELEASE(request);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGroup,
|
||||
imgIDecoderObserver *aObserver, nsISupports *cx,
|
||||
imgIRequest **_retval)
|
||||
{
|
||||
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::CreateNewProxyForRequest", "imgRequest", aRequest);
|
||||
|
||||
/* XXX If we move decoding onto seperate threads, we should save off the
|
||||
calling thread here and pass it off to |proxyRequest| so that it call
|
||||
proxy calls to |aObserver|.
|
||||
*/
|
||||
|
||||
imgRequestProxy *proxyRequest;
|
||||
NS_NEWXPCOM(proxyRequest, imgRequestProxy);
|
||||
if (!proxyRequest) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(proxyRequest);
|
||||
|
||||
// init adds itself to imgRequest's list of observers
|
||||
nsresult rv = proxyRequest->Init(aRequest, aLoadGroup, aObserver, cx);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(proxyRequest);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*_retval = NS_STATIC_CAST(imgIRequest*, proxyRequest);
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
NS_RELEASE(proxyRequest);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* proxy stream listener class used to handle multipart/x-mixed-replace
|
||||
*/
|
||||
|
||||
#include "nsIRequest.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(ProxyListener, nsIStreamListener, nsIRequestObserver)
|
||||
|
||||
ProxyListener::ProxyListener(nsIStreamListener *dest) :
|
||||
mDestListener(dest)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
ProxyListener::~ProxyListener()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
|
||||
/** nsIRequestObserver methods **/
|
||||
|
||||
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP ProxyListener::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt)
|
||||
{
|
||||
if (!mDestListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
|
||||
if (channel) {
|
||||
nsXPIDLCString contentType;
|
||||
nsresult rv = channel->GetContentType(getter_Copies(contentType));
|
||||
|
||||
if (contentType.get()) {
|
||||
/* If multipart/x-mixed-replace content, we'll insert a MIME decoder
|
||||
in the pipeline to handle the content and pass it along to our
|
||||
original listener.
|
||||
*/
|
||||
if (NS_LITERAL_CSTRING("multipart/x-mixed-replace").Equals(contentType)) {
|
||||
|
||||
nsCOMPtr<nsIStreamConverterService> convServ(do_GetService("@mozilla.org/streamConverters;1", &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIStreamListener> toListener(mDestListener);
|
||||
nsCOMPtr<nsIStreamListener> fromListener;
|
||||
|
||||
rv = convServ->AsyncConvertData(NS_LITERAL_STRING("multipart/x-mixed-replace").get(),
|
||||
NS_LITERAL_STRING("*/*").get(),
|
||||
toListener,
|
||||
nsnull,
|
||||
getter_AddRefs(fromListener));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mDestListener = fromListener;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mDestListener->OnStartRequest(aRequest, ctxt);
|
||||
}
|
||||
|
||||
/* void onStopRequest (in nsIRequest request, in nsISupports ctxt, in nsresult status); */
|
||||
NS_IMETHODIMP ProxyListener::OnStopRequest(nsIRequest *aRequest, nsISupports *ctxt, nsresult status)
|
||||
{
|
||||
if (!mDestListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mDestListener->OnStopRequest(aRequest, ctxt, status);
|
||||
}
|
||||
|
||||
/** nsIStreamListener methods **/
|
||||
|
||||
/* void onDataAvailable (in nsIRequest request, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */
|
||||
NS_IMETHODIMP ProxyListener::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
|
||||
{
|
||||
if (!mDestListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mDestListener->OnDataAvailable(aRequest, ctxt, inStr, sourceOffset, count);
|
||||
}
|
||||
491
mozilla/modules/libpref/src/init/all.js
Normal file
491
mozilla/modules/libpref/src/init/all.js
Normal file
@@ -0,0 +1,491 @@
|
||||
/* -*- Mode: Java; 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 "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):
|
||||
*/
|
||||
|
||||
// SYNTAX HINTS: dashes are delimiters. Use underscores instead.
|
||||
// The first character after a period must be alphabetic.
|
||||
|
||||
pref("network.search.url","http://cgi.netscape.com/cgi-bin/url_search.cgi?search=");
|
||||
|
||||
pref("keyword.URL", "http://keyword.netscape.com/keyword/");
|
||||
pref("keyword.enabled", true);
|
||||
pref("general.useragent.locale", "chrome://navigator/locale/navigator.properties");
|
||||
pref("general.useragent.misc", "rv:0.9+");
|
||||
|
||||
pref("general.startup.browser", true);
|
||||
pref("general.startup.mail", false);
|
||||
pref("general.startup.news", false);
|
||||
pref("general.startup.editor", false);
|
||||
pref("general.startup.compose", false);
|
||||
pref("general.startup.addressbook", false);
|
||||
|
||||
pref("general.open_location.last_url", "");
|
||||
pref("general.open_location.last_window_choice", 0);
|
||||
|
||||
// 0 = blank, 1 = home (browser.startup.homepage), 2 = last
|
||||
pref("browser.startup.page", 1);
|
||||
pref("browser.startup.homepage", "chrome://navigator-region/locale/region.properties");
|
||||
// "browser.startup.homepage_override" was for 4.x
|
||||
pref("browser.startup.homepage_override.1", true);
|
||||
pref("browser.startup.autoload_homepage", true);
|
||||
|
||||
pref("browser.cache.disk_cache_size", 50000);
|
||||
pref("browser.cache.enable", true);
|
||||
pref("browser.cache.disk.enable", true);
|
||||
pref("browser.cache.memory_cache_size", 4096);
|
||||
pref("browser.cache.disk_cache_ssl", false);
|
||||
pref("browser.cache.check_doc_frequency", 0);
|
||||
|
||||
pref("browser.display.use_document_fonts", 1); // 0 = never, 1 = quick, 2 = always
|
||||
pref("browser.display.use_document_colors", true);
|
||||
pref("browser.display.use_system_colors",true);
|
||||
pref("browser.display.foreground_color", "#000000");
|
||||
pref("browser.display.background_color", "#C0C0C0");
|
||||
pref("browser.anchor_color", "#0000EE");
|
||||
pref("browser.visited_color", "#551A8B");
|
||||
pref("browser.underline_anchors", true);
|
||||
|
||||
pref("browser.display.use_focus_colors", false);
|
||||
pref("browser.display.focus_background_color", "#117722");
|
||||
pref("browser.display.focus_text_color", "#ffffff");
|
||||
pref("browser.display.focus_ring_width", 1);
|
||||
pref("browser.display.focus_ring_on_anything", false);
|
||||
|
||||
pref("browser.chrome.toolbar_tips", true);
|
||||
pref("browser.chrome.toolbar_style", 2);
|
||||
|
||||
pref("browser.toolbars.showbutton.bookmarks", true);
|
||||
pref("browser.toolbars.showbutton.go", false);
|
||||
pref("browser.toolbars.showbutton.home", true);
|
||||
pref("browser.toolbars.showbutton.mynetscape", true);
|
||||
pref("browser.toolbars.showbutton.net2phone", true);
|
||||
pref("browser.toolbars.showbutton.print", true);
|
||||
pref("browser.toolbars.showbutton.search", true);
|
||||
|
||||
pref("accessibility.browsewithcaret", false);
|
||||
pref("accessibility.usetexttospeech", "");
|
||||
pref("accessibility.usebrailledisplay", "");
|
||||
|
||||
// Dialog modality issues
|
||||
pref("browser.prefWindowModal", true);
|
||||
pref("browser.show_about_as_stupid_modal_window", false);
|
||||
|
||||
pref("browser.download.progressDnldDialog.keepAlive", false); // keep the dnload progress dialog up after dnload is complete
|
||||
|
||||
// various default search settings
|
||||
pref("browser.search.defaulturl", "chrome://navigator-region/locale/region.properties");
|
||||
pref("browser.search.opensidebarsearchpanel", true);
|
||||
pref("browser.search.last_search_category", "NC:SearchCategory?category=urn:search:category:1");
|
||||
pref("browser.search.mode", 0);
|
||||
pref("browser.search.powermode", 0);
|
||||
pref("browser.urlbar.autocomplete.enabled", true);
|
||||
pref("browser.urlbar.clickSelectsAll",false);
|
||||
|
||||
pref("browser.history.last_page_visited", "");
|
||||
pref("browser.history_expire_days", 9);
|
||||
pref("browser.sessionhistory.max_entries", 50);
|
||||
|
||||
pref("browser.PICS.ratings_enabled", false);
|
||||
pref("browser.PICS.pages_must_be_rated", false);
|
||||
pref("browser.PICS.disable_for_this_session", false);
|
||||
pref("browser.PICS.reenable_for_this_session", false);
|
||||
pref("browser.PICS.service.http___home_netscape_com_default_rating.service_enabled", true);
|
||||
pref("browser.PICS.service.http___home_netscape_com_default_rating.s", 0);
|
||||
|
||||
pref("browser.target_new_blocked", false);
|
||||
|
||||
// loading and rendering of framesets and iframes
|
||||
pref("browser.frames.enabled", true);
|
||||
|
||||
// view source
|
||||
pref("view_source.syntax_highlight", true);
|
||||
|
||||
// gfx widgets
|
||||
pref("nglayout.widget.mode", 2);
|
||||
pref("nglayout.widget.gfxscrollbars", true);
|
||||
|
||||
// use nsViewManager2
|
||||
pref("nglayout.view.useViewManager2", true);
|
||||
|
||||
// css2 hover pref
|
||||
pref("nglayout.events.showHierarchicalHover", false);
|
||||
|
||||
// whether or not to use xbl form controls
|
||||
pref("nglayout.debug.enable_xbl_forms", false);
|
||||
|
||||
// Smart Browsing prefs
|
||||
pref("browser.related.enabled", true);
|
||||
pref("browser.related.autoload", 1); // 0 = Always, 1 = After first use, 2 = Never
|
||||
pref("browser.related.provider", "http://www-rl.netscape.com/wtgn?");
|
||||
pref("browser.related.disabledForDomains", "");
|
||||
pref("browser.goBrowsing.enabled", true);
|
||||
|
||||
//Internet Search
|
||||
pref("browser.search.defaultenginename", "chrome://navigator/locale/navigator.properties");
|
||||
|
||||
// Default Capability Preferences: Security-Critical!
|
||||
// Editing these may create a security risk - be sure you know what you're doing
|
||||
//pref("capability.policy.default.barprop.visible.set", "UniversalBrowserWrite");
|
||||
|
||||
pref("capability.policy.default.Domexception.code", "allAccess");
|
||||
pref("capability.policy.default.Domexception.message", "allAccess");
|
||||
pref("capability.policy.default.Domexception.name", "allAccess");
|
||||
pref("capability.policy.default.Domexception.result", "allAccess");
|
||||
pref("capability.policy.default.Domexception.tostring", "allAccess");
|
||||
|
||||
pref("capability.policy.default.History.back", "allAccess");
|
||||
pref("capability.policy.default.History.current", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.forward", "allAccess");
|
||||
pref("capability.policy.default.History.go", "allAccess");
|
||||
//pref("capability.policy.default.History.item", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.length", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.next", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.previous", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.toString", "UniversalBrowserRead");
|
||||
|
||||
pref("capability.policy.default.HTMLDocument.close", "allAccess");
|
||||
pref("capability.policy.default.HTMLDocument.open", "allAccess");
|
||||
pref("capability.policy.default.HTMLDocument.write", "allAccess");
|
||||
pref("capability.policy.default.HTMLDocument.writeln", "allAccess");
|
||||
|
||||
pref("capability.policy.default.Location.hash.set", "allAccess");
|
||||
pref("capability.policy.default.Location.host.set", "allAccess");
|
||||
pref("capability.policy.default.Location.hostname.set", "allAccess");
|
||||
pref("capability.policy.default.Location.href.set", "allAccess");
|
||||
pref("capability.policy.default.Location.pathname.set", "allAccess");
|
||||
pref("capability.policy.default.Location.port.set", "allAccess");
|
||||
pref("capability.policy.default.Location.protocol.set", "allAccess");
|
||||
pref("capability.policy.default.Location.reload", "allAccess");
|
||||
pref("capability.policy.default.Location.replace", "allAccess");
|
||||
pref("capability.policy.default.Location.search.set", "allAccess");
|
||||
|
||||
pref("capability.policy.default.Navigator.preference", "allAccess");
|
||||
pref("capability.policy.default.Navigator.preferenceinternal.get", "UniversalPreferencesRead");
|
||||
pref("capability.policy.default.Navigator.preferenceinternal.set", "UniversalPreferencesWrite");
|
||||
|
||||
pref("capability.policy.default.Window.blur", "allAccess");
|
||||
pref("capability.policy.default.Window.close", "allAccess");
|
||||
pref("capability.policy.default.Window.closed", "allAccess");
|
||||
pref("capability.policy.default.Window.Components", "allAccess");
|
||||
pref("capability.policy.default.Window.document", "allAccess");
|
||||
pref("capability.policy.default.Window.focus", "allAccess");
|
||||
pref("capability.policy.default.Window.history", "allAccess");
|
||||
pref("capability.policy.default.Window.location", "allAccess");
|
||||
// window.openDialog is insecure and must be made inaccessible from web scripts - see bug 56009
|
||||
pref("capability.policy.default.Window.opendialog", "noAccess");
|
||||
pref("capability.policy.default.Window.self", "allAccess");
|
||||
pref("capability.policy.default.Window.window", "allAccess");
|
||||
|
||||
pref("capability.policy.mailnews.Domexception.tostring", "noAccess");
|
||||
pref("capability.policy.mailnews.HTMLDocument.domain", "noAccess");
|
||||
pref("capability.policy.mailnews.HTMLDocument.URL", "noAccess");
|
||||
//pref("capability.policy.mailnews.nsdocument.location", "noAccess");
|
||||
pref("capability.policy.mailnews.sites", "mailbox: imap: news:");
|
||||
pref("capability.policy.mailnews.Window.name.set", "noAccess");
|
||||
pref("capability.policy.mailnews.Window.location", "noAccess");
|
||||
|
||||
pref("javascript.enabled", true);
|
||||
pref("javascript.allow.mailnews", false);
|
||||
pref("javascript.options.strict", false);
|
||||
|
||||
// advanced prefs
|
||||
pref("advanced.always_load_images", true);
|
||||
pref("security.enable_java", true);
|
||||
pref("css.allow", true);
|
||||
pref("advanced.mailftp", false);
|
||||
pref("image.animation_mode", "normal");
|
||||
|
||||
pref("offline.startup_state", 0);
|
||||
pref("offline.send.unsent_messages", 0);
|
||||
pref("offline.download.download_messages", 0);
|
||||
pref("offline.prompt_synch_on_exit", true);
|
||||
pref("offline.news.download.use_days", 0);
|
||||
|
||||
pref("network.hosts.smtp_server", "mail");
|
||||
pref("network.hosts.pop_server", "mail");
|
||||
pref("network.protocols.useSystemDefaults", false); // set to true if user links should use system default handlers
|
||||
|
||||
// <ruslan>
|
||||
pref("network.http.version", "1.1"); // default
|
||||
// pref("network.http.version", "1.0"); // uncomment this out in case of problems
|
||||
// pref("network.http.version", "0.9"); // it'll work too if you're crazy
|
||||
// keep-alive option is effectively obsolete. Nevertheless it'll work with
|
||||
// some older 1.0 servers:
|
||||
|
||||
pref("network.http.keep-alive", true); // set it to false in case of problems
|
||||
pref("network.http.proxy.keep-alive", true );
|
||||
pref("network.http.keep-alive.timeout", 300);
|
||||
|
||||
pref("network.http.max-connections", 16);
|
||||
pref("network.http.max-connections-per-server", 8);
|
||||
pref("network.http.keep-alive.max-connections", 20); // max connections to be kept alive
|
||||
pref("network.http.keep-alive.max-connections-per-server", 8);
|
||||
|
||||
pref("network.http.connect.timeout", 30); // in seconds
|
||||
pref("network.http.request.timeout", 120); // in seconds
|
||||
|
||||
// Enable http compression: comment this out in case of problems with 1.1
|
||||
pref("network.http.accept-encoding" ,"gzip,deflate,compress,identity");
|
||||
|
||||
pref("network.http.pipelining" , false);
|
||||
pref("network.http.proxy.pipelining", false);
|
||||
|
||||
// Always pipeling the very first request: this will only work when you are
|
||||
// absolutely sure the the site or proxy you are browsing to/through support
|
||||
// pipelining; the default behavior will be that the browser will first make
|
||||
// a normal, non-pipelined request, then examine and remember the responce
|
||||
// and only the subsequent requests to that site will be pipeline
|
||||
pref("network.http.pipelining.firstrequest", false);
|
||||
|
||||
// Max number of requests in the pipeline
|
||||
pref("network.http.pipelining.maxrequests" , 4);
|
||||
|
||||
pref("network.http.proxy.ssl.connect",true);
|
||||
// </ruslan>
|
||||
|
||||
// until the directory view has an owner
|
||||
// necko will produce html -- dougt
|
||||
pref("network.dir.generate_html", true);
|
||||
|
||||
// sspitzer: change this back to "news" when we get to beta.
|
||||
// for now, set this to news.mozilla.org because you can only
|
||||
// post to the server specified by this pref.
|
||||
pref("network.hosts.nntp_server", "news.mozilla.org");
|
||||
|
||||
pref("network.hosts.socks_server", "");
|
||||
pref("network.hosts.socks_serverport", 1080);
|
||||
pref("network.hosts.socks_conf", "");
|
||||
pref("network.image.imageBehavior", 0); // 0-Accept, 1-dontAcceptForeign, 2-dontUse
|
||||
pref("network.image.warnAboutImages", false);
|
||||
pref("network.proxy.autoconfig_url", "");
|
||||
pref("network.proxy.type", 0);
|
||||
pref("network.proxy.ftp", "");
|
||||
pref("network.proxy.ftp_port", 0);
|
||||
pref("network.proxy.gopher", "");
|
||||
pref("network.proxy.gopher_port", 0);
|
||||
pref("network.proxy.news", "");
|
||||
pref("network.proxy.news_port", 0);
|
||||
pref("network.proxy.http", "");
|
||||
pref("network.proxy.http_port", 0);
|
||||
pref("network.proxy.wais", "");
|
||||
pref("network.proxy.wais_port", 0);
|
||||
pref("network.proxy.ssl", "");
|
||||
pref("network.proxy.ssl_port", 0);
|
||||
pref("network.proxy.socks", "");
|
||||
pref("network.proxy.socks_port", 0);
|
||||
pref("network.proxy.no_proxies_on", "");
|
||||
pref("network.online", true); //online/offline
|
||||
pref("network.accept_cookies", 0); // 0 = Always, 1 = warn, 2 = never
|
||||
pref("network.foreign_cookies", 0); // 0 = Accept, 1 = Don't accept
|
||||
pref("network.cookie.cookieBehavior", 0); // 0-Accept, 1-dontAcceptForeign, 2-dontUse
|
||||
pref("network.cookie.warnAboutCookies", false);
|
||||
pref("signon.rememberSignons", true);
|
||||
pref("network.sendRefererHeader", 2); // 0=don't send any, 1=send only on clicks, 2=send on image requests as well
|
||||
pref("network.enablePad", false); // Allow client to do proxy autodiscovery
|
||||
pref("converter.html2txt.structs", true); // Output structured phrases (strong, em, code, sub, sup, b, i, u)
|
||||
pref("converter.html2txt.header_strategy", 1); // 0 = no indention; 1 = indention, increased with header level; 2 = numbering and slight indention
|
||||
pref("wallet.captureForms", true);
|
||||
pref("wallet.notified", false);
|
||||
pref("wallet.TutorialFromMenu", "chrome://navigator/locale/navigator.properties");
|
||||
pref("wallet.Server", "chrome://navigator/locale/navigator.properties");
|
||||
pref("wallet.Samples", "chrome://navigator/locale/navigator.properties");
|
||||
pref("wallet.version", "1");
|
||||
pref("wallet.enabled", true);
|
||||
pref("wallet.crypto", false);
|
||||
pref("imageblocker.enabled", true);
|
||||
pref("intl.accept_languages", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.accept_charsets", "iso-8859-1,*,utf-8");
|
||||
pref("intl.collationOption", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.menuitems.alwaysappendacceskeys","chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.static", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more1", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more2", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more3", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more4", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more5", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.mailedit", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.cache", "");
|
||||
pref("intl.charsetmenu.mailview.cache", "");
|
||||
pref("intl.charsetmenu.composer.cache", "");
|
||||
pref("intl.charsetmenu.browser.cache.size", 5);
|
||||
pref("intl.charset.detector", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charset.default", "chrome://navigator/locale/navigator.properties");
|
||||
|
||||
pref("font.default", "serif");
|
||||
pref("font.size.variable.ar", 16);
|
||||
pref("font.size.fixed.ar", 13);
|
||||
|
||||
pref("font.size.variable.el", 16);
|
||||
pref("font.size.fixed.el", 13);
|
||||
|
||||
pref("font.size.variable.he", 16);
|
||||
pref("font.size.fixed.he", 13);
|
||||
|
||||
pref("font.size.variable.ja", 16);
|
||||
pref("font.size.fixed.ja", 16);
|
||||
|
||||
pref("font.size.variable.ko", 16);
|
||||
pref("font.size.fixed.ko", 16);
|
||||
|
||||
pref("font.size.variable.th", 16);
|
||||
pref("font.size.fixed.th", 13);
|
||||
|
||||
pref("font.size.variable.tr", 16);
|
||||
pref("font.size.fixed.tr", 13);
|
||||
|
||||
pref("font.size.variable.x-baltic", 16);
|
||||
pref("font.size.fixed.x-baltic", 13);
|
||||
|
||||
pref("font.size.variable.x-central-euro", 16);
|
||||
pref("font.size.fixed.x-central-euro", 13);
|
||||
|
||||
pref("font.size.variable.x-cyrillic", 16);
|
||||
pref("font.size.fixed.x-cyrillic", 13);
|
||||
|
||||
pref("font.size.variable.x-unicode", 16);
|
||||
pref("font.size.fixed.x-unicode", 13);
|
||||
|
||||
pref("font.size.variable.x-western", 16);
|
||||
pref("font.size.fixed.x-western", 13);
|
||||
|
||||
pref("font.size.variable.zh-CN", 16);
|
||||
pref("font.size.fixed.zh-CN", 16);
|
||||
|
||||
pref("font.size.variable.zh-TW", 16);
|
||||
pref("font.size.fixed.zh-TW", 16);
|
||||
|
||||
// -- folders (Mac: these are binary aliases.)
|
||||
localDefPref("mail.signature_file", "");
|
||||
localDefPref("mail.directory", "");
|
||||
|
||||
pref("images.dither", "auto");
|
||||
localDefPref("news.directory", "");
|
||||
localDefPref("security.directory", "");
|
||||
|
||||
pref("autoupdate.enabled", true);
|
||||
|
||||
pref("silentdownload.enabled", true);
|
||||
pref("silentdownload.directory", "");
|
||||
pref("silentdownload.range", 3000);
|
||||
pref("silentdownload.interval", 10000);
|
||||
|
||||
pref("browser.editor.disabled", false);
|
||||
|
||||
pref("spellchecker.dictionary", "");
|
||||
|
||||
pref("signed.applets.codebase_principal_support", false);
|
||||
pref("security.checkloaduri", true);
|
||||
pref("security.xpconnect.plugin.unrestricted", true);
|
||||
|
||||
// Modifier key prefs: default to Windows settings,
|
||||
// menu access key = alt, accelerator key = control.
|
||||
pref("ui.key.accelKey", 17);
|
||||
pref("ui.key.menuAccessKey", 18);
|
||||
pref("ui.key.menuAccessKeyFocuses", false);
|
||||
pref("ui.key.saveLink.shift", true); // true = shift, false = meta
|
||||
|
||||
// Middle-mouse handling
|
||||
pref("middlemouse.paste", false);
|
||||
pref("middlemouse.openNewWindow", true);
|
||||
pref("middlemouse.contentLoadURL", false);
|
||||
pref("middlemouse.scrollbarPosition", false);
|
||||
|
||||
// Clipboard behavior
|
||||
pref("clipboard.autocopy", false);
|
||||
|
||||
// 0=lines, 1=pages, 2=history , 3=text size
|
||||
pref("mousewheel.withnokey.action",0);
|
||||
pref("mousewheel.withnokey.numlines",1);
|
||||
pref("mousewheel.withnokey.sysnumlines",true);
|
||||
pref("mousewheel.withcontrolkey.action",0);
|
||||
pref("mousewheel.withcontrolkey.numlines",1);
|
||||
pref("mousewheel.withcontrolkey.sysnumlines",true);
|
||||
pref("mousewheel.withshiftkey.action",0);
|
||||
pref("mousewheel.withshiftkey.numlines",1);
|
||||
pref("mousewheel.withshiftkey.sysnumlines",false);
|
||||
pref("mousewheel.withaltkey.action",2);
|
||||
pref("mousewheel.withaltkey.numlines",1);
|
||||
pref("mousewheel.withaltkey.sysnumlines",false);
|
||||
|
||||
pref("profile.confirm_automigration",true);
|
||||
|
||||
// Customizable toolbar stuff
|
||||
pref("custtoolbar.personal_toolbar_folder", "");
|
||||
|
||||
pref("sidebar.customize.all_panels.url", "http://sidebar-rdf.netscape.com/%LOCALE%/sidebar-rdf/%SIDEBAR_VERSION%/all-panels.rdf");
|
||||
pref("sidebar.customize.more_panels.url", "http://dmoz.org/Netscape/Sidebar/");
|
||||
|
||||
pref("prefs.converted-to-utf8",false);
|
||||
// --------------------------------------------------
|
||||
// IBMBIDI
|
||||
// --------------------------------------------------
|
||||
//
|
||||
// ------------------
|
||||
// Text Direction
|
||||
// ------------------
|
||||
// 1 = directionLTRBidi *
|
||||
// 2 = directionRTLBidi
|
||||
pref("bidi.direction", 1);
|
||||
// ------------------
|
||||
// Text Type
|
||||
// ------------------
|
||||
// 1 = charsettexttypeBidi *
|
||||
// 2 = logicaltexttypeBidi
|
||||
// 3 = visualtexttypeBidi
|
||||
pref("bidi.texttype", 1);
|
||||
// ------------------
|
||||
// Controls Text Mode
|
||||
// ------------------
|
||||
// 1 = logicalcontrolstextmodeBidiCmd
|
||||
// 2 = visiualcontrolstextmodeBidi
|
||||
// 3 = containercontrolstextmodeBidi *
|
||||
pref("bidi.controlstextmode", 1);
|
||||
// ------------------
|
||||
// Clipboard Text Mode
|
||||
// ------------------
|
||||
// 1 = logicalclipboardtextmodeBidi
|
||||
// 2 = visiualclipboardtextmodeBidi
|
||||
// 3 = sourceclipboardtextmodeBidi *
|
||||
pref("bidi.clipboardtextmode", 3);
|
||||
// ------------------
|
||||
// Numeral Style
|
||||
// ------------------
|
||||
// 1 = regularcontextnumeralBidi *
|
||||
// 2 = hindicontextnumeralBidi
|
||||
// 3 = arabicnumeralBidi
|
||||
// 4 = hindinumeralBidi
|
||||
pref("bidi.numeral", 1);
|
||||
// ------------------
|
||||
// Support Mode
|
||||
// ------------------
|
||||
// 1 = mozillaBidisupport *
|
||||
// 2 = OsBidisupport
|
||||
// 3 = disableBidisupport
|
||||
pref("bidi.support", 1);
|
||||
// ------------------
|
||||
// Charset Mode
|
||||
// ------------------
|
||||
// 1 = doccharactersetBidi *
|
||||
// 2 = defaultcharactersetBidi
|
||||
pref("bidi.characterset", 1);
|
||||
|
||||
|
||||
pref("browser.throbber.url","chrome://navigator-region/locale/region.properties");
|
||||
493
mozilla/modules/libpref/src/nsAutoConfig.cpp
Normal file
493
mozilla/modules/libpref/src/nsAutoConfig.cpp
Normal file
@@ -0,0 +1,493 @@
|
||||
/* -*- 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.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):
|
||||
* Mitesh Shah <mitesh@netscape.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsAutoConfig.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "prmem.h"
|
||||
#include "jsapi.h"
|
||||
#include "prefapi.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsLiteralString.h"
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsAutoConfig, nsIAutoConfig, nsITimerCallback, nsIStreamListener,nsIObserver)
|
||||
|
||||
nsAutoConfig::nsAutoConfig()
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsresult nsAutoConfig::Init()
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
|
||||
nsresult rv=NS_OK;
|
||||
|
||||
mLoaded = PR_FALSE;
|
||||
|
||||
// Registering the object as an observer to the profile-after-change topic
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (observerService) {
|
||||
rv = observerService->AddObserver(this,
|
||||
NS_LITERAL_STRING("profile-after-change").get());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
nsCOMPtr<nsIPrefService> prefs =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = prefs->GetBranch(nsnull,getter_AddRefs(mPrefBranch));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoConfig::~nsAutoConfig()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (observerService)
|
||||
rv = observerService->RemoveObserver(this,
|
||||
NS_LITERAL_STRING("profile-after-change").get());
|
||||
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoConfig::OnStartRequest(nsIRequest* request, nsISupports* context)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoConfig::OnDataAvailable(nsIRequest* request,
|
||||
nsISupports* context,
|
||||
nsIInputStream *aIStream,
|
||||
PRUint32 aSourceOffset,
|
||||
PRUint32 aLength)
|
||||
{
|
||||
PRUint32 amt, size;
|
||||
nsresult rv;
|
||||
char buf[1025];
|
||||
|
||||
while (aLength) {
|
||||
size = PR_MIN(aLength, sizeof(buf));
|
||||
rv = aIStream->Read(buf, size, &amt);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION((NS_BASE_STREAM_WOULD_BLOCK != rv),
|
||||
"The stream should never block.");
|
||||
return rv;
|
||||
}
|
||||
mBuf.Append(buf,amt);
|
||||
aLength -= amt;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoConfig::OnStopRequest(nsIRequest* request, nsISupports* context,
|
||||
nsresult aStatus)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// If the request is failed, go read the failover.jsc file
|
||||
if (NS_FAILED(aStatus)) {
|
||||
return readOfflineFile();
|
||||
}
|
||||
|
||||
//Checking for the http response, if failure go read the failover file.
|
||||
nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(request));
|
||||
if (pHTTPCon) {
|
||||
PRUint32 httpStatus;
|
||||
pHTTPCon->GetResponseStatus(&httpStatus);
|
||||
if (httpStatus != 200)
|
||||
return readOfflineFile();
|
||||
}
|
||||
|
||||
// Send the autoconfig.jsc to javascript engine.
|
||||
PRBool success = PREF_EvaluateConfigScript(mBuf.get(), mBuf.Length(),nsnull,
|
||||
PR_FALSE,PR_TRUE,PR_FALSE);
|
||||
if (success) {
|
||||
rv = writeFailoverFile(); /* Write the autoconfig.jsc to
|
||||
failover.jsc (cached copy) */
|
||||
if(NS_FAILED(rv))
|
||||
NS_WARNING("Error writing failover.jsc file");
|
||||
// Clean up the previous read.
|
||||
// If there is a timer, these methods will be called again.
|
||||
mBuf.Truncate(0);
|
||||
mLoaded = PR_TRUE; //Releasing the deadlock
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
NS_WARNING("Error reading autoconfig.jsc from the network, reading the offline version");
|
||||
// Clean up the previous read so it will be ready for
|
||||
// the next updated read.
|
||||
mBuf.Truncate(0);
|
||||
return readOfflineFile();
|
||||
}
|
||||
}
|
||||
|
||||
// Notify method as a TimerCallBack function
|
||||
NS_IMETHODIMP_(void) nsAutoConfig::Notify(nsITimer *timer)
|
||||
{
|
||||
DownloadAutoCfg();
|
||||
}
|
||||
|
||||
/* Observe() is called twice: once at the instantiation time and other
|
||||
after the profile is set. It doesn't do anything but return NS_OK during the
|
||||
creation time. Second time it calls DownloadAutoCfg().
|
||||
*/
|
||||
NS_IMETHODIMP nsAutoConfig::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-after-change").get()))
|
||||
{
|
||||
// Getting the current profile name since we already have the
|
||||
// pointer to the object.
|
||||
nsCOMPtr<nsIProfile> profile = do_QueryInterface(aSubject);
|
||||
if (profile) {
|
||||
nsXPIDLString profileName;
|
||||
rv = profile->GetCurrentProfile(getter_Copies(profileName));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
// setting the member variable to the current profile name
|
||||
mCurrProfile.AssignWithConversion(profileName);
|
||||
else
|
||||
return rv;
|
||||
}
|
||||
return DownloadAutoCfg();
|
||||
}
|
||||
else if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("app-startup").get()))
|
||||
{
|
||||
// This is the object instantiation, do nothing and return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAutoConfig::DownloadAutoCfg()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCAutoString emailAddr;
|
||||
nsXPIDLCString urlName;
|
||||
PRBool appendMail=PR_FALSE, offline=PR_FALSE;
|
||||
static PRBool firstTime = PR_TRUE;
|
||||
|
||||
|
||||
// get the value of the autoconfig url
|
||||
rv = mPrefBranch->GetCharPref("autoadmin.global_config_url",
|
||||
getter_Copies(urlName));
|
||||
if(NS_FAILED(rv) || (nsCRT::strlen(urlName) == 0))
|
||||
return NS_OK; /* Return ok if there is no config url set. */
|
||||
|
||||
// Check to see if the network is online/offline
|
||||
|
||||
nsCOMPtr<nsIIOService> ios =
|
||||
do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = ios->GetOffline(&offline);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (offline) {
|
||||
|
||||
PRBool offlineFailover = PR_FALSE;
|
||||
rv = mPrefBranch->GetBoolPref("autoadmin.offline_failover",
|
||||
&offlineFailover);
|
||||
|
||||
// Read the failover.jsc if the network is offline and the pref says so
|
||||
if ( offlineFailover ) {
|
||||
return readOfflineFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsCAutoString cfgUrl(urlName);
|
||||
|
||||
/* Append user's identity at the end of the URL if the pref says so.
|
||||
First we are checking for the user's email address but if it is not
|
||||
available in the case where the client is used without messenger, user's
|
||||
profile name will be used as an unique identifier
|
||||
*/
|
||||
|
||||
rv = mPrefBranch->GetBoolPref("autoadmin.append_emailaddr", &appendMail);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && appendMail) {
|
||||
rv = getEmailAddr(emailAddr);
|
||||
if (NS_SUCCEEDED(rv) && emailAddr) {
|
||||
/* Adding the unique identifier at the end of autoconfig URL.
|
||||
In this case the autoconfig URL is a script and
|
||||
emailAddr as passed as an argument */
|
||||
cfgUrl.Append("?");
|
||||
cfgUrl.Append(emailAddr);
|
||||
}
|
||||
}
|
||||
|
||||
// Getting an event queue. If we start an AsyncOpen, the thread
|
||||
// needs to wait before the reading of autoconfig is done
|
||||
|
||||
nsCOMPtr<nsIEventQueue> currentThreadQ;
|
||||
|
||||
if (firstTime) {
|
||||
nsCOMPtr<nsIEventQueueService> service =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = service->GetThreadEventQueue(NS_CURRENT_THREAD,getter_AddRefs(currentThreadQ));
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
}
|
||||
mLoaded = PR_FALSE;
|
||||
|
||||
// create a new url
|
||||
|
||||
nsCOMPtr<nsIURI> url;
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(url), cfgUrl, nsnull, nsnull);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
// open a channel for the url
|
||||
|
||||
rv = NS_OpenURI(getter_AddRefs(channel),url, nsnull, nsnull);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->AsyncOpen(this, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
readOfflineFile();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Set a repeating timer if the pref is set.
|
||||
// This is to be done only once.
|
||||
|
||||
if (firstTime) {
|
||||
firstTime = PR_FALSE;
|
||||
PRInt32 minutes = 0;
|
||||
rv = mPrefBranch->GetIntPref("autoadmin.refresh_interval",
|
||||
&minutes);
|
||||
if(NS_SUCCEEDED(rv) && minutes > 0) {
|
||||
// Create a new timer and pass this nsAutoConfig
|
||||
// object as a timer callback.
|
||||
nsCOMPtr<nsITimer> timer;
|
||||
timer = do_CreateInstance("@mozilla.org/timer;1",&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = timer->Init(this, minutes*60*1000, NS_PRIORITY_NORMAL,
|
||||
NS_TYPE_REPEATING_SLACK);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// process events until we're finished. AutoConfig.jsc reading needs
|
||||
// to be finished before the browser starts loading up
|
||||
// We are waiting for the mLoaded which will be set through
|
||||
// onStopRequest or readOfflineFile methods
|
||||
// There is a possibility of deadlock so we need to make sure
|
||||
// that mLoaded will be set to true in any case (success/failure)
|
||||
|
||||
PLEvent *event;
|
||||
while (!mLoaded) {
|
||||
rv = currentThreadQ->WaitForEvent(&event);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"-->nsAutoConfig::DownloadAutoCfg: currentThreadQ->WaitForEvent failed...");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = currentThreadQ->HandleEvent(event);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "-->nsAutoConfig::DownloadAutoCfg: currentThreadQ->HandleEvent failed...");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
}
|
||||
|
||||
} //first_time
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // nsPref::DownloadAutoCfg()
|
||||
|
||||
|
||||
|
||||
nsresult nsAutoConfig::readOfflineFile()
|
||||
{
|
||||
PRBool failCache = PR_TRUE;
|
||||
nsresult rv;
|
||||
PRBool offline;
|
||||
|
||||
rv = mPrefBranch->GetBoolPref("autoadmin.failover_to_cached", &failCache);
|
||||
|
||||
if (failCache == PR_FALSE) {
|
||||
|
||||
// disable network connections and return.
|
||||
|
||||
nsCOMPtr<nsIIOService> ios =
|
||||
do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
|
||||
rv = ios->GetOffline(&offline);
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
if (!offline) {
|
||||
rv = ios->SetOffline(PR_TRUE);
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
}
|
||||
|
||||
// lock the "network.online" prference so user cannot toggle back to
|
||||
// online mode.
|
||||
rv = mPrefBranch->SetBoolPref("network.online", PR_FALSE);
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
mPrefBranch->LockPref("network.online");
|
||||
|
||||
mLoaded = PR_TRUE;
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
// failCache = true
|
||||
|
||||
// Open the file and read the content.
|
||||
// execute the javascript file
|
||||
|
||||
nsCOMPtr<nsIFile> failoverFile;
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(failoverFile));
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
#ifdef XP_MAC
|
||||
failoverFile->Append("Essential Files");
|
||||
#endif
|
||||
|
||||
failoverFile->Append("failover.jsc");
|
||||
rv = evaluateLocalFile(failoverFile);
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING("Couldn't open failover.jsc, going back to default prefs");
|
||||
mLoaded = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAutoConfig::evaluateLocalFile(nsIFile* file)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInputStream> inStr;
|
||||
|
||||
rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), file);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt64 fileSize;
|
||||
PRUint32 fs, amt=0;
|
||||
file->GetFileSize(&fileSize);
|
||||
LL_L2UI(fs, fileSize); // Converting 64 bit structure to unsigned int
|
||||
char* buf = (char *) PR_Malloc(fs*sizeof(char)) ;
|
||||
if(!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = inStr->Read(buf, fs, &amt);
|
||||
if (NS_FAILED(rv))
|
||||
NS_ASSERTION((NS_BASE_STREAM_WOULD_BLOCK != rv),
|
||||
"The stream should never block.");
|
||||
|
||||
if (!PREF_EvaluateConfigScript(buf,fs,nsnull, PR_FALSE, PR_TRUE, PR_FALSE)){
|
||||
PR_FREEIF(buf);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
inStr->Close();
|
||||
PR_FREEIF(buf);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAutoConfig::writeFailoverFile()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFile> failoverFile;
|
||||
nsCOMPtr<nsIOutputStream> outStr;
|
||||
PRUint32 amt;
|
||||
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(failoverFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#ifdef XP_MAC
|
||||
failoverFile->Append("Essential Files");
|
||||
#endif
|
||||
|
||||
failoverFile->Append("failover.jsc");
|
||||
|
||||
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outStr), failoverFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = outStr->Write(mBuf.get(),mBuf.Length(),&amt);
|
||||
outStr->Close();
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAutoConfig::getEmailAddr(nsAWritableCString & emailAddr)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
nsXPIDLCString prefValue;
|
||||
|
||||
/* Getting an email address through set of three preferences:
|
||||
First getting a default account with
|
||||
"mail.accountmanager.defaultaccount"
|
||||
second getting an associated id with the default account
|
||||
Third getting an email address with id
|
||||
*/
|
||||
|
||||
rv = mPrefBranch->GetCharPref("mail.accountmanager.defaultaccount",
|
||||
getter_Copies(prefValue));
|
||||
// Checking prefValue and its length. Since by default the preference
|
||||
// is set to nothing
|
||||
if (NS_SUCCEEDED(rv) && nsCRT::strlen(prefValue) > 0) {
|
||||
emailAddr = NS_LITERAL_CSTRING("mail.account.") +
|
||||
nsLocalCString(prefValue) + NS_LITERAL_CSTRING(".identities");
|
||||
rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
|
||||
getter_Copies(prefValue));
|
||||
if (NS_FAILED(rv) || nsCRT::strlen(prefValue) < 0) return rv;
|
||||
emailAddr = NS_LITERAL_CSTRING("mail.identity.") +
|
||||
nsLocalCString(prefValue) + NS_LITERAL_CSTRING(".useremail");
|
||||
rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
|
||||
getter_Copies(prefValue));
|
||||
if (NS_FAILED(rv) || nsCRT::strlen(prefValue) < 0) return rv;
|
||||
emailAddr = nsLocalCString(prefValue);
|
||||
}
|
||||
else {
|
||||
if (mCurrProfile) {
|
||||
emailAddr = mCurrProfile;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsAutoConfig::reportError()
|
||||
{
|
||||
NS_ERROR("AutoConfig::readOfflineFile() failed");
|
||||
mLoaded = PR_TRUE; //Releasing lock to avoid deadlock in DownloadAutoCfg()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
BIN
mozilla/modules/plugin/base/macbuild/plugin.mcp
Normal file
BIN
mozilla/modules/plugin/base/macbuild/plugin.mcp
Normal file
Binary file not shown.
105
mozilla/modules/plugin/base/src/Makefile.in
Normal file
105
mozilla/modules/plugin/base/src/Makefile.in
Normal file
@@ -0,0 +1,105 @@
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = plugin
|
||||
XPIDL_MODULE = layout
|
||||
LIBRARY_NAME = gkplugin
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = xpcom string java pref necko gtkxtbin webshell caps intl dom locale layout widget cookie mimetype oji exthandler docshell webbrwsr nkcache gfx2 timer windowwatcher js
|
||||
# for xlib port
|
||||
REQUIRES += xlibrgb
|
||||
|
||||
CPPSRCS = \
|
||||
ns4xPlugin.cpp \
|
||||
ns4xPluginInstance.cpp \
|
||||
nsPluginDocLoaderFactory.cpp \
|
||||
nsPluginHostImpl.cpp \
|
||||
nsPluginModule.cpp \
|
||||
nsPluginInstancePeer.cpp \
|
||||
nsPluginViewer.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH), BeOS)
|
||||
CPPSRCS += nsPluginsDirBeOS.cpp
|
||||
else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
CPPSRCS += nsPluginsDirOS2.cpp
|
||||
else
|
||||
CPPSRCS += nsPluginsDirUnix.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
EXPORTS = \
|
||||
nsPluginsCID.h \
|
||||
nsIPluginHost.h \
|
||||
nsIPluginInstanceOwner.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
EXTRA_DSO_LIBS += gkgfx
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_NECKO_UTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_PLUGIN
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt
|
||||
else
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt
|
||||
endif #MOZ_MONOLITHIC_TOOLKIT
|
||||
endif #MOZ_ENABLE_GTK
|
||||
|
||||
ifdef MOZ_ENABLE_QT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_QT_LDFLAGS)
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
CFLAGS += $(MOZ_QT_CFLAGS)
|
||||
else
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
endif #MOZ_MONOLITHIC_TOOLKIT
|
||||
endif #MOZ_ENABLE_QT
|
||||
99
mozilla/modules/plugin/base/src/makefile.win
Normal file
99
mozilla/modules/plugin/base/src/makefile.win
Normal file
@@ -0,0 +1,99 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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):
|
||||
|
||||
DEPTH=..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
||||
EXPORTS = \
|
||||
nsPluginsCID.h \
|
||||
nsIPluginHost.h \
|
||||
nsIPluginInstanceOwner.h
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = gkplugin
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
MODULE=raptor
|
||||
IS_COMPONENT=1
|
||||
|
||||
DEFINES =-D_IMPL_NS_PLUGIN -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\ns4xPlugin.obj \
|
||||
.\$(OBJDIR)\ns4xPluginInstance.obj \
|
||||
.\$(OBJDIR)\nsPluginDocLoaderFactory.obj \
|
||||
.\$(OBJDIR)\nsPluginHostImpl.obj \
|
||||
.\$(OBJDIR)\nsPluginModule.obj \
|
||||
.\$(OBJDIR)\nsPluginInstancePeer.obj \
|
||||
.\$(OBJDIR)\nsPluginViewer.obj \
|
||||
.\$(OBJDIR)\nsPluginsDirWin.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS = \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\plugin \
|
||||
-I$(PUBLIC)\java \
|
||||
!ifdef NECKO
|
||||
-I$(PUBLIC)\necko \
|
||||
!else
|
||||
-I$(PUBLIC)\netlib \
|
||||
!endif
|
||||
-I$(PUBLIC)\oji \
|
||||
-I$(PUBLIC)\cache \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\js \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
-D_IMPL_NS_PLUGIN \
|
||||
-GX \
|
||||
$(NULL)
|
||||
|
||||
!ifdef NU_CACHE
|
||||
CACHELIBNAME=cache.lib
|
||||
!else
|
||||
CACHELIBNAME=netcache.lib
|
||||
!endif
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\gkgfxwin.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\xppref32.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
WIN_LIBS = \
|
||||
version.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
it:
|
||||
echo $(LLIBS)
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
||||
4437
mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp
Normal file
4437
mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
BIN
mozilla/modules/plugin/macbuild/plugin.mcp
Normal file
BIN
mozilla/modules/plugin/macbuild/plugin.mcp
Normal file
Binary file not shown.
105
mozilla/modules/plugin/nglsrc/Makefile.in
Normal file
105
mozilla/modules/plugin/nglsrc/Makefile.in
Normal file
@@ -0,0 +1,105 @@
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = plugin
|
||||
XPIDL_MODULE = layout
|
||||
LIBRARY_NAME = gkplugin
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = xpcom string java pref necko gtkxtbin webshell caps intl dom locale layout widget cookie mimetype oji exthandler docshell webbrwsr nkcache gfx2 timer windowwatcher js
|
||||
# for xlib port
|
||||
REQUIRES += xlibrgb
|
||||
|
||||
CPPSRCS = \
|
||||
ns4xPlugin.cpp \
|
||||
ns4xPluginInstance.cpp \
|
||||
nsPluginDocLoaderFactory.cpp \
|
||||
nsPluginHostImpl.cpp \
|
||||
nsPluginModule.cpp \
|
||||
nsPluginInstancePeer.cpp \
|
||||
nsPluginViewer.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH), BeOS)
|
||||
CPPSRCS += nsPluginsDirBeOS.cpp
|
||||
else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
CPPSRCS += nsPluginsDirOS2.cpp
|
||||
else
|
||||
CPPSRCS += nsPluginsDirUnix.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
EXPORTS = \
|
||||
nsPluginsCID.h \
|
||||
nsIPluginHost.h \
|
||||
nsIPluginInstanceOwner.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
EXTRA_DSO_LIBS += gkgfx
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_NECKO_UTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_PLUGIN
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt
|
||||
else
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt
|
||||
endif #MOZ_MONOLITHIC_TOOLKIT
|
||||
endif #MOZ_ENABLE_GTK
|
||||
|
||||
ifdef MOZ_ENABLE_QT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_QT_LDFLAGS)
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
CFLAGS += $(MOZ_QT_CFLAGS)
|
||||
else
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
endif #MOZ_MONOLITHIC_TOOLKIT
|
||||
endif #MOZ_ENABLE_QT
|
||||
99
mozilla/modules/plugin/nglsrc/makefile.win
Normal file
99
mozilla/modules/plugin/nglsrc/makefile.win
Normal file
@@ -0,0 +1,99 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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):
|
||||
|
||||
DEPTH=..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
||||
EXPORTS = \
|
||||
nsPluginsCID.h \
|
||||
nsIPluginHost.h \
|
||||
nsIPluginInstanceOwner.h
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = gkplugin
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
MODULE=raptor
|
||||
IS_COMPONENT=1
|
||||
|
||||
DEFINES =-D_IMPL_NS_PLUGIN -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\ns4xPlugin.obj \
|
||||
.\$(OBJDIR)\ns4xPluginInstance.obj \
|
||||
.\$(OBJDIR)\nsPluginDocLoaderFactory.obj \
|
||||
.\$(OBJDIR)\nsPluginHostImpl.obj \
|
||||
.\$(OBJDIR)\nsPluginModule.obj \
|
||||
.\$(OBJDIR)\nsPluginInstancePeer.obj \
|
||||
.\$(OBJDIR)\nsPluginViewer.obj \
|
||||
.\$(OBJDIR)\nsPluginsDirWin.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS = \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\plugin \
|
||||
-I$(PUBLIC)\java \
|
||||
!ifdef NECKO
|
||||
-I$(PUBLIC)\necko \
|
||||
!else
|
||||
-I$(PUBLIC)\netlib \
|
||||
!endif
|
||||
-I$(PUBLIC)\oji \
|
||||
-I$(PUBLIC)\cache \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\js \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
-D_IMPL_NS_PLUGIN \
|
||||
-GX \
|
||||
$(NULL)
|
||||
|
||||
!ifdef NU_CACHE
|
||||
CACHELIBNAME=cache.lib
|
||||
!else
|
||||
CACHELIBNAME=netcache.lib
|
||||
!endif
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\gkgfxwin.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\xppref32.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
WIN_LIBS = \
|
||||
version.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
it:
|
||||
echo $(LLIBS)
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
||||
4437
mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp
Normal file
4437
mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,46 +0,0 @@
|
||||
Mstone building instructions
|
||||
|
||||
For Unix, just "gmake" one of these
|
||||
release The usual optimized build
|
||||
debug Debug build includes some asserts
|
||||
|
||||
rpackage Build the release and package it
|
||||
dpackage Build the debug version and package it
|
||||
|
||||
all_OPT Build a multi-platform package
|
||||
all_DBG Build a multi-platform debug package
|
||||
|
||||
For NT, run autobuild.bat. This will build and package both the debug
|
||||
and optimized versions. Perl must already be built and installed in
|
||||
\. The NT build may be behind the Unix stuff. Pull the build/package/*
|
||||
subdirectories into the main build/package before doing a 'make all_???'.
|
||||
|
||||
You can build multiple OSes in the same tree. Debug and optimized
|
||||
builds are kept separately. The all_??? targets will combine whatever
|
||||
OSes are present into a multi-architecture package (including NT).
|
||||
Note that you have ot build and package each OS before doing the all_
|
||||
step.
|
||||
|
||||
|
||||
Helper components
|
||||
|
||||
Linux usually comes with workable versions of gnuplot and perl. Most
|
||||
other OSes don't. Mstone can build and package perl, gnuplot, and gd
|
||||
with the right settings. These will be automatically built and
|
||||
packaged if they are present.
|
||||
|
||||
Unpack gd1.3 or later in the mstone directory. You can probably find
|
||||
gd from here: http://www.boutell.com/gd/. The directory should look
|
||||
like gd?.*. Right now we need the (obsolete) version 1.3 to generate
|
||||
GIF files (without patented run-length coding). The scripts need to
|
||||
be updated to be able to handle PNG or GIF files.
|
||||
|
||||
Unpack gnuplot 3.7 or later in the mstone directory. You can probably
|
||||
find gnuplot from http://www.cs.dartmouth.edu/gnuplot_info.html. The
|
||||
directory should look like gnuplot-?.* (the exact version should not
|
||||
matter). Gnuplot requres gd to generate GIFs (which is what we need).
|
||||
|
||||
Unpack perl 5.005 or later in the mstone directory. You can probably
|
||||
find perl from http://www.perl.com/pub/language/info/software.html.
|
||||
The directory should look like perl5.* (the exact version should
|
||||
not matter).
|
||||
@@ -1,73 +0,0 @@
|
||||
2005-02-19 Dan Christian <robodan@idiom.com>
|
||||
|
||||
* Merge big Sendmail patch see ChangeLog-Sendmail for details
|
||||
|
||||
* src/bench.h (VERSION): Start working toward version 5.0 (now 4.9)
|
||||
|
||||
2004-09-07 Dan Christian <robodan@idiom.com>
|
||||
|
||||
* data/*.msg: Updated with more realistic messages
|
||||
|
||||
* bin/args.pl: Really fix doc link to be relative
|
||||
|
||||
* src/smtp.c (sendSMTPLoop): Handle file lists (random selection)
|
||||
(sendFile): New, send file with option offset and head/tail
|
||||
(SmtpFilePrep): Split a glob pattern to a list
|
||||
(SmtpFileInit): New, split out initial file scan
|
||||
|
||||
* src/bench.c (rangeNext): Get to last value in a random range
|
||||
|
||||
2004-06-14 Dan Christian <robodan@idiom.com>
|
||||
|
||||
* Makefile (VERSION): Bump version to 4.3
|
||||
|
||||
* Make build work on recent versions of Linux and Solaris
|
||||
|
||||
* Make ssh the default way to get a remote shell
|
||||
|
||||
* Support SVG graph output (not supported by all browsers)
|
||||
|
||||
* Use rfc822 style from addresses
|
||||
|
||||
* Fix documentation link on index page to be local
|
||||
|
||||
2000-04-28 Dan Christian <dac@x.cx>
|
||||
|
||||
* http and wmap now use common routines from http-util
|
||||
|
||||
* http is now separated from the pish command structure.
|
||||
|
||||
2000-04-27 Dan Christian <dac@x.cx>
|
||||
|
||||
* bin/genplot.pl: Support gnuplot generating images other than gif
|
||||
|
||||
* src/smtp.c (sendSMTPStart): Send domain name with HELO
|
||||
|
||||
2000-04-05 Dan Christian <robodan@netscape.com>
|
||||
* Fix bug in WMAP where the login field was reporting banner data.
|
||||
|
||||
* Add a reconnect concept to WMAP. This separates out the
|
||||
reconnect activity from the initial connections. There is still a
|
||||
bug/feature that the reconnect increments an error which can
|
||||
eventually hit the maxErrors limit. You have to record the error
|
||||
or else you could not get the "connections" graph right.
|
||||
|
||||
2000-03-31 Dan Christian <robodan@netscape.com>
|
||||
|
||||
* Merged setup and mstone into one script to reduce command
|
||||
namespace polution. "mstone setup" is the the same as "setup".
|
||||
|
||||
* Made setup try to be more tolerant of OSes that were not
|
||||
include in the distribution. SunOS 5.7 will fall back to 5.6.
|
||||
|
||||
* Now package conf/general.wld.in and only copy to general.wld if
|
||||
there isn't one already in place. This means that you can unpack
|
||||
new bits over old bits without blowing away your configuration.
|
||||
|
||||
* Added <includeOnce file> command to workloads. This allows
|
||||
tests to be used either as a stand alone or as part of another
|
||||
test (e.g. smtp).
|
||||
|
||||
* Converted ChangeLog to more common formating
|
||||
|
||||
* Spilt off old ChangeLog entries to ChangeLog.1 and ChangeLog.2
|
||||
@@ -1,86 +0,0 @@
|
||||
2005-02-03 Thom O'Connor <thom@sendmail.com>
|
||||
|
||||
* Merge Mozilla mstone HEAD with Sendmail,Inc. modifications. In
|
||||
particular, this included some hand-waving around the bitwise
|
||||
operators "leaveMailOnServer" in the Mozilla branch and the
|
||||
dinst_t struct pish->leaveMailOnServerDist.
|
||||
|
||||
2005-01-25 Thom O'Connor <thom@sendmail.com>
|
||||
|
||||
* Fix comments, properly attribute Sean O'Rourke's contributions.
|
||||
|
||||
2004-09-21 Thom O'Connor <thom@sendmail.com>
|
||||
|
||||
* Modified config/config.mk to build SSL version of mailclient.
|
||||
|
||||
2004-06-07 Thom O'Connor <thom@sendmail.com>
|
||||
|
||||
* Remove _thread_sys_poll defininition for poll in FreeBSD builds
|
||||
(bench.h).
|
||||
|
||||
2001-04-27 Sean O'Rourke <sean@sendmail.com>
|
||||
|
||||
* distributions can now be truncated. This is used to prevent
|
||||
0-recipient messages, and could be used to prevent enormous
|
||||
messages.
|
||||
|
||||
* throttling: Preload workloads use some additional mstone magic
|
||||
to throttle delivery rate based on server responsiveness. This is
|
||||
still in the experimental phase, and may change.
|
||||
|
||||
* fix for parsing bug exposed by distribution truncation notation.
|
||||
|
||||
2001-03-10 Sean O'Rourke <sean@sendmail.com>
|
||||
|
||||
* clients: Fixed up code for specifying client counts on a
|
||||
per-host or per-group basis. This eliminates the need to force
|
||||
the mozilla distribution code to do one's bidding.
|
||||
|
||||
* smtpsink.pl: Very basic threaded perl SMTP sink. This may go
|
||||
away to be replaced by the sink from smtpslam. Needs much better
|
||||
statistics.
|
||||
|
||||
2001-02-24 Sean O'Rourke <sean@sendmail.com>
|
||||
|
||||
* checksums added. See {checksum,md5}.{c,h}. Auto-generated
|
||||
messages can currently have checksums computed over the body, and
|
||||
pop and multipop retrieval will verify the sum.
|
||||
|
||||
2001-02-21 Sean O'Rourke <sean@sendmail.com>
|
||||
|
||||
* MIME generation changed to generate deep messages rather than
|
||||
several parts. This should be a better test of MIME parsers,
|
||||
forcing them to save more state.
|
||||
|
||||
2001-02-18 Sean O'Rourke <sean@sendmail.com>
|
||||
|
||||
* mstone_changes.html: update SSL documentation.
|
||||
|
||||
* wld, defaults.pm: divide the ever-expanding "config" section
|
||||
into more descriptive subparts: clients, server, sink, mstone.
|
||||
|
||||
* report: now in bin directory, where it should be.
|
||||
|
||||
2001-02-17 Sean O'Rourke <sean@sendmail.com>
|
||||
|
||||
* client.c, main.c, parse.c: removed old throttling code, as it
|
||||
wasn't being used.
|
||||
|
||||
* ALL: General code cleanup.
|
||||
|
||||
* sysdep.c: simplified rlimit-bumping code, added increase for
|
||||
RLIM_NPROC, as threads are procs on some systems.
|
||||
|
||||
* imap4.c: removed silliness of malloc()ing a buffer the size of
|
||||
the entire message every time we retrieve a message.
|
||||
|
||||
* xalloc.c, xalloc.h: consolidated memory allocation so everyone
|
||||
handles OOM the same way (for now, dump core).
|
||||
|
||||
* constants.h: various assumptions and limits, were in bench.h.
|
||||
|
||||
* events: added event-queue model to reduce thread requirements.
|
||||
Eventually, it would be nice for a consultant to be able to run
|
||||
this off a laptop to test a small- to medium-sized box. For
|
||||
now, at least, configuration remains the same. This doesn't
|
||||
work on NT. Oh, well.
|
||||
@@ -1,129 +0,0 @@
|
||||
MailStone 4.1: Changes to since version 4.0
|
||||
|
||||
* threads are used on all platforms reduces memory requirements by
|
||||
10x for large numbers of clients must run as root for maximum
|
||||
connections per process
|
||||
|
||||
* massive internal code and script cleanup / rewrite performance
|
||||
improvements for socket handling (blocking) and caching files and
|
||||
name lookups
|
||||
|
||||
* filename and path conventions restructuring '/mailstone'
|
||||
hardwired path no longer required mailstone/results/index.html
|
||||
(index of test runs) mailstone/results/<datestamp>/stderr (look
|
||||
here for errors) mailstone/results/<datestamp>/results.html
|
||||
mailstone/results/<datestamp>/results.txt
|
||||
mailstone/results/<datestamp>/work.wld (workload config used)
|
||||
mailstone/results/<datestamp>/testbed.tbd (testbed used)
|
||||
mailstone/results/<datestamp>/summary.csv (per client summary)
|
||||
mailstone/results/<datestamp>/*.gif (graphs)
|
||||
mailstone/tmp/<datestamp>/*.out (raw results from each client)
|
||||
mailstone/conf/*.wld (workload file) mailstone/conf/*.html
|
||||
(machine descriptions for reports) mailstone/data/*.msg (sample
|
||||
test messages)
|
||||
|
||||
* periodic statistics reporting allows for trend analysis of many
|
||||
variables per protocol. sampling rate is automatically determined
|
||||
by mailmaster Can now generate on-the-fly reports for above by
|
||||
running "process"
|
||||
|
||||
* The accountFormat directive is now obsolete. Use loginFormat
|
||||
and addressFormat instead.
|
||||
|
||||
* The numAccounts and beginAccounts directives are now obsolete.
|
||||
Use numLogins, firstLogin, numAddresses, and firstAddress instead.
|
||||
|
||||
* The sequentialLogins directive disables random account number
|
||||
selection. This insures a predictable account sequence.
|
||||
|
||||
* The checkMailInterval directive for IMAP is now obsolete. Use
|
||||
loopDelay instead.
|
||||
|
||||
* The directives idleTime, loopDelay, and numLoops now apply to
|
||||
all protocols. See the manual for how loopDelay and numLoops are
|
||||
used by each protocol.
|
||||
|
||||
* a command directive such as <SMTP> without HOSTS=xxx will now
|
||||
apply to all clients in the testbed
|
||||
|
||||
* <include> directive for workload and testbed files (e.g. for
|
||||
user profile)
|
||||
|
||||
* workloads are now passed to 'mailclient' through stdin no test
|
||||
specific files need to be copied to client machines more
|
||||
synchonized test startup
|
||||
|
||||
* 'setup' script will copy mailclient and test messages
|
||||
(data/*.msg) to each testbed machine in /var/tmp
|
||||
|
||||
* 'cleanup' form of setup will remove mailclient and test messages
|
||||
from each testbed machine in /var/tmp
|
||||
|
||||
* 'checktime' form of setup will (nearly) simultaneously retrieve
|
||||
time from each client. This lets you easily check for clock
|
||||
problems.
|
||||
|
||||
* 'timesync' form of setup will (nearly) simultaneously set time
|
||||
on each client. This only works on OSs that support setting
|
||||
seconds through the "date" command. rdate or ntpdate should be
|
||||
used if available. You must be the root user and be able to rsh
|
||||
as root for timesync to work.
|
||||
|
||||
* Improved reports in text and html (formatting and content)
|
||||
|
||||
* The text version of the report is now only displayed
|
||||
automatically if "-v" is given.
|
||||
|
||||
* Graphs with more than one protocol will also display a "Total"
|
||||
graph
|
||||
|
||||
* The graphs can now be customized for each test (see sample.wld
|
||||
for the default)
|
||||
|
||||
* You can now add graphs (in addition to the default or configured
|
||||
ones) by using "process timestamp -a conf/moregraph.wld".
|
||||
|
||||
* An informative index of test runs is now generated in
|
||||
results/index.html
|
||||
|
||||
* The index is updated while the run is in progress to make
|
||||
checking for errors easier.
|
||||
|
||||
* The error log now displays times relative to test start.
|
||||
|
||||
* Memory use while processing results has been greatly reduced.
|
||||
|
||||
* A summary of the data from each process is now saved in a
|
||||
Comma-separated-value (CSV) file. results/timestamp/clients.csv
|
||||
|
||||
* A summary of the data over time is now saved in a
|
||||
Comma-separated-value (CSV) file.
|
||||
results/timestamp/protocol-time.csv
|
||||
|
||||
* new gnuplot binary included, can output directly to gif format
|
||||
|
||||
* read and write performance numbers now reported separately
|
||||
|
||||
* new runtime banners and copyrights (ooh boy)
|
||||
|
||||
* idleTime option for IMAP fixed, plus now applies to all commands
|
||||
|
||||
* blockTime now sets a delay between command blocks
|
||||
|
||||
* Process model is as follows
|
||||
User runs the top-level 'mstone' script
|
||||
This calls 'conf/testname.pl' with command line arguments
|
||||
This calls 'mailmaster.pl' with config and command line arguments
|
||||
mailmaster uses 'rsh' or equivalent to launch mailclients
|
||||
mailclient runs on each testbed and forks numprocs
|
||||
each proc spawns numthreads (one per client)
|
||||
|
||||
<run tests> (note: results are being sent continuously)
|
||||
|
||||
threads send results back through sockets to top mailclient
|
||||
mailclient forwards results back over stdout via rsh pipe
|
||||
(for future work - do some data reduction/combining here)
|
||||
mailmaster directs output to each client-<hostname> file
|
||||
mailmaster launches report generator
|
||||
|
||||
* sample LDIF fragment for a postmaster entry included
|
||||
@@ -1,77 +0,0 @@
|
||||
MailStone 4.15: Changes to Mailstone since version 4.1
|
||||
|
||||
* Setup now checks license acceptance and configures a basic
|
||||
setup. By default, it will also create a user LDIF file with a
|
||||
'allusers' account.
|
||||
|
||||
* All parameters and and testbed information may now be specified
|
||||
in the workload files (*.wld). New sections: CONFIG, CLIENT,
|
||||
MONITOR, PRETEST, and POSTTEST. Command line parameters still
|
||||
override the files. A complete copy of the configuration is saved
|
||||
in results/<TIMESTAMP>/all.wld.
|
||||
|
||||
* The '*.pl', '*.tbd', and 'config*' files in ./conf/ are
|
||||
depreciated. These should still work, but the new sections are
|
||||
simpler and more flexible.
|
||||
|
||||
* Any CONFIG parameter can now be specified on the command line
|
||||
using the form: 'PARAMETER=value'. Note that PARAMETER is case
|
||||
insensitive. No whitespace is allowed before or after the '='.
|
||||
|
||||
* The new switch '-l' or CONFIG parameter 'ClientCount' can now
|
||||
specify the total number of clients. The 'MaxClients' and
|
||||
'MaxThreads' parameters in each CLIENT section control load
|
||||
balancing. If the 'processes' and 'threads' parameters are set,
|
||||
then the load for that CLIENT section will not be adjusted, but
|
||||
will be taken into account when calculating other CLIENT sections.
|
||||
If just 'processes' is set, then only the thread count will be
|
||||
adjusted. All hosts in a CLIENT section will run the same number
|
||||
of processes and threads.
|
||||
|
||||
* bin/makeusers.pl now creates users, broadcast account, etc.
|
||||
Numbered passwords are now suppored. The new user/password format
|
||||
now replaces '%ld' with the user number to match the rest of
|
||||
mailstone. The ldif/ directory is obsolete. Run "perl/bin/perl
|
||||
bin/makeusers.pl -h" for usage.
|
||||
|
||||
* NT client machines may now be used from a Unix test master. See
|
||||
conf/sample.wld for configuration details.
|
||||
|
||||
* Commands can now be run for a specified block count, error
|
||||
count, or time (whichever comes first). Set 'maxBlocks' and/or
|
||||
'maxErrors'.
|
||||
|
||||
* Telemetry logging to /var/tmp/mstone-log.pn.tn is now performed
|
||||
when "telemetry 1" is specified.
|
||||
|
||||
* The name used in the "CLIENT" section is now used to match
|
||||
"HOSTS=..." qualifier. Compatibility with "hostname" is no longer
|
||||
needed.
|
||||
|
||||
* Config values can now use quoted characters such as \n, \r, \t
|
||||
|
||||
* Config values can be continued using \ (backslash)
|
||||
|
||||
* System configuration information (SYSCONFIG) can now be
|
||||
specified entirely within a workload file by quoting the newlines.
|
||||
|
||||
* Config values get enclosing double-quotes stripped
|
||||
|
||||
* Preliminary support for HTTP and WMAP (WebMail) testing.
|
||||
|
||||
* New table formats are easier to interpret and allow more protocols.
|
||||
|
||||
* The new text format report is easier to machine processes.
|
||||
|
||||
* The following command line switches are now obsolete: -f, -g,
|
||||
-e, -p, and -l. The same functionality can be obtained by
|
||||
FREQUENCY=<interval>, GNUPLOT=<path>, RSH=<path>, RCP=<path>, and
|
||||
TEMPDIR=<directory> respectively.
|
||||
|
||||
* File backups are now created. When ./process is run multiple
|
||||
times, the old files are moved to the ./tmp/<TIMESTAMP>/
|
||||
directory.
|
||||
|
||||
* perl has been updated to include full perl5.005_03 install
|
||||
package. Perl support for each architecture is now under the
|
||||
perl/ directory.
|
||||
@@ -1,222 +0,0 @@
|
||||
|
||||
Mstone 4.15 Quick Installation
|
||||
|
||||
This version of Mstone runs on many current UNIX platforms and NT.
|
||||
Only a web browser and text editor are needed to view the results and
|
||||
configure tests.
|
||||
|
||||
|
||||
QUICK INSTALL
|
||||
-------------
|
||||
|
||||
IMPORTANT: If you have an existing mstone, save a copy of the
|
||||
mstone/conf directory to preserve any configuration files you may want
|
||||
to keep.
|
||||
|
||||
Unpack distribution:
|
||||
|
||||
tar xzf /tmp/mstone_OPT.tar.gz
|
||||
or
|
||||
gunzip -c /tmp/mstone_OPT.tar.gz | tar xf -
|
||||
or
|
||||
unzip /tmp/mstone_OPT.zip
|
||||
|
||||
cd mstone
|
||||
|
||||
Both the tar.gz file and the zip file are identical. Use whichever is
|
||||
more convenient for you.
|
||||
|
||||
This will create a sub-directory named "mstone" with files and
|
||||
directories under that.
|
||||
|
||||
cd mstone
|
||||
|
||||
NOTE: all scripts must be run from the mstone directory.
|
||||
|
||||
|
||||
Do initial configuration:
|
||||
|
||||
Run "mstone config". It will ask you about your system configuration.
|
||||
Fill in the appropriate values and create the optional user accounts
|
||||
and broadcast account. When it asks about client machines, enter them
|
||||
seperated by commas, with no spaces (e.g. host1,host2,host3). If you
|
||||
need to re-configure, run "mstone config".
|
||||
|
||||
The machine starting the test may also be a client. For accurate
|
||||
results, clients should not be run on the test mailserver machine (or
|
||||
its directory server). If all the client machines are not running
|
||||
the same operating system version, see "Configuring Client Machines"
|
||||
below to configure for different OSes.
|
||||
|
||||
When the test master is on NT, only the local machine may be a client
|
||||
and only one process is allowed. You will not be asked about client
|
||||
machines.
|
||||
|
||||
Setup only configures the most important parameters. If you have more
|
||||
advanced needs, edit conf/general.wld appropriately.
|
||||
|
||||
Run "mstone setup". It will now push the necessary files to each
|
||||
client machine. If there are problems (i.e. with rsh permissions),
|
||||
fix them and re-run "mstone setup" until everything works.
|
||||
|
||||
|
||||
Install test accounts:
|
||||
|
||||
Setup will create a file called conf/MAILHOST.ldif (where MAILHOST is the
|
||||
name of your mail server). If you are not using Netscape Messaging
|
||||
and Directory Servers, then you may have to edit the ldif file or use
|
||||
alternate means to create the user accounts.
|
||||
|
||||
To import these users into Netscape Messaging Server, use "add
|
||||
entries" from the directory console or use the ldapmodify command line
|
||||
utility.
|
||||
|
||||
Note: imports will go faster if access logging is disabled. For large
|
||||
user counts (more than 10,000 users), it may be much faster to export
|
||||
the current database, merge the files together manually, and then
|
||||
import the new database.
|
||||
|
||||
Here is how the ldapmodify supplied with Netscape Messaging Server
|
||||
would be used.
|
||||
|
||||
setenv LD_LIBRARY_PATH /usr/netscape/messaging/lib
|
||||
cd /usr/netscape/messaging
|
||||
shared/bin/ldapmodify -h mailhost -a -D 'cn=directory manager' -w d_m_password < conf/MAILHOST.ldif
|
||||
|
||||
|
||||
Check time consistency:
|
||||
|
||||
IMPORTANT: The system time on each client machine must be synchronized
|
||||
within one second of each other for accurate results graphs.
|
||||
|
||||
Run "checktime" to see the time on each client. There should not be
|
||||
more than two seconds difference among the displayed time.
|
||||
|
||||
The best way to synchronize clients is use NTP (Network Time Protocol)
|
||||
or similar protocols (like rdate or timeslave) that have sub second
|
||||
accuracy.
|
||||
|
||||
A simple utility called "timesync" is provide to push the local
|
||||
system time to all clients. You must be root and have root rsh
|
||||
permissions to use timesync. Timesync only works on OSs that support
|
||||
setting seconds using "date MMDDhhmmCCYY.ss". Timesync is only
|
||||
accurate to a second (at best) and should only be used if better
|
||||
protocols aren't available.
|
||||
|
||||
When running the test master on NT, "checktime" and "timesync" are
|
||||
never needed (because there is only one client machine). Timesync
|
||||
will be ignored for NT clients, another method must be used
|
||||
(e.g. timeserv or Dimension4).
|
||||
|
||||
|
||||
Run tests:
|
||||
|
||||
Try it out. Use small process and thread counts until everything is
|
||||
working.
|
||||
|
||||
mstone pop -t 30s
|
||||
|
||||
The script will tell you how many processes and threads it is running
|
||||
on each system and where errors are logged. At the end of the test,
|
||||
it will print out a URL for the test results and an indication of the
|
||||
size of the errorlog file (stderr).
|
||||
|
||||
The results of the mstone run will display statistics for each
|
||||
protocol that was tested. The results are presented in both a HTML
|
||||
web page and a text file. The text file is simple and uniform, while
|
||||
the web page is more user readable. The web page has links to the
|
||||
test configuration files, error log, and the text version.
|
||||
|
||||
For long tests run (e.g. 8 hours), the results can be updated while
|
||||
the test is running by using the "process" utility. Don't run
|
||||
"process" near the very end of the test.
|
||||
|
||||
If a test has to be aborted, then use "process" to generate a report
|
||||
using the available data.
|
||||
|
||||
|
||||
Customize tests:
|
||||
|
||||
Copy and edit the scripts (e.g. "conf/pop.wld") to define new tests.
|
||||
The CONFIG section specifies all the attributes used in the test.
|
||||
Other sections specify the protocols to be tested and the parameters
|
||||
for them.
|
||||
|
||||
All switches can be overridden on the command line to facilitate
|
||||
easier testing. The exact configuration (include command line
|
||||
overrides) is stored with the results from each test.
|
||||
|
||||
|
||||
Maintenance:
|
||||
|
||||
You can run "mstone setup" at any time (except during a test :-) to
|
||||
update the files on the client machines.
|
||||
|
||||
Use "mstone cleanup" to remove the files created by "mstone setup".
|
||||
|
||||
After the test is finished, the directories under "tmp/" can be
|
||||
compressed or deleted to save space. All the information about a test
|
||||
run is stored in the "results/" directories.
|
||||
|
||||
|
||||
Configuring client machines:
|
||||
|
||||
Edit conf/general.wld to include CLIENT sections for each machines to
|
||||
use.
|
||||
|
||||
You can also specify the OS type for each client machine. Set the
|
||||
"Arch" parameter in each CLIENT section as appropriate (e.g. SunOS5.6,
|
||||
Linux2.2_x86, AIX4.2, HP-UXB.11.00, IRIX6.5, OSF1V4.0, WINNT4.0). The
|
||||
directories under "bin" specify the available OS types.
|
||||
|
||||
For NT4.0 clients with a UNIX test master, you will need to configure
|
||||
"command" and "tempDir" for proper operation. See the "HOSTS=winnt01"
|
||||
example in conf/sample.wld.
|
||||
|
||||
The total number of processes and threads that can be supported on a
|
||||
client is dependent on the number of commands in the test, the OS, and
|
||||
available memory. Check the stderr log for messages about not being
|
||||
able to create processes or threads. Check on the client machines
|
||||
during the test and make sure they aren't running out of CPU. The
|
||||
UNIX programs "top" and "vmstat" are good for this. If the client CPU
|
||||
is more than 75% busy, use more machines.
|
||||
|
||||
Also watch out for network saturation. You may have to use machines
|
||||
with separate networks to the server to reach full server load.
|
||||
|
||||
|
||||
Know problems:
|
||||
|
||||
There can be extraneous errors or connections after the specified end
|
||||
of the test. These are most likely do to stopping the test and should
|
||||
be ignored.
|
||||
|
||||
At the end of the test, all current connections will logout without
|
||||
any delays. This can cause very high peak loads.
|
||||
|
||||
If one process exits early (due to misconfiguration or resource
|
||||
exhaustion) and the monitoring command did not specify a count (%c),
|
||||
then the monitoring tasks will be terminated early as well.
|
||||
|
||||
Monitoring commands that specify a count (%c), may take longer than
|
||||
predicted and delay the processing of test results. This is because
|
||||
vmstat actually delays the requested time plus the time needed to
|
||||
generate the statistics summary.
|
||||
|
||||
If you are doing tests with large thread counts, you may have to run
|
||||
as root to allow mailclient to raise its resource limits.
|
||||
|
||||
The telemetry logging for SMTP, POP3, and IMAP4 is incomplete. Most
|
||||
commands are captured, but banners and message contents may be missing.
|
||||
|
||||
The MaxBlocks parameter gets divided by the total number of processes
|
||||
before starting each client. This doesn't account for clients that
|
||||
don't have commands to run.
|
||||
|
||||
The HTTP protocol used by WMAP allows connections to be dropped and
|
||||
re-connected as needed. WMAP logs this as an error and an additional
|
||||
connect. The error log must be consulted to distinguish another types
|
||||
of connection errors (timeout or connection refused) from an automatic
|
||||
re-connect.
|
||||
|
||||
The HTTP protocol test is experimental and subject to change.
|
||||
@@ -1,19 +0,0 @@
|
||||
The contents of this software package are subject to the Netscape
|
||||
Public License Version 1.1 (the "License"); you may not use this
|
||||
software 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.
|
||||
|
||||
Alternatively, the this software package may be used under the terms
|
||||
of the GNU Public License (the "GPL"), in which case the provisions of
|
||||
the GPL are applicable instead of those above. If you wish to allow
|
||||
use of your version of this file only under the terms of the GPL and
|
||||
not to allow others to use your version of this file under the NPL,
|
||||
indicate your decision by deleting the provisions above and replace
|
||||
them with the notice and other provisions required by the GPL. If you
|
||||
do not delete the provisions above, a recipient may use your version
|
||||
of this file under either the NPL or the GPL.
|
||||
@@ -1,535 +0,0 @@
|
||||
MOZILLA PUBLIC LICENSE
|
||||
Version 1.1
|
||||
|
||||
---------------
|
||||
|
||||
1. Definitions.
|
||||
|
||||
1.0.1. "Commercial Use" means distribution or otherwise making the
|
||||
Covered Code available to a third party.
|
||||
|
||||
1.1. "Contributor" means each entity that creates or contributes to
|
||||
the creation of Modifications.
|
||||
|
||||
1.2. "Contributor Version" means the combination of the Original
|
||||
Code, prior Modifications used by a Contributor, and the Modifications
|
||||
made by that particular Contributor.
|
||||
|
||||
1.3. "Covered Code" means the Original Code or Modifications or the
|
||||
combination of the Original Code and Modifications, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.4. "Electronic Distribution Mechanism" means a mechanism generally
|
||||
accepted in the software development community for the electronic
|
||||
transfer of data.
|
||||
|
||||
1.5. "Executable" means Covered Code in any form other than Source
|
||||
Code.
|
||||
|
||||
1.6. "Initial Developer" means the individual or entity identified
|
||||
as the Initial Developer in the Source Code notice required by Exhibit
|
||||
A.
|
||||
|
||||
1.7. "Larger Work" means a work which combines Covered Code or
|
||||
portions thereof with code not governed by the terms of this License.
|
||||
|
||||
1.8. "License" means this document.
|
||||
|
||||
1.8.1. "Licensable" means having the right to grant, to the maximum
|
||||
extent possible, whether at the time of the initial grant or
|
||||
subsequently acquired, any and all of the rights conveyed herein.
|
||||
|
||||
1.9. "Modifications" means any addition to or deletion from the
|
||||
substance or structure of either the Original Code or any previous
|
||||
Modifications. When Covered Code is released as a series of files, a
|
||||
Modification is:
|
||||
A. Any addition to or deletion from the contents of a file
|
||||
containing Original Code or previous Modifications.
|
||||
|
||||
B. Any new file that contains any part of the Original Code or
|
||||
previous Modifications.
|
||||
|
||||
1.10. "Original Code" means Source Code of computer software code
|
||||
which is described in the Source Code notice required by Exhibit A as
|
||||
Original Code, and which, at the time of its release under this
|
||||
License is not already Covered Code governed by this License.
|
||||
|
||||
1.10.1. "Patent Claims" means any patent claim(s), now owned or
|
||||
hereafter acquired, including without limitation, method, process,
|
||||
and apparatus claims, in any patent Licensable by grantor.
|
||||
|
||||
1.11. "Source Code" means the preferred form of the Covered Code for
|
||||
making modifications to it, including all modules it contains, plus
|
||||
any associated interface definition files, scripts used to control
|
||||
compilation and installation of an Executable, or source code
|
||||
differential comparisons against either the Original Code or another
|
||||
well known, available Covered Code of the Contributor's choice. The
|
||||
Source Code can be in a compressed or archival form, provided the
|
||||
appropriate decompression or de-archiving software is widely available
|
||||
for no charge.
|
||||
|
||||
1.12. "You" (or "Your") means an individual or a legal entity
|
||||
exercising rights under, and complying with all of the terms of, this
|
||||
License or a future version of this License issued under Section 6.1.
|
||||
For legal entities, "You" includes any entity which controls, is
|
||||
controlled by, or is under common control with You. For purposes of
|
||||
this definition, "control" means (a) the power, direct or indirect,
|
||||
to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (b) ownership of more than fifty percent
|
||||
(50%) of the outstanding shares or beneficial ownership of such
|
||||
entity.
|
||||
|
||||
2. Source Code License.
|
||||
|
||||
2.1. The Initial Developer Grant.
|
||||
The Initial Developer hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license, subject to third party intellectual property
|
||||
claims:
|
||||
(a) under intellectual property rights (other than patent or
|
||||
trademark) Licensable by Initial Developer to use, reproduce,
|
||||
modify, display, perform, sublicense and distribute the Original
|
||||
Code (or portions thereof) with or without Modifications, and/or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patents Claims infringed by the making, using or
|
||||
selling of Original Code, to make, have made, use, practice,
|
||||
sell, and offer for sale, and/or otherwise dispose of the
|
||||
Original Code (or portions thereof).
|
||||
|
||||
(c) the licenses granted in this Section 2.1(a) and (b) are
|
||||
effective on the date Initial Developer first distributes
|
||||
Original Code under the terms of this License.
|
||||
|
||||
(d) Notwithstanding Section 2.1(b) above, no patent license is
|
||||
granted: 1) for code that You delete from the Original Code; 2)
|
||||
separate from the Original Code; or 3) for infringements caused
|
||||
by: i) the modification of the Original Code or ii) the
|
||||
combination of the Original Code with other software or devices.
|
||||
|
||||
2.2. Contributor Grant.
|
||||
Subject to third party intellectual property claims, each Contributor
|
||||
hereby grants You a world-wide, royalty-free, non-exclusive license
|
||||
|
||||
(a) under intellectual property rights (other than patent or
|
||||
trademark) Licensable by Contributor, to use, reproduce, modify,
|
||||
display, perform, sublicense and distribute the Modifications
|
||||
created by such Contributor (or portions thereof) either on an
|
||||
unmodified basis, with other Modifications, as Covered Code
|
||||
and/or as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims infringed by the making, using, or
|
||||
selling of Modifications made by that Contributor either alone
|
||||
and/or in combination with its Contributor Version (or portions
|
||||
of such combination), to make, use, sell, offer for sale, have
|
||||
made, and/or otherwise dispose of: 1) Modifications made by that
|
||||
Contributor (or portions thereof); and 2) the combination of
|
||||
Modifications made by that Contributor with its Contributor
|
||||
Version (or portions of such combination).
|
||||
|
||||
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
|
||||
effective on the date Contributor first makes Commercial Use of
|
||||
the Covered Code.
|
||||
|
||||
(d) Notwithstanding Section 2.2(b) above, no patent license is
|
||||
granted: 1) for any code that Contributor has deleted from the
|
||||
Contributor Version; 2) separate from the Contributor Version;
|
||||
3) for infringements caused by: i) third party modifications of
|
||||
Contributor Version or ii) the combination of Modifications made
|
||||
by that Contributor with other software (except as part of the
|
||||
Contributor Version) or other devices; or 4) under Patent Claims
|
||||
infringed by Covered Code in the absence of Modifications made by
|
||||
that Contributor.
|
||||
|
||||
3. Distribution Obligations.
|
||||
|
||||
3.1. Application of License.
|
||||
The Modifications which You create or to which You contribute are
|
||||
governed by the terms of this License, including without limitation
|
||||
Section 2.2. The Source Code version of Covered Code may be
|
||||
distributed only under the terms of this License or a future version
|
||||
of this License released under Section 6.1, and You must include a
|
||||
copy of this License with every copy of the Source Code You
|
||||
distribute. You may not offer or impose any terms on any Source Code
|
||||
version that alters or restricts the applicable version of this
|
||||
License or the recipients' rights hereunder. However, You may include
|
||||
an additional document offering the additional rights described in
|
||||
Section 3.5.
|
||||
|
||||
3.2. Availability of Source Code.
|
||||
Any Modification which You create or to which You contribute must be
|
||||
made available in Source Code form under the terms of this License
|
||||
either on the same media as an Executable version or via an accepted
|
||||
Electronic Distribution Mechanism to anyone to whom you made an
|
||||
Executable version available; and if made available via Electronic
|
||||
Distribution Mechanism, must remain available for at least twelve (12)
|
||||
months after the date it initially became available, or at least six
|
||||
(6) months after a subsequent version of that particular Modification
|
||||
has been made available to such recipients. You are responsible for
|
||||
ensuring that the Source Code version remains available even if the
|
||||
Electronic Distribution Mechanism is maintained by a third party.
|
||||
|
||||
3.3. Description of Modifications.
|
||||
You must cause all Covered Code to which You contribute to contain a
|
||||
file documenting the changes You made to create that Covered Code and
|
||||
the date of any change. You must include a prominent statement that
|
||||
the Modification is derived, directly or indirectly, from Original
|
||||
Code provided by the Initial Developer and including the name of the
|
||||
Initial Developer in (a) the Source Code, and (b) in any notice in an
|
||||
Executable version or related documentation in which You describe the
|
||||
origin or ownership of the Covered Code.
|
||||
|
||||
3.4. Intellectual Property Matters
|
||||
(a) Third Party Claims.
|
||||
If Contributor has knowledge that a license under a third party's
|
||||
intellectual property rights is required to exercise the rights
|
||||
granted by such Contributor under Sections 2.1 or 2.2,
|
||||
Contributor must include a text file with the Source Code
|
||||
distribution titled "LEGAL" which describes the claim and the
|
||||
party making the claim in sufficient detail that a recipient will
|
||||
know whom to contact. If Contributor obtains such knowledge after
|
||||
the Modification is made available as described in Section 3.2,
|
||||
Contributor shall promptly modify the LEGAL file in all copies
|
||||
Contributor makes available thereafter and shall take other steps
|
||||
(such as notifying appropriate mailing lists or newsgroups)
|
||||
reasonably calculated to inform those who received the Covered
|
||||
Code that new knowledge has been obtained.
|
||||
|
||||
(b) Contributor APIs.
|
||||
If Contributor's Modifications include an application programming
|
||||
interface and Contributor has knowledge of patent licenses which
|
||||
are reasonably necessary to implement that API, Contributor must
|
||||
also include this information in the LEGAL file.
|
||||
|
||||
(c) Representations.
|
||||
Contributor represents that, except as disclosed pursuant to
|
||||
Section 3.4(a) above, Contributor believes that Contributor's
|
||||
Modifications are Contributor's original creation(s) and/or
|
||||
Contributor has sufficient rights to grant the rights conveyed by
|
||||
this License.
|
||||
|
||||
3.5. Required Notices.
|
||||
You must duplicate the notice in Exhibit A in each file of the Source
|
||||
Code. If it is not possible to put such notice in a particular Source
|
||||
Code file due to its structure, then You must include such notice in a
|
||||
location (such as a relevant directory) where a user would be likely
|
||||
to look for such a notice. If You created one or more Modification(s)
|
||||
You may add your name as a Contributor to the notice described in
|
||||
Exhibit A. You must also duplicate this License in any documentation
|
||||
for the Source Code where You describe recipients' rights or ownership
|
||||
rights relating to Covered Code. You may choose to offer, and to
|
||||
charge a fee for, warranty, support, indemnity or liability
|
||||
obligations to one or more recipients of Covered Code. However, You
|
||||
may do so only on Your own behalf, and not on behalf of the Initial
|
||||
Developer or any Contributor. You must make it absolutely clear than
|
||||
any such warranty, support, indemnity or liability obligation is
|
||||
offered by You alone, and You hereby agree to indemnify the Initial
|
||||
Developer and every Contributor for any liability incurred by the
|
||||
Initial Developer or such Contributor as a result of warranty,
|
||||
support, indemnity or liability terms You offer.
|
||||
|
||||
3.6. Distribution of Executable Versions.
|
||||
You may distribute Covered Code in Executable form only if the
|
||||
requirements of Section 3.1-3.5 have been met for that Covered Code,
|
||||
and if You include a notice stating that the Source Code version of
|
||||
the Covered Code is available under the terms of this License,
|
||||
including a description of how and where You have fulfilled the
|
||||
obligations of Section 3.2. The notice must be conspicuously included
|
||||
in any notice in an Executable version, related documentation or
|
||||
collateral in which You describe recipients' rights relating to the
|
||||
Covered Code. You may distribute the Executable version of Covered
|
||||
Code or ownership rights under a license of Your choice, which may
|
||||
contain terms different from this License, provided that You are in
|
||||
compliance with the terms of this License and that the license for the
|
||||
Executable version does not attempt to limit or alter the recipient's
|
||||
rights in the Source Code version from the rights set forth in this
|
||||
License. If You distribute the Executable version under a different
|
||||
license You must make it absolutely clear that any terms which differ
|
||||
from this License are offered by You alone, not by the Initial
|
||||
Developer or any Contributor. You hereby agree to indemnify the
|
||||
Initial Developer and every Contributor for any liability incurred by
|
||||
the Initial Developer or such Contributor as a result of any such
|
||||
terms You offer.
|
||||
|
||||
3.7. Larger Works.
|
||||
You may create a Larger Work by combining Covered Code with other code
|
||||
not governed by the terms of this License and distribute the Larger
|
||||
Work as a single product. In such a case, You must make sure the
|
||||
requirements of this License are fulfilled for the Covered Code.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation.
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Code due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description
|
||||
must be included in the LEGAL file described in Section 3.4 and must
|
||||
be included with all distributions of the Source Code. Except to the
|
||||
extent prohibited by statute or regulation, such description must be
|
||||
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
|
||||
5. Application of this License.
|
||||
|
||||
This License applies to code to which the Initial Developer has
|
||||
attached the notice in Exhibit A and to related Covered Code.
|
||||
|
||||
6. Versions of the License.
|
||||
|
||||
6.1. New Versions.
|
||||
Netscape Communications Corporation ("Netscape") may publish revised
|
||||
and/or new versions of the License from time to time. Each version
|
||||
will be given a distinguishing version number.
|
||||
|
||||
6.2. Effect of New Versions.
|
||||
Once Covered Code has been published under a particular version of the
|
||||
License, You may always continue to use it under the terms of that
|
||||
version. You may also choose to use such Covered Code under the terms
|
||||
of any subsequent version of the License published by Netscape. No one
|
||||
other than Netscape has the right to modify the terms applicable to
|
||||
Covered Code created under this License.
|
||||
|
||||
6.3. Derivative Works.
|
||||
If You create or use a modified version of this License (which you may
|
||||
only do in order to apply it to code which is not already Covered Code
|
||||
governed by this License), You must (a) rename Your license so that
|
||||
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
|
||||
"MPL", "NPL" or any confusingly similar phrase do not appear in your
|
||||
license (except to note that your license differs from this License)
|
||||
and (b) otherwise make it clear that Your version of the license
|
||||
contains terms which differ from the Mozilla Public License and
|
||||
Netscape Public License. (Filling in the name of the Initial
|
||||
Developer, Original Code or Contributor in the notice described in
|
||||
Exhibit A shall not of themselves be deemed to be modifications of
|
||||
this License.)
|
||||
|
||||
7. DISCLAIMER OF WARRANTY.
|
||||
|
||||
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
|
||||
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
|
||||
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
|
||||
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
|
||||
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
|
||||
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
|
||||
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
|
||||
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||
|
||||
8. TERMINATION.
|
||||
|
||||
8.1. This License and the rights granted hereunder will terminate
|
||||
automatically if You fail to comply with terms herein and fail to cure
|
||||
such breach within 30 days of becoming aware of the breach. All
|
||||
sublicenses to the Covered Code which are properly granted shall
|
||||
survive any termination of this License. Provisions which, by their
|
||||
nature, must remain in effect beyond the termination of this License
|
||||
shall survive.
|
||||
|
||||
8.2. If You initiate litigation by asserting a patent infringement
|
||||
claim (excluding declatory judgment actions) against Initial Developer
|
||||
or a Contributor (the Initial Developer or Contributor against whom
|
||||
You file such action is referred to as "Participant") alleging that:
|
||||
|
||||
(a) such Participant's Contributor Version directly or indirectly
|
||||
infringes any patent, then any and all rights granted by such
|
||||
Participant to You under Sections 2.1 and/or 2.2 of this License
|
||||
shall, upon 60 days notice from Participant terminate prospectively,
|
||||
unless if within 60 days after receipt of notice You either: (i)
|
||||
agree in writing to pay Participant a mutually agreeable reasonable
|
||||
royalty for Your past and future use of Modifications made by such
|
||||
Participant, or (ii) withdraw Your litigation claim with respect to
|
||||
the Contributor Version against such Participant. If within 60 days
|
||||
of notice, a reasonable royalty and payment arrangement are not
|
||||
mutually agreed upon in writing by the parties or the litigation claim
|
||||
is not withdrawn, the rights granted by Participant to You under
|
||||
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
|
||||
the 60 day notice period specified above.
|
||||
|
||||
(b) any software, hardware, or device, other than such Participant's
|
||||
Contributor Version, directly or indirectly infringes any patent, then
|
||||
any rights granted to You by such Participant under Sections 2.1(b)
|
||||
and 2.2(b) are revoked effective as of the date You first made, used,
|
||||
sold, distributed, or had made, Modifications made by that
|
||||
Participant.
|
||||
|
||||
8.3. If You assert a patent infringement claim against Participant
|
||||
alleging that such Participant's Contributor Version directly or
|
||||
indirectly infringes any patent where such claim is resolved (such as
|
||||
by license or settlement) prior to the initiation of patent
|
||||
infringement litigation, then the reasonable value of the licenses
|
||||
granted by such Participant under Sections 2.1 or 2.2 shall be taken
|
||||
into account in determining the amount or value of any payment or
|
||||
license.
|
||||
|
||||
8.4. In the event of termination under Sections 8.1 or 8.2 above,
|
||||
all end user license agreements (excluding distributors and resellers)
|
||||
which have been validly granted by You or any distributor hereunder
|
||||
prior to termination shall survive termination.
|
||||
|
||||
9. LIMITATION OF LIABILITY.
|
||||
|
||||
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
|
||||
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
|
||||
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
|
||||
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
|
||||
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
|
||||
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
|
||||
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
|
||||
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
|
||||
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
|
||||
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
|
||||
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
|
||||
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
|
||||
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
10. U.S. GOVERNMENT END USERS.
|
||||
|
||||
The Covered Code is a "commercial item," as that term is defined in
|
||||
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
|
||||
software" and "commercial computer software documentation," as such
|
||||
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
|
||||
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
|
||||
all U.S. Government End Users acquire Covered Code with only those
|
||||
rights set forth herein.
|
||||
|
||||
11. MISCELLANEOUS.
|
||||
|
||||
This License represents the complete agreement concerning subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. This License shall be governed by
|
||||
California law provisions (except to the extent applicable law, if
|
||||
any, provides otherwise), excluding its conflict-of-law provisions.
|
||||
With respect to disputes in which at least one party is a citizen of,
|
||||
or an entity chartered or registered to do business in the United
|
||||
States of America, any litigation relating to this License shall be
|
||||
subject to the jurisdiction of the Federal Courts of the Northern
|
||||
District of California, with venue lying in Santa Clara County,
|
||||
California, with the losing party responsible for costs, including
|
||||
without limitation, court costs and reasonable attorneys' fees and
|
||||
expenses. The application of the United Nations Convention on
|
||||
Contracts for the International Sale of Goods is expressly excluded.
|
||||
Any law or regulation which provides that the language of a contract
|
||||
shall be construed against the drafter shall not apply to this
|
||||
License.
|
||||
|
||||
12. RESPONSIBILITY FOR CLAIMS.
|
||||
|
||||
As between Initial Developer and the Contributors, each party is
|
||||
responsible for claims and damages arising, directly or indirectly,
|
||||
out of its utilization of rights under this License and You agree to
|
||||
work with Initial Developer and Contributors to distribute such
|
||||
responsibility on an equitable basis. Nothing herein is intended or
|
||||
shall be deemed to constitute any admission of liability.
|
||||
|
||||
13. MULTIPLE-LICENSED CODE.
|
||||
|
||||
Initial Developer may designate portions of the Covered Code as
|
||||
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
|
||||
Developer permits you to utilize portions of the Covered Code under
|
||||
Your choice of the NPL or the alternative licenses, if any, specified
|
||||
by the Initial Developer in the file described in Exhibit A.
|
||||
|
||||
EXHIBIT A-Netscape Public License.
|
||||
|
||||
"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 the Netscape Mailstone code, released
|
||||
March 17, 2000.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1999-2000 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
Marcel DePaolis <marcel@netscape.com>
|
||||
Jim Salter <jsalter@netscape.com>
|
||||
Mike Blakely, David Shak, Brain Williams
|
||||
|
||||
Alternatively, the contents of this file may be used under the
|
||||
terms of the GNU General Public license Version 2 or later
|
||||
(the "GPL"), in which case the provisions of GPL are
|
||||
applicable instead of those above. If you wish to allow use
|
||||
of your version of this file only under the terms of the GPL
|
||||
and not to allow others to use your version of this file
|
||||
under the NPL, indicate your decision by deleting the
|
||||
provisions above and replace them with the notice and other
|
||||
provisions required by the GPL. If you do not delete the
|
||||
provisions above, a recipient may use your version of this
|
||||
file under either the NPL or the GPL License."
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
AMENDMENTS
|
||||
|
||||
The Netscape Public License Version 1.1 ("NPL") consists of the
|
||||
Mozilla Public License Version 1.1 with the following Amendments,
|
||||
including Exhibit A-Netscape Public License. Files identified with
|
||||
"Exhibit A-Netscape Public License" are governed by the Netscape
|
||||
Public License Version 1.1.
|
||||
|
||||
Additional Terms applicable to the Netscape Public License.
|
||||
I. Effect.
|
||||
These additional terms described in this Netscape Public
|
||||
License -- Amendments shall apply to the Mozilla Communicator
|
||||
client code and to all Covered Code under this License.
|
||||
|
||||
II. "Netscape's Branded Code" means Covered Code that Netscape
|
||||
distributes and/or permits others to distribute under one or more
|
||||
trademark(s) which are controlled by Netscape but which are not
|
||||
licensed for use under this License.
|
||||
|
||||
III. Netscape and logo.
|
||||
This License does not grant any rights to use the trademarks
|
||||
"Netscape", the "Netscape N and horizon" logo or the "Netscape
|
||||
lighthouse" logo, "Netcenter", "Gecko", "Java" or "JavaScript",
|
||||
"Smart Browsing" even if such marks are included in the Original
|
||||
Code or Modifications.
|
||||
|
||||
IV. Inability to Comply Due to Contractual Obligation.
|
||||
Prior to licensing the Original Code under this License, Netscape
|
||||
has licensed third party code for use in Netscape's Branded Code.
|
||||
To the extent that Netscape is limited contractually from making
|
||||
such third party code available under this License, Netscape may
|
||||
choose to reintegrate such code into Covered Code without being
|
||||
required to distribute such code in Source Code form, even if
|
||||
such code would otherwise be considered "Modifications" under
|
||||
this License.
|
||||
|
||||
V. Use of Modifications and Covered Code by Initial Developer.
|
||||
V.1. In General.
|
||||
The obligations of Section 3 apply to Netscape, except to
|
||||
the extent specified in this Amendment, Section V.2 and V.3.
|
||||
|
||||
V.2. Other Products.
|
||||
Netscape may include Covered Code in products other than the
|
||||
Netscape's Branded Code which are released by Netscape
|
||||
during the two (2) years following the release date of the
|
||||
Original Code, without such additional products becoming
|
||||
subject to the terms of this License, and may license such
|
||||
additional products on different terms from those contained
|
||||
in this License.
|
||||
|
||||
V.3. Alternative Licensing.
|
||||
Netscape may license the Source Code of Netscape's Branded
|
||||
Code, including Modifications incorporated therein, without
|
||||
such Netscape Branded Code becoming subject to the terms of
|
||||
this License, and may license such Netscape Branded Code on
|
||||
different terms from those contained in this License.
|
||||
|
||||
VI. Litigation.
|
||||
Notwithstanding the limitations of Section 11 above, the
|
||||
provisions regarding litigation in Section 11(a), (b) and (c) of
|
||||
the License shall apply to all disputes relating to this License.
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
# Makefile for mstone
|
||||
# use gmake
|
||||
# Builds each of the components and then packages everything
|
||||
|
||||
topsrcdir = .
|
||||
|
||||
CP := cp -p
|
||||
|
||||
ifndef INCLUDED_CONFIG_MK
|
||||
include $(topsrcdir)/config/config.mk
|
||||
endif
|
||||
|
||||
|
||||
# dynamically find the optional directories names
|
||||
LIBGD_DIR = $(wildcard gd?.*)
|
||||
GNUPLOT_DIR = $(wildcard gnuplot-?.*)
|
||||
PERL_DIR = $(wildcard perl5.*)
|
||||
|
||||
# file that we package
|
||||
GDFILES = gd.txt gd.html libgd.* gd.h demoin.gif gddemo giftogd webgif
|
||||
GNUPLOTFILES = gnuplot Copyright gnuplot_x11 gnuplot.1 gnuplot.gih
|
||||
|
||||
VERSION = 4.3
|
||||
TARBALL = mstone-$(VERSION)-$(NSARCH)$(OBJDIR_TAG).tar.gz
|
||||
ZIPFILE = mstone-$(VERSION)-$(NSARCH)$(OBJDIR_TAG).zip
|
||||
TARBALL_ALL = mstone-$(VERSION)-all$(OBJDIR_TAG).tar.gz
|
||||
ZIPFILE_ALL = mstone-$(VERSION)-all$(OBJDIR_TAG).zip
|
||||
|
||||
NTFILES = mstone.bat process.bat setup.bat
|
||||
|
||||
all:: usage
|
||||
|
||||
usage::
|
||||
@$(ECHO) "gmake [ release | rpackage | debug | dpackage ]"
|
||||
@$(ECHO) " [ DIST=/m/dist/mailstone/1999xxxx dist ]"
|
||||
@$(ECHO) " [ all_DBG | all_OPT ]"
|
||||
@$(ECHO) "perl is" $(PERL_DIR) ". gd is" $(LIBGD_DIR) ". gnuplot is" $(GNUPLOT_DIR) "."
|
||||
|
||||
targets:: $(OBJDIR) mailclient
|
||||
|
||||
ifneq (,$(LIBGD_DIR))
|
||||
targets:: libgd
|
||||
endif
|
||||
|
||||
ifneq (,$(GNUPLOT_DIR))
|
||||
targets:: gnuplot
|
||||
endif
|
||||
|
||||
ifneq (,$(PERL_DIR))
|
||||
targets:: perl
|
||||
endif
|
||||
|
||||
$(OBJDIR):
|
||||
-mkdir -p $(OBJDIR)
|
||||
|
||||
mailclient::
|
||||
@$(ECHO) "\n===== [`date`] making OS_CONFIG=$(NSARCH) BUILD_VARIANT=$(BUILD_VARIANT)\n"
|
||||
cd src; $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) OBJDIR=../$(OBJDIR) PKGDIR=../$(PKGDIR) all
|
||||
|
||||
# Use our top level makefiles to drive the component builds
|
||||
libgd $(OBJDIR)/gd/libgd.a::
|
||||
$(MAKE) -f gd.mk LIBGD_DIR=$(LIBGD_DIR) libgd
|
||||
|
||||
gnuplot $(OBJDIR)/gnuplot/gnuplot::
|
||||
$(MAKE) -f gnuplot.mk LIBGD_DIR=$(LIBGD_DIR) GNUPLOT_DIR=$(GNUPLOT_DIR) gnuplot
|
||||
|
||||
perl $(OBJDIR)/perl/perl::
|
||||
$(MAKE) -f perl.mk PERL_DIR=$(PERL_DIR) perl
|
||||
|
||||
# Create packaging binary directories
|
||||
# Note: dont make gd or gnuplot here. For multi-OS, they are links
|
||||
mkpkgdirs:: $(PKGDIR)/bin $(PKGDIR)/conf $(PKGDIR)/data $(PKGDIR)/doc
|
||||
|
||||
$(PKGDIR)/bin:
|
||||
mkdir -p $(PKGDIR)/bin
|
||||
|
||||
$(PKGDIR)/conf:
|
||||
mkdir -p $(PKGDIR)/conf
|
||||
|
||||
$(PKGDIR)/data:
|
||||
mkdir -p $(PKGDIR)/data
|
||||
|
||||
$(PKGDIR)/doc:
|
||||
mkdir -p $(PKGDIR)/doc
|
||||
|
||||
$(PKGDIR)/gd:
|
||||
mkdir -p $(PKGDIR)/gd
|
||||
|
||||
$(PKGDIR)/gnuplot:
|
||||
mkdir -p $(PKGDIR)/gnuplot
|
||||
|
||||
$(PKGDIR)/perl:
|
||||
mkdir -p $(PKGDIR)/perl
|
||||
|
||||
|
||||
# operating system independent share-files (at least for Unix)
|
||||
pkg-share-files:: mkpkgdirs
|
||||
@$(ECHO) "\n===== [`date`] making package share-files...\n"
|
||||
$(CP) mstone process $(PKGDIR)
|
||||
(cd $(PKGDIR); [ ! -f setup ] || rm -f setup; ln -s mstone setup)
|
||||
(cd $(PKGDIR); [ ! -f cleanup ] || rm -f cleanup; ln -s mstone cleanup)
|
||||
(cd $(PKGDIR); [ ! -f checktime ] || rm -f checktime; ln -s mstone checktime)
|
||||
(cd $(PKGDIR); [ ! -f timesync ] || rm -f timesync; ln -s mstone timesync)
|
||||
-$(CP) nsarch bin/*.pl $(PKGDIR)/bin
|
||||
-$(CP) conf/*.wld conf/*.wld.in conf/*.html $(PKGDIR)/conf
|
||||
-$(CP) data/*.msg $(PKGDIR)/data
|
||||
-$(CP) doc/*.html doc/*.gif $(PKGDIR)/doc
|
||||
-$(CP) INSTALL $(PKGDIR)
|
||||
-$(CP) README $(PKGDIR)
|
||||
-$(CP) ChangeLog $(PKGDIR)
|
||||
-$(CP) LICENSE $(PKGDIR)
|
||||
|
||||
# split out OS specific file so that combined packaging possible (set PKGDIR)
|
||||
pkg-arch-files-gd:: $(PKGDIR)/gd $(OBJDIR)/gd/libgd.a
|
||||
$(CP) $(addprefix $(OBJDIR)/gd/, $(GDFILES)) $(PKGDIR)/gd
|
||||
-$(STRIP) $(PKGDIR)/gd/webgif $(PKGDIR)/gd/giftogd $(PKGDIR)/gd/gddemo
|
||||
|
||||
pkg-arch-files-gnuplot:: $(PKGDIR)/gnuplot $(OBJDIR)/gnuplot/gnuplot
|
||||
$(CP) $(addprefix $(OBJDIR)/gnuplot/, $(GNUPLOTFILES)) $(PKGDIR)/gnuplot
|
||||
-$(STRIP) $(PKGDIR)/gnuplot/gnuplot $(PKGDIR)/gnuplot/gnuplot_x11
|
||||
|
||||
ifneq (,$(LIBGD_DIR))
|
||||
pkg-arch-files:: pkg-arch-files-gd
|
||||
endif
|
||||
|
||||
ifneq (,$(GNUPLOT_DIR))
|
||||
pkg-arch-files:: pkg-arch-files-gnuplot
|
||||
endif
|
||||
|
||||
pkg-arch-files:: $(PKGDIR)/bin $(OBJDIR)/mailclient
|
||||
@$(ECHO) "\n===== [`date`] making package arch-files...\n"
|
||||
$(CP) $(OBJDIR)/mailclient $(PKGDIR)/bin
|
||||
-$(STRIP) $(PKGDIR)/bin/mailclient
|
||||
|
||||
pkg-perl-files:: $(PKGDIR)/bin $(OBJDIR)/perl/perl
|
||||
@$(ECHO) "\n===== [`date`] making package perl-files...\n"
|
||||
$(MAKE) -f perl.mk PERL_DIR=$(PERL_DIR) \
|
||||
BUILD_VARIANT=$(BUILD_VARIANT) \
|
||||
OBJDIR=$(OBJDIR) PKGDIR=$(PKGDIR) package-perl
|
||||
find $(PKGDIR)/perl/lib -name .packlist -exec rm {} \; -print
|
||||
-$(STRIP) $(PKGDIR)/perl/bin/perl
|
||||
-$(STRIP) $(PKGDIR)/perl/bin/a2p
|
||||
|
||||
# for combined packaging, this should not be part of pkg-arch-files
|
||||
# perl is handled seperately do to its size
|
||||
ifneq (,$(PERL_DIR))
|
||||
pkg:: pkg-perl-files
|
||||
endif
|
||||
|
||||
pkg:: targets pkg-share-files pkg-arch-files
|
||||
|
||||
tarball: build/$(TARBALL)
|
||||
|
||||
build/$(TARBALL):
|
||||
@$(ECHO) "\n===== [`date`] making os tar file...\n"
|
||||
-rm -f build/$(TARBALL)
|
||||
cd $(dir $(PKGDIR)) && tar cf - . | gzip > ../../$(TARBALL)
|
||||
|
||||
zipfile: build/$(ZIPFILE)
|
||||
|
||||
build/$(ZIPFILE):
|
||||
@$(ECHO) "\n===== [`date`] making os zip file...\n"
|
||||
-rm -f build/$(ZIPFILE)
|
||||
cd $(dir $(PKGDIR)) && zip -r -q ../../$(ZIPFILE) .
|
||||
|
||||
|
||||
########################################################################
|
||||
# Generate a combined build for every Unix OS that is already packaged
|
||||
# NT has to be done seperately because it has different file names
|
||||
# We have to nuke some old parts, because permissions wont allow overwrites
|
||||
# Finally, dont ship perl development headers and libraries
|
||||
all_DBG all_OPT::
|
||||
@$(ECHO) "===== [`date`] unified packaging for $@..."
|
||||
$(MAKE) NSARCH=$@ OBJDIR_TAG='' \
|
||||
PKGDIR=$(topsrcdir)/build/package/$@.OBJ/mstone pkg-share-files
|
||||
./ospkg.sh $@.OBJ \
|
||||
$(notdir $(shell ls -d build/package/[A-Z]*$(subst all,,$@.OBJ)))
|
||||
[ -d $(topsrcdir)/build/package/$@.OBJ/mstone/bin/WINNT4.0 ] \
|
||||
&& cp -p $(NTFILES) $(topsrcdir)/build/package/$@.OBJ/mstone; :
|
||||
-rm -f ./build/mstone-$(VERSION)-$@.tar.gz
|
||||
cd ./build/package/$@.OBJ \
|
||||
&& tar cf - . | gzip > ../../mstone-$(VERSION)-$@.tar.gz
|
||||
-rm -f ./build/mstone-$(VERSION)-$@.zip
|
||||
cd ./build/package/$@.OBJ \
|
||||
&& zip -r -q ../../mstone-$(VERSION)-$@.zip .
|
||||
|
||||
|
||||
########################################################################
|
||||
# Copy all the packaged trees to the distribution site
|
||||
# Copy in the unified tarball and zip file
|
||||
# Link mstone to mailstone for Netscape back compatibility
|
||||
# Re-map short Linux name to standard Netscape convention
|
||||
dist::
|
||||
@[ "$(DIST)" != "" ] || ($(MAKE) usage && /bin/false)
|
||||
@[ ! -d "$(DIST)" ] || ($(ECHO) "Error: $(DIST) already exists" && \
|
||||
$(MAKE) usage && /bin/false)
|
||||
mkdir -p $(DIST)
|
||||
cp -p build/mstone-$(VERSION)-all_*.*[a-z] $(DIST)/
|
||||
(cd build/package; tar cf - *.OBJ) | (cd $(DIST); tar xf - )
|
||||
for l in $(DIST)/*_???.OBJ ; do \
|
||||
(cd $$l; ln -s mstone mailstone); done
|
||||
cd $(DIST); for l in Linux*_???.OBJ ; do \
|
||||
nn=`echo $$l | sed -e 's/_OPT/_glibc_PTH_OPT/' | sed -e 's/_DBG/_glibc_PTH_DBG/'`; \
|
||||
ln -s $$l $$nn; done
|
||||
|
||||
# since the default is release mode, this can just work off a dependency
|
||||
release:: targets
|
||||
#release::
|
||||
# @$(ECHO) "\n===== [`date`] making release build..."
|
||||
# $(MAKE) BUILD_VARIANT=release OBJDIR_TAG=_OPT targets
|
||||
@$(ECHO) "\n===== [`date`] making release build done."
|
||||
|
||||
rpackage:: release pkg #tarball zipfile
|
||||
#rpackage:: release
|
||||
# @$(ECHO) "\n===== [`date`] making release package..."
|
||||
# $(MAKE) BUILD_VARIANT=release OBJDIR_TAG=_OPT pkg tarball zipfile
|
||||
@$(ECHO) "\n===== [`date`] making release package done."
|
||||
|
||||
# since the default is release mode, start a make with the right mode
|
||||
debug::
|
||||
@$(ECHO) "\n===== [`date`] making debug build..."
|
||||
$(MAKE) BUILD_VARIANT=debug OBJDIR_TAG=_DBG targets
|
||||
@$(ECHO) "\n===== [`date`] making debug build done."
|
||||
|
||||
# We dont usually bother to tar up a debug build
|
||||
dpackage:: debug
|
||||
@$(ECHO) "\n===== [`date`] making debug package..."
|
||||
$(MAKE) BUILD_VARIANT=debug OBJDIR_TAG=_DBG pkg
|
||||
@$(ECHO) "\n===== [`date`] making debug package done."
|
||||
|
||||
# These are old and may be broken
|
||||
cleanvariant::
|
||||
(cd src; $(MAKE) OBJDIR=../$(OBJDIR) clean)
|
||||
rm -rf $(PKGDIR)
|
||||
|
||||
clean::
|
||||
$(MAKE) BUILD_VARIANT=release OBJDIR_TAG=_OPT cleanvariant
|
||||
$(MAKE) BUILD_VARIANT=debug OBJDIR_TAG=_DBG cleanvariant
|
||||
|
||||
distcleanvariant::
|
||||
(cd src; $(MAKE) OBJDIR=../$(OBJDIR) distclean)
|
||||
rm -rf $(OBJDIR) $(PKGDIR)
|
||||
|
||||
distclean:: clean
|
||||
$(MAKE) BUILD_VARIANT=release OBJDIR_TAG=_OPT distcleanvariant
|
||||
$(MAKE) BUILD_VARIANT=debug OBJDIR_TAG=_DBG distcleanvariant
|
||||
@@ -1,75 +0,0 @@
|
||||
|
||||
MSTONE 4.2
|
||||
|
||||
Mstone is a mail server performance testing tool designed to simulate
|
||||
the different types and volume of mail traffic a mail server would
|
||||
experience during a peak activity period. Mstone was formerly known
|
||||
as Mailstone.
|
||||
|
||||
A quick installation guide is available in INSTALL.
|
||||
|
||||
The full Mailstone 4.15 user manual is available at
|
||||
http://lxr.mozilla.org/mozilla/source/mstone/doc/MailStone.html
|
||||
|
||||
Testing strategy
|
||||
----------------
|
||||
|
||||
Mstone is capable of opening SMTP, POP3, IMAP4, and other protocol
|
||||
connections to mail servers. The number and type of connections made
|
||||
to the mail server is based on a weighted command list which provides
|
||||
the ability to test mail server implementation requirements.
|
||||
|
||||
A series of perl script allow you to setup client machines, run tests,
|
||||
and then cleanup client machine files. Each client machine has a copy
|
||||
of the mailclient program and SMTP message files. When the test is
|
||||
run, the mailclient is started with the proper command line and work load.
|
||||
|
||||
After experimenting with mstone loads, you will notice that there
|
||||
are a few factors that can distort server the byte and message
|
||||
throughput. You will find that the server byte throughput is related
|
||||
to the average SMTP message (file) size. Also, server throughput, in
|
||||
bytes and messages, is affected by larger than normal POP3/IMAP4
|
||||
mailboxes. So it is important to approach the mstone command
|
||||
configuration with data collected from existing mail server
|
||||
implementations, for example, a customer might say "during our peak
|
||||
activity in the morning, we handle up to two thousand employees
|
||||
sending an average of 5 messages of 20K average size and receiving 25
|
||||
messages of same size". With input like this, you can begin tuning
|
||||
mstone to generate relevant data.
|
||||
|
||||
There are two important things to consider when reviewing the results of
|
||||
mstone performance analysis: Was the test run on target for
|
||||
simulating the type and volume of mail traffic; and did the server, both
|
||||
software and machine, handle the load within an acceptable margin?
|
||||
|
||||
With this information, it can be determined: whether enough SMTP
|
||||
connections were made to the server during the run, and how many
|
||||
messages were downloaded over how many POP3/IMAP4 connections. If the
|
||||
number of SMTP connections is not in the acceptable range, then
|
||||
consider adding more client processes/machines or checking the server
|
||||
performance during the run. The message/connection ratio for
|
||||
POP3/IMAP4 should be checked for soundness, and adjustments should be
|
||||
made to the mailboxes before running the next test.
|
||||
|
||||
Monitoring the server performance during test runs is crucial in
|
||||
understanding the results. If the number of client connections is not
|
||||
being achieved and the server cpu usage and process run queue is not
|
||||
settling down after the initial spike, then modifications to the server
|
||||
architecture could be in order.
|
||||
|
||||
The analysis of mstone results is an iterative process of client
|
||||
(mstone client) and server tuning. The bottom line is to determine
|
||||
whether the messaging solution can handle the type of load expected in
|
||||
an acceptable manner.
|
||||
|
||||
|
||||
Server Log Tuning
|
||||
-----------------
|
||||
The Messaging and Directory server ship with access logging enabled by
|
||||
default. This gives the most information about what is going on in
|
||||
the system, but can reduce performance. You should test the way the
|
||||
system will be run.
|
||||
|
||||
Noticeable performance increases are often obtained by disabling access
|
||||
logging on the directory server and by reducing the logging level of
|
||||
the messaging servers from "Notice" to "Warning".
|
||||
@@ -1,16 +0,0 @@
|
||||
Under the terms of the Mozilla Public License, Version 1.1, granted
|
||||
by Mozilla, Sendmail Inc. is contributing the following Source Code
|
||||
changes to the Mozilla mstone source repository.
|
||||
|
||||
Sendmail, Inc. is making available these source code modifications
|
||||
according to the Distribution Obligations as listed in section 3
|
||||
of the Mozilla Public License, Version 1.1
|
||||
|
||||
The changes provided herein are described in the included files:
|
||||
|
||||
README.Sendmail-mstone_changes.html
|
||||
ChangeLog-Sendmail
|
||||
|
||||
All modifications are derived, directly or indirectly, from the original
|
||||
code as provided by Mozilla.
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
<html>
|
||||
<head><title>Sendmail, Inc. Mstone changes</title></head>
|
||||
<body>
|
||||
|
||||
<h3>Mstone modifications</h3>
|
||||
|
||||
<ol>
|
||||
<li><h4>Random Variable Parameters</h4>
|
||||
|
||||
In addition to taking on constant values, some parameters can now be
|
||||
sampled from probability distributions. These variables are:
|
||||
<ul>
|
||||
<li><code>startDelay</code>
|
||||
<li><code>idleTime</code>
|
||||
<li><code>blockTime</code>
|
||||
<li><code>loopDelay</code>
|
||||
<li><code>numRecips</code>
|
||||
<li><code>size</code>
|
||||
<li><code>headers</code>
|
||||
<li><code>mime</code>
|
||||
<li><code>leaveMailOnServer</code>
|
||||
<li><code>bandwidth</code>
|
||||
<li><code>latency</code>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
The following distributions are currently implemented:
|
||||
<ul>
|
||||
<li>Uniform (~unif(a, b))
|
||||
<li>Normal (~normal(a, b))
|
||||
<li>Log-Normal (~lognormal(a, b))
|
||||
<li>Weibull (~weib(a, b, c))
|
||||
<li>Exponential (~exp(a))
|
||||
<li>Constant (~const(a))
|
||||
<li>Binomial (~binomial(a))
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Sampled values may also be constrained by a minimum and maximum value.
|
||||
This is particularly useful for e.g. the normal and lognormal
|
||||
distributions, though over-tight constraints will create a "lump" at
|
||||
the end of the generated distribution, and any constraints may change
|
||||
the distribution's characteristics (e.g. mean). To specify
|
||||
constraints, do the following:
|
||||
|
||||
<h5>getdist</h5>
|
||||
|
||||
<p>
|
||||
There is also a helper tool called "getdist" in the Sendmail mstone
|
||||
distribution. Building getdist:
|
||||
|
||||
<pre>
|
||||
file: mstone/src/idle.c
|
||||
# gcc -DTEST_PROB -Dxalloc=malloc -Dxfree=free -lm idle.c
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Rename the resulting binary to "getdist"
|
||||
|
||||
<p>
|
||||
<b>Using getdist</b>
|
||||
|
||||
<p>
|
||||
To run it interactively:
|
||||
|
||||
<ol>
|
||||
<li>Start up getdist</li>
|
||||
<li>Enter the distribution you want to see a sample and mean (ignore warning about 'gets()')</li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
Example:
|
||||
|
||||
<pre>
|
||||
% getdist
|
||||
warning: this program uses gets(), which is unsafe.
|
||||
~lognormal(3,4.5)
|
||||
Samples:
|
||||
6.846493
|
||||
0.109578
|
||||
31.402784
|
||||
0.467486
|
||||
21.905714
|
||||
7.113645
|
||||
0.225102
|
||||
29.372181
|
||||
4.252427
|
||||
1.444493
|
||||
mean: 29.128932
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
It will only OUTPUT 10 samples as examples but the mean
|
||||
is calculated based on 2000 samples by default. You can specify
|
||||
the mean sample size on the command line by giving it a -n option:
|
||||
|
||||
<pre>
|
||||
% getdist -n 1000000
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
This will calculate the mean based on a sample of 1000000 entries.
|
||||
|
||||
<p>
|
||||
The above data was calculated with 2M samples.
|
||||
|
||||
<p>
|
||||
<i>Known Problems</i><BR>
|
||||
It appears (anecdotally) that the first set of samples returned by
|
||||
getdist are inaccurate. After starting the getdist program interactively,
|
||||
it may appear necessary to ignore the first set of output, but that entering
|
||||
the distribution again will return a more accurate result.<BR>
|
||||
|
||||
<p>
|
||||
For example:
|
||||
|
||||
<pre>
|
||||
# getdist
|
||||
~lognormal(10,2)
|
||||
Samples:
|
||||
670043.575395
|
||||
48.842052
|
||||
54.039792
|
||||
0.460849
|
||||
2.152179
|
||||
32.534664
|
||||
6.163511
|
||||
42.827706
|
||||
27.806642
|
||||
4.966444
|
||||
mean: 364.747532
|
||||
var: 224352671.855287
|
||||
stddev: 14978.406853
|
||||
~lognormal(10,2)
|
||||
Samples:
|
||||
1.842800
|
||||
39.760727
|
||||
4.798239
|
||||
10.722216
|
||||
27.052030
|
||||
28.923926
|
||||
61.504273
|
||||
20.743583
|
||||
5.373420
|
||||
42.195531
|
||||
mean: 25.510130
|
||||
var: 2674.124997
|
||||
stddev: 51.711942
|
||||
</pre>
|
||||
|
||||
|
||||
<dl>
|
||||
<dt><code>~dist(...) : [min,]</code>
|
||||
<dd>force all sampled values to be >= <code>min</code>
|
||||
<dt><code>~dist(...) : [min,max]</code>
|
||||
<dd>force all sampled values X to be <code>min</code> <= X <= <code>max</code>.
|
||||
<dt><code>~dist(...) : [,max]</code>
|
||||
<dd>force values to be <= <code>max</code>
|
||||
</dl>
|
||||
|
||||
<li><h4>Parsing Changes</h4>
|
||||
|
||||
All of the time-valued test parameters except <code>rampTime</code>
|
||||
and <code>time</code> now have millisecond values. In particular,
|
||||
this means that a value of "17" parses to 17
|
||||
<strong>milliseconds</strong>, not 17 seconds. Use "17s" instead.
|
||||
<p>
|
||||
|
||||
Size-valued parameters can have units of "k" or "m" to indicate
|
||||
kilobytes or megabytes, respectively.
|
||||
<p>
|
||||
|
||||
For parameters supporting random-variable values, a value starting
|
||||
with "~" will be interpreted as a random variable specification of the
|
||||
form "~NAME([ARGS ...])". Unit suffixes (e.g. "s", and "m") apply to
|
||||
random variable parameters as well as constant values. This implies
|
||||
that for unitless parameters, the suffixes corresponding to the random
|
||||
variable's units will still be recognized (i.e. the values will be
|
||||
multiplied by the appropriate factors). This is probably best
|
||||
considered as a "bug" rather than excercised as a "feature."
|
||||
<p>
|
||||
|
||||
<code>blockTime</code>, <code>loopDelay</code>, and
|
||||
<code>idleTime</code> now refer to the total amount of time a command
|
||||
block, loop, and initialization phase should take, respectively, not
|
||||
the amount of time the simulation should stall after completing each
|
||||
phase. For example, if a block takes 2 seconds to complete, and the
|
||||
block time is 4 seconds, the client thread will sleep for 2 seconds
|
||||
after finishing instead of the full 4.<p>
|
||||
|
||||
<code>rampTime</code> is now solely for the benefit of the client
|
||||
machines, to control the rate at which threads are started. The rate
|
||||
at which commands from a given protocol are started is now controlled
|
||||
by the <code>startDelay</code> variable, which is
|
||||
distribution-valued. Thus the actual command loop now looks like
|
||||
this:
|
||||
|
||||
<pre>
|
||||
wait for startDelay
|
||||
start counting idleTime
|
||||
start counting blockTime
|
||||
execute start function
|
||||
wait for remainder of idleTime
|
||||
for (1 ... numLoops)
|
||||
start counting loopDelay
|
||||
execute loop function
|
||||
wait for remainder of loopDelay
|
||||
execute end function
|
||||
wait for remainder of blockTime
|
||||
</pre>
|
||||
|
||||
<li><h4>Automatic Message Generation</h4>
|
||||
|
||||
Both MIME and text/plain messages can now be generated automatically.
|
||||
To enable automatic message generation, set the <code>file</code>
|
||||
attribute of an SMTP block to "auto". The messages will then have at
|
||||
least as many headers as the value of the <code>headers</code>
|
||||
attribute, have bodies <code>size</code> bytes long, and have
|
||||
<code>mime</code> MIME parts. To generate text/plain messages, set
|
||||
<code>mime</code> to zero.
|
||||
|
||||
<table border=1 cellpadding=2>
|
||||
<tr><th>Attribute</th><th>Description</th></tr>
|
||||
|
||||
<tr>
|
||||
<td><code>headers <i>N</i></code></td>
|
||||
<td>(optional; default=5) Each automatically generated message will
|
||||
have <code>min(<i>N</i>, min_hdrs)</code> headers, where
|
||||
<code>min_hdrs</code> is 5 for text/plain, and about 7 for MIME
|
||||
messages. Additional headers are named
|
||||
"X-generated-header-%d". </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>size <i>N</i></code></td>
|
||||
<td>(required) Each generated message will have a body be <i>N</i>
|
||||
bytes long.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>mime <i>N</i></code></td>
|
||||
<td>Each generated message will have <code>N</code> MIME parts. If
|
||||
the value of <code>size</code> does not allow <code>N</code> parts,
|
||||
one part is generated. If <code>N</code> is zero, the message is
|
||||
text/plain.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code>checksum <i>{yes|no|save}</i></code></td>
|
||||
<td>For SMTP: each generated message will have the MD5 sum of the
|
||||
message body appended to the message unless the value is <i>no</i>.
|
||||
For retrieval protocols, checksums will be verified. (NOT
|
||||
IMPLEMENTED: if <code>checksum</code> is <i>save</i>, messages with
|
||||
incorrect checksums will be saved to temporary files for later
|
||||
examination.) </td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<li><h4>Linespeed Emulation</h4>
|
||||
|
||||
SMTP, POP, and IMAP all support a form of linespeed emulation,
|
||||
controlled via the <code>latency</code> and <code>bandwidth</code>
|
||||
parameters.
|
||||
|
||||
<table border=1 cellpadding=2>
|
||||
<tr><th>Attribute</th><th>Description</th></tr>
|
||||
|
||||
<tr><td><code>latency <i>N</i></code></td>
|
||||
<td>Set the network latency to <code>N</code> milliseconds.</td></tr>
|
||||
|
||||
<tr><td><code>bandwidth <i>N</i></code></td>
|
||||
|
||||
<td>Transfer at most <code>N</code> bytes per second.</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<li><h4>TLS support</h4>
|
||||
|
||||
If you have openssl, mstone now supports STARTTLS for SMTP and IMAP,
|
||||
and STLS for POP (both old-style and MULTIPOP), as well as SSL
|
||||
tunneling. This support is <strong>not</strong> well-tested, and TLS
|
||||
can be a bit tricky to set up, so use at your own risk. TLS
|
||||
introduces several new attributes to the protocol blocks:
|
||||
|
||||
<table border=1 cellpadding=2>
|
||||
<tr><th>Attribute</th><th>Description</th></tr>
|
||||
|
||||
<tr><td><code>sslcert <i>filename</i></code></td>
|
||||
<td>Read the client's cert from <i>filename</i>, which should be in
|
||||
PEM format. </td></tr>
|
||||
|
||||
<tr><td><code>sslkey <i>filename</i></code></td>
|
||||
|
||||
<td>Read the client's private key from <i>filename</i>, which should
|
||||
be in PEM format.</td></tr>
|
||||
|
||||
<tr><td><code>usetls {0|1}</code></td>
|
||||
|
||||
<td>Turn STARTTLS/STLS on or off (default: off). <b>Note</b>:
|
||||
<code>starttls</code> and <code>ssltunnel</code> are mutually
|
||||
exlcusive.</td></tr>
|
||||
|
||||
<tr><td><code>ssltunnel {0|1}</code></td>
|
||||
|
||||
<td>Turn SSL tunneling on or off (default: off).</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<li><h4>"Multi-POP" protocol</h4>
|
||||
|
||||
<b>Note</b>: multipop, always a band-aid, is hopefully obsoleted by
|
||||
the new event-queue execution model. Though it has not been tested,
|
||||
it should be easier, more efficient, and more accurate to use the
|
||||
normal POP protocol with events to simulate a large number of users
|
||||
with a reasonable number of threads. Once this has been tested,
|
||||
automatically-generated workloads should revert to using POP.
|
||||
|
||||
<p>To simulate a large number of concurrently active POP users with
|
||||
Mstone's extravagant use of threads, and to simulate a period of
|
||||
activity comprised of several POP sessions one can use the MULTIPOP
|
||||
protocol to multiplex active users onto a single thread. The protocol
|
||||
has all the same parameters as POP, plus the following:
|
||||
|
||||
<table border=1 cellpadding=2>
|
||||
<tr><th>Attribute</th><th>Description</th></tr>
|
||||
|
||||
<tr><td><code>userSpacing</code></td>
|
||||
|
||||
<td>Total time for each user's session.</td>
|
||||
</tr>
|
||||
<tr><td><code>usersPerModem</code></td>
|
||||
|
||||
<td>The maximum number of concurrently connected users is limited
|
||||
to <code>users / usersPerModem</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
The protocol functions are substantially different. Instead of
|
||||
simulating a single login-check-logout sequence, a protocol block
|
||||
simulates an entire active period for a set of users. Each user
|
||||
checks mail once in the initialization function, once each time the
|
||||
loop body is executed, and once more in the protocol conclusion
|
||||
function.
|
||||
<p>
|
||||
|
||||
<li><h4>"Event-queue" implementation</h4>
|
||||
|
||||
<p>
|
||||
Unless the "noevents" parameter in the "<config>" section is set to 1,
|
||||
or mailclient is not given the "-e" flag, mstone will run in
|
||||
"event-queue" mode. Instead of creating one thread per client, it
|
||||
will multiplex clients over a much smaller number of threads. This is
|
||||
intended to increase the tool's scalability.
|
||||
|
||||
<p>
|
||||
Note that I/O is still synchronous with this model, so the number of
|
||||
threads required will approximately equal the maximum number of
|
||||
concurrent operations. Also note that this change does not reduce the
|
||||
number of required file descriptors.
|
||||
|
||||
<p>
|
||||
|
||||
<li><h4>Other Minor Additions</h4>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>IMAP now has a ramp-down time, enabled by defining
|
||||
<code>IMAP_RAMPDOWN</code>. IMAP threads now exit uniformly between
|
||||
the time the test is supposed to be over and the time Mstone starts
|
||||
killing them.
|
||||
|
||||
<li>Mstone used to always time out connections after 60 seconds. The
|
||||
timeout value can now be configured on a per-block basis via the
|
||||
<code>timeout</code> parameter. The value of the timeout parameter must
|
||||
be defined in milliseconds, so the following value would mean a timeout
|
||||
of one (1) hour:<BR>
|
||||
|
||||
timeout 3600000
|
||||
|
||||
<li>Simplified client allocation. It is now possible to specify the
|
||||
number of clients in each group by specifying a value for
|
||||
<code>clients</code> in each <code><CLIENT></code> section and
|
||||
<em>not</em> specifying a global <code>clientCount</code> in the
|
||||
<code><CONFIG></code> section.
|
||||
|
||||
</ul>
|
||||
|
||||
<li><h4>Bug Fixes</h4>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>SMTP now ignores debugging output appearing over the connection.
|
||||
Before, Mstone would generate an error when talking to
|
||||
e.g. <code>sendmail -d64.5</code>.
|
||||
|
||||
<li>(now it works...) The old sequence of IMAP commands used by
|
||||
Mstone was incorrect. Instead of only downloading unread messages, it
|
||||
would download all messages received since the start of the session
|
||||
each time a new messages was received. Depending on what you were
|
||||
doing, this could have a serious effect on your results.
|
||||
|
||||
</ul>
|
||||
|
||||
<li><h4>Wish List</h4>
|
||||
|
||||
<ul>
|
||||
<li>Scriptable user behavior for POP and IMAP protocols. While we should
|
||||
probably not go overboard, adding more configuration options to Mstone
|
||||
is probably not the answer. There is already some support for more
|
||||
complex behaviors in the IMAP code -- we may or may not want to make
|
||||
use of it. More to the point, wider coverage of the IMAP
|
||||
protocol is vital to QA's use of the tool.
|
||||
</ul>
|
||||
|
||||
</ol>
|
||||
</body></html>
|
||||
@@ -1,189 +0,0 @@
|
||||
Mstone TODO List
|
||||
|
||||
Updated:
|
||||
3-20-2000 Dan Christian
|
||||
|
||||
======================================================================
|
||||
Minor improvements
|
||||
|
||||
Data reduction at each testbed client
|
||||
|
||||
Test message generator (plain and MIME styles)
|
||||
|
||||
More graphs for multiple runs
|
||||
|
||||
Option to drop a fraction of connections
|
||||
|
||||
IMAP delete without reading
|
||||
Just get the message list and delete everything. This could
|
||||
be the fastest way to drain out the store.
|
||||
|
||||
|
||||
Display MIN/MAX or standard deviation on graphs
|
||||
Gnuplot can do data points with error bars. You could either
|
||||
use MIN/MAX or the standard deviation for the error bars. There are
|
||||
issues with calculating the standard deviation numbers throughout the
|
||||
graph that need to be addressed.
|
||||
|
||||
|
||||
Statistics reset
|
||||
At least the MIN and MAX statistics could be easily reset
|
||||
during the test (after ramp up). This keeps the transients during
|
||||
startup and shutdown from dominating these numbers. The standard
|
||||
deviation statistics are much trickier to reset during the run. It
|
||||
may be better to isolate sections in post processing.
|
||||
|
||||
|
||||
Perl web server
|
||||
Sometimes it would be nice to include our own web server to
|
||||
provide the results (instead of using file: URLs). This would also be
|
||||
a gateway to form based test configuration editing and allow results
|
||||
to be interactively updated during tests. Perl with a socket library
|
||||
could handle this without too much trouble.
|
||||
|
||||
|
||||
Dynamic test loading
|
||||
Finalize an API for dynamically loading tests. This would
|
||||
allow tests to be added or updated separately from the core
|
||||
functionality. This may be needed for some types of security testing.
|
||||
|
||||
|
||||
Link graphs to the results tables
|
||||
There are already tags by each graph. You should be able to
|
||||
link the appropriate results table entry to each graph. This sort of
|
||||
tricky since graphs often combine multiple entries.
|
||||
|
||||
|
||||
Show statistics for every block
|
||||
Statistics are actually kept for every block in every thread.
|
||||
There should be a way to view information at this detail.
|
||||
|
||||
|
||||
Man pages
|
||||
The online docs are nice, but good 'ol man pages would be
|
||||
great in a different way.
|
||||
|
||||
|
||||
Reduce namespace polution
|
||||
Scripts names like setup and cleanup are too general. They
|
||||
|
||||
should be part of the main 'mstone' script (e.g. mstone setup).
|
||||
|
||||
Examples of script series
|
||||
Include example scripts to run entire series of tests in a
|
||||
sane way.
|
||||
|
||||
|
||||
Fix FORMAT clash
|
||||
At the start of a test, each client process outputs the
|
||||
information needed to report all its protocols. When there are
|
||||
multiple processes on one client, these FORMAT lines can intermix and
|
||||
cause parsing errors.
|
||||
|
||||
|
||||
Set connection drop rate
|
||||
Drop some percentage of the connections without a proper
|
||||
shutdown. This tests how well a server can detect and recover from
|
||||
hard disconnects.
|
||||
|
||||
|
||||
Improve randomness
|
||||
The way that we generate random numbers in a range may be not
|
||||
generate the proper randomness. We are using lrand48()%range we
|
||||
should use (lrand48/RAND_RANGE)*range. There are some end conditions
|
||||
that need to be thought about. All of this is in the sequence code;
|
||||
one change should fix (or break :) everything.
|
||||
|
||||
Also, we may be generating numbers that are never used. This
|
||||
may be costly, and can create holes in the proper sequence.
|
||||
|
||||
|
||||
Improve printing
|
||||
The color graphs are great on screen, but tend to print
|
||||
poorly. Either we need a better way to generate a printable version
|
||||
(maybe through a CGI button), or the seperate protocols need to be
|
||||
printed individually. Also, Communicator does a lousy job of keeping
|
||||
title with tables or graphs. Hopefully, Mozilla will do better.
|
||||
|
||||
|
||||
======================================================================
|
||||
Whole new protocol tests:
|
||||
|
||||
ICQ
|
||||
Test high volume instant messaging. Very useful for the
|
||||
bridges and gateways that people are considering using.
|
||||
|
||||
|
||||
WAP
|
||||
WAP is the emerging standard for mobile phones.
|
||||
|
||||
|
||||
WCAP
|
||||
Web based calendar services
|
||||
|
||||
|
||||
LDAP
|
||||
Use the LDAP SDK to do basic LDAP testing. The SDK probably
|
||||
isn't fast enough to call this a real performance test, but you can at
|
||||
least test performance degredation due to load from a real application
|
||||
(like a mail server).
|
||||
|
||||
|
||||
DNS
|
||||
Mail servers use DNS a lot. You should at least be able to
|
||||
see if performance is degrading due to load.
|
||||
|
||||
|
||||
Disk/filesystem
|
||||
Test read, write, sync, link, un-link, and append performance under
|
||||
multiple threads.
|
||||
|
||||
|
||||
Cert servers
|
||||
Test certificate authenticity checking performance
|
||||
|
||||
|
||||
======================================================================
|
||||
Possible dummy servers:
|
||||
|
||||
SMTP
|
||||
Receive mail via SMTP and ignore it. Usefull for SMTP relay
|
||||
testing.
|
||||
|
||||
|
||||
DNS
|
||||
Simulate slow DNS server lookups. Usefull for SMTP relay testing.
|
||||
|
||||
|
||||
======================================================================
|
||||
Major changes
|
||||
|
||||
Throttling
|
||||
Monitor and control transaction rates so that specific load
|
||||
levels can be easily specified. The rates should be able to vary to
|
||||
simulate peek hour usage and disconnect-restore.
|
||||
|
||||
|
||||
NSPR threading
|
||||
Use NSPR for threading and sockets. This may allow other OSes
|
||||
to be used as clients. This might be easy, since mstone does not need
|
||||
any locking, just simple thread creation and harvesting. NSPR
|
||||
argument parsing and hashes may also be useful.
|
||||
|
||||
|
||||
SSL
|
||||
Support SSL on the protocols that allow it. May require NSPR.
|
||||
|
||||
|
||||
Line speed emulation
|
||||
Simulate the variable delays and limited throughput of dial up
|
||||
connections.
|
||||
|
||||
|
||||
Scripting
|
||||
Allow more detailed control of protocol tests. It looks
|
||||
difficult to make this scalable and fast.
|
||||
|
||||
|
||||
Combined tests
|
||||
Deliver mail over SMTP and then see when it arrives using IMAP.
|
||||
@@ -1,462 +0,0 @@
|
||||
#!/bin/ksh
|
||||
########################################################################
|
||||
# buildall - automated multi-platform build tool
|
||||
#
|
||||
# 10/09/97 - marcel - created
|
||||
# 10/13/97 - marcel - support shared build tree
|
||||
# 2/11/98 - marcel - updated for 4.0 Beta builds (need -update)
|
||||
# 2/26/98 - marcel - added -r, -t and host specifiers
|
||||
# 7/01/99 - robodan - added VAR=value ability
|
||||
# 8/01/99 - robodan - explicitly know about building on localhost
|
||||
# 10/15/99 - robodan - remove older OSes from build list
|
||||
# 2000/4/7 - robodan - Created mstone version
|
||||
########################################################################
|
||||
#
|
||||
# This script is intended to do a set of UNIX builds for a
|
||||
# given CVS module. It is designed to use 'rsh' between a
|
||||
# set of trusting hosts and use shared NFS storage with common
|
||||
# mount points (e.g. /u/username/...)
|
||||
#
|
||||
# To check if you have rights to rsh to a particular host, try:
|
||||
# rsh hostname "echo $PATH"
|
||||
# You may have to edit your .rhosts or /etc/hosts.equiv
|
||||
#
|
||||
# A target directory will be created based on the current date.
|
||||
#
|
||||
# A set of global build logs plus a log per platform are kept
|
||||
# in a log directory under the target
|
||||
#
|
||||
# It will checkout a copy of the source, duplicate it for
|
||||
# each platform and perform a set of remote builds in parallel.
|
||||
# The script will exit when all the work has been completed.
|
||||
#
|
||||
# Example usage:
|
||||
# cd ~/src; buildall msg
|
||||
# Result:
|
||||
# ~/src/19980210_40.1/
|
||||
# ~/src/19980210_40.1/logs/...
|
||||
# ~/src/19980210_40.1/src/...
|
||||
# ...
|
||||
#
|
||||
|
||||
# Buildhosts
|
||||
DEFAULT_BUILDHOSTS="kimo nugget vsync shave purgatory trex0"
|
||||
|
||||
usage() {
|
||||
echo ""
|
||||
echo "usage: buildall [ make assigns... ] < -t | target > [ -r ] [ buildhosts... ]"
|
||||
echo " [ -t | --test]: just test rsh and report OS versions."
|
||||
echo " [-r | --respin]: rebuild in place using existing source."
|
||||
echo " [-p | --postbuild]: Execute post build command too."
|
||||
echo " [make assigns]: e.g. VARIANT=release"
|
||||
echo " <target>: one of: mstone42"
|
||||
echo " [buildhosts...]: default [$DEFAULT_BUILDHOSTS]"
|
||||
echo ""
|
||||
exit 1
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# Set these defaults and options for your desired build
|
||||
########################################################################
|
||||
|
||||
# Target base destination directory
|
||||
DESTBASE=`pwd`
|
||||
|
||||
# Can we do multiple ARCH builds in same source tree
|
||||
SHARESRC=yes
|
||||
|
||||
DESCRIPTION=""
|
||||
BUILDHOSTS=""
|
||||
RESPIN="no"
|
||||
POSTBUILD="no"
|
||||
JUST_TEST="no"
|
||||
DESTTYPE=""
|
||||
CO_CMD="cvs -d $CVSROOT -q checkout"
|
||||
CHECKOUT=""
|
||||
CHECKOUT2=""
|
||||
#MOZCVSROOT=':pserver:anonymous@cvs.mozilla.org:/cvsroot'
|
||||
MOZCVSROOT=':pserver:robodan%netscape.com@cvs.mozilla.org:/cvsroot'
|
||||
|
||||
MAKE="gmake"
|
||||
MK_ARG=""
|
||||
|
||||
ARGS="$@"
|
||||
|
||||
for ARG in "$@"; do
|
||||
|
||||
# If this is a make assignment (FOO=whatever), add it to make command
|
||||
# Arguments with quotes in them dont go all the way through.
|
||||
# Make args trick: 'FOO=nop -j 2'
|
||||
# The pre-post arg stuff uses hostnames as a switch, ugly calling syntax.
|
||||
if [[ -n "`echo z$ARG | egrep '^z[A-Z0-9_]+=[^ ]'`" ]] ; then
|
||||
if [[ -n "$DESCRIPTION" ]] ; then
|
||||
echo "Arg after target is ignored! ($ARG)"
|
||||
continue
|
||||
fi
|
||||
if [[ -z "$BUILDHOSTS" ]] ; then # pre args
|
||||
MAKE="$MAKE $ARG"
|
||||
else # post args
|
||||
MK_ARG="$MK_ARG $ARG"
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
# should we just rebuild todays latest source...
|
||||
if [[ "$ARG" = "-r" || "$ARG" = "--respin" || "$ARG" = "respin" ]]; then
|
||||
RESPIN="yes"
|
||||
continue
|
||||
fi
|
||||
|
||||
# should we just run post build command...
|
||||
if [[ "$ARG" = "-p" || "$ARG" = "--postbuild" || "$ARG" = "postbuild" ]]; then
|
||||
POSTBUILD="yes"
|
||||
continue
|
||||
fi
|
||||
|
||||
# should we just test remote connectivity and execute permissions...
|
||||
if [[ "$ARG" = "-t" || "$ARG" = "--test" ]]; then
|
||||
JUST_TEST="yes"
|
||||
RESPIN="yes"
|
||||
continue
|
||||
fi
|
||||
|
||||
# We will pull source using: "$CHECKOUT"
|
||||
# And build on each machine: "cd $BUILDDIR && $BUILDCMD"
|
||||
|
||||
|
||||
# expand targets (but dont confuse hosts for targets (msg7))
|
||||
|
||||
# These will build just mstone
|
||||
# expand targets (but dont confuse hosts for targets (msg7))
|
||||
if [[ "$BUILDCMD" = "" && "$ARG" = mailstone* ]]; then
|
||||
case ${ARG#mstone} in
|
||||
"")
|
||||
"42")
|
||||
DESTTYPE=_MSTONE42
|
||||
MS_BRANCH=""
|
||||
#BUILDCMD="$MAKE $MK_ARG debug release"
|
||||
#POSTCMD="$MAKE $MK_ARG all_DBG.OBJ all_OPT.OBJ"
|
||||
BUILDCMD="$MAKE $MK_ARG rpackage"
|
||||
POSTCMD="$MAKE $MK_ARG all_OPT"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown mstone version in $ARG"
|
||||
echo "Try mstone42"
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
DESCRIPTION="Mstone $MS_BRANCH"
|
||||
BUILDDIR=./mozilla/mstone
|
||||
CVSROOT=$MOZCVSROOT
|
||||
CHECKOUT="$CO_CMD $MS_BRANCH mozilla/mstone"
|
||||
# BUG No way to unpack perl, gd, and gnuplot before building
|
||||
continue
|
||||
fi
|
||||
|
||||
#########################
|
||||
# Other...
|
||||
#########################
|
||||
|
||||
# These will print some tools info
|
||||
if [[ "$ARG" = "tools" ]]; then
|
||||
CHECKOUT="$CO_CMD modules"
|
||||
BUILDDIR=.
|
||||
BUILDCMD="which gcc && ls -l /tools/ns/bin/gcc && which gcc-2.7.2.1 && ls -l /tools/ns/bin/gcc-2.7.2.1"
|
||||
continue
|
||||
fi
|
||||
|
||||
#########################
|
||||
# Everything else is assumed to be a hostname
|
||||
#########################
|
||||
|
||||
BUILDHOSTS="$ARG $BUILDHOSTS"
|
||||
|
||||
done # for ARG in $*; do
|
||||
|
||||
if [[ "$BUILDHOSTS" = "" ]]; then
|
||||
BUILDHOSTS=$DEFAULT_BUILDHOSTS
|
||||
fi
|
||||
|
||||
if [[ "$BUILDCMD" = "" && "$JUST_TEST" = "no" ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
########################################################################
|
||||
# You shouldn't have to modify stuff below here too much
|
||||
########################################################################
|
||||
|
||||
# Who and Where are we
|
||||
PROG=buildall
|
||||
RSH=rsh
|
||||
SYS=`uname -s`
|
||||
echo SYS=$SYS
|
||||
if [[ "$SYS" = "HP-UX" ]]; then
|
||||
RSH=remsh
|
||||
fi
|
||||
|
||||
########################################################################
|
||||
# Simple log output function
|
||||
########################################################################
|
||||
|
||||
log() {
|
||||
# echo "[`date +\"%Y/%m/%d %H:%M:%S\"`] $PROG: $*"
|
||||
echo "`date +\"%H:%M:%S\"` $PROG: $*"
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# Error
|
||||
########################################################################
|
||||
|
||||
quit() {
|
||||
log "$* (exiting)..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Where should the work be done
|
||||
REV=1
|
||||
WORKDIR=$DESTBASE/`date +"%Y%m%d"`$DESTTYPE.$REV
|
||||
LASTWORKDIR=$WORKDIR
|
||||
LASTREV=$REV
|
||||
|
||||
while [[ -d $WORKDIR ]]; do
|
||||
LASTREV=$REV
|
||||
let "REV= REV + 1"
|
||||
LASTWORKDIR=$WORKDIR
|
||||
WORKDIR=$DESTBASE/`date +"%Y%m%d"`$DESTTYPE.$REV
|
||||
done
|
||||
|
||||
if [[ "$RESPIN" = "yes" ]]; then
|
||||
WORKDIR=$LASTWORKDIR
|
||||
REV=$LASTREV
|
||||
fi
|
||||
BUILDREV=$REV
|
||||
|
||||
if [[ ! -d $WORKDIR && "$RESPIN" = "yes" ]]; then
|
||||
quit "missing expected respin workdir ($WORKDIR)"
|
||||
fi
|
||||
|
||||
mkdir -p $WORKDIR
|
||||
|
||||
# Where to send logs
|
||||
LOGDIR=$WORKDIR/logs
|
||||
[[ -d $LOGDIR ]] || mkdir $LOGDIR
|
||||
|
||||
# What tool to use for compressed tar
|
||||
if [[ -x /tools/ns/bin/tar ]] ; then # ROBDAN 9-15-98 for Linux
|
||||
TAR=/tools/ns/bin/tar
|
||||
else
|
||||
TAR=tar
|
||||
fi
|
||||
|
||||
SRCDIR=$WORKDIR/src
|
||||
SRCTAR=$WORKDIR/src.tar.gz
|
||||
|
||||
########################################################################
|
||||
# The function which extracts the source and prepares for copies
|
||||
########################################################################
|
||||
|
||||
prepare_source() {
|
||||
log "Preparing source code..."
|
||||
mkdir $SRCDIR
|
||||
(cd $SRCDIR;
|
||||
log "Extracting source in $SRCDIR...";
|
||||
log "$CHECKOUT > $LOGDIR/cvs-co.txt";
|
||||
$CHECKOUT > $LOGDIR/cvs-co.txt;
|
||||
RET=$?
|
||||
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $CHECKOUT"; fi
|
||||
if [[ "$CHECKOUT2" != "" ]]; then
|
||||
log "$CHECKOUT2 >> $LOGDIR/cvs-co.txt";
|
||||
$CHECKOUT2 >> $LOGDIR/cvs-co.txt;
|
||||
RET=$?
|
||||
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $CHECKOUT2"; fi
|
||||
fi
|
||||
log "Listing source...";
|
||||
ls -Rl > $LOGDIR/src-ls-Rl.txt
|
||||
log "Archiving source..."
|
||||
$TAR czf $SRCTAR .
|
||||
)
|
||||
RET=$?
|
||||
if [[ $RET -ne 0 ]]; then
|
||||
quit "### Failed($RET): cannot prepare source";
|
||||
else
|
||||
log "Source extraction complete";
|
||||
fi
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# The function which does a build
|
||||
########################################################################
|
||||
|
||||
do_rbuild() {
|
||||
OSDEST=$1
|
||||
|
||||
if [ "$SHARESRC" = "yes" ]; then
|
||||
RSRCDIR=$SRCDIR
|
||||
else
|
||||
RSRCDIR=$WORKDIR/$OSDEST
|
||||
fi
|
||||
|
||||
[[ -d $RSRCDIR ]] || mkdir -p $RSRCDIR
|
||||
|
||||
cd $RSRCDIR;
|
||||
|
||||
# do any late variable expansions
|
||||
RAWCMD=$BUILDCMD
|
||||
BUILDCMD=$(eval echo $RAWCMD)
|
||||
|
||||
if [[ $RHOST = localhost ]] ; then
|
||||
log "Build locally for $OSDEST ($BUILDCMD)...";
|
||||
cd $BUILDDIR && pwd && $BUILDCMD && echo $PROG: Success
|
||||
RET=$?
|
||||
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $OSDEST build"; fi
|
||||
|
||||
log "Completed local build..."
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$SHARESRC" != "yes" ]]; then
|
||||
log "Extracting source for $OSDEST...";
|
||||
$RSH $RHOST -n "cd $RSRCDIR && pwd && $TAR xzf $SRCTAR";
|
||||
RET=$?
|
||||
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $OSDEST source extraction"; fi
|
||||
else
|
||||
log "Using common source in $RSRCDIR";
|
||||
fi
|
||||
|
||||
log "Building for $OSDEST ($BUILDCMD)...";
|
||||
$RSH $RHOST -n "cd $RSRCDIR/$BUILDDIR && pwd && $BUILDCMD && echo $PROG: Success"
|
||||
RET=$?
|
||||
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $OSDEST build"; fi
|
||||
|
||||
log "Completed $OSDEST...";
|
||||
}
|
||||
|
||||
buildhost() {
|
||||
RHOST=$1
|
||||
|
||||
log "Query $RHOST configuration...";
|
||||
|
||||
if [[ $RHOST = localhost ]] ; then
|
||||
uname -s > /tmp/$$.$RHOST 2>&1
|
||||
else
|
||||
$RSH $RHOST -n "uname -s" > /tmp/$$.$RHOST 2>&1
|
||||
RET=$?
|
||||
if [[ $RET -ne 0 ]]; then
|
||||
quit "..[$RHOST] ### Failed($RET): $RSH $RHOST -n \"uname -s\"";
|
||||
fi
|
||||
fi
|
||||
ROSTYPE=`tail -1 /tmp/$$.$RHOST`
|
||||
|
||||
if [[ "$ROSTYPE" = "AIX" ]]; then
|
||||
$RSH $RHOST -n "uname -v" > /tmp/$$.$RHOST 2>&1
|
||||
ROSTYPE=${ROSTYPE}`tail -1 /tmp/$$.$RHOST`
|
||||
fi
|
||||
|
||||
if [[ $RHOST = localhost ]] ; then
|
||||
uname -r > /tmp/$$.$RHOST 2>&1
|
||||
else
|
||||
$RSH $RHOST -n "uname -r" > /tmp/$$.$RHOST 2>&1
|
||||
fi
|
||||
ROSREV=`tail -1 /tmp/$$.$RHOST`
|
||||
rm /tmp/$$.$RHOST
|
||||
|
||||
if [[ $RHOST = localhost ]] ; then
|
||||
OSDEST=`hostname | cut -f1 -d.`-${ROSTYPE}${ROSREV}
|
||||
else
|
||||
OSDEST=${RHOST}-${ROSTYPE}${ROSREV}
|
||||
fi
|
||||
log "..Building on [$OSDEST]..."
|
||||
|
||||
REV=1 # find unique logfile name
|
||||
OSLOG=$LOGDIR/$OSDEST.$REV
|
||||
while [[ -f $OSLOG ]]; do
|
||||
let "REV = REV + 1"
|
||||
OSLOG=$LOGDIR/$OSDEST.$REV
|
||||
done
|
||||
|
||||
if [[ "$JUST_TEST" = "yes" ]]; then
|
||||
echo "$PROG: Success" > $OSLOG
|
||||
else
|
||||
( do_rbuild $OSDEST ) > $OSLOG 2>&1
|
||||
fi
|
||||
|
||||
grep "$PROG: Success" $OSLOG > /dev/null
|
||||
RET=$?
|
||||
if [[ $RET -eq 0 ]]; then
|
||||
RESULT="SUCCESS";
|
||||
else
|
||||
RESULT="FAILURE($RET)";
|
||||
fi
|
||||
log "..Completed [$OSDEST] <$RESULT>.";
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# The function which initiates all the builds
|
||||
########################################################################
|
||||
|
||||
do_builds() {
|
||||
log "Launching builds..."
|
||||
|
||||
for HOST in $BUILDHOSTS; do
|
||||
buildhost $HOST &
|
||||
done
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# main
|
||||
########################################################################
|
||||
|
||||
main() {
|
||||
if [[ "$JUST_TEST" = "yes" ]]; then
|
||||
log "Automated test starting..."
|
||||
else
|
||||
log "Automated build of [$DESCRIPTION] starting..."
|
||||
fi
|
||||
log ""
|
||||
log " ARGS = $ARGS"
|
||||
log " BUILDHOSTS = $BUILDHOSTS"
|
||||
log " WORKDIR = $WORKDIR"
|
||||
log " SRCDIR = $SRCDIR"
|
||||
log " LOGDIR = $LOGDIR"
|
||||
log " CHECKOUT = $CHECKOUT"
|
||||
log " BUILDDIR = $BUILDDIR"
|
||||
log " BUILDCMD = $BUILDCMD"
|
||||
log " RESPIN = $RESPIN"
|
||||
log ""
|
||||
|
||||
[[ "$RESPIN" = "no" ]] && prepare_source
|
||||
do_builds
|
||||
log "Waiting for all builds to complete..."
|
||||
wait
|
||||
log "All builds completed."
|
||||
|
||||
if [[ -n "$POSTCMD" && "$POSTBUILD" = "yes" ]] ; then
|
||||
log "Running post build command."
|
||||
|
||||
REV=1 # find unique logfile name
|
||||
POSTLOG=$LOGDIR/postbuild.$REV
|
||||
while [[ -f $POSTLOG ]]; do
|
||||
let "REV = REV + 1"
|
||||
POSTLOG=$LOGDIR/postbuild.$REV
|
||||
done
|
||||
|
||||
echo "Dir $SRCDIR/$BUILDDIR" > $POSTLOG
|
||||
echo "Cmd $POSTCMD" >> $POSTLOG
|
||||
(cd $SRCDIR/$BUILDDIR && $POSTCMD && echo $PROG: Success) >> $POSTLOG 2>&1
|
||||
|
||||
log "Post build command completed."
|
||||
elif [[ -n "$POSTCMD" ]] ; then
|
||||
echo "Skipping post build command: $POSTCMD"
|
||||
fi
|
||||
}
|
||||
|
||||
REV=1
|
||||
PROGLOG=$LOGDIR/$PROG.$REV
|
||||
|
||||
while [[ -f $PROGLOG ]]; do
|
||||
REV=`expr $REV + 1`
|
||||
PROGLOG=$LOGDIR/$PROG.$REV
|
||||
done
|
||||
|
||||
main | tee $PROGLOG 2>&1
|
||||
exit 0
|
||||
@@ -1,164 +0,0 @@
|
||||
@if not "%echo%" == "on" echo off
|
||||
|
||||
REM ************ simple autobuild for mailstone
|
||||
|
||||
setlocal
|
||||
|
||||
set BOTH=0
|
||||
|
||||
if not "%1" == "" goto GetTag
|
||||
|
||||
set BOTH=1
|
||||
set TAG=_OPT
|
||||
goto SetConfig
|
||||
|
||||
:GetTag
|
||||
|
||||
if %1 == dbg set TAG=_DBG
|
||||
if %1 == DBG set TAG=_DBG
|
||||
if %1 == Debug set TAG=_DBG
|
||||
if %1 == debug set TAG=_DBG
|
||||
if %1 == Release set TAG=_OPT
|
||||
if %1 == release set TAG=_OPT
|
||||
if %1 == opt set TAG=_OPT
|
||||
if %1 == OPT set TAG=_OPT
|
||||
if %1 == optimize set TAG=_OPT
|
||||
if %1 == Optimize set TAG=_OPT
|
||||
if %1 == optimized set TAG=_OPT
|
||||
if %1 == Optimized set TAG=_OPT
|
||||
if %1 == clean goto CleanBoth
|
||||
|
||||
:SetConfig
|
||||
|
||||
if %TAG% == _DBG set Config=Debug
|
||||
if %TAG% == _OPT set Config=Release
|
||||
|
||||
set ARCH=WINNT4.0%TAG%.OBJ
|
||||
|
||||
set FINAL_PATH=built\package\%ARCH%\mailstone
|
||||
|
||||
if not "%2" == "clean" if not exist %FINAL_PATH%\nul mkdir %FINAL_PATH%
|
||||
|
||||
|
||||
REM ************ first, clean the binary release
|
||||
nmake /f mailstone.mak CFG="mailstone - Win32 %Config%" /nologo NO_EXTERNAL_DEPS=1 CLEAN
|
||||
|
||||
if not "%2" == "clean" goto BuildMailstone
|
||||
|
||||
if exist src\%Config%\nul echo y | rd /s src\%Config% > nul
|
||||
if exist src\gnuplot-3.7\%Config%\nul echo y | rd /s src\gnuplot-3.7\%Config% > nul
|
||||
if exist src\gd1.3\%Config%\nul echo y | rd /s src\gd1.3\%Config% > nul
|
||||
if exist built\%ARCH%\nul echo y | rd /s built\%ARCH% > nul
|
||||
if exist %FINAL_PATH%\nul echo y | rd /s %FINAL_PATH% > nul
|
||||
|
||||
goto done
|
||||
|
||||
:BuildMailstone
|
||||
|
||||
REM **************** next, build it
|
||||
nmake /f mailstone.mak CFG="mailstone - Win32 %Config%" /nologo NO_EXTERNAL_DEPS=1
|
||||
if errorlevel 1 goto BadBuild
|
||||
|
||||
REM ************ next, copy the top-level files
|
||||
copy mstone.bat %FINAL_PATH%
|
||||
copy setup.bat %FINAL_PATH%
|
||||
copy CHANGELOG %FINAL_PATH%
|
||||
copy INSTALL %FINAL_PATH%
|
||||
copy README %FINAL_PATH%
|
||||
copy LICENSE %FINAL_PATH%
|
||||
|
||||
REM ************ now, copy the files for running mailstone into bin
|
||||
if not exist %FINAL_PATH%\bin\nul mkdir %FINAL_PATH%\bin
|
||||
copy built\%ARCH%\mailclient.exe %FINAL_PATH%\bin
|
||||
if exist built\package\%ARCH%\mailclient.exe copy built\package\%ARCH%\mailclient.exe %FINAL_PATH%\bin
|
||||
if exist built\package\%ARCH%\mailclient.exe del /f /q built\package\%ARCH%\mailclient.exe
|
||||
copy bin\*.pl %FINAL_PATH%\bin
|
||||
|
||||
REM ************ now, copy the configuration files into conf
|
||||
if not exist %FINAL_PATH%\conf\nul mkdir %FINAL_PATH%\conf
|
||||
copy conf\*.* %FINAL_PATH%\conf
|
||||
|
||||
REM ************ now, copy the data files into data
|
||||
if not exist %FINAL_PATH%\data\nul mkdir %FINAL_PATH%\data
|
||||
copy data\*.msg %FINAL_PATH%\data
|
||||
|
||||
REM ************ now, copy the gd files into gd
|
||||
if not exist %FINAL_PATH%\gd\nul mkdir %FINAL_PATH%\gd
|
||||
copy src\gd1.3\index.html %FINAL_PATH%\gd\gd.html
|
||||
|
||||
REM ************ now, copy the gnuplot files into gnuplot
|
||||
if not exist %FINAL_PATH%\gnuplot\nul mkdir %FINAL_PATH%\gnuplot
|
||||
copy built\%ARCH%\gnuplot\gnuplot.exe %FINAL_PATH%\gnuplot
|
||||
copy src\gnuplot-3.7\Copyright %FINAL_PATH%\gnuplot
|
||||
copy src\gnuplot-3.7\docs\gnuplot.1 %FINAL_PATH%\gnuplot
|
||||
|
||||
REM ************ now, copy the perl files into perl
|
||||
if not exist %FINAL_PATH%\perl\nul mkdir %FINAL_PATH%\perl
|
||||
if not exist %FINAL_PATH%\perl\bin\nul mkdir %FINAL_PATH%\perl\bin
|
||||
if not exist %FINAL_PATH%\perl\lib\nul mkdir %FINAL_PATH%\perl\lib
|
||||
if not exist %FINAL_PATH%\perl\lib\5.00503\nul mkdir %FINAL_PATH%\perl\lib\5.00503
|
||||
if not exist %FINAL_PATH%\perl\lib\5.00503\MSWin32-x86\nul mkdir %FINAL_PATH%\perl\lib\5.00503\MSWin32-x86
|
||||
#copy built\%ARCH%\perl\perl.exe %FINAL_PATH%\perl\bin
|
||||
#rcp -b sandpit:/share/builds/components/perl5/WINNT-perl5/perl.exe %FINAL_PATH%\perl\bin\perl.exe
|
||||
#if errorlevel 1 goto BadRcp
|
||||
#if not exist %FINAL_PATH%\perl\perl.exe goto BadRcp
|
||||
#rcp -b sandpit:/share/builds/components/perl5/WINNT-perl5/perl300.dll %FINAL_PATH%\perl\bin\perl300.dll
|
||||
#if errorlevel 1 goto BadRcp
|
||||
#if not exist %FINAL_PATH%\perl\perl300.dll goto BadRcp
|
||||
|
||||
copy src\perl5.005_03\Artistic %FINAL_PATH%\perl
|
||||
copy c:\perl\5.00503\bin\MSWin32-x86\perl.exe %FINAL_PATH%\perl\bin
|
||||
copy c:\perl\5.00503\bin\MSWin32-x86\perl.dll %FINAL_PATH%\perl\bin
|
||||
copy c:\perl\5.00503\lib\*.pm %FINAL_PATH%\perl\lib\5.00503
|
||||
copy c:\perl\5.00503\lib\*.pl %FINAL_PATH%\perl\lib\5.00503
|
||||
copy c:\perl\5.00503\lib\MSWin32-x86\*.pm %FINAL_PATH%\perl\lib\5.00503\MSWin32-x86
|
||||
|
||||
|
||||
goto end
|
||||
|
||||
:CleanBoth
|
||||
|
||||
echo.
|
||||
echo NOTICE: CLEANING debug build
|
||||
call autobuild.bat debug clean
|
||||
|
||||
echo NOTICE: CLEANING optimized build
|
||||
call autobuild.bat release clean
|
||||
|
||||
echo NOTICE: Removing generated dependency files
|
||||
del /s *.dep
|
||||
|
||||
if exist built\nul echo y | rd /s built > nul
|
||||
|
||||
goto done
|
||||
|
||||
:BadRcp
|
||||
|
||||
echo.
|
||||
echo ERROR: Failed to rcp perl files over to mailstone packaging
|
||||
echo ERROR: Two common causes of this are .rhosts permissions or a broken rcp.exe
|
||||
echo ERROR: Make sure you are not using rcp.exe from NT4.0 SP4
|
||||
echo ERROR: The SP5 version is available in \\cobra\engineering\bin\rcp_sp5.exe
|
||||
echo ERROR: Use this version to replace ...\system32\rcp.exe
|
||||
goto done
|
||||
|
||||
:BadBuild
|
||||
|
||||
echo.
|
||||
echo ERROR: Failed to build mailstone
|
||||
goto done
|
||||
|
||||
:end
|
||||
|
||||
echo.
|
||||
|
||||
if %BOTH% == 0 goto done
|
||||
if %TAG% == _DBG goto done
|
||||
|
||||
set TAG=_DBG
|
||||
goto SetConfig
|
||||
|
||||
:done
|
||||
|
||||
endlocal
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# This file does argument processing, file IO, and other utility routines
|
||||
|
||||
# Where the online docs live
|
||||
#$mailstoneURL =
|
||||
# "http://home.netscape.com/eng/server/messaging/4.1/mailston/stone.htm";
|
||||
#$mailstoneURL =
|
||||
# "http://lxr.mozilla.org/mozilla/source/mstone/doc/MailStone.html";
|
||||
#$mailstoneURL =
|
||||
# "http://docs.iplanet.com/docs/manuals/messaging/nms415/mailstone/stone.htm"
|
||||
$mailstoneURL = "doc/MailStone.html";
|
||||
|
||||
# Subdirs for results (each under a timestamp dir). Should just hardwire.
|
||||
$tmpbase = "tmp";
|
||||
$resultbase = "results";
|
||||
|
||||
# This holds everything about the test and system configuration
|
||||
@workload = ();
|
||||
# Setup the special CONFIG section
|
||||
$params{"sectionTitle"} = "CONFIG";
|
||||
$params{"sectionParams"} = "";
|
||||
$params{"lineList"} = ();
|
||||
push @workload, \%params;
|
||||
|
||||
# Get the lists discribing the data we process
|
||||
do 'protoconf.pl' || die "$@\n";
|
||||
|
||||
%includedFiles = (); # array of included files
|
||||
|
||||
do 'util.pl' || die "$@\n";
|
||||
|
||||
return 1;
|
||||
@@ -1,310 +0,0 @@
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
# Sean O'Rourke <sean@sendmail.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# This file deals with the graphs data only
|
||||
# Interfaces to gnuplot to generate gifs for HTML inclusion.
|
||||
|
||||
do 'util.pl';
|
||||
sub warn_system;
|
||||
sub die_system;
|
||||
|
||||
# Type of images to hold plots (e.g. png, gif, jpeg, svg, tiff, pbm, etc)
|
||||
unless ($params{IMAGETYPE}) {
|
||||
# Should probe gnuplot and see if it can generate one of:
|
||||
# png, gif, jpeg, svg, tiff, or pbm.
|
||||
# Not all the programs that use args.pl need this (or have gnuplot, yet)
|
||||
my $outfile = "$tmpbase/termtypes.out";
|
||||
my %types = (); # hash of interesting types that we spot
|
||||
|
||||
unless (open(NEW, "<$outfile")) { # re-use old file if present
|
||||
($params{DEBUG}) &&
|
||||
print "Asking gnuplot what output types it supports\n";
|
||||
|
||||
# SEAN: this appears to do what they want:
|
||||
warn_system "echo 'set term' | $params{GNUPLOT} > $outfile";
|
||||
|
||||
open(NEW, "<$outfile") ||
|
||||
warn ": Could not open gnuplot output for parsing ($outfile): $!";
|
||||
}
|
||||
|
||||
# now check through the output for terminal types we can use.
|
||||
# I havent verified the jpeg or tiff types. e-mail me success or failure
|
||||
while (<NEW>) {
|
||||
(/\spng\s/) && ++$types{"png"} && next;
|
||||
(/\sgif\s/) && ++$types{"gif"} && next;
|
||||
(/\sjpeg\s/) && ++$types{"jpeg"} && next;
|
||||
(/\ssvg\s/) && ++$types{"svg"} && next;
|
||||
(/\stiff\s/) && ++$types{"tiff"} && next;
|
||||
(/\spbm\s/) && ++$types{"pbm"} && next;
|
||||
}
|
||||
close (NEW);
|
||||
|
||||
($params{DEBUG}) &&
|
||||
print "Found these gnuplot types: " . (join " ", (keys %types)) . "\n";
|
||||
|
||||
# The ordering here determines our preferences
|
||||
# This list is by likely browser compatibility and image compactness
|
||||
# png is about 10x smaller than gif
|
||||
# svg is smooth and scalable but usually requires a plug-in
|
||||
# jpeg will probably look bad, but will be directly supported
|
||||
if ($types{"png"}) { $params{IMAGETYPE}="png"; }
|
||||
elsif ($types{"gif"}) { $params{IMAGETYPE}="gif"; }
|
||||
elsif ($types{"jpeg"}) { $params{IMAGETYPE}="jpeg"; }
|
||||
elsif ($types{"svg"}) { $params{IMAGETYPE}="svg"; }
|
||||
elsif ($types{"tiff"}) { $params{IMAGETYPE}="tiff"; }
|
||||
elsif ($types{"pbm"}) { $params{IMAGETYPE}="pbm"; }
|
||||
else {
|
||||
warn "Gnuplot doesn't support any good image types. Check $outfile.\n";
|
||||
$params{IMAGETYPE} = undef;
|
||||
}
|
||||
# leave the output file around to speed up repeat runs
|
||||
}
|
||||
|
||||
# sub function to write data files, fire off gnuscript, and clean up
|
||||
# Uses global startTime and endTime figured above
|
||||
# genPlot counterName title label \@protocols \@variables
|
||||
sub genPlot {
|
||||
my $name = shift;
|
||||
my $title = shift;
|
||||
my $label = shift;
|
||||
my $protos = shift || die "genPlot: '$name' missing protocols";
|
||||
my $f = shift;
|
||||
my $vars = shift || die "genPlot: '$name' missing vars";
|
||||
|
||||
my $runlist = "";
|
||||
my $totPoints = 0;
|
||||
my $totProtos = 0;
|
||||
my @realProtos;
|
||||
my @goodProtos;
|
||||
|
||||
# user fewer data points than pixels to look good.
|
||||
# on 640x480 gif, the graph is about 579x408
|
||||
my $maxData = int (($params{CHARTWIDTH}-60) * 0.9);
|
||||
my $averageCnt = int (($endTime - $startTime + ($maxData - 1))/$maxData);
|
||||
if ($averageCnt < 1) { $averageCnt = 1; } # must be a positive int
|
||||
|
||||
($params{DEBUG}) && print "$name: averageCnt=$averageCnt vars = @$vars \n";
|
||||
|
||||
foreach $p (@$protos) { # First see if there is anything to graph
|
||||
($p =~ /^Total$/o) && next; # derived if needed
|
||||
my $pPoints = 0;
|
||||
my $gp = $graphs{$p};
|
||||
ALLVAR: foreach $vm (@$vars) {
|
||||
my $vp = ($f) ? $gp->{$vm}->{$f} : $gp->{$vm};
|
||||
|
||||
unless (($vp) && (scalar %$vp)) {
|
||||
#print "genplot Checking: $p $vm $f => NO\n";
|
||||
next;
|
||||
}
|
||||
#print "genplot Checking: $p $vm $f => ";
|
||||
foreach $time (keys %$vp) {
|
||||
next unless ($vp->{$time} != 0);
|
||||
$totPoints++;
|
||||
$pPoints++;
|
||||
#print "VALUES\n";
|
||||
last ALLVAR;
|
||||
}
|
||||
#print "nothing\n"
|
||||
}
|
||||
if ($pPoints > 0) { # count how many protocols have non 0
|
||||
$totProtos++;
|
||||
push @goodProtos, $p;
|
||||
}
|
||||
}
|
||||
($params{DEBUG}) && print "\tprotocols: @goodProtos\n";
|
||||
|
||||
if ($totPoints == 0) { # nothing in any protocol
|
||||
print "No data for graph '$name', variables '@$vars'\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach $p (@$protos) {
|
||||
unlink ("$tmpdir/$name.$p"); # remove any previous runs
|
||||
|
||||
(($p =~ /^Total$/o) && ($totProtos <= 1))
|
||||
&& next; # skip Totally if only 1 protocol plus total
|
||||
|
||||
($p !~ /^Total$/o) && push @realProtos, $p; # everything but Total
|
||||
|
||||
# if ($p =~ /^Total$/o) { # move from last to first
|
||||
# $runlist = "\'$name.$p\' with lines, " . $runlist;
|
||||
# next;
|
||||
# }
|
||||
|
||||
$runlist .= ", " if ($runlist); # later ones
|
||||
|
||||
$runlist .= "\'$name.$p\' with lines";
|
||||
}
|
||||
|
||||
$totPoints = 0;
|
||||
foreach $p (@realProtos) { # create the plot data files
|
||||
open(DATA, ">$tmpdir/$name.$p") ||
|
||||
die "Can't open $tmpdir/$name.$p:$!";
|
||||
my $gp = $graphs{$p};
|
||||
my $n = 0;
|
||||
my $s = 0.0;
|
||||
my $sTime = 0.0;
|
||||
my $vp = ($f) ? $gp->{$vars->[0]}->{$f} : $gp->{$vars->[0]};
|
||||
|
||||
# foreach $time (sort numeric keys %$vp) {
|
||||
for (my $tm = $startTime; $tm <= $endTime; $tm++) {
|
||||
my $v = 0.0;
|
||||
foreach $vm (@$vars) {
|
||||
$vp = ($f) ? $gp->{$vm}->{$f} : $gp->{$vm};
|
||||
|
||||
$totPoints++;
|
||||
|
||||
# due to optimization in updateDelta,
|
||||
# 0 entries are undefined (also avoids warning)
|
||||
$v += ($vp->{$tm}) ? $vp->{$tm} : 0;
|
||||
|
||||
# if ($vp->{$tm} < 0) {
|
||||
# print $name, ": proto=", $p, " var=", $vm,
|
||||
# " value=", $vp->{$tm}, "\n";
|
||||
# }
|
||||
}
|
||||
$s += $v;
|
||||
$n += 1;
|
||||
if ($n == 1) { # NOTE: shifts left in sliding window
|
||||
$sTime = $tm-$startTime;
|
||||
}
|
||||
if ($n >= $averageCnt) {
|
||||
printf (DATA "%d %f\n", $sTime * $timeStep, $s/$n);
|
||||
$n = 0;
|
||||
$s = 0.0;
|
||||
}
|
||||
}
|
||||
if ($n > 0) { # handle end case
|
||||
printf (DATA "%d %f\n", $sTime * $timeStep, $s/$n);
|
||||
}
|
||||
close(DATA);
|
||||
}
|
||||
#($params{DEBUG}) && print "\tpoints: $totPoints\n";
|
||||
|
||||
# need to handle "Total" case
|
||||
# read the other files and write out the sum
|
||||
# FIX: total my be mis-aligned with data
|
||||
if (($#$protos > $#realProtos) && ($totProtos > 1)) {
|
||||
unlink ("$tmpdir/$name.Total");
|
||||
open(DATA, ">$tmpdir/$name.Total") ||
|
||||
die "Can't open $tmpdir/$name.Total:$!";
|
||||
|
||||
foreach $r (@goodProtos) { # get file handles
|
||||
open($r, "$tmpdir/$name.$r")
|
||||
|| die "Couldn't open $tmpdir/$name.$r: $!";
|
||||
}
|
||||
# ASSUMES files are identical in order
|
||||
my $first = shift @goodProtos;
|
||||
# print "First protocol: $first Rest: @realProtos\n";
|
||||
while (<$first>) {
|
||||
my ($t, $s) = split ' ', $_;
|
||||
foreach $r (@goodProtos) { # get file handles
|
||||
$l = <$r>;
|
||||
if ($l) {
|
||||
my ($tt, $v) = split ' ', $l;
|
||||
$t = $tt unless ($t); # in case first proto missing time
|
||||
$s += $v;
|
||||
}
|
||||
}
|
||||
printf (DATA "%d %f\n", $t, $s);
|
||||
}
|
||||
|
||||
foreach $r (@goodProtos) { close($r); }
|
||||
close (DATA);
|
||||
}
|
||||
|
||||
# SEAN: don't even try if we aren't generating images:
|
||||
return 0 unless $params{IMAGETYPE};
|
||||
|
||||
# Create a script to feed to gnuplot, which creates a .gif graph.
|
||||
$runTime = ($endTime - $startTime + 1) * $timeStep;
|
||||
unlink("$tmpdir/$name.gpt");
|
||||
open(SCRIPT, ">$tmpdir/$name.gpt")
|
||||
|| die "Can't open $tmpdir/$name.gpt:$!";
|
||||
|
||||
$gnuplot = $params{GNUPLOT};
|
||||
return 1 unless $gnuplot;
|
||||
if ($gnuplot !~ /^\//) { # if not absolute, adjust for cd $tmpbase
|
||||
$gnuplot = "../../$gnuplot"; # ASSUME $tmpbase is single dir
|
||||
}
|
||||
#print "gnuplot is $gnuplot $params{GNUPLOT}\n";
|
||||
|
||||
my $varstring = ""; # create display version of names
|
||||
foreach $t (@$vars) {
|
||||
$varstring .= ", " if ($varstring);
|
||||
$varstring .= ($timerNames{$t}) ? $timerNames{$t} : $t;
|
||||
}
|
||||
|
||||
# Setup output "terminal type"
|
||||
if ($params{IMAGETYPE} eq "gif") { # gif type has different arguments
|
||||
print SCRIPT "set terminal $params{IMAGETYPE} small size $params{CHARTWIDTH},$params{CHARTHEIGHT}\n";
|
||||
} elsif ($params{IMAGETYPE} eq "svg") { # svg type has different args too
|
||||
print SCRIPT "set terminal $params{IMAGETYPE} size $params{CHARTWIDTH} $params{CHARTHEIGHT}\n";
|
||||
} else { # most types work like this
|
||||
print SCRIPT "set terminal $params{IMAGETYPE} small color\n";
|
||||
if (($params{CHARTWIDTH} != 640) || ($params{CHARTHEIGHT} != 480)) {
|
||||
my $xscale = $params{CHARTWIDTH} / 640;
|
||||
my $yscale = $params{CHARTHEIGHT} / 480;
|
||||
print SCRIPT "set size $xscale,$yscale\n";
|
||||
}
|
||||
}
|
||||
print SCRIPT<<"!GROK!THIS!";
|
||||
set output "../../$resultdir/$name.$params{IMAGETYPE}" # ASSUME $tmpbase is single dir
|
||||
set autoscale
|
||||
set xlabel "Test time (seconds)"
|
||||
set ylabel "$label"
|
||||
set title "$title ($varstring) -- $params{TSTAMP}"
|
||||
plot [0:$runTime] $runlist
|
||||
!GROK!THIS!
|
||||
close(SCRIPT);
|
||||
|
||||
# run script from tmpbase to clean up line labeling
|
||||
# my $olddir=getcwd();
|
||||
chdir $tmpdir;
|
||||
warn_system (split (/\s/, $gnuplot), "$name.gpt");
|
||||
chdir "../..";
|
||||
# chdir $olddir;
|
||||
|
||||
unless ($params{DEBUG}) {
|
||||
# cleanup the plot data (or leave around for debugging)
|
||||
foreach $p (@$protos) {
|
||||
unlink("$tmpdir/$name.$p");
|
||||
}
|
||||
unlink("$tmpdir/$name.gpt");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
@@ -1,629 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
# Mike Blakely
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# see setup.pl for full usage
|
||||
# mailmaster [-d] [-c <config file>] ...
|
||||
|
||||
# This script reads in the client configuration files and will
|
||||
# fork children to rsh the mailclient process on network clients,
|
||||
# each child will write test results to /mailstone directory before
|
||||
# dying. The parent will the read and combine the results.
|
||||
#
|
||||
# Make sure the user running this script has rsh privilege across
|
||||
# all client machines
|
||||
|
||||
print "Netscape Mailstone version 4.2\n";
|
||||
print "Copyright (c) Netscape Communications Corp. 1997-2000\n";
|
||||
|
||||
# this parses the command line and config file
|
||||
do 'args.pl'|| die "$@\n";
|
||||
sub die_system;
|
||||
sub warn_system;
|
||||
|
||||
parseArgs(); # parse command line
|
||||
|
||||
{ # get unique date string
|
||||
my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
|
||||
my $tstamp = sprintf ("%04d%02d%02d.%02d%02d",
|
||||
1900+$year, 1+$mon, $mday, $hour, $min);
|
||||
|
||||
if ( -d "$resultbase/$tstamp") { # check for runs within a minute
|
||||
my $tail = 'a';
|
||||
while ( -d "$resultbase/$tstamp$tail" ) { $tail++; }
|
||||
$tstamp .= $tail;
|
||||
}
|
||||
$params{TSTAMP} = $tstamp;
|
||||
}
|
||||
|
||||
$resultdir = "$resultbase/$params{TSTAMP}";
|
||||
$tmpdir = "$tmpbase/$params{TSTAMP}";
|
||||
$resultstxt = "$resultdir/results.txt";
|
||||
$resultshtml = "$resultdir/results.html";
|
||||
mkdir ("$resultbase", 0775);
|
||||
mkdir ("$tmpbase", 0775);
|
||||
mkdir ("$resultdir", 0775);
|
||||
mkdir ("$tmpdir", 0775);
|
||||
|
||||
# Make sure we have everything
|
||||
die "Must specify the test time" unless $params{TIME};
|
||||
die "Must specify a workload file" unless $params{WORKLOAD};
|
||||
|
||||
if ($params{TESTBED}) { # BACK COMPATIBILITY
|
||||
readTestbedFile ($params{TESTBED}) || die "Error reading testbed: $@\n";
|
||||
}
|
||||
|
||||
$testsecs = figureTimeSeconds ($params{TIME}, "seconds");
|
||||
|
||||
# figure out the processes and thread, given the desired number
|
||||
# takes into account all the constraints. todo can be a float.
|
||||
sub figurePT {
|
||||
my $sec = shift;
|
||||
my $todo = shift;
|
||||
my $p = 1; # first guess
|
||||
my $t = 1;
|
||||
my $start = 1; # initial process guess
|
||||
my $end = 250; # highest process guess
|
||||
|
||||
if ($todo < 1) { # mark this client as inactive
|
||||
$sec->{PROCESSES} = 0;
|
||||
$sec->{THREADS} = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (($section->{MAXCLIENTS}) && ($todo > $section->{MAXCLIENTS})) {
|
||||
$todo = $section->{MAXCLIENTS}; # trim to max client per host
|
||||
}
|
||||
if ($section->{PROCESSES}) { # they set this part already
|
||||
$start = int ($section->{PROCESSES});
|
||||
$end = $start;
|
||||
$p = $start;
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
print "Using specified $p processes for clients $slist\n";
|
||||
}
|
||||
|
||||
$end = int ($section->{MAXPROCESSES})
|
||||
if ($section->{MAXPROCESSES}); # they set a max
|
||||
|
||||
if (($params{NT}) || ($section->{ARCH} eq "NT4.0")) {
|
||||
$end = 1; # # NT is currently limited to 1 process
|
||||
$start = 1;
|
||||
$p = 1;
|
||||
}
|
||||
|
||||
# step through some process counts
|
||||
# it should first reduce errors due to MAXTHREADS,
|
||||
# the it will reduce errors due to integer math.
|
||||
# not optimal, just good enough
|
||||
my $misses = 0;
|
||||
for (my $n = $start; $n <= $end; $n++) { # try some process counts
|
||||
my $tryt = int ($todo / $n);
|
||||
if (($sec->{MAXTHREADS}) && ($tryt > $sec->{MAXTHREADS})) {
|
||||
$tryt = $sec->{MAXTHREADS};
|
||||
}
|
||||
# see if this is a better match than the last one
|
||||
if (abs ($todo - ($n * $tryt)) < abs ($todo - ($p * $t))) {
|
||||
$p = $n;
|
||||
$t = $tryt;
|
||||
$misses = 0;
|
||||
} else {
|
||||
$misses++;
|
||||
last if ($misses > 1); # getting worse
|
||||
}
|
||||
}
|
||||
$sec->{PROCESSES} = $p;
|
||||
$sec->{THREADS} = $t;
|
||||
return $p * $t;
|
||||
}
|
||||
|
||||
# Allocate CLIENTCOUNT to the client machines
|
||||
# try NOT to turn this into a massive linear programming project
|
||||
# works best to put bigger machines last
|
||||
if ($params{CLIENTCOUNT}) {
|
||||
my $todo = $params{CLIENTCOUNT};
|
||||
my $softcli = 0; # how many can we play with
|
||||
|
||||
foreach $section (@workload) { # see which are already fixed
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
unless (($section->{PROCESSES}) && ($section->{THREADS})) {
|
||||
$softcli++;
|
||||
next;
|
||||
}
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my @hlist = split /[\s,]/, $slist;
|
||||
my $hcnt = (1 + $#hlist);
|
||||
|
||||
# subtract fixed entries
|
||||
my $tcount = ($section->{THREADS}) ? $section->{THREADS} : 1;
|
||||
$todo -= $tcount * $section->{PROCESSES} * $hcnt;
|
||||
$clientProcCount += $section->{PROCESSES} * $hcnt; # total processes
|
||||
$params{DEBUG} &&
|
||||
print "Fixed load group with $hcnt hosts: $section->{PROCESSES} x $tcount\n";
|
||||
}
|
||||
|
||||
$params{DEBUG} &&
|
||||
print "Allocating $todo clients over $softcli groups\n";
|
||||
if ($softcli) {
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
next if (($section->{PROCESSES}) && ($section->{THREADS}));
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my @hlist = split /[\s,]/, $slist;
|
||||
my $hcnt = (1 + $#hlist);
|
||||
|
||||
#print "todo=$todo softcli=$softcli hcnt=$hcnt\n";
|
||||
$todo -= $hcnt * figurePT ($section, $todo / ($softcli * $hcnt));
|
||||
$clientProcCount += $hcnt * $section->{PROCESSES}; # total procs
|
||||
|
||||
$softcli--;
|
||||
last if ($softcli <= 0); # should not happen
|
||||
}
|
||||
}
|
||||
if ($todo) {
|
||||
print "Warning: Could not allocate $todo of $params{CLIENTCOUNT} clients.\n";
|
||||
$params{CLIENTCOUNT} -= $todo;
|
||||
}
|
||||
|
||||
|
||||
} else { # figure out the client count
|
||||
my $cnt = 0;
|
||||
foreach $section (@workload) { # see which are already fixed
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
# next unless ($section->{PROCESSES});
|
||||
next unless $section->{CLIENTS};
|
||||
|
||||
my $clients = $section->{CLIENTS};
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my @hlist = split /[\s,]/, $slist;
|
||||
my $hcnt = scalar @hlist;
|
||||
|
||||
$clients /= $hcnt;
|
||||
my $maxp = ($section->{MAXPROCESSES} || 10000);
|
||||
my $maxt = ($section->{MAXTHREADS} || 10000);
|
||||
if ($maxp * $maxt < $clients) {
|
||||
die <<EOS;
|
||||
Too many clients for hosts $section->{sectionParams}:
|
||||
clients = $section->{CLIENTS}
|
||||
maxThreads = $section->{MAXTHREADS}
|
||||
maxProcesses = $section->{MAXPROCESSES}
|
||||
EOS
|
||||
}
|
||||
my ($nt, $np);
|
||||
if ($maxt >= $clients) {
|
||||
$nt = $clients;
|
||||
$np = 1;
|
||||
} else {
|
||||
$np = int (($clients / $maxt) + (($clients % $maxt) ? 1 : 0));
|
||||
$nt = int ($clients / $np);
|
||||
}
|
||||
|
||||
$section->{THREADS} = $nt;
|
||||
$section->{PROCESSES} = $np;
|
||||
# $section->{CLIENTS} = $np * $nt * $hcnt;
|
||||
$cnt += $nt * $np * $hcnt;
|
||||
$clientProcCount += $np * $hcnt; # total processes
|
||||
}
|
||||
$params{CLIENTCOUNT} = $cnt;
|
||||
die "No clients configured!\n" unless ($cnt > 0);
|
||||
}
|
||||
|
||||
# This has to be written into save workload file for later processing
|
||||
unless ($params{FREQUENCY}) { # unless frequency set on command line
|
||||
my $chartp = ($params{CHARTPOINTS}) ? $params{CHARTPOINTS} : 464;
|
||||
|
||||
# approximate data points for good graphs (up to 2 times this)
|
||||
$params{FREQUENCY} = int ($testsecs / $chartp);
|
||||
if ($params{FREQUENCY} < 2) { # fastest is every 2 seconds
|
||||
$params{FREQUENCY} = 2;
|
||||
} elsif ($params{FREQUENCY} > 60) { # slowest is every minute
|
||||
$params{FREQUENCY} = 60;
|
||||
}
|
||||
}
|
||||
|
||||
{ # set a unique block id on every section
|
||||
my $id = 0;
|
||||
my $configSeen = 0;
|
||||
my $defaultSeen = 0;
|
||||
foreach $section (@workload) {
|
||||
if ($section->{"sectionTitle"} =~ /^CONFIG$/) {
|
||||
next if $configSeen;
|
||||
$configSeen++;
|
||||
}
|
||||
if ($section->{"sectionTitle"} =~ /^DEFAULT$/) {
|
||||
next if $defaultSeen;
|
||||
$defaultSeen++;
|
||||
}
|
||||
$id++; # number 1, 2, ...
|
||||
if ($section->{"sectionTitle"} =~ /^(CONFIG|CLIENT)$/) {
|
||||
$section->{BLOCKID} = $id;
|
||||
} else {
|
||||
push @{$section->{"lineList"}}, "blockID\t$id\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Write the version we pass to mailclient
|
||||
writeWorkloadFile ("$resultdir/work.wld", \@workload,
|
||||
\@scriptWorkloadSections);
|
||||
|
||||
# Write the complete inclusive version
|
||||
writeWorkloadFile ("$resultdir/all.wld", \@workload);
|
||||
|
||||
# SEAN: copy the wld.in file to the result directory for later
|
||||
# statistics gathering.
|
||||
my $wld = $params{WORKLOAD};
|
||||
if (-f "$wld.in") {
|
||||
die_system "cp $wld.in $resultdir/wld.in";
|
||||
} else {
|
||||
unless ($wld !~ /\.preload_(new|old|touch)$/) {
|
||||
warn "Can't find wld.in file for `$wld'\n" unless -f "$wld.in";
|
||||
}
|
||||
}
|
||||
|
||||
setConfigDefaults(); # pick up any missing defaults
|
||||
|
||||
unless ($#protocolsAll > 0) {
|
||||
die "No protocols found. Test Failed!\n";
|
||||
}
|
||||
|
||||
print "Starting: ", scalar(localtime), "\n";
|
||||
|
||||
# redirect STDERR
|
||||
open SAVEERR, ">&STDERR";
|
||||
open(STDERR, ">$resultdir/stderr") || warn "Can't redirect STDERR:$!\n";
|
||||
|
||||
$totalProcs = 0; # number of clients started
|
||||
|
||||
# iterate over every client in the testbed, complete the cmd and rsh
|
||||
if ($params{NT}) { # single client on local host
|
||||
pathprint ("Starting clients (errors logged to $resultdir/stderr)\n");
|
||||
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
my $tcount = ($section->{THREADS}) ? $section->{THREADS} : 1;
|
||||
|
||||
|
||||
# Build the initial Mailclient command line
|
||||
my $preCmd = ($section->{COMMAND})
|
||||
? $section->{COMMAND} : $params{CLIENTCOMMAND};
|
||||
$preCmd .= " -s -t $params{TIME} -f $params{FREQUENCY}";
|
||||
$preCmd .= " -d" if ($params{DEBUG});
|
||||
$preCmd .= " -r" if ($params{TELEMETRY});
|
||||
$preCmd .= " -R $params{RAMPTIME}" if ($params{RAMPTIME});
|
||||
$preCmd .= " -m $params{MAXERRORS}" if ($params{MAXERRORS});
|
||||
$preCmd .= " -M $params{MAXBLOCKS}" if ($params{MAXBLOCKS});
|
||||
$preCmd .= " -n 1 -N $tcount";
|
||||
$preCmd .= ($params{USEGROUPS} && $section->{GROUP})
|
||||
? " -H $section->{GROUP}" : " -H $cli";
|
||||
|
||||
my $stdout = "$tmpdir/localhost.out";
|
||||
|
||||
$totalProcs += $tcount;
|
||||
do 'makeindex.pl' || warn "$@\n"; # html index
|
||||
|
||||
printf "\nTest duration: %d %s. Rampup time: %d %s. Number of clients: %d\n",
|
||||
figureTimeNumber ($params{TIME}),
|
||||
figureTimeUnits ($params{TIME}, "seconds"),
|
||||
figureTimeNumber ($params{RAMPTIME}),
|
||||
figureTimeUnits ($params{RAMPTIME}, "seconds"),
|
||||
$totalProcs;
|
||||
|
||||
print STDERR "localhost: cd $params{TEMPDIR}; $preCmd\n";
|
||||
|
||||
# Redirect STDIN, and STDOUT
|
||||
#open SAVEIN, "<STDIN";
|
||||
open STDIN, "<$resultdir/work.wld"
|
||||
|| die "Coundn't open $resultdir/work.wld for input\n";
|
||||
open SAVEOUT, ">&STDOUT";
|
||||
open STDOUT, ">$stdout"
|
||||
|| die "Couldnt open $stdout for output\n";
|
||||
|
||||
chdir $params{TEMPDIR} || die "Could not cd $params{TEMPDIR}: $!\n";
|
||||
warn_system $preCmd;
|
||||
close STDOUT;
|
||||
open STDOUT, ">&SAVEOUT";
|
||||
printf "Test done.\n";
|
||||
|
||||
chdir $cwd || die "Could not cd $cwd: $!\n";
|
||||
last; # only do the first one
|
||||
}
|
||||
} else { # not NT (forking works)
|
||||
|
||||
foreach $section (@workload) { # do pre run commands
|
||||
next unless ($section->{sectionTitle} =~ /PRETEST/i);
|
||||
unless ($section->{COMMAND}) {
|
||||
print "PreTest with no Command for $section->{sectionParams}\n";
|
||||
next;
|
||||
}
|
||||
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my $myCmd = $section->{COMMAND};
|
||||
$myCmd =~ s/%f/$params{FREQUENCY}/; # fill in frequency variable
|
||||
if ($myCmd =~ m/%c/o) { # dont force down if count is used
|
||||
$count = $testsecs / $params{FREQUENCY};
|
||||
$myCmd =~ s/%c/$count/; # fill in count variable
|
||||
}
|
||||
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
|
||||
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
print "Running pre test command on $cli\n";
|
||||
open PRE, ">>$resultdir/$cli-pre.log";
|
||||
print PRE "========\n";
|
||||
print PRE "$myCmd\n";
|
||||
print PRE "========\n";
|
||||
close PRE;
|
||||
print STDERR "$cli: $myCmd\n"; # log the actual command
|
||||
forkproc ($rsh, $cli, $myCmd,
|
||||
"/dev/null", "$resultdir/$cli-pre.log");
|
||||
}
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
wait(); # run multiple PRETEST section sequentially
|
||||
}
|
||||
}
|
||||
|
||||
foreach $section (@workload) { # start monitors
|
||||
next unless ($section->{sectionTitle} =~ /MONITOR/i);
|
||||
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my $myCmd = ($section->{COMMAND})
|
||||
? $section->{COMMAND} : $params{MONITORCOMMAND};
|
||||
my $forceDown = 0;
|
||||
$myCmd =~ s/,/ /g; # turn commas into spaces BACK COMPATIBIILITY
|
||||
$myCmd =~ s/%f/$params{FREQUENCY}/; # fill in frequency variable
|
||||
|
||||
if ($myCmd =~ m/%c/o) { # dont force down if count is used
|
||||
$count = $testsecs / $params{FREQUENCY};
|
||||
$myCmd =~ s/%c/$count/; # fill in count variable
|
||||
} else {
|
||||
$forceDown = 1;
|
||||
}
|
||||
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
|
||||
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
printf "Monitoring on $cli\n";
|
||||
open PRE, ">>$resultdir/$cli-run.log";
|
||||
print PRE "========\n";
|
||||
print PRE "$myCmd\n";
|
||||
print PRE "========\n";
|
||||
close PRE;
|
||||
print STDERR "$cli: $myCmd\n"; # log the actual command
|
||||
$pid = forkproc ($rsh, $cli, $myCmd,
|
||||
"/dev/null", "$resultdir/$cli-run.log");
|
||||
push @forceDownPids, $pid if ($forceDown); # save PID for shutdown
|
||||
}
|
||||
}
|
||||
|
||||
print "Starting clients (errors logged to $resultdir/stderr)\n";
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
next unless ($section->{PROCESSES}); # unused client
|
||||
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
|
||||
my $pcount = $section->{PROCESSES};
|
||||
my $tcount = ($section->{THREADS}) ? $section->{THREADS} : 0;
|
||||
my $tempdir;
|
||||
if ($section->{TEMPDIR}) {
|
||||
$tempdir = $section->{TEMPDIR};
|
||||
} elsif ($params{TEMPDIR}) {
|
||||
$tempdir = $params{TEMPDIR};
|
||||
}
|
||||
my $preCmd = "./" . (($section->{COMMAND})
|
||||
? $section->{COMMAND} : $params{CLIENTCOMMAND});
|
||||
$preCmd .= " -e" unless ($params{NOEVENTS});
|
||||
$preCmd .= " -s -t $params{TIME} -f $params{FREQUENCY}";
|
||||
$preCmd .= " -d" if ($params{DEBUG});
|
||||
$preCmd .= " -r" if ($params{TELEMETRY});
|
||||
$preCmd .= " -R $params{RAMPTIME}" if ($params{RAMPTIME});
|
||||
if ($params{MAXERRORS}) {
|
||||
# distribute error count over processes, rounding up
|
||||
my $n = int (($params{MAXERRORS} + $clientProcCount - 1)
|
||||
/ $clientProcCount);
|
||||
$n = 1 if ($n < 1);
|
||||
$preCmd .= " -m $n";
|
||||
}
|
||||
if ($params{MAXBLOCKS}) {
|
||||
# distribute block count over processes, rounding up
|
||||
my $n = int (($params{MAXBLOCKS} + $clientProcCount - 1)
|
||||
/ $clientProcCount);
|
||||
$n = 1 if ($n < 1);
|
||||
$preCmd .= " -M $n";
|
||||
}
|
||||
$preCmd = "cd $tempdir; " . $preCmd if ($tempdir);
|
||||
$preCmd =~ s!/!\\!g if ($section->{ARCH} eq "NT4.0");
|
||||
$preCmd =~ s/;/&&/g if ($section->{ARCH} eq "NT4.0");
|
||||
|
||||
my $total_clients = $section->{CLIENTS};
|
||||
my $residue = $total_clients - ($tcount * $pcount);
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
my $stdout = getClientFilename ($cli, $section);
|
||||
my $myCmd = $preCmd;
|
||||
$myCmd .= ($params{USEGROUPS} && $section->{GROUP})
|
||||
? " -H $section->{GROUP}" : " -H $cli";
|
||||
my $foo = ($params{USEGROUPS} && $section->{GROUP})
|
||||
? $section->{GROUP} : undef;
|
||||
|
||||
if ($tcount) {
|
||||
my $nt = $tcount;
|
||||
if ($residue > 0) {
|
||||
++$nt;
|
||||
$residue -= $pcount;
|
||||
}
|
||||
$myCmd .= " -n $pcount -N $nt";
|
||||
printf "Starting $pcount x $nt on $cli%s\n",
|
||||
$foo?" (group = $foo)":'';
|
||||
$totalProcs += $pcount * $nt;
|
||||
} else {
|
||||
my $np = $pcount;
|
||||
if ($residue > 0) {
|
||||
++$np;
|
||||
--$residue;
|
||||
}
|
||||
$myCmd .= " -n $np";
|
||||
printf "Starting $np processes on $foo\n";
|
||||
$totalProcs += $np;
|
||||
}
|
||||
|
||||
print STDERR "$cli: $myCmd\n"; # log the actual command
|
||||
$pid = forkproc ($rsh, $cli, $myCmd,
|
||||
"$resultdir/work.wld", $stdout);
|
||||
push @localPids, $pid if ($cli =~ /^localhost$/i);
|
||||
}
|
||||
}
|
||||
|
||||
if (@localPids) {
|
||||
# print "Trapping extraneous local signals\n";
|
||||
# This doesnt trap quite right. We dont die, but shell returns...
|
||||
$SIG{ALRM} = 'IGNORE'; # in case we get an ALRM from the mailclient
|
||||
}
|
||||
|
||||
printf "\nTest duration: %d %s. Rampup time: %d %s. Number of clients: %d\n",
|
||||
figureTimeNumber ($params{TIME}),
|
||||
figureTimeUnits ($params{TIME}, "seconds"),
|
||||
figureTimeNumber ($params{RAMPTIME}),
|
||||
figureTimeUnits ($params{RAMPTIME}, "seconds"),
|
||||
$totalProcs;
|
||||
|
||||
do 'makeindex.pl' || warn "$@\n"; # html index
|
||||
|
||||
print "Waiting for test to finish.\n";
|
||||
print "Waiting: ", scalar(localtime), "\n";
|
||||
# wait for children to finish
|
||||
$pid = wait();
|
||||
if (@forceDownPids) { # shut down after the first return.
|
||||
print "Shutting down @forceDownPids\n";
|
||||
kill 1 => @forceDownPids; # sigHUP
|
||||
# kill 9 => @forceDownPids; # sigTERM
|
||||
}
|
||||
while ($pid != -1) { # wait for all children
|
||||
$pid = wait();
|
||||
}
|
||||
|
||||
foreach $section (@workload) { # do post test commands
|
||||
next unless ($section->{sectionTitle} =~ /POSTTEST/i);
|
||||
unless ($section->{COMMAND}) {
|
||||
print "PostTest with no command for $section->{sectionParams}\n";
|
||||
next;
|
||||
}
|
||||
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my $myCmd = $section->{COMMAND};
|
||||
$myCmd =~ s/%f/$params{FREQUENCY}/; # fill in frequency variable
|
||||
if ($myCmd =~ m/%c/o) { # dont force down if count is used
|
||||
$count = $testsecs / $params{FREQUENCY};
|
||||
$myCmd =~ s/%c/$count/; # fill in count variable
|
||||
}
|
||||
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
|
||||
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
printf "Running post test command on $cli\n";
|
||||
open PRE, ">>$resultdir/$cli-post.log";
|
||||
print PRE "========\n";
|
||||
print PRE "$myCmd\n";
|
||||
print PRE "========\n";
|
||||
close PRE;
|
||||
print STDERR "$cli: $myCmd\n"; # log the actual command
|
||||
forkproc ($rsh, $cli, $myCmd,
|
||||
"/dev/null", "$resultdir/$cli-post.log");
|
||||
}
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
wait(); # run multiple POSTTEST section sequentially
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print STDERR "\nDone.\n";
|
||||
close(STDERR);
|
||||
open STDERR, ">&SAVEERR";
|
||||
|
||||
print "\nClients done: ", scalar(localtime), "\n";
|
||||
print "Collecting results\n";
|
||||
|
||||
do 'reduce.pl' || die "$@\n"; # generate graphs and sums
|
||||
|
||||
print "Generating results pages\n";
|
||||
|
||||
do 'report.pl' || die "$@\n";
|
||||
|
||||
# Now display that data to console
|
||||
if ($params{VERBOSE}) {
|
||||
fileShow ($resultstxt);
|
||||
print "\n";
|
||||
}
|
||||
print "Processing done: ", scalar (localtime), "\n";
|
||||
|
||||
pathprint ("\nResults (text):\t$resultstxt\n");
|
||||
pathprint ( "Results (HTML):\t$resultshtml\n");
|
||||
print "Index of runs: \tfile://$cwd/$resultbase/index.html\n";
|
||||
|
||||
|
||||
# Now check for major problems in the stderr file
|
||||
if (open(RESULTSTXT, "$resultdir/stderr")) {
|
||||
$ERRCNT=0;
|
||||
while (<RESULTSTXT>) { $ERRCNT++; }
|
||||
close(RESULTSTXT);
|
||||
pathprint ("Error log ($ERRCNT lines):\t$resultdir/stderr\n");
|
||||
}
|
||||
|
||||
{ # list user requested logging
|
||||
my @logfiles = <$resultdir/*-pre.log>;
|
||||
if (@logfiles) {
|
||||
foreach $f (@logfiles) {
|
||||
print "Pre test log: \t$f\n";
|
||||
}
|
||||
}
|
||||
@logfiles = <$resultdir/*-run.log>;
|
||||
if (@logfiles) {
|
||||
foreach $f (@logfiles) {
|
||||
print "Monitoring log: \t$f\n";
|
||||
}
|
||||
}
|
||||
@logfiles = <$resultdir/*-post.log>;
|
||||
if (@logfiles) {
|
||||
foreach $f (@logfiles) {
|
||||
print "Post test log: \t$f\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "Mailmaster done: ", scalar(localtime), "\n"; exit 0;
|
||||
@@ -1,115 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# usage: perl -Ibin makeindex.pl
|
||||
# Look at all the results files and create a top level index
|
||||
|
||||
unless ($resultbase) { # pick up systematic defaults, if needed
|
||||
do 'args.pl'|| die $@;
|
||||
parseArgs(); # parse command line
|
||||
}
|
||||
|
||||
($testname = $params{WORKLOAD}) =~ s:conf/::;
|
||||
$testname =~ s:.wld::;
|
||||
|
||||
my $entry = "";
|
||||
|
||||
$entry .= "<TR><TD><BR><A HREF=\"$params{TSTAMP}/results.html\">$params{TSTAMP}</A></TD>";
|
||||
$entry .= "<TD>$testname</TD>\n";
|
||||
$entry .= "<TD>$params{TITLE}</TD>\n";
|
||||
$entry .= "<TD>$params{TIME}</TD>\n";
|
||||
$entry .= "<TD>$params{CLIENTCOUNT}</TD>\n";
|
||||
$entry .= "<TD><A HREF=\"$params{TSTAMP}/all.wld\">workload</A></TD>\n";
|
||||
$entry .= "<TD><A HREF=\"$params{TSTAMP}/stderr\">stderr</A></TD></TR>\n";
|
||||
|
||||
if (-r "$resultbase/index.html") {
|
||||
fileInsertAfter ("$resultbase/index.html",
|
||||
"^<!-- INSERT TAGS HERE",
|
||||
$entry);
|
||||
} else { # create index from scratch
|
||||
system ("cd $resultbase; ln -s ../doc .");
|
||||
open(INDEXNEW, ">$resultbase/index.new") ||
|
||||
die "Couldn't open $resultbase/index.new: $!";
|
||||
|
||||
print INDEXNEW <<END;
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<TITLE>
|
||||
MailStone Results
|
||||
</TITLE>
|
||||
<HEAD>
|
||||
</HEAD>
|
||||
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#FF0000" ALINK="#000088">
|
||||
<A HREF=$mailstoneURL>Mailstone documentation</A><BR>
|
||||
<TABLE BORDER=2>
|
||||
<CAPTION> Mozilla MailStone Results Index </CAPTION>
|
||||
<TR>
|
||||
<TH>Run</TH> <TH>Testname</TH> <TH> Title </TH>
|
||||
<TH>Duration</TH> <TH>Clients</TH> <TH>Details</TH> <TH>Error log</TH>
|
||||
</TR>
|
||||
<!-- INSERT TAGS HERE - DO NOT DELETE THIS LINE -->
|
||||
END
|
||||
|
||||
print INDEXNEW $entry; # put in this entry
|
||||
|
||||
# Add in any existing entries
|
||||
# get a list of all the results files
|
||||
@resall = <$resultbase/*/results.html>;
|
||||
# Write out all the links
|
||||
# This could be rather slow, but we only do it when index.html is missing
|
||||
foreach $filefull (reverse @resall) {
|
||||
my $file = $filefull;
|
||||
$file =~ s:$resultbase/::;
|
||||
if ($file eq $params{TSTAMP}) { next; } # written above
|
||||
my $dir = $file;
|
||||
$dir =~ s:/results.html::;
|
||||
# dont read in old workloads, it will override the current one
|
||||
print INDEXNEW "<TR><TD><BR><A HREF=\"$file\">$dir</A></TD>\n";
|
||||
print INDEXNEW "<TD> </TD><TD> </TD><TD> </TD><TD> </TD>\n";
|
||||
print INDEXNEW "<TD><A HREF=\"$dir/all.wld\">workload</A></TD>\n";
|
||||
print INDEXNEW "<TD><A HREF=\"$dir/stderr\">stderr</A></TD></TR>\n";
|
||||
}
|
||||
|
||||
print INDEXNEW <<END;
|
||||
</TABLE>
|
||||
</BODY>
|
||||
</HTML>
|
||||
END
|
||||
close (INDEXNEW);
|
||||
fileBackup ("$resultbase/index.html");
|
||||
rename ("$resultbase/index.new", "$resultbase/index.html");
|
||||
print "Created $resultbase/index.html\n";
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -1,414 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# script to create test user accounts for Netscape Messaging Server 3, 4
|
||||
#
|
||||
# Given a set of parameters, this script will create an LDIF file
|
||||
# for a number of email users of the form:
|
||||
# test1, test2, test3, ...
|
||||
#
|
||||
# usage: perl create_accounts_ldif [users] [broadcast] [postmaster] [ options ]
|
||||
# [ -a allUsersAlias ]
|
||||
# [ -b basedn ]
|
||||
# [ -d maildomain ]
|
||||
# [ -f firstaccount ]
|
||||
# [ -k ]
|
||||
# [ -m mailhost ]
|
||||
# [ -n numaccounts ]
|
||||
# [ -o outputfile ]
|
||||
# [ -p password ]
|
||||
# [ -s storebase ]
|
||||
# [ -u username ]
|
||||
# [ -v ]
|
||||
# [ -w workload ]
|
||||
# [ -x maxstores ]
|
||||
# [ -3 ]
|
||||
#
|
||||
#perl -Ibin -- bin/makeusers.pl -d mailhost.example.com -m mailhost.example.com -b 'o=example.com' -u mailhost-test -n 100 -4 -o mailhost100.ldif
|
||||
|
||||
# Create the ldif for the user accounts and/or broadcast, postmaster account.
|
||||
#
|
||||
# The ldif then must be added to
|
||||
# the directory by hand (ldapadd, or through the dir admin server's
|
||||
# Database Mgmt->Add entries from an ldif file).
|
||||
|
||||
# A faster way
|
||||
# is to export the existing directory, append the results of
|
||||
# this script, and re-import the combined file. This can be
|
||||
# done using the following Netscape Directory Server commands:
|
||||
# stop-slapd
|
||||
# db2ldif outputfile
|
||||
# [ merge files ]
|
||||
# ldif2db inputfile # for DS4 you would typically use -noconfig
|
||||
# start-sladp
|
||||
#
|
||||
|
||||
print "Netscape Mailstone.\nCopyright (c) 1998,1999 Netscape Communications Corp.\n";
|
||||
|
||||
# server to be used in the internet mail address of the users
|
||||
$domain = "newdomain.example.net";
|
||||
|
||||
# machine that will act as the user's mailhost
|
||||
$mailhost = "mailhost.example.net";
|
||||
|
||||
# base dn for the user entries, e.g. o=Ace Industry,c=US
|
||||
$basedn = "o=Benchmark Lab, c=US";
|
||||
|
||||
# name of broadcast account
|
||||
$bcastacct = "allusers";
|
||||
|
||||
# name of broadcast account
|
||||
$postmasteraddr = "root\@localhost";
|
||||
|
||||
# base name to build user names, will construct test0, test1, ...
|
||||
$username = "test%ld";
|
||||
|
||||
# user passwds, in SHA format, the passwd below is 'netscape'
|
||||
#$userpassword = "{SHA}aluWfd0LYY9ImsJb3h4afrI4AXk=";
|
||||
# these can also be imported as cleartext
|
||||
$userpassword = "netscape";
|
||||
|
||||
# 0: no numbered passwords, 1: number with userID
|
||||
$maxpass = 0;
|
||||
|
||||
# first account to use
|
||||
$firstaccount = 0;
|
||||
|
||||
# number of user accounts to create ($first - $first+$num-1)
|
||||
$numaccounts = 1_000;
|
||||
|
||||
# For larger systems, spreading the users over multiple partitions
|
||||
# is usually a good idea. This example assumes you have
|
||||
# created partitions named p0, p1, etc.
|
||||
|
||||
# store partition base name
|
||||
$storebase = "p%ld";
|
||||
|
||||
# max store number (0 - maxstores-1), skip if 0
|
||||
$maxstores = 0;
|
||||
|
||||
#default to msg 4 schemas
|
||||
$usemsg4schema = 1;
|
||||
|
||||
#default to writing to stdout
|
||||
$outfile = STDOUT;
|
||||
|
||||
# Initial UID for genpasswd
|
||||
$firstuid = 1000;
|
||||
|
||||
sub usage {
|
||||
print "Usage: perl -Ibin -- makeusers [users] [broadcast] [postmaster]\n";
|
||||
print "\t[ -w workload ] [ -o outputFile ]\n";
|
||||
print "\t[ -d mailDomain ] [ -m mailHost ] [ -b baseDN ]\n";
|
||||
print "\t[ -u username ] [ -f firstAccount ] [ -n numAccounts ]\n";
|
||||
print "\t[ -p password ] [ -k ]\n";
|
||||
print "\t[ -s storeBase ] [ -x numStores ]\n";
|
||||
print "\t[ -a allUsersAlias ] [ -t postmasterAddress ]\n";
|
||||
print "\t[ -3 ]|[ -4 ]\n";
|
||||
}
|
||||
|
||||
sub readWorkConfig { # read the workload in, parse our params
|
||||
my $workloadfile = shift || die "Workload file name expected\n";
|
||||
|
||||
do 'args.pl'|| die $@;
|
||||
readWorkloadFile ($workloadfile, \@workload)
|
||||
|| die "Error reading workload: $@\n";
|
||||
# assign all the parameters from the config
|
||||
$mailhost = $defaultSection->{SERVER}
|
||||
if ($defaultSection->{SERVER});
|
||||
if ($defaultSection->{ADDRESSFORMAT}) {
|
||||
my $addr = $defaultSection->{ADDRESSFORMAT};
|
||||
$addr =~ s/^.*@//;
|
||||
$domain = $addr;
|
||||
}
|
||||
if ($defaultSection->{LOGINFORMAT}) {
|
||||
my $user = $defaultSection->{LOGINFORMAT};
|
||||
#$user =~ s/%ld$//;
|
||||
$username = $user;
|
||||
}
|
||||
$numaccounts = $defaultSection->{NUMLOGINS}
|
||||
if ($defaultSection->{NUMLOGINS});
|
||||
$firstaccount = $defaultSection->{FIRSTLOGINS}
|
||||
if ($defaultSection->{FIRSTLOGINS});
|
||||
|
||||
$userpassword = $defaultSection->{PASSWDFORMAT}
|
||||
if ($defaultSection->{SERVER});
|
||||
|
||||
if ($userpassword =~ m/%ld/) { # see if numbered passwords
|
||||
$maxpass++;
|
||||
#$userpassword =~ s/%ld//g;
|
||||
}
|
||||
|
||||
# what isnt set: basedn, storebase, maxstores, usemsg4schema
|
||||
}
|
||||
|
||||
while (@ARGV) {
|
||||
$arg = shift(@ARGV);
|
||||
|
||||
if ($arg =~ /^-a$/i) { # allusers (broadcast) user name
|
||||
$bcastacct = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-b$/i) { # LDAP base DN
|
||||
$basedn = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-d$/i) { # mail domain
|
||||
$domain = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-f$/i) { # initial account
|
||||
$firstaccount = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-k$/i) { # use numbered passwords
|
||||
$maxpass++;
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-h$/i) { # help
|
||||
usage();
|
||||
exit 0;
|
||||
}
|
||||
if ($arg =~ /^-m$/i) { # mail server name
|
||||
$mailhost = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-n$/i) { # number of accounts
|
||||
$numaccounts = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-o$/i) { # name output file
|
||||
my $fname = shift || die "File name expected\n";
|
||||
open OUTFILE, ">$fname" || die "Error opening file $@\n";
|
||||
$outfile = OUTFILE;
|
||||
next; # use msg4 user admin schema
|
||||
}
|
||||
if ($arg =~ /^-p$/i) { # password
|
||||
$userpassword = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-s$/i) { # base name for above
|
||||
$storebase = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-t$/i) { # postmaster address
|
||||
$postmasteraddress = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-u$/i) { # user name base
|
||||
$username = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-v$/i) { # be verbose
|
||||
$verbose++;
|
||||
next;
|
||||
}
|
||||
# do this when read, so that later switches can override
|
||||
if ($arg =~ /^-w$/i) { # get a workload file
|
||||
readWorkConfig (shift(@ARGV));
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-x$/i) { # number of partitions (0 to skip)
|
||||
$maxstores = shift(@ARGV);
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-3$/) { # no msg4 schema
|
||||
$usemsg4schema = 0;
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-4$/) { # use msg4 user admin schema
|
||||
$usemsg4schema = 1;
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^users$/i) {
|
||||
$genusers++;
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^broadcast$/i) {
|
||||
$genbroadcast++;
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^passwd$/i) {
|
||||
$genpasswd++;
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^postmaster$/i) {
|
||||
$genpostmaster++;
|
||||
next;
|
||||
}
|
||||
|
||||
print STDERR "Unknown argument $arg. Use -h for help.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
unless (($genusers) || ($genbroadcast) || ($genpasswd) || ($genpostmaster)) {
|
||||
print STDERR "Must specify mode [users] [broadcast] [postmaster] ...\n";
|
||||
usage();
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# specify number fields, if needed
|
||||
unless ($username =~ /%ld/) {
|
||||
$username .= '%ld';
|
||||
}
|
||||
if (($maxpass) && !($userpassword =~ /%ld/)) {
|
||||
$userpassword .= '%ld';
|
||||
}
|
||||
if (($maxstores) && !($storename =~ /%ld/)) {
|
||||
$storename .= '%ld';
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
print STDERR "Here is the configuration:\n";
|
||||
print STDERR "baseDN='$basedn' \t";
|
||||
print STDERR (($usemsg4schema) ? "-4\n" : "-3\n");
|
||||
print STDERR "mailHost='$mailhost' \tdomain='$domain'\n";
|
||||
print STDERR "userName='$username' \tnumAccounts=$numaccounts \tfirstAccount=$firstaccount\n";
|
||||
print STDERR "userPassword='$userpassword'\n";
|
||||
print STDERR "allUsersAccount='$bcastacct'\n" if ($genbroadcast);
|
||||
print STDERR "postmasterAddress='$postmasterAddress'\n" if ($genpostmaster);
|
||||
}
|
||||
|
||||
|
||||
if ($genusers) { # Create the user accounts
|
||||
$storenum=0;
|
||||
for ($i = $firstaccount; $i < $firstaccount+$numaccounts; $i++) {
|
||||
# build user account name
|
||||
my $acctname = $username;
|
||||
$acctname =~ s/%ld/$i/; # insert user number
|
||||
my $password = $userpassword;
|
||||
$password =~ s/%ld/$i/; # insert user number
|
||||
|
||||
|
||||
|
||||
# MAKE SURE THERE ARE NO TRAILING SPACES IN THE LDIF
|
||||
my $extradata = "";
|
||||
|
||||
if ($maxstores > 0) { # assign them to a store
|
||||
my $storename = $storebase;
|
||||
$storename =~ s/%ld/$storenum/;
|
||||
$extradata .= "mailmessagestore: $storename\n";
|
||||
$storenum++;
|
||||
$storenum=0 if ($storenum >= $maxstores);
|
||||
}
|
||||
|
||||
$extradata .= "objectclass: nsMessagingServerUser\n"
|
||||
if ($usemsg4schema);
|
||||
|
||||
print $outfile <<END;
|
||||
dn: uid=$acctname, $basedn
|
||||
userpassword: $password
|
||||
givenname: $acctname
|
||||
sn: $acctname
|
||||
cn: $acctname
|
||||
uid: $acctname
|
||||
mail: $acctname\@$domain
|
||||
mailhost: $mailhost
|
||||
maildeliveryoption: mailbox
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
objectclass: mailRecipient
|
||||
$extradata
|
||||
END
|
||||
}
|
||||
}
|
||||
|
||||
if ($genbroadcast) { # Create the broadcast account
|
||||
# MAKE SURE THERE ARE NO TRAILING SPACES IN THE LDIF
|
||||
my $password = $userpassword;
|
||||
$password =~ s/%ld//; # strip user number
|
||||
# initial part
|
||||
print $outfile <<END;
|
||||
dn: uid=$bcastacct, $basedn
|
||||
userpassword: $password
|
||||
givenname: $bcastacct
|
||||
sn: $bcastacct
|
||||
cn: $bcastacct
|
||||
uid: $bcastacct
|
||||
mail: $bcastacct\@$domain
|
||||
mailhost: $mailhost
|
||||
maildeliveryoption: forward
|
||||
END
|
||||
|
||||
# now put in each address
|
||||
for ($i = $firstaccount; $i < $firstaccount+$numaccounts; $i++) {
|
||||
# build user account name
|
||||
my $acctname = $username;
|
||||
$acctname =~ s/%ld/$i/; # insert user number
|
||||
|
||||
print $outfile "mailforwardingaddress: $acctname\@$domain\n";
|
||||
}
|
||||
|
||||
# final part
|
||||
print $outfile <<END;
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
objectclass: mailRecipient
|
||||
|
||||
END
|
||||
}
|
||||
|
||||
if ($genpostmaster) { # Create the postmaster account
|
||||
# MAKE SURE THERE ARE NO TRAILING SPACES IN THE LDIF
|
||||
print $outfile <<END;
|
||||
dn: cn=postmaster, $basedn
|
||||
cn: postmaster
|
||||
mail: postmaster\@$domain
|
||||
mailalternateaddress: postmaster\@$mailhost
|
||||
mgrprfc822mailmember: $postmasterAddress
|
||||
objectclass: top
|
||||
objectclass: mailGroup
|
||||
objectclass: groupOfUniqueNames
|
||||
|
||||
END
|
||||
}
|
||||
|
||||
# mixing passwd output with the ldif output above would be quite silly
|
||||
if ($genpasswd) { # Create passwd entries for makeusers
|
||||
for ($i = $firstaccount; $i < $firstaccount+$numaccounts; $i++) {
|
||||
# build user account name
|
||||
my $acctname = $username;
|
||||
$acctname =~ s/%ld/$i/; # insert user number
|
||||
my $password = $userpassword;
|
||||
$password =~ s/%ld/$i/; # insert user number
|
||||
my $uid = $firstuid + $i;
|
||||
print $outfile "$acctname:$password:$uid:$uid:Mail user $acctname:/home/$acctname:/bin/sh\n";
|
||||
}
|
||||
}
|
||||
|
||||
exit 0;
|
||||
@@ -1,147 +0,0 @@
|
||||
#!/bin/sh
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# Figure out standard system names
|
||||
|
||||
UNAME_REPORTS=`uname`
|
||||
UNAME_OS_ARCH=`uname -s`
|
||||
UNAME_OS_RELEASE=`uname -r`
|
||||
|
||||
OS_ARCH=$UNAME_OS_ARCH
|
||||
OS_RELEASE=$UNAME_OS_RELEASE
|
||||
OS_CONFIG=${OS_ARCH}${OS_RELEASE}
|
||||
|
||||
if [ "$UNAME_OS_ARCH" = "SunOS" ]; then
|
||||
PROCESSOR=`uname -p`
|
||||
if [ "$PROCESSOR" = "i386" ]; then
|
||||
BUILD_ARCH=x86
|
||||
else
|
||||
BUILD_ARCH=SPARC
|
||||
fi
|
||||
BUILD_OS=SOLARIS
|
||||
if [ "$UNAME_OS_RELEASE" = "5.5" ]; then
|
||||
BUILD_VER=2.5
|
||||
elif [ "$UNAME_OS_RELEASE" = "5.5.1" ]; then
|
||||
BUILD_VER=2.5
|
||||
elif [ "$UNAME_OS_RELEASE" = "5.6" ]; then
|
||||
BUILD_VER=2.6
|
||||
elif [ "$UNAME_OS_RELEASE" = "5.7" ]; then
|
||||
BUILD_VER=7
|
||||
elif [ "$UNAME_OS_RELEASE" = "5.8" ]; then
|
||||
BUILD_VER=8
|
||||
fi
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "HP-UX" ]; then
|
||||
BUILD_ARCH=HPPA
|
||||
BUILD_OS=$UNAME_OS_ARCH
|
||||
BUILD_VER=$OS_RELEASE
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "AIX" ]; then
|
||||
BUILD_ARCH=POWER
|
||||
BUILD_OS=$UNAME_OS_ARCH
|
||||
BUILD_VER=`uname -v`.`uname -r`
|
||||
OS_CONFIG=${BUILD_OS}${BUILD_VER}
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "OSF1" ]; then
|
||||
BUILD_ARCH=ALPHA
|
||||
BUILD_OS=$UNAME_OS_ARCH
|
||||
BUILD_VER=$OS_RELEASE
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "IRIX64" -o "$UNAME_OS_ARCH" = "IRIX" ]; then
|
||||
BUILD_ARCH=MIPS
|
||||
BUILD_OS=IRIX
|
||||
BUILD_VER=$OS_RELEASE
|
||||
OS_CONFIG=${BUILD_OS}${OS_RELEASE}
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "BSD/386" ]; then
|
||||
BUILD_ARCH=x86
|
||||
BUILD_OS=BSDI
|
||||
BUILD_VER=$OS_RELEASE
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "FreeBSD" ]; then
|
||||
BUILD_ARCH=`uname -p`
|
||||
BUILD_OS=$UNAME_OS_ARCH
|
||||
BUILD_VER=$UNAME_OS_RELEASE
|
||||
if [ "$BUILD_ARCH" = "i386" ]; then
|
||||
BUILD_ARCH=x86
|
||||
fi
|
||||
OS_CONFIG=${BUILD_OS}${BUILD_VER}_${BUILD_ARCH}
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "SCO_SV" ]; then
|
||||
BUILD_ARCH=x86
|
||||
BUILD_OS=SCO
|
||||
BUILD_VER=$OS_RELEASE
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "UNIX_SV" ]; then
|
||||
# Check for braindamage
|
||||
grep NCR /etc/bcheckrc > /dev/null 2>&1
|
||||
BUILD_ARCH=x86
|
||||
if [ $? = 0 ]; then
|
||||
BUILD_OS=NCR
|
||||
else
|
||||
BUILD_OS=UNIXWARE
|
||||
fi
|
||||
BUILD_VER=$OS_RELEASE
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "NEWS-OS" ]; then
|
||||
BUILD_ARCH=`uname -p`
|
||||
BUILD_OS=SONY
|
||||
BUILD_VER=$OS_RELEASE
|
||||
|
||||
elif [ "$UNAME_OS_ARCH" = "UNIX_System_V" ]; then
|
||||
BUILD_ARCH=`uname -p`
|
||||
BUILD_OS=NEC
|
||||
BUILD_VER=$OS_RELEASE
|
||||
|
||||
elif [ $UNAME_OS_ARCH = Linux ]; then
|
||||
BUILD_ARCH=`uname -m`
|
||||
if [ -n "`echo $BUILD_ARCH | grep -e '86$'`" ] ; then
|
||||
BUILD_ARCH=x86
|
||||
fi
|
||||
BUILD_OS=$UNAME_OS_ARCH
|
||||
BUILD_VER=`echo $OS_RELEASE | cut -f1,2 -d.`
|
||||
OS_CONFIG=${BUILD_OS}${BUILD_VER}_${BUILD_ARCH}
|
||||
fi
|
||||
|
||||
case "$UNAME_OS_ARCH" in
|
||||
SINIX*|ReliantUNIX*)
|
||||
BUILD_ARCH=`uname -p`
|
||||
BUILD_OS="ReliantUNIX"
|
||||
BUILD_VER=$OS_RELEASE
|
||||
;;
|
||||
esac
|
||||
|
||||
#PLATFORM=${BUILD_ARCH}_${BUILD_OS}_${BUILD_VER}
|
||||
#echo $PLATFORM
|
||||
echo $OS_CONFIG
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/bin/sh
|
||||
# The conZtents 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# re-process a data run
|
||||
# by default, use the most recent one
|
||||
# Usage: process
|
||||
# or
|
||||
# Usage: process TIMESTAMP [args...]
|
||||
# or
|
||||
# Usage: process results/TIMESTAMP [args...]
|
||||
|
||||
if [ ! -x perl/bin/perl -o ! -f .license ] ; then # see if setup was ever run
|
||||
echo "Critical files are missing. Run setup."
|
||||
exit 2;
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ] ; then # do most recent run
|
||||
# since the directories are time stamps with fixed fields,
|
||||
# alphabetical order is also time order
|
||||
dir=`ls -d results/[0-9]*.[0-9]* | tail -1`
|
||||
else # use specified run
|
||||
if [ -d results/$1 ] ; then # timestamp
|
||||
dir=results/$1
|
||||
shift
|
||||
elif [ -d $1 ] ; then # results/timestamp
|
||||
dir=$1
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$dir" ] ; then
|
||||
if [ -f $dir/all.wld ] ; then # unified workload file
|
||||
perl/bin/perl -Ibin -- bin/process.pl -w $dir/all.wld "$@"
|
||||
else # BACK COMPATIBILITY form
|
||||
perl/bin/perl -Ibin -- bin/process.pl -c $dir/config.cfg "$@"
|
||||
fi
|
||||
else # pass in whatever they gave us
|
||||
perl/bin/perl -Ibin -- bin/process.pl "$@"
|
||||
fi
|
||||
@@ -1,371 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# Generate reports independently of mailmaster
|
||||
# Can be used during a run or after mailmaster has finished
|
||||
|
||||
print "Netscape Mailstone\n";
|
||||
print "Copyright (c) 1997-2000 Netscape Communications Corp.\n";
|
||||
|
||||
# this parses the command line and config file
|
||||
do 'args.pl'|| die $@;
|
||||
parseArgs(); # parse command line
|
||||
setConfigDefaults(); # pick up any missing defaults
|
||||
|
||||
$resultdir = "$resultbase/$params{TSTAMP}";
|
||||
$tmpdir = "$tmpbase/$params{TSTAMP}";
|
||||
$resultstxt = "$resultdir/results.txt";
|
||||
$resultshtml = "$resultdir/results.html";
|
||||
|
||||
if ($params{TESTBED}) { # BACK COMPATIBILITY
|
||||
$params{TESTBED} = "$resultdir/testbed.tbd"; # use saved testbed
|
||||
# open the saved testbed conf file
|
||||
readTestbedFile($params{TESTBED}) || die "$@\n";
|
||||
}
|
||||
|
||||
# Convert old style to new. Write the complete inclusive workload
|
||||
writeWorkloadFile ("$resultdir/all.wld", \@workload)
|
||||
unless ((-r "$resultdir/all.wld") || (-r "$resultdir/all.wld.gz"));
|
||||
|
||||
$testsecs = figureTimeSeconds ($params{TIME}, "minutes");
|
||||
|
||||
print "Starting data reduction\n";
|
||||
|
||||
sub readClientCSV {
|
||||
my $file = shift;
|
||||
my @fields;
|
||||
my $line;
|
||||
|
||||
print "Reading client summary: $file\n";
|
||||
open(CSV, "<$file") || # Summary of all clients
|
||||
open(CSV, "gunzip -c $file.gz |") ||
|
||||
return 0; # failed
|
||||
|
||||
# Title line: Verify that arguments are in the same order
|
||||
$line = <CSV>;
|
||||
unless ($line) {
|
||||
print "readClientCSV: Error reading $file. \n";
|
||||
return 0;
|
||||
}
|
||||
chomp $line; # strip newline
|
||||
@fields = split /,/, $line; # turn into an array
|
||||
my $cli = shift @fields; # pull off client header
|
||||
my $cn = shift @fields; # pull off num header
|
||||
my $pro = shift @fields; # pull off protocol header
|
||||
|
||||
# Client array, per variable, per protocol
|
||||
foreach $p (@protocols) {
|
||||
# This hash will hold the timers
|
||||
$clidata{$p} = ArrayInstance->new();
|
||||
foreach $t (@timers) {
|
||||
# This hash will hold the values in the timer
|
||||
$clidata{$p}->{$t} = ArrayInstance->new();
|
||||
foreach $f (@{$timerFields{$t}}) {
|
||||
# This hash that will hold the actual values per client
|
||||
$clidata{$p}->{$t}->{$f} = ArrayInstance->new();
|
||||
}
|
||||
}
|
||||
foreach $t (@scalarClientFields) { # non-timer fields
|
||||
# This hash that will hold the actual values per client
|
||||
$clidata{$p}->{$t} = ArrayInstance->new();
|
||||
}
|
||||
}
|
||||
|
||||
foreach $f (@commClientFields) { # proto independent
|
||||
my $v = shift @fields;
|
||||
if ($v !~ m/$f/i) {
|
||||
print "readClientCSV: Protocol order mismatch '$v', '$f' \n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
foreach $t (@timers) { # timers
|
||||
foreach $f (@{$timerFields{$t}}) {
|
||||
my $v = shift @fields;
|
||||
if ($v !~ m/$t:$f/i) {
|
||||
print "readClientCSV: Protocol order mismatch '$v', '$t:$f' \n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach $t (@scalarClientFields) { # scalars
|
||||
my $v = shift @fields;
|
||||
if ($v !~ m/$t/i) {
|
||||
print "readClientCSV: Protocol order mismatch '$v', '$t' \n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
# Now read actual data
|
||||
while (<CSV>) {
|
||||
chomp; # strip newline
|
||||
@fields = split /,/; # turn into an array
|
||||
my $cli = shift @fields; # pull off client header
|
||||
my $cn = shift @fields; # pull off num header
|
||||
my $p = shift @fields; # pull off protocol header
|
||||
my $cp = $clidata{$p};
|
||||
|
||||
# Create the needed finals arrays
|
||||
unless ($finals{$p}) {
|
||||
#print "Creating finals{$p}\n"; # DEBUG
|
||||
$finals{$p} = ArrayInstance->new();
|
||||
foreach $t (@timers) {
|
||||
$finals{$p}->{$t} = ArrayInstance->new();
|
||||
}
|
||||
}
|
||||
|
||||
foreach $f (@commClientFields) { # proto independent
|
||||
$cliGen{$f}->{$cn} = shift @fields;
|
||||
}
|
||||
foreach $t (@timers) { # timers
|
||||
foreach $f (@{$timerFields{$t}}) {
|
||||
$cp->{$t}->{$f}->{$cn} = shift @fields;
|
||||
$finals{$p}->{$t}->{$f} += $cp->{$t}->{$f}->{$cn};
|
||||
}
|
||||
}
|
||||
foreach $t (@scalarClientFields) { # scalars
|
||||
$cp->{$t}->{$cn} = shift @fields;
|
||||
$finals{$p}->{$t} += $cp->{$t}->{$cn};
|
||||
}
|
||||
|
||||
foreach $section (@workload) { # find thread count for this client
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
next unless ($section->{sectionParams} =~ /$cli/);
|
||||
#print "Process $cli has threads $section->{THREADS}\n";
|
||||
$reportingClients += ($section->{THREADS})
|
||||
? $section->{THREADS} : 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
close (CSV);
|
||||
return 1; # success
|
||||
}
|
||||
|
||||
sub readTimeCSV {
|
||||
my $file = shift;
|
||||
my $p = shift;
|
||||
my $gp = $graphs{$p};
|
||||
my $line;
|
||||
|
||||
print "Reading time $p summary: $file\n";
|
||||
open(CSV, "<$file") || # Summary over time
|
||||
open(CSV, "gunzip -c $file.gz |") ||
|
||||
return 0; # failed
|
||||
|
||||
# Verify that arguments are in the same order
|
||||
$line = <CSV>;
|
||||
unless ($line) {
|
||||
print "readTimeCSV: Error reading $file. \n";
|
||||
return 0;
|
||||
}
|
||||
chomp $line; # strip newline
|
||||
@fields = split /,/, $line;
|
||||
my $t = shift @fields; # pull off time header
|
||||
foreach $t (@timers) {
|
||||
foreach $f (@{$timerFields{$t}}) {
|
||||
my $v = shift @fields;
|
||||
if ($v !~ m/$t:$f/i) {
|
||||
print "readTimeCSV: Protocol order mismatch '$v', '$t:$f' \n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach $t (@scalarGraphFields) {
|
||||
my $v = shift @fields;
|
||||
if ($v !~ m/$t/i) {
|
||||
print "readTimeCSV: Protocol order mismatch '$v', '$t' \n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
while (<CSV>) {
|
||||
chomp;
|
||||
#print "LINE: $_\n";
|
||||
@fields = split /,/;
|
||||
my $tm = shift @fields; # pull off time header
|
||||
#print "t=$t ";
|
||||
foreach $t (@timers) {
|
||||
foreach $f (@{$timerFields{$t}}) {
|
||||
$gp->{$t}->{$f}->{$tm} = shift @fields;
|
||||
#print "$v=$gp->{$v}->{$tm} ";
|
||||
}
|
||||
}
|
||||
foreach $t (@scalarGraphFields) {
|
||||
$gp->{$t}->{$tm} = shift @fields;
|
||||
#print "$v=$gp->{$v}->{$tm} ";
|
||||
}
|
||||
#print "\n";
|
||||
}
|
||||
close (CSV);
|
||||
return 1; # success
|
||||
}
|
||||
|
||||
sub loadCSV {
|
||||
my @csvs = <$resultdir/time-*.csv>;
|
||||
@csvs = <$resultdir/time-*.csv.gz> unless (@csvs);
|
||||
return 0 unless (@csvs); # no time.csv files
|
||||
|
||||
# stuff normally done from reduce.pl (should all be in protoconf?)
|
||||
# Basic sanity check
|
||||
return 0 unless ($testsecs > 0);
|
||||
|
||||
$startTime = 0; # these are timeInSeconds/$timeStep
|
||||
$endTime = 0;
|
||||
|
||||
# keep graphs with somewhat more precision than sample rate;
|
||||
$timeStep = int ($params{FREQUENCY} / 2);
|
||||
if ($timeStep < 1) { $timeStep = 1; }
|
||||
|
||||
# global results initialization
|
||||
$reportingClients = 0;
|
||||
$totalProcs = 0; # number of clients started
|
||||
|
||||
foreach $f (@commClientFields) { # protocol independent fields
|
||||
$cliGen{$f} = ArrayInstance->new();
|
||||
}
|
||||
|
||||
return 0 unless (readClientCSV ("$resultdir/clients.csv")); # client info
|
||||
|
||||
foreach $c (@csvs) { # read time info
|
||||
$c =~ s/.gz$//; # strip .gz extension
|
||||
my $p = $c; # strip down to protocol portion
|
||||
$p =~ s/$resultdir\/time-//;
|
||||
$p =~ s/.csv$//;
|
||||
return 0 unless (readTimeCSV ($c, $p));
|
||||
}
|
||||
|
||||
return 0 unless ($reportingClients > 0);
|
||||
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my @hlist = split /[\s,]/, $slist;
|
||||
my $hcnt = (1 + $#hlist);
|
||||
my $pcount = $section->{PROCESSES};
|
||||
my $tcount = ($section->{THREADS}) ? $section->{THREADS} : 1;
|
||||
|
||||
$totalProcs += $pcount * $tcount * $hcnt;
|
||||
}
|
||||
|
||||
# Find time extent for a key graph
|
||||
($startTime, $endTime) = dataMinMax ("blocks", \@protocols,
|
||||
$startTime, $endTime);
|
||||
|
||||
$realTestSecs = ($endTime - $startTime) * $timeStep;
|
||||
$realTestSecs = 1 unless ($realTestSecs); # in case of small MaxBlocks
|
||||
printf "Reported test duration %d seconds with %d second resolution\n",
|
||||
$realTestSecs, $timeStep;
|
||||
$realTestSecs = $testsecs if ($realTestSecs > $testsecs);
|
||||
|
||||
my @newProtos; # figure real protocol list
|
||||
foreach $p (@protocols) {
|
||||
my $gp = $graphs{$p};
|
||||
my $numValid = 0;
|
||||
# See if there is real data here
|
||||
CHECKVAL: foreach $t (@timers) {
|
||||
foreach $f (@{$timerFields{$t}}) {
|
||||
my $vp = $gp->{$t}->{$f};
|
||||
next unless ($vp); # no data
|
||||
next unless (scalar %$vp); # redundant???
|
||||
|
||||
#print "Checking: $p $t $f => ENTRIES\n";
|
||||
$numValid++;
|
||||
last CHECKVAL;
|
||||
}
|
||||
}
|
||||
($numValid > 0) || next;
|
||||
|
||||
push @newProtos, $p;
|
||||
}
|
||||
# update protocol list to only have what was used
|
||||
@protocols = @newProtos;
|
||||
@protocolsAll = @newProtos;
|
||||
push @protocolsAll, "Total";
|
||||
}
|
||||
|
||||
|
||||
my $doFull = 1; # re-processing is currently broken
|
||||
|
||||
# if (!((-f "$resultdir/clients.csv")
|
||||
# || (-f "$resultdir/clients.csv.gz"))) { # no processing yet
|
||||
# $doFull = 1;
|
||||
# } else { # see if any source is newer than csv
|
||||
# foreach $section (@workload) {
|
||||
# next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
# my $slist = $section->{sectionParams};
|
||||
# $slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
# foreach $cli (split /[\s,]/, $slist) {
|
||||
# my $fname = getClientFilename ($cli, $section);
|
||||
# if ((-r $fname) # raw source exists
|
||||
# && ((-M "$resultdir/clients.csv")
|
||||
# > (-M $fname))) { # newer
|
||||
# #print "$fname is newer than $resultdir/clients.csv\n";
|
||||
# $doFull++;
|
||||
# last;
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
# unless ($doFull) { # do CSV load
|
||||
# # if this is a csv only run, then these may not exist yet
|
||||
# mkdir ("$tmpbase", 0775);
|
||||
# mkdir ("$tmpdir", 0775);
|
||||
# unless (-r "$resultbase/index.html") {
|
||||
# do 'makeindex.pl' || warn "$@\n"; # html index
|
||||
# }
|
||||
|
||||
# $doFull = 1 unless (loadCSV); # if CSV fails, fall back to full processing
|
||||
# }
|
||||
|
||||
if ($doFull) {
|
||||
do 'reduce.pl' || die "$@\n";
|
||||
}
|
||||
|
||||
|
||||
print "Generating results pages:\t", scalar (localtime), "\n";
|
||||
|
||||
do 'report.pl' || die "$@\n";
|
||||
|
||||
# Now display that data to console
|
||||
if ($params{VERBOSE}) {
|
||||
fileShow ($resultstxt);
|
||||
print "\n";
|
||||
}
|
||||
|
||||
pathprint ("\nResults (text):\t$resultstxt\n");
|
||||
pathprint ( "Results (HTML):\t$resultshtml\n");
|
||||
print "Index of runs: \tfile://$cwd/$resultbase/index.html\n";
|
||||
|
||||
print "Process done:\t", scalar (localtime), "\n";
|
||||
@@ -1,158 +0,0 @@
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# This define the structures that hold summary, client, and graph data,
|
||||
|
||||
# This sets the names used for display. Can be internationalized.
|
||||
# All top level names are here (both timers and scalars).
|
||||
# Any unlisted names will map to themselves.
|
||||
%timerNames
|
||||
= (
|
||||
#internal name, Printed name
|
||||
"total", "total",
|
||||
"conn", "connect",
|
||||
"reconn", "reconnect",
|
||||
"banner", "banner",
|
||||
"login", "login",
|
||||
"cmd", "command",
|
||||
"submit", "submit",
|
||||
"retrieve", "retrieve",
|
||||
"logout", "logout",
|
||||
"idle", "idle",
|
||||
"connections", "connections",
|
||||
"blocks", "blocks",
|
||||
);
|
||||
|
||||
# This sets the names used for display. Can be internationalized.
|
||||
%fieldNames
|
||||
= (
|
||||
#internal name, Printed name
|
||||
"Try", "Try",
|
||||
"Error", "Error",
|
||||
"BytesR", "BytesR",
|
||||
"BytesW", "BytesW",
|
||||
"Time", "Time",
|
||||
"TimeMin", "TMin",
|
||||
"TimeMax", "TMax",
|
||||
"Time2", "TStd",
|
||||
);
|
||||
|
||||
|
||||
# hold time graphs for each protocol
|
||||
%graphs = ();
|
||||
|
||||
# Totals are done during plotting, if needed
|
||||
%finals = (); # create base finals hash
|
||||
|
||||
# These are sections that dont get passed to mailclient (case insensitive)
|
||||
@scriptWorkloadSections
|
||||
= (
|
||||
"Config", # special, references %params
|
||||
"Client", # testbed client(s)
|
||||
"Graph", # graph generation
|
||||
"Setup", # things to run with ./setup
|
||||
"Startup", # things to run before test
|
||||
"Monitor", # other performance monitoring
|
||||
"PreTest", # things to run before test
|
||||
"PostTest", # things to run after test
|
||||
);
|
||||
|
||||
# These are sections that arent protocols. Anything else must be.
|
||||
@nonProtocolSections
|
||||
= (@scriptWorkloadSections, ("Default"));
|
||||
|
||||
# These are the known workload parameters (as they will print)
|
||||
# These are coerced to upper case internally (do NOT internationize)
|
||||
@workloadParameters
|
||||
= (
|
||||
"addressFormat",
|
||||
"arch",
|
||||
"blockID",
|
||||
"blockTime",
|
||||
"chartHeight",
|
||||
"chartPoints",
|
||||
"chartWidth",
|
||||
"clientCount",
|
||||
"command",
|
||||
"comments",
|
||||
"file",
|
||||
"firstAddress",
|
||||
"firstLogin",
|
||||
"frequency",
|
||||
"gnuplot",
|
||||
"group",
|
||||
"idleTime",
|
||||
"leaveMailOnServer",
|
||||
"loginFormat",
|
||||
"loopDelay",
|
||||
"numAddresses",
|
||||
"numLogins",
|
||||
"numLoops",
|
||||
"numRecips",
|
||||
"mailClient",
|
||||
"maxBlocks",
|
||||
"maxClients",
|
||||
"maxErrors",
|
||||
"maxThreads",
|
||||
"maxProcesses",
|
||||
"passwdFormat",
|
||||
"processes",
|
||||
"rampTime",
|
||||
"rcp",
|
||||
"rsh",
|
||||
"sequentialAddresses",
|
||||
"sequentialLogins",
|
||||
"server",
|
||||
"smtpMailFrom",
|
||||
"sysConfig",
|
||||
"threads",
|
||||
"telemetry",
|
||||
"tempDir",
|
||||
"time",
|
||||
"title",
|
||||
"TStamp",
|
||||
"useAuthLogin",
|
||||
"useEHLO",
|
||||
"weight",
|
||||
"wmapBannerCmds",
|
||||
"wmapClientHeader",
|
||||
"wmapInBoxCmds",
|
||||
"wmapLoginCmd",
|
||||
"wmapLoginData",
|
||||
"wmapLogoutCmds",
|
||||
"wmapMsgReadCmds",
|
||||
"wmapMsgWriteCmds",
|
||||
"workload",
|
||||
);
|
||||
|
||||
return 1;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,605 +0,0 @@
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# This file deals with the summary data only
|
||||
|
||||
# Should be packages
|
||||
do 'genplot.pl' || die "$@\n";
|
||||
|
||||
sub walkSetupTotals {
|
||||
my $a = shift; my $f = shift; my $p = shift;
|
||||
if ($p =~ /(\w+):(\w+):$/) {
|
||||
my $tm = $2;
|
||||
if (!($finals{Total}->{$tm}->{$f})) {
|
||||
$finals{Total}->{$tm}->{$f} = $a;
|
||||
} elsif ($f =~ /Min$/) {
|
||||
$finals{Total}->{$tm}->{$f} = $a
|
||||
if (($a > 0.0) && ($a < $finals{Total}->{$tm}->{$f}));
|
||||
} elsif ($f =~ /Max$/) {
|
||||
$finals{Total}->{$tm}->{$f} = $a if ($a > $finals{Total}->{$tm}->{$f});
|
||||
} else {
|
||||
$finals{Total}->{$tm}->{$f} += $a;}
|
||||
}
|
||||
elsif ($p =~ /(\w+):$/) {
|
||||
$finals{Total}->{$f} += $a;
|
||||
}
|
||||
}
|
||||
|
||||
sub setupTotals {
|
||||
# Figure out combined timers for "Total" protocol
|
||||
# We might do a smarter merge here (look at context and try to match order)
|
||||
# As long as the first protocol is a superset, it wont matter
|
||||
my @tnames;
|
||||
foreach $proto (@protocols) {
|
||||
foreach $n (@{$protocolFields{$proto}}) {
|
||||
my $t = $n;
|
||||
$t =~ s/([][{}*+?^.\/])/\\$1/g; # quote regex syntax
|
||||
my $found = 0;
|
||||
foreach $tn (@tnames) { # see if it is in the list already
|
||||
next unless ($tn =~ /$t/);
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
#print "proto $proto: Found $n\n" if ($found > 0);
|
||||
next if ($found > 0);
|
||||
#print "proto $proto: Add $n\n";
|
||||
push @tnames, $n; # add to list
|
||||
}
|
||||
}
|
||||
#print "'Total' timers @tnames\n";
|
||||
$protocolFields{"Total"} = \@tnames;
|
||||
|
||||
# Create "Total" hashes
|
||||
$finals{Total} = ArrayInstance->new();
|
||||
foreach $n (@{$protocolFields{"Total"}}) { # all timers
|
||||
my $t = $n; # dont modify original list
|
||||
if ($t =~ /^\[(\w+)\]$/) { # Timer case, strip off brackets
|
||||
$finals{Total}->{$1} = ArrayInstance->new();
|
||||
#print "Creating Total timer field $1\n";
|
||||
} else { # scalar
|
||||
$finals{Total}->{$n} = 0;
|
||||
#print "Creating Total scalar field $n\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Total finals array
|
||||
foreach $proto (@protocols) {
|
||||
foreach $t (@{$protocolFields{$proto}}) {
|
||||
if ($t =~ /^\[(\w+)\]$/) { # Timer case, strip off brackets
|
||||
my $tm = $1;
|
||||
foreach $f (@timerFieldsAll) {
|
||||
my $a = $finals{$proto}->{$tm}->{$f};
|
||||
if (!($finals{Total}->{$tm}->{$f})) { # never touched
|
||||
$finals{Total}->{$tm}->{$f} = $a;
|
||||
} elsif ($f =~ /Min$/) {
|
||||
$finals{Total}->{$tm}->{$f} = $a
|
||||
if (($a > 0.0)
|
||||
&& ($a < $finals{Total}->{$tm}->{$f}));
|
||||
} elsif ($f =~ /Max$/) {
|
||||
$finals{Total}->{$tm}->{$f} = $a
|
||||
if ($a > $finals{Total}->{$tm}->{$f});
|
||||
} else {
|
||||
$finals{Total}->{$tm}->{$f} += $a;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$finals{Total}->{$t} += $finals{$proto}->{$t};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Convert Time2 to standard deviation
|
||||
foreach $proto (@protocolsAll) {
|
||||
foreach $n (@{$protocolFields{$proto}}) {
|
||||
my $t = $n; # dont modify original list
|
||||
if ($t =~ /^\[(\w+)\]$/) { $t = $1; } # strip off brackets
|
||||
next unless ($finals{$proto}->{$t}); # proto doesnt have timer
|
||||
next unless ($finals{$proto}->{$t}->{Try});
|
||||
next unless ($finals{$proto}->{$t}->{Time2} > 0);
|
||||
my $ss = $finals{$proto}->{$t}->{Time2};
|
||||
my $tot = $finals{$proto}->{$t}->{Time};
|
||||
my $n = $finals{$proto}->{$t}->{Try};
|
||||
next unless ($n > 0); # skip if this is 0
|
||||
|
||||
my $var = ($ss - (($tot * $tot) / $n)) / $n;
|
||||
print "$proto->$t var < 0: Time2=$ss Time=$tot n=$n\n"
|
||||
if ($var < 0);
|
||||
$finals{$proto}->{$t}->{Time2} = ($var > 0) ? sqrt ($var) : 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
# Divide total times by trys to get averate time
|
||||
foreach $proto (@protocolsAll) {
|
||||
foreach $n (@{$protocolFields{$proto}}) {
|
||||
my $t = $n; # dont modify original list
|
||||
if ($t =~ /^\[(\w+)\]$/) { $t = $1; } # strip off brackets
|
||||
next unless ($finals{$proto}->{$t}); # proto doesnt have timer
|
||||
($finals{$proto}->{$t}->{Try}) || next;
|
||||
$finals{$proto}->{$t}->{Time} /= $finals{$proto}->{$t}->{Try}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# The text version is designed to be machine processable
|
||||
# commify and kformat are not used
|
||||
sub genTextReport {
|
||||
fileBackup ($resultstxt); # if processing as we go, backup old file
|
||||
# Open a text file to hold the results
|
||||
open(RESULTSTXT, ">$resultstxt") ||
|
||||
die "Couldn't open $resultstxt: $!";
|
||||
|
||||
# Store results as text
|
||||
printf RESULTSTXT "---- Mozilla MailStone Results $params{TSTAMP} ----\n";
|
||||
|
||||
printf RESULTSTXT "\t\t%s\n", $params{TITLE};
|
||||
printf RESULTSTXT "\t\t%s\n", $params{COMMENTS};
|
||||
printf RESULTSTXT "\n";
|
||||
printf RESULTSTXT "Test duration: %d %s. Rampup: %d %s. Reported duration %s seconds\n",
|
||||
figureTimeNumber ($params{TIME}),
|
||||
figureTimeUnits ($params{TIME}, "minutes"),
|
||||
figureTimeNumber ($params{RAMPTIME}),
|
||||
figureTimeUnits ($params{RAMPTIME}, "seconds"), $realTestSecs;
|
||||
printf RESULTSTXT "Number of reporting clients: %s of %s\n",
|
||||
$reportingClients, $totalProcs;
|
||||
|
||||
foreach $proto (@protocolsAll) {
|
||||
# do op counters
|
||||
printf RESULTSTXT "\n%-15s ", $proto;
|
||||
foreach $f (@timerFieldsAll) {
|
||||
#($f =~ m/^Time2$/o) && next;
|
||||
printf RESULTSTXT "%13s",
|
||||
($fieldNames{$f}) ? $fieldNames{$f} : $f;
|
||||
}
|
||||
foreach $n (@{$protocolFields{$proto}}) {
|
||||
my $t = $n; # dont modify original list
|
||||
unless ($t =~ /^\[(\w+)\]$/) { # scalar case
|
||||
#next; # skip scalars for now
|
||||
# do scalar counters. Column should line up with "Try"
|
||||
printf RESULTSTXT "\n%-15s ",
|
||||
$proto . ":" . (($timerNames{$t}) ? $timerNames{$t} : $t);
|
||||
printf RESULTSTXT
|
||||
"%13s", $finals{$proto}->{$t};
|
||||
next;
|
||||
} else { # strip off brackets
|
||||
$t = $1;
|
||||
}
|
||||
printf RESULTSTXT "\n%-15s ",
|
||||
$proto . ":" . (($timerNames{$t}) ? $timerNames{$t} : $t);
|
||||
foreach $f (@timerFieldsAll) {
|
||||
#($f =~ m/^Time2$/o) && next;
|
||||
if ($f =~ m/Time/o) {
|
||||
printf RESULTSTXT
|
||||
"%13.3f", $finals{$proto}->{$t}->{$f};
|
||||
} elsif ($f =~ m/Bytes/o) {
|
||||
printf RESULTSTXT
|
||||
"%13d", $finals{$proto}->{$t}->{$f};
|
||||
} else {
|
||||
printf RESULTSTXT
|
||||
"%13s", $finals{$proto}->{$t}->{$f};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# do ops/sec
|
||||
printf RESULTSTXT "\n\n%-15s ", $proto;
|
||||
foreach $f (@timerFieldsAll) {
|
||||
($f =~ m/^Time/o) && next;
|
||||
printf RESULTSTXT "%9s/sec",
|
||||
($fieldNames{$f}) ? $fieldNames{$f} : $f;
|
||||
}
|
||||
foreach $n (@{$protocolFields{$proto}}) {
|
||||
my $t = $n; # dont modify original list
|
||||
unless ($t =~ /^\[(\w+)\]$/) { # scalar case
|
||||
#next; # skip scalars for now
|
||||
# do scalar counter/sec. Column should line up with "Try"
|
||||
printf RESULTSTXT "\n%-15s ",
|
||||
$proto . ":" . (($timerNames{$t}) ? $timerNames{$t} : $t) . "/s";
|
||||
printf RESULTSTXT
|
||||
"%13.3f", $finals{$proto}->{$t} / $realTestSecs;
|
||||
next;
|
||||
} else {
|
||||
$t = $1;
|
||||
}
|
||||
printf RESULTSTXT "\n%-15s ",
|
||||
$proto . ":" . (($timerNames{$t}) ? $timerNames{$t} : $t) . "/s";
|
||||
foreach $f (@timerFieldsAll) {
|
||||
($f =~ m/^Time/o) && next;
|
||||
if ($f =~ m/Bytes/o) {
|
||||
printf RESULTSTXT
|
||||
"%13d",
|
||||
$finals{$proto}->{$t}->{$f} / $realTestSecs;
|
||||
} else {
|
||||
printf RESULTSTXT
|
||||
"%13.3f",
|
||||
$finals{$proto}->{$t}->{$f} / $realTestSecs;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf RESULTSTXT "\n\n";
|
||||
}
|
||||
|
||||
if ($params{SYSCONFIG}) {
|
||||
print RESULTSTXT "\nSytem config details\n";
|
||||
if (($params{SYSCONFIG} =~ m/^\S+$/o)
|
||||
&& (open(SCFILE, "<$params{SYSCONFIG}"))) {
|
||||
while (<SCFILE>) {
|
||||
(m/^<\S+>\s*$/o) && next; # skip HTML only on them
|
||||
s/<\S+>//g; # trim out obvious HTML commands
|
||||
s/<!--.*-->//g; # trim out HTML comments
|
||||
print RESULTSTXT $_;
|
||||
}
|
||||
close(SCFILE);
|
||||
} else {
|
||||
my $l = $params{SYSCONFIG}; # filter similar to above
|
||||
$l =~ s/<\S+>//g; # trim out obvious HTML commands
|
||||
$l =~ s/<!--.*-->//g; # trim out HTML comments
|
||||
$l =~ s/\\\n/\n/g; # turn quoted newline to plain newline
|
||||
print RESULTSTXT $l;
|
||||
}
|
||||
}
|
||||
|
||||
close(RESULTSTXT);
|
||||
}
|
||||
|
||||
# Write the main part of the HTML page
|
||||
sub genHTMLReportStart {
|
||||
fileBackup ($resultshtml); # if processing as we go, backup old file
|
||||
# Open an html file to hold the results
|
||||
open(RESULTSHTML, ">$resultshtml") ||
|
||||
die "Couldn't open $resultshtml: $!";
|
||||
|
||||
print RESULTSHTML <<END;
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<A NAME=TitleSection>
|
||||
<TITLE>
|
||||
Mozilla MailStone Results $params{TSTAMP}
|
||||
</TITLE>
|
||||
</A>
|
||||
<HEAD>
|
||||
</HEAD>
|
||||
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#FF0000" ALINK="#000088">
|
||||
<CENTER>
|
||||
<HR NOSHADE WIDTH="100%">
|
||||
<H1>Mozilla MailStone Results $params{TSTAMP}</H1>
|
||||
<H2>$params{TITLE}</H2>
|
||||
<I>$params{COMMENTS}</I>
|
||||
<HR WIDTH="100%">
|
||||
</CENTER>
|
||||
|
||||
END
|
||||
printf RESULTSHTML "<BR><B>Test duration:</B> %d %s. ",
|
||||
figureTimeNumber ($params{TIME}),
|
||||
figureTimeUnits ($params{TIME}, "minutes");
|
||||
printf RESULTSHTML "<B>Rampup:</B> %d %s. ",
|
||||
figureTimeNumber ($params{RAMPTIME}),
|
||||
figureTimeUnits ($params{RAMPTIME}, "seconds");
|
||||
printf RESULTSHTML "<B>Reported duration:</B> %s seconds\n",
|
||||
commify ($realTestSecs);
|
||||
|
||||
printf RESULTSHTML "<BR><B>Reporting clients:</B> %s of %s\n",
|
||||
commify ($reportingClients), commify ($totalProcs);
|
||||
|
||||
print RESULTSHTML <<END;
|
||||
<BR>
|
||||
Test <A HREF="all.wld">complete workload</a> description.
|
||||
Filtered <A HREF="work.wld">workload</a> description.
|
||||
<BR>
|
||||
Plain <A HREF="results.txt">text version</a> of results.
|
||||
Log of <A HREF="stderr">stderr</a> and debugging output.
|
||||
<BR>
|
||||
|
||||
<A NAME=MonitoringSection></A>
|
||||
END
|
||||
|
||||
{ # list user requested logging
|
||||
my @logfiles = <$resultdir/*-pre.log>;
|
||||
if (@logfiles) {
|
||||
foreach $f (@logfiles) {
|
||||
$f =~ s/$resultdir\///o; # strip directory out
|
||||
$f =~ s/-pre\.log$//o; # strip extension off
|
||||
print RESULTSHTML "Pre test log: <A HREF=\"$f-pre.log\">$f</a><BR>\n";
|
||||
}
|
||||
}
|
||||
@logfiles = <$resultdir/*-run.log>;
|
||||
if (@logfiles) {
|
||||
foreach $f (@logfiles) {
|
||||
$f =~ s/$resultdir\///o; # strip directory out
|
||||
$f =~ s/-run\.log$//o; # strip extension off
|
||||
print RESULTSHTML "Monitoring log: <A HREF=\"$f-run.log\">$f</a><BR>\n";
|
||||
}
|
||||
}
|
||||
@logfiles = <$resultdir/*-post.log>;
|
||||
if (@logfiles) {
|
||||
foreach $f (@logfiles) {
|
||||
$f =~ s/$resultdir\///o; # strip directory out
|
||||
$f =~ s/-post\.log$//o; # strip extension off
|
||||
print RESULTSHTML "Post test log: <A HREF=\"$f-post.log\">$f</a><BR>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#print RESULTSHTML
|
||||
#"<CENTER><H2>Results per protocol</H2></CENTER>\n";
|
||||
|
||||
foreach $proto (@protocolsAll) {
|
||||
printf RESULTSHTML "<A NAME=%sTable></A>\n", $proto;
|
||||
printf RESULTSHTML
|
||||
"<TABLE BORDER=2 CELLSPACING=2 CELLPADDING=2 COLS=%d WIDTH=\"95%%\">",
|
||||
2+$#{@{$protocolFields{$proto}}};
|
||||
print RESULTSHTML
|
||||
"<CAPTION>$proto Counters</CAPTION>\n";
|
||||
# do op counters
|
||||
print RESULTSHTML
|
||||
"<TR><TH>$proto</TH>\n";
|
||||
foreach $f (@timerFieldsAll) {
|
||||
#($f =~ m/^Time2$/o) && next;
|
||||
printf RESULTSHTML "<TH>%s</TH> ",
|
||||
($fieldNames{$f}) ? $fieldNames{$f} : $f;
|
||||
}
|
||||
print RESULTSHTML
|
||||
"</TR>\n";
|
||||
foreach $n (@{$protocolFields{$proto}}) {
|
||||
my $t = $n; # dont modify original list
|
||||
unless ($t =~ /^\[(\w+)\]$/) { # scalar case
|
||||
next; # skip scalars for now
|
||||
# do scalar counters. Column should line up with "Try"
|
||||
printf RESULTSHTML "<TR ALIGN=RIGHT><TH>%s</TH>\n",
|
||||
($timerNames{$t}) ? $timerNames{$t} : $t;
|
||||
printf RESULTSHTML
|
||||
"<TD>%s</TD> ",
|
||||
commify ($finals{$proto}->{$t});
|
||||
next;
|
||||
} else {
|
||||
$t = $1;
|
||||
}
|
||||
printf RESULTSHTML "<TR ALIGN=RIGHT><TH>%s</TH>\n",
|
||||
($timerNames{$t}) ? $timerNames{$t} : $t;
|
||||
foreach $f (@timerFieldsAll) {
|
||||
#($f =~ m/^Time2$/o) && next;
|
||||
if ($f =~ m/Time/o) {
|
||||
printf RESULTSHTML
|
||||
"<TD>%s</TD> ",
|
||||
tformat ($finals{$proto}->{$t}->{$f});
|
||||
} elsif ($f =~ m/Bytes/o) {
|
||||
printf RESULTSHTML
|
||||
"<TD>%s</TD> ",
|
||||
kformat ($finals{$proto}->{$t}->{$f});
|
||||
} else {
|
||||
printf RESULTSHTML
|
||||
"<TD>%s</TD> ",
|
||||
commify ($finals{$proto}->{$t}->{$f});
|
||||
}
|
||||
}
|
||||
print RESULTSHTML "</TR>\n";
|
||||
}
|
||||
|
||||
# do ops/sec
|
||||
print RESULTSHTML
|
||||
"<TR><TH>$proto</TH>\n";
|
||||
foreach $f (@timerFieldsAll) {
|
||||
($f =~ m/^Time/o) && next;
|
||||
printf RESULTSHTML "<TH>%s/sec</TH> ",
|
||||
($fieldNames{$f}) ? $fieldNames{$f} : $f;
|
||||
}
|
||||
print RESULTSHTML
|
||||
"</TR>\n";
|
||||
foreach $n (@{$protocolFields{$proto}}) {
|
||||
my $t = $n; # dont modify original list
|
||||
unless ($t =~ /^\[(\w+)\]$/) { # scalar case
|
||||
next; # skip scalars for now
|
||||
# do scalar counters. Column should line up with "Try"
|
||||
printf RESULTSHTML "<TR ALIGN=RIGHT><TH>%s</TH>\n",
|
||||
($timerNames{$t}) ? $timerNames{$t} : $t;
|
||||
printf RESULTSHTML
|
||||
"<TD>%.3f</TD> ",
|
||||
$finals{$proto}->{$t} / $realTestSecs;
|
||||
next;
|
||||
} else {
|
||||
$t = $1;
|
||||
}
|
||||
printf RESULTSHTML "<TR ALIGN=RIGHT><TH>%s</TH>\n",
|
||||
($timerNames{$t}) ? $timerNames{$t} : $t;
|
||||
foreach $f (@timerFieldsAll) {
|
||||
($f =~ m/^Time/o) && next;
|
||||
if ($f =~ m/Bytes/o) {
|
||||
printf RESULTSHTML
|
||||
"<TD>%s</TD> ",
|
||||
kformat ($finals{$proto}->{$t}->{$f} / $realTestSecs);
|
||||
} else {
|
||||
printf RESULTSHTML
|
||||
"<TD>%.3f</TD> ",
|
||||
$finals{$proto}->{$t}->{$f} / $realTestSecs;
|
||||
}
|
||||
}
|
||||
print RESULTSHTML "</TR>\n";
|
||||
}
|
||||
printf RESULTSHTML "</TABLE> <BR>\n\n";
|
||||
}
|
||||
|
||||
print RESULTSHTML <<END;
|
||||
|
||||
<BR>
|
||||
|
||||
<CENTER>
|
||||
<A NAME=GraphSection></A>
|
||||
END
|
||||
}
|
||||
|
||||
%genplotGraphs = ();
|
||||
|
||||
# Call genplot; and, if a graph is generated, insert the HTML reference to it
|
||||
sub genHTMLReportGraph {
|
||||
my $name = shift;
|
||||
my $title = shift;
|
||||
my $label = shift;
|
||||
my $protos = shift || die "genHTMLReportGraph: '$name' missing protocols";
|
||||
my $field = shift;
|
||||
my $vars = shift || die "genHTMLReportGraph: '$name' missing vars";
|
||||
|
||||
if ($genplotGraphs{$name}) {
|
||||
print "Graph $name has already been generated.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$genplotGraphs{$name} = $title;
|
||||
|
||||
# Delineate and tag each graph
|
||||
print RESULTSHTML "<A NAME=$name><HR SIZE=4 WIDTH=\"90%\"></A>\n";
|
||||
if (genPlot ($name, $title, $label, $protos, $field, $vars) > 0) {
|
||||
print RESULTSHTML <<END;
|
||||
<P><H3>$title</H3>
|
||||
<IMG SRC=$name.$params{IMAGETYPE} ALT="$label"></P>
|
||||
END
|
||||
} else {
|
||||
print RESULTSHTML "<BR>Graph \"$name\" contained no data (@{$vars}).<BR>\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Write the final parts of the HTML page
|
||||
sub genHTMLReportEnd {
|
||||
print RESULTSHTML <<END;
|
||||
<!-- INSERT IMAGES HERE - DO NOT DELETE THIS LINE -->
|
||||
</CENTER>
|
||||
<A NAME=EndSection></A>
|
||||
END
|
||||
|
||||
if ($params{SYSCONFIG}) {
|
||||
print RESULTSHTML "<HR WIDTH=\"100%\">";
|
||||
print RESULTSHTML "<CENTER><H2>Details</H2></CENTER>\n";
|
||||
if (($params{SYSCONFIG} =~ m/^\S+$/o)
|
||||
&& (open(SCFILE, "<$params{SYSCONFIG}"))) { # see if its a file
|
||||
while (<SCFILE>) {
|
||||
print RESULTSHTML $_;
|
||||
}
|
||||
close(SCFILE);
|
||||
} else { # output text directly
|
||||
my $l = $params{SYSCONFIG};
|
||||
$l =~ s/\\\n/\n/g; # turn quoted newline to plain newline
|
||||
print RESULTSHTML $l;
|
||||
}
|
||||
}
|
||||
|
||||
print RESULTSHTML <<END;
|
||||
|
||||
<HR NOSHADE WIDTH="100%">
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
END
|
||||
close(RESULTSHTML);
|
||||
}
|
||||
|
||||
|
||||
# Actually generate the standard stuff
|
||||
setupTotals();
|
||||
genTextReport();
|
||||
|
||||
|
||||
genHTMLReportStart();
|
||||
|
||||
my $graphCount = 0;
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /GRAPH/i);
|
||||
my $name = $section->{sectionParams};
|
||||
$name =~ s/name=\s*//; # strip off initial bit
|
||||
my @varlist = split (/[\s,]+/, $section->{VARIABLES});
|
||||
|
||||
$graphCount++;
|
||||
genHTMLReportGraph ($name, $section->{TITLE}, $section->{LABEL},
|
||||
($section->{FIELD} =~ /Time/o)
|
||||
? \@protocols : \@protocolsAll,
|
||||
$section->{FIELD}, \@varlist);
|
||||
}
|
||||
|
||||
if ($graphCount <= 0) { # use built ins
|
||||
|
||||
# generate the graphs we want
|
||||
# NOTE: the first argument (name), must be unique; sets file name
|
||||
genHTMLReportGraph ("connects",
|
||||
"Number of connections attempted", "Connections/sec",
|
||||
\@protocolsAll, "Try", ["conn" ]);
|
||||
genHTMLReportGraph ("connections",
|
||||
"Total connections", "Connections",
|
||||
\@protocolsAll, "", ["connections" ]);
|
||||
genHTMLReportGraph ("errors",
|
||||
"Number of connection errors", "Errors/sec",
|
||||
\@protocolsAll, "Error", ["conn", "banner", "login", "logout" ]);
|
||||
genHTMLReportGraph ("retrieves",
|
||||
"Number of messages read", "Messages/sec",
|
||||
\@protocolsAll, "Try", ["retrieve" ]);
|
||||
genHTMLReportGraph ("submits",
|
||||
"Number of messages written", "Messages/sec",
|
||||
\@protocolsAll, "Try", ["submit" ]);
|
||||
genHTMLReportGraph ("commands",
|
||||
"Protocol commands", "Commands/sec",
|
||||
\@protocolsAll, "Try", ["cmd" ]);
|
||||
genHTMLReportGraph ("readBytes",
|
||||
"Bytes read", "Bytes/sec",
|
||||
\@protocolsAll, "BytesR", ["login", "banner", "cmd", "retrieve", "submit", "logout" ]);
|
||||
genHTMLReportGraph ("writeBytes",
|
||||
"Bytes written", "Bytes/sec",
|
||||
\@protocolsAll, "BytesW", ["login", "banner", "cmd", "retrieve", "submit", "logout" ]);
|
||||
genHTMLReportGraph ("msgTime",
|
||||
"Message transfer time", "Seconds per message",
|
||||
\@protocols, "Time", ["cmd", "submit", "retrieve" ]);
|
||||
genHTMLReportGraph ("setupTime",
|
||||
"Connection setup time", "Seconds per connection",
|
||||
\@protocols, "Time", ["conn", "banner", "login" ]);
|
||||
genHTMLReportGraph ("blocks",
|
||||
"Number of mailstone blocks executed", "Blocks/sec",
|
||||
\@protocolsAll, "", ["blocks" ]);
|
||||
}
|
||||
|
||||
if ($params{ADDGRAPHS}) { # pick up additional graphs
|
||||
my @graphs = ();
|
||||
readWorkloadFile ($params{ADDGRAPHS}, \@graphs);
|
||||
foreach $section (@graphs) {
|
||||
next unless ($section->{sectionTitle} =~ /GRAPH/i);
|
||||
my $name = $section->{sectionParams};
|
||||
$name =~ s/name=\s*//; # strip off initial bit
|
||||
my @varlist = split (/[\s,]+/, $section->{VARIABLES});
|
||||
|
||||
$graphCount++;
|
||||
genHTMLReportGraph ($name, $section->{TITLE}, $section->{LABEL},
|
||||
($section->{FIELD} =~ /Time/o)
|
||||
? \@protocols : \@protocolsAll,
|
||||
$section->{FIELD}, \@varlist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
genHTMLReportEnd();
|
||||
|
||||
return 1;
|
||||
@@ -1,205 +0,0 @@
|
||||
#!/bin/ksh
|
||||
|
||||
# global configuration parameters.
|
||||
# Fill in defaults for anything that is not already set
|
||||
|
||||
# Look for testname$test_form, first
|
||||
export test_form=${test_form:-""}
|
||||
|
||||
# string appended to every description
|
||||
export desc_conf=${desc_conf:-""}
|
||||
|
||||
# extra arguments common to all tests
|
||||
export extra_args=${extra_args:-""}
|
||||
|
||||
# error limit to abort sequence
|
||||
export error_limit=${error_limit:-100}
|
||||
|
||||
# set this to only show what it will do
|
||||
export only_show_it=${only_show_it:-0}
|
||||
|
||||
# time to allow the server to calm down after each run
|
||||
export sleep_time=${sleep_time:-5}
|
||||
|
||||
# This is where we store the important runs
|
||||
export save_dir=${save_dir:-"results.save"}
|
||||
|
||||
# Basic sanity test
|
||||
if [[ ! -x /usr/bin/perl || ! -f .license ]] ; then # see if setup was ever run
|
||||
echo "Critical files are missing. Run setup."
|
||||
exit 2;
|
||||
fi
|
||||
|
||||
find_timestamp () { # find the timestamp string from latest run
|
||||
#OLD timestamp=`ls -d results/[0-9]*.[0-9][0-9][0-9][0-9]?(a-z) | tail -1`
|
||||
|
||||
# list all directories with the timestamp pattern
|
||||
timestamp=`echo results/[0-9]*.[0-9][0-9][0-9][0-9]?([a-z])`
|
||||
# strip all but the last one
|
||||
timestamp=${timestamp##* }
|
||||
|
||||
# strip the top directory name out
|
||||
timestamp=${timestamp#results/}
|
||||
|
||||
# return it
|
||||
echo $timestamp
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# copy last mailstone run from the current directory to good results directory
|
||||
save_run () {
|
||||
|
||||
[[ -d $save_dir ]] || \
|
||||
mkdir $save_dir
|
||||
|
||||
[[ $only_show_it -gt 0 ]] && return 0 # dont do anything important
|
||||
|
||||
if [[ -n "$last_timestamp" && -d "results/$last_timestamp/" ]] ; then
|
||||
cp -pR results/$last_timestamp $save_dir/
|
||||
# index probably has lots of extra junk, but its better than nothing
|
||||
cp -pf results/index.html $save_dir/
|
||||
fi
|
||||
}
|
||||
|
||||
# Display and run a command. Skip if in only_show mode.
|
||||
run () {
|
||||
if [[ $only_show_it -gt 0 ]] ; then
|
||||
echo "Would run:" "$@"
|
||||
return 0
|
||||
fi
|
||||
echo "Running: " "$@"
|
||||
"$@"
|
||||
}
|
||||
|
||||
# Sleep. Skip if in only_show mode.
|
||||
run_sleep () {
|
||||
if [[ $only_show_it -gt 0 ]] ; then
|
||||
echo "Would sleep:" "$@"
|
||||
return 0
|
||||
fi
|
||||
echo "Sleeping: " "$@"
|
||||
sleep "$@"
|
||||
}
|
||||
# for readability, just use sleep
|
||||
alias sleep=run_sleep
|
||||
|
||||
|
||||
# This runs the actual mstone run and check for errors
|
||||
# compress tmp files
|
||||
# Usage: run_test testname description [args...]
|
||||
run_test () {
|
||||
testname="$1"; shift;
|
||||
desc="$1"; shift;
|
||||
|
||||
# see if a special version of this test exists
|
||||
if [[ -f conf/$testname$test_form.wld ]] ; then
|
||||
testname=$testname$test_form
|
||||
fi
|
||||
|
||||
#oldtimestamp=`find_timestamp`
|
||||
|
||||
if [[ $only_show_it -gt 0 ]] ; then
|
||||
echo "Would run:" mstone $testname -b "$desc $desc_conf" $extra_args "$@"
|
||||
if [[ ! -f conf/$testname.wld ]] ; then
|
||||
echo "Configuration Error: No such test $testname"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "\n##########################################################"
|
||||
if [[ ! -f conf/$testname.wld ]] ; then
|
||||
echo "CONFIGURATION ERROR: No such test $testname"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "\nRunning:" mstone $testname -b "$desc $desc_conf" $extra_args "$@"
|
||||
# We actually bypass the mstone script
|
||||
/usr/bin/perl -Ibin -- bin/mailmaster.pl -w conf/$testname.wld -b "$desc $desc_conf" $extra_args "$@"
|
||||
stat=$?
|
||||
|
||||
# BUG if another test is running at the same time, this is wrong
|
||||
timestamp="`find_timestamp`"
|
||||
|
||||
# test failed to even run
|
||||
if [[ $stat -ne 0 ]]
|
||||
then
|
||||
echo "ABORT! Test failed to start"
|
||||
[[ -n "$mail_list" ]] && \
|
||||
mail_series "DotCom Failed run: `date`" "$mail_list"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# compress tmp files. get the csv files, too.
|
||||
gzip tmp/$timestamp/* results/$timestamp/*.csv
|
||||
|
||||
# stick the timestamp someplace global for a save_run
|
||||
export last_timestamp=$timestamp
|
||||
export all_timestamps="$all_timestamps $timestamp"
|
||||
|
||||
# save the results
|
||||
save_run
|
||||
|
||||
# see how many errors we hit
|
||||
totline=`grep 'Total:total ' results/$timestamp/results.txt`
|
||||
|
||||
# strip label and first field
|
||||
errors=${totline##+([+-z])+( )+([+-9])+( )}
|
||||
# strip trailing fields
|
||||
errors=${errors%% *}
|
||||
|
||||
echo "" # space things out
|
||||
|
||||
if [[ $errors -gt $error_limit ]] ; then
|
||||
echo "ABORT! Errors ($errors) exceed error limit ($error_limit)"
|
||||
[[ -n "$mail_list" ]] && \
|
||||
mail_series "DotCom Aborted run: `date`" "$mail_list"
|
||||
exit 1
|
||||
fi
|
||||
echo "Run completed OK ($errors errors). Timestamp $timestamp"
|
||||
|
||||
sleep $sleep_time
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Usage: mail_series subject "address,address,..."
|
||||
mail_series () {
|
||||
subject=$1; shift
|
||||
file=/tmp/series$$.tar
|
||||
|
||||
if [[ $only_show_it -gt 0 ]] ; then
|
||||
echo "Would mail results about $subject" to "$@"
|
||||
return 0
|
||||
fi
|
||||
echo "Mailing results about $subject" to "$@"
|
||||
|
||||
tar cf $file $save_dir/index.html
|
||||
for f in $all_timestamps ; do
|
||||
tar rf $file $save_dir/$f
|
||||
done
|
||||
gzip $file
|
||||
echo "$all_timestamps" | uuenview -b -30000 -s "$subject" -m "$@" $file.gz
|
||||
rm -f $file.gz
|
||||
}
|
||||
|
||||
# parse command line arguments
|
||||
while [[ -n "$1" ]]
|
||||
do
|
||||
case $1 in
|
||||
# -n mode, do not execute, just show
|
||||
-n) only_show_it=1; shift;;
|
||||
|
||||
# set test form
|
||||
-f) shift; test_form=$1; shift;;
|
||||
|
||||
# set test extra description
|
||||
-d) shift; desc_conf=$1; shift;;
|
||||
|
||||
# Rest are to be passed in exactly
|
||||
--) shift; break;;
|
||||
|
||||
#default, pick up as an extra arg
|
||||
*) extra_args="$extra_args $1"; shift;;
|
||||
esac
|
||||
done
|
||||
@@ -1,464 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# 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 the Netscape Mailstone utility,
|
||||
# released March 17, 2000.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999-2000 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Christian <robodan@netscape.com>
|
||||
# Marcel DePaolis <marcel@netcape.com>
|
||||
# Jim Salter <jsalter@netscape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU Public License (the "GPL"), in which case the
|
||||
# provisions of the GPL are applicable instead of those above.
|
||||
# If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL and not to allow others to use your
|
||||
# version of this file under the NPL, indicate your decision by
|
||||
# deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this
|
||||
# file under either the NPL or the GPL.
|
||||
#####################################################
|
||||
|
||||
# usage: setup.pl setup|cleanup|checktime|timesync -m machine_file
|
||||
# message files are expected to be in ./data/ and end with ".msg"
|
||||
|
||||
print "Netscape Mailstone.\nCopyright (c) 1997-2000 Netscape Communications Corp.\n";
|
||||
|
||||
$mode = shift; # mode must be first
|
||||
|
||||
# this parses the command line for -m machinefile
|
||||
# also sets many defaults
|
||||
do 'args.pl'|| die $@;
|
||||
sub warn_system;
|
||||
sub die_system;
|
||||
|
||||
parseArgs(); # parse command line
|
||||
|
||||
setConfigDefaults(); # setup RSH and RCP
|
||||
|
||||
$cpcmd = "cp"; # copy files... dir
|
||||
$rmcmd = "rm -f"; # remove files...
|
||||
|
||||
die "Must specify workload file" unless (@workload);
|
||||
|
||||
# Add or change client machines
|
||||
sub configClients {
|
||||
print "\n You can enter multiple machines like this: host1,host2\n";
|
||||
my @d = <bin/*/bin>;
|
||||
if (@d) {
|
||||
my @d2;
|
||||
foreach (@d2 = @d) { s/^bin\/// }
|
||||
foreach (@d = @d2) { s/\/bin$// }
|
||||
print " These OS versions are available:\n@d\n";
|
||||
}
|
||||
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
my $arch = "default OS";
|
||||
$arch = $section->{ARCH} if ($section->{ARCH});
|
||||
print "\nWhat is the name of the client(s) for $arch [$slist]: ";
|
||||
my $ans = <STDIN>; chomp $ans;
|
||||
if ($ans) {
|
||||
$ans =~ s/\s//g; # strip any whitespace
|
||||
fileReplaceText ($params{WORKLOAD}, "<CLIENT", $slist, $ans);
|
||||
}
|
||||
}
|
||||
while (1) {
|
||||
print "\nWhat additional client(s) [none]: ";
|
||||
my $ans = <STDIN>; chomp $ans;
|
||||
last unless ($ans); # done
|
||||
last if ($ans =~ /^none$/i);
|
||||
$ans =~ s/\s//g; # strip any whitespace
|
||||
my $block = "\n<CLIENT HOSTS=$ans>\n";
|
||||
|
||||
print "What OS type [default]: ";
|
||||
my $ans = <STDIN>; chomp $ans;
|
||||
$block .= " Arch\t$ans\n" if ($ans && !($ans =~ /^default$/i));
|
||||
|
||||
$block .= "</CLIENT>\n";
|
||||
fileInsertAfter ($params{WORKLOAD}, "^</CLIENT>", $block);
|
||||
}
|
||||
}
|
||||
|
||||
# Create a user ldif file
|
||||
sub configUserLdif {
|
||||
my $name = "conf/$defaultSection->{SERVER}.ldif";
|
||||
print "\nWhat file to you want to create [$name]? ";
|
||||
$ans = <STDIN>; chomp $ans;
|
||||
$name = $ans if ($ans);
|
||||
|
||||
my $mode = "users";
|
||||
print "\nDo you want to create a broadcast account [y]? ";
|
||||
$ans = <STDIN>;
|
||||
$mode .= " broadcast" unless ($ans =~ /^n/i);
|
||||
|
||||
my $basedn = $defaultSection->{SERVER}; # pick a default
|
||||
$basedn =~ s/^.*?\.//; # strip off before first dot
|
||||
$basedn = "o=$basedn";
|
||||
|
||||
print "\nWhat is LDAP base DN [$basedn]? ";
|
||||
$ans = <STDIN>; chomp $ans;
|
||||
$basedn = $ans if ($ans);
|
||||
|
||||
my $args = $params{MAKEUSERSARGS};
|
||||
|
||||
print "\n Common additional makeusers arguments:\n";
|
||||
print "\t-s storeName -x storeCount \tMultiple store partitions\n";
|
||||
print "\t[-3|-4] \tConfigure for NSMS 3.x or 4.x\n";
|
||||
print "Any extra arguments to makeusers [$args]? ";
|
||||
$ans = <STDIN>; chomp $ans;
|
||||
$args = $ans if ($ans);
|
||||
|
||||
my $perlbin = "/usr/bin/perl";
|
||||
|
||||
$params{DEBUG} &&
|
||||
print "$perlbin -Ibin -- bin/makeusers.pl $mode -w $params{WORKLOAD} -b '$basedn' -o $name $args\n";
|
||||
|
||||
print "\nGenerating $name (this can take a while)\n";
|
||||
warn_system "$perlbin -Ibin -- bin/makeusers.pl $mode -w $params{WORKLOAD} -b '$basedn' -o $name $args";
|
||||
print "LDIF generation complete. See $name\n";
|
||||
print "\tSee the manual or INSTALL to create users using the LDIF file.\n";
|
||||
}
|
||||
|
||||
# This uses a match pattern plus text to text replacements.
|
||||
# Could make all changes and then write out new workload
|
||||
# You would have to be carefull about sections with multi-line support.
|
||||
sub configWorkload {
|
||||
my $ans;
|
||||
|
||||
print "\nWhat is the name of the mail host [$defaultSection->{SERVER}]: ";
|
||||
$ans = <STDIN>; chomp $ans;
|
||||
if ($ans) {
|
||||
fileReplaceText ($params{WORKLOAD},
|
||||
"(SERVER|SMTPMAILFROM|ADDRESSFORMAT)",
|
||||
$defaultSection->{SERVER}, $ans);
|
||||
$defaultSection->{SERVER} = $ans; # needed for ldif generation
|
||||
}
|
||||
print "\nWhat is the user name pattern [$defaultSection->{LOGINFORMAT}]: ";
|
||||
$ans = <STDIN>; chomp $ans;
|
||||
if ($ans) {
|
||||
fileReplaceText ($params{WORKLOAD},
|
||||
"(LOGINFORMAT|ADDRESSFORMAT)",
|
||||
$defaultSection->{LOGINFORMAT}, $ans);
|
||||
$ans =~ s/%ld/0/; # create smtpMailFrom user
|
||||
my $olduser = $defaultSection->{SMTPMAILFROM};
|
||||
$olduser =~ s/@.*$//; # strip off after @
|
||||
fileReplaceText ($params{WORKLOAD},
|
||||
"SMTPMAILFROM",
|
||||
$olduser, $ans);
|
||||
}
|
||||
|
||||
print "\nWhat is the password pattern [$defaultSection->{PASSWDFORMAT}]: ";
|
||||
$ans = <STDIN>; chomp $ans;
|
||||
fileReplaceText ($params{WORKLOAD}, "PASSWDFORMAT",
|
||||
$defaultSection->{PASSWDFORMAT}, $ans);
|
||||
|
||||
$defaultSection->{NUMLOGINS} = 100 unless ($defaultSection->{NUMLOGINS});
|
||||
print "\nHow many users [$defaultSection->{NUMLOGINS}]: ";
|
||||
$ans = <STDIN>; chomp $ans;
|
||||
fileReplaceText ($params{WORKLOAD}, "(NUMADDRESSES|NUMLOGINS)",
|
||||
$defaultSection->{NUMLOGINS}, $ans);
|
||||
|
||||
$defaultSection->{FIRSTLOGIN} = 0 unless ($defaultSection->{FIRSTLOGIN});
|
||||
print "\nWhat is the first user number [$defaultSection->{FIRSTLOGIN}]: ";
|
||||
$ans = <STDIN>; chomp $ans;
|
||||
fileReplaceText ($params{WORKLOAD}, "(FIRSTADDRESS|FIRSTLOGIN)",
|
||||
$defaultSection->{FIRSTLOGIN}, $ans);
|
||||
|
||||
unless ($params{NT}) {
|
||||
configClients ();
|
||||
}
|
||||
|
||||
print "\nDo you want to view the edited $params{WORKLOAD} [y]? ";
|
||||
$ans = <STDIN>;
|
||||
unless ($ans =~ /^n/i) {
|
||||
print "Here is the edited $params{WORKLOAD}:\n\n";
|
||||
fileShow ($params{WORKLOAD});
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print "\nDo you want to generate a user LDIF file [y]? ";
|
||||
$ans = <STDIN>;
|
||||
unless ($ans =~ /^n/i) {
|
||||
configUserLdif ();
|
||||
}
|
||||
}
|
||||
|
||||
# See if license file has been displayed
|
||||
if (($mode ne "cleanup") && (! -f ".license" )) {
|
||||
fileShow ("LICENSE");
|
||||
# SEAN: blow off annoying agreement message.
|
||||
# print "\nDo you agree to the terms of the license? (yes/no) ";
|
||||
# my $ans = <STDIN>;
|
||||
# print "\n";
|
||||
# unless ($ans =~ /^yes$/i) {
|
||||
# print "License not agreed to.\n";
|
||||
# exit 0;
|
||||
# }
|
||||
my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
|
||||
open (LIC, ">.license");
|
||||
printf LIC "%04d$mon$mday$hour$min\n", $year+1900;
|
||||
close (LIC);
|
||||
}
|
||||
|
||||
if ($mode eq "config") { # re-run config
|
||||
configWorkload ();
|
||||
|
||||
print "\nMake any additional changes to $params{WORKLOAD} and then re-run 'setup'\n";
|
||||
exit 0;
|
||||
} elsif ($mode ne "cleanup") { # check if configured
|
||||
my $unconf = 0; # see if default values are in use
|
||||
foreach $section (@workload) {
|
||||
($section->{SERVER})
|
||||
&& ($section->{SERVER} =~ /example\.com$/)
|
||||
&& $unconf++;
|
||||
($section->{SMTPMAILFROM})
|
||||
&& ($section->{SMTPMAILFROM} =~ /example\.com$/)
|
||||
&& $unconf++;
|
||||
($section->{ADDRESSFORMAT})
|
||||
&& ($section->{ADDRESSFORMAT} =~ /example\.com$/)
|
||||
&& $unconf++;
|
||||
last if ($unconf > 0);
|
||||
}
|
||||
if ($unconf > 0) {
|
||||
print "Server has not been configured (example.com is an invalid address).\n";
|
||||
print "Do you want to setup a simple configuration now [y]?";
|
||||
my $ans = <STDIN>;
|
||||
if ($ans =~ /^n/i) {
|
||||
print "Re-run setup when you have edited the configuration.\n";
|
||||
exit 0;
|
||||
}
|
||||
configWorkload ();
|
||||
|
||||
print "\nMake any additional changes to $params{WORKLOAD} and then re-run 'setup'\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode eq "timesync") {
|
||||
if ($params{NT}) {
|
||||
print "Timesync has no effect on NT\n";
|
||||
exit 0;
|
||||
}
|
||||
my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
|
||||
$mon += 1; # adjust from 0 based to std
|
||||
$systime = sprintf ("%02d%02d%02d%02d%04d.%02d",
|
||||
$mon, $mday, $hour, $min, 1900+$year, $sec);
|
||||
} elsif ($mode eq "checktime") {
|
||||
if ($params{NT}) { # if running on NT, then only single client
|
||||
print "Checktime not needed on NT\n";
|
||||
exit 0;
|
||||
}
|
||||
mkdir ("$resultbase", 0775);
|
||||
mkdir ("$tmpbase", 0775);
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
open MAKEIT, ">$tmpbase/$cli.tim";
|
||||
close MAKEIT;
|
||||
}
|
||||
}
|
||||
} elsif (($mode eq "setup") || ($mode eq "cleanup")) {
|
||||
@msgs = <data/*.msg>;
|
||||
foreach (@files = @msgs) { s/data\/// }
|
||||
print "Found these message files:\n@files\n\n";
|
||||
if ($params{NT}) { # handle NT localhost here
|
||||
exit 0 if ($mode =~ /cleanup$/);
|
||||
my $clipath = "bin/WINNT4.0/bin/mailclient.exe";
|
||||
print "Copying $clipath and message files to $cli\n";
|
||||
die_system "copy $clipath $params{TEMPDIR}";
|
||||
foreach $f (@files) {
|
||||
die_system "copy $f $params{TEMPDIR}";
|
||||
}
|
||||
exit 0; # without perl:fork, no more to do
|
||||
}
|
||||
}
|
||||
|
||||
# iterate over every client in the testbed, complete the cmd and rsh
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
|
||||
my $rcp = ($section->{RCP}) ? $section->{RCP} : $params{RCP};
|
||||
my $tempdir;
|
||||
if ($section->{TEMPDIR}) {
|
||||
$tempdir = $section->{TEMPDIR};
|
||||
} elsif ($params{TEMPDIR}) {
|
||||
$tempdir = $params{TEMPDIR};
|
||||
}
|
||||
|
||||
my $cliarch = $section->{ARCH};
|
||||
|
||||
# presumed architecture for bin/mailclient on localhost:
|
||||
my $local_arch = `bin/nsarch`;
|
||||
chomp $local_arch;
|
||||
|
||||
# Try to determine arch if it hasn't been explicitly set.
|
||||
if (!$cliarch) {
|
||||
if ($cli =~ /localhost/) {
|
||||
$cliarch = `bin/nsarch`;
|
||||
chomp $cliarch;
|
||||
} else {
|
||||
$cliarch = `$rsh $cli sh < bin/nsarch`;
|
||||
chomp $cliarch;
|
||||
}
|
||||
}
|
||||
|
||||
# most time critical first
|
||||
if ($mode eq "timesync") {
|
||||
next if ($cli =~ /^localhost$/i); # dont reset our own time
|
||||
# run all these in parallel to minimize skew
|
||||
next if ($cliarch eq "NT4.0");
|
||||
forkproc ($rsh, $cli, "date $systime");
|
||||
}
|
||||
|
||||
elsif ($mode eq "checktime") {
|
||||
# run all these in parallel to minimize skew
|
||||
forkproc ($rsh, $cli, ($cliarch eq "NT4.0")
|
||||
? "time" : "date",
|
||||
"/dev/null", "$tmpbase/$cli.tim");
|
||||
}
|
||||
|
||||
elsif ($mode eq "setup") {
|
||||
my ($clibin) = split /\s/, (($section->{COMMAND})
|
||||
? $section->{COMMAND}
|
||||
: $params{CLIENTCOMMAND});
|
||||
my $clipath = ''; # do nothing by default
|
||||
|
||||
# Look for architecture-specific binary.
|
||||
if ($cliarch) {
|
||||
|
||||
# fallback to just os-name if we can't find an exact match.
|
||||
my $approx = $cliarch;
|
||||
$approx =~ s/^(\D+).*/$1/;
|
||||
my $approx_bin = <"bin/${approx}*/bin/$clibin">;
|
||||
|
||||
if (-x "bin/$cliarch/bin/$clibin") {
|
||||
# exact match.
|
||||
$clipath = "bin/$cliarch/bin/$clibin";
|
||||
} elsif (-x $approx_bin) {
|
||||
# approximate match
|
||||
$clipath = $approx_bin;
|
||||
} elsif ($local_arch =~ /^$approx/) {
|
||||
# same arch as localhost
|
||||
$clipath = "bin/mailclient";
|
||||
} else {
|
||||
print STDERR
|
||||
"Requested OS $cliarch for $cli not found. ",
|
||||
"Not copying binary.\n";
|
||||
}
|
||||
} else {
|
||||
# arch not found
|
||||
print STDERR "Cannot determine architecture for $cli. ",
|
||||
"Not copying binary.\n";
|
||||
}
|
||||
# See if we have anything to copy:
|
||||
if ("$clipath @files" !~ /\S/) {
|
||||
print STDERR "Nothing to copy to $cli. Skipping.\n";
|
||||
next;
|
||||
}
|
||||
my $rdir = ($tempdir) ? "$tempdir/" : ".";
|
||||
# chmod so that the remote files can be easily cleaned up
|
||||
my $rcmd = "chmod g+w @files $clibin; uname -a";
|
||||
$rcmd = "cd $tempdir; " . $rcmd if ($tempdir);
|
||||
$rdir =~ s!/!\\!g if ($cliarch eq "NT4.0");
|
||||
if ($cli =~ /^localhost$/i) {
|
||||
die "TEMPDIR must be set for 'localhost'\n"
|
||||
unless ($tempdir);
|
||||
die "Invalid local NT copy. Should never get here.\n"
|
||||
if ($cliarch eq "NT4.0"); # should never happen
|
||||
print "Copying $clipath and message files to $rdir\n";
|
||||
die_system ("$cpcmd @msgs $clipath $rdir");
|
||||
die_system ($rcmd);
|
||||
} else {
|
||||
print "$rcp $clipath @msgs $cli:$rdir\n" if ($params{DEBUG});
|
||||
print "Copying $clipath and message files to $cli:$rdir\n";
|
||||
warn_system (split (/\s+/, $rcp), $clipath, @msgs, "$cli:$rdir");
|
||||
next if ($cliarch eq "NT4.0"); # chmod not valid
|
||||
print "rcmd='$rcmd'\n" if ($params{DEBUG});
|
||||
die_system (split (/\s+/, $rsh), $cli, $rcmd);
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
|
||||
elsif ($mode eq "cleanup") {
|
||||
if ($params{DEBUG}) { # get debug files
|
||||
print "Cleaning up debug files on $cli\n";
|
||||
my $rcmd = ($cliarch eq "NT4.0") ? "DEL" : "$rmcmd";
|
||||
$rmcmd .= " mstone-debug.[0-9]*";
|
||||
$rcmd = "cd $tempdir; " . $rcmd if ($tempdir);
|
||||
$rcmd =~ s/;/&&/g if ($cliarch eq "NT4.0");
|
||||
if ($cli =~ /^localhost$/i) {
|
||||
die "TEMPDIR must be set for 'localhost'\n"
|
||||
unless ($tempdir);
|
||||
warn_system ($rcmd);
|
||||
} else {
|
||||
warn_system (split (/\s+/, $rsh), $cli, $rcmd);
|
||||
}
|
||||
} else {
|
||||
print "Cleaning $cli\n";
|
||||
my $rcmd = ($cliarch eq "NT4.0") ? "DEL" : "$rmcmd";
|
||||
$rcmd .= " $clibin @files";
|
||||
$rcmd = "cd $tempdir; " . $rcmd if ($tempdir);
|
||||
$rcmd =~ s/;/&&/g if ($cliarch eq "NT4.0");
|
||||
if ($cli =~ /^localhost$/i) {
|
||||
die "TEMPDIR must be set for 'localhost'\n"
|
||||
unless ($tempdir);
|
||||
warn_system ($rcmd);
|
||||
} else {
|
||||
warn_system (split (/\s+/, $rsh), $cli, $rcmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
die "Couldn't recognize mode $mode!\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# wait for children to finish
|
||||
if (($mode eq "timesync") || ($mode eq "checktime")) {
|
||||
$pid = wait();
|
||||
while ($pid != -1) {
|
||||
$pid = wait();
|
||||
}
|
||||
}
|
||||
|
||||
# Print the results of the time checks
|
||||
if ($mode eq "checktime") {
|
||||
print "Time from each client:\n";
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
my $slist = $section->{sectionParams};
|
||||
$slist =~ s/HOSTS=\s*//; # strip off initial bit
|
||||
foreach $cli (split /[\s,]/, $slist) {
|
||||
open TIMEFILE, "$tmpbase/$cli.tim"
|
||||
|| warn "Counldn't open $tmpbase/$cli.tim\n";
|
||||
printf "%32s: ", $cli;
|
||||
while (<TIMEFILE>) { print; last;} # single line (2 on NT)
|
||||
close(TIMEFILE);
|
||||
unlink "$tmpbase/$cli.tim";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
/*
|
||||
* 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 the Netscape Mailstone utility,
|
||||
* released March 17, 2000.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999-2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Sean O'Rourke <sean@sendmail.com>
|
||||
* Thom O'Connor <thom@sendmail.com>
|
||||
* Sendmail, Inc.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License Version 2 or later (the "GPL"), in
|
||||
* which case the provisions of the GPL are applicable instead of
|
||||
* those above. If you wish to allow use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice and
|
||||
* other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file
|
||||
* under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
use Thread qw(async);
|
||||
use FileHandle qw(_IOLBF);
|
||||
use Socket;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
|
||||
# options
|
||||
my $maxconn = SOMAXCONN;
|
||||
my $t_banner = 0;
|
||||
my $t_from = 0;
|
||||
my $t_rcpt = 0;
|
||||
my $t_dot = 0;
|
||||
my $port = 25;
|
||||
my $cs = '';
|
||||
my $log = '';
|
||||
my $proto = getprotobyname('tcp');
|
||||
|
||||
# statistics
|
||||
my ($cmds, $errs, $bytesw, $bytesr, $msgs);
|
||||
|
||||
GetOptions('maxconn:i' => \$maxconn,
|
||||
'banner-delay:i' => \$t_banner,
|
||||
'from-delay:i' => \$t_from,
|
||||
'rcpt-delay:i' => \$t_rcpt,
|
||||
'dot-delay:i' => \$t_dot,
|
||||
'log:s' => \$log,
|
||||
'checksums:s' => sub { use Digest::MD5; $cs = $_[0]; })
|
||||
|| &usage;
|
||||
|
||||
if (@ARGV == 1) {
|
||||
($port) = @ARGV;
|
||||
}
|
||||
|
||||
if ($log) {
|
||||
if (open(LOG, ">$log")) {
|
||||
print STDERR "Logging messages to $log\n";
|
||||
} else {
|
||||
warn ("Cannot open logfile $log\n");
|
||||
$log = '';
|
||||
}
|
||||
}
|
||||
|
||||
socket(S, PF_INET, SOCK_STREAM, $proto) || die $!;
|
||||
setsockopt(S, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) || die $!;
|
||||
|
||||
(bind(S, sockaddr_in($port, INADDR_ANY))
|
||||
&& listen(S, $maxconn))
|
||||
|| die $!;
|
||||
|
||||
my $addr;
|
||||
my $fh = new FileHandle;
|
||||
my $cnt = 0;
|
||||
|
||||
$SIG{INT} = sub { close(LOG); print STDERR "done\n"; exit 0; };
|
||||
|
||||
while(my $addr = accept($fh, S)) {
|
||||
if (++$cnt % 100 == 0) {
|
||||
print STDERR "$cnt\r";
|
||||
}
|
||||
my $thr = async { do_smtp($addr, $fh); };
|
||||
$thr->join;
|
||||
$fh = new FileHandle;
|
||||
}
|
||||
|
||||
sub usage
|
||||
{
|
||||
print STDERR <<EOS;
|
||||
Usage: $0 [options] [port]
|
||||
EOS
|
||||
exit -1;
|
||||
}
|
||||
|
||||
sub netline
|
||||
{
|
||||
my $fh = shift;
|
||||
my $line = $fh->getline;
|
||||
$line =~ s/\r\n$// if $line;
|
||||
$line;
|
||||
}
|
||||
|
||||
sub millisleep
|
||||
{
|
||||
my $t = shift;
|
||||
select(undef, undef, undef, $t) if $t > 0;
|
||||
}
|
||||
|
||||
sub netprint($@)
|
||||
{
|
||||
my ($fh, @stuff) = @_;
|
||||
foreach (@_) {
|
||||
s/([^\r])\n/$1\r\n/g;
|
||||
$fh->print($_);
|
||||
}
|
||||
}
|
||||
|
||||
sub do_smtp
|
||||
{
|
||||
my ($addr, $s) = @_;
|
||||
my $buf;
|
||||
my ($port, $iaddr) = sockaddr_in($addr);
|
||||
my $name = gethostbyaddr($iaddr, AF_INET);
|
||||
$s->setvbuf($buf, _IOLBF, 1024);
|
||||
|
||||
millisleep($t_banner);
|
||||
$s->print("220 wazzup, bro?\r\n");
|
||||
my %state = ('conn' => $s,
|
||||
'host' => $name);
|
||||
my %funcs = ('helo' => \&do_helo,
|
||||
'ehlo' => \&do_helo,
|
||||
'word' => \&do_helo,
|
||||
|
||||
'quit' => \&do_quit,
|
||||
'latr' => \&do_quit,
|
||||
|
||||
'mail' => \&do_from,
|
||||
'rcpt' => \&do_rcpt,
|
||||
'data' => \&do_data,
|
||||
'rset' => \&do_ok,
|
||||
'vrfy' => \&do_ok,
|
||||
'noop' => \&do_ok,
|
||||
);
|
||||
while (my $line = netline($s))
|
||||
{
|
||||
my ($cmd, $arg) = ($line =~ /^\s*(\S+)\s*(.*)$/);
|
||||
die "cmd = `$cmd'" unless ($cmd = lc($cmd));
|
||||
# fail 1% of commands
|
||||
if ($funcs{$cmd}) {
|
||||
&{$funcs{$cmd}}(\%state, $cmd, $arg, \%funcs);
|
||||
} else {
|
||||
$s->print("500 5.0.0 no. Just... no.\r\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub already_said_that
|
||||
{
|
||||
my ($state, $cmd, $arg) = @_;
|
||||
$state->{conn}->print("503 5.0.0 Dude, you already said that.\r\n");
|
||||
}
|
||||
|
||||
sub do_helo
|
||||
{
|
||||
my ($state, $cmd, $arg) = @_;
|
||||
$state->{helohost} = $arg;
|
||||
die unless $cmd;
|
||||
if ($cmd eq 'helo') {
|
||||
if ($arg eq $state->{host}) {
|
||||
$state->{conn}->print("221 hello Mr. Honest\r\n");
|
||||
} else {
|
||||
$state->{conn}->print("221 We know where you live, $state->{iaddr}\r\n");
|
||||
}
|
||||
} elsif ($cmd eq 'ehlo') {
|
||||
my $esmtp = <<EOS;
|
||||
250-localhost is pleased to make your acquaintance, and offers:
|
||||
250 8bitmime
|
||||
EOS
|
||||
if ($arg) {
|
||||
netprint($state->{conn}, $esmtp);
|
||||
} else {
|
||||
$state->{conn}->print("501 5.0.0 tell me more...\r\n");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$state->{conn}->print("221 2.0.0 peace brother\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
sub do_quit
|
||||
{
|
||||
my ($state, $cmd) = @_;
|
||||
$state->{conn}->print( "221 2.0.0 drop in any time\r\n");
|
||||
close ($state->{conn});
|
||||
}
|
||||
|
||||
sub do_from
|
||||
{
|
||||
my ($state, $cmd, $args, $funcs) = @_;
|
||||
millisleep($t_from);
|
||||
$state->{conn}->print( "250 2.1.0 Okay, keep talking\r\n");
|
||||
$funcs->{rcpt} = \&do_rcpt;
|
||||
}
|
||||
|
||||
sub do_rcpt
|
||||
{
|
||||
my ($state, $cmd, $args, $funcs) = @_;
|
||||
my ($rcpt) = ($args =~ /to\:\s*(.+)/i);
|
||||
millisleep($t_rcpt);
|
||||
$state->{conn}->print("250 2.1.5 ${rcpt}'s cool\r\n");
|
||||
$funcs->{data} = \&do_data;
|
||||
}
|
||||
|
||||
sub do_data
|
||||
{
|
||||
my ($state, $cmd, $args, $funcs) = @_;
|
||||
$state->{conn}->print( "354 up to the dot...\r\n");
|
||||
if ($cs) {
|
||||
my $line;
|
||||
my $md5 = Digest::MD5->new;
|
||||
# skip headers
|
||||
header: while ($_ = netline($state->{conn})) {
|
||||
last header if /^$/;
|
||||
last body if /^\.$/;
|
||||
}
|
||||
|
||||
body: while ($_ = $state->{conn}->getline) {
|
||||
if (/^=CS=MD5=(.+)\r/) {
|
||||
my $sum = $1;
|
||||
my $end = netline($state->{conn});
|
||||
|
||||
if ($end ne '.') {
|
||||
print STDERR "Fake checksum?: $sum\n";
|
||||
while (netline($state->{conn}) ne '.') { }
|
||||
} elsif (lc($sum) eq lc($md5->hexdigest)) {
|
||||
# print STDERR "MD5 sum OK.\n";
|
||||
} else {
|
||||
print STDERR "MD5 sum mismatch: $sum, ",
|
||||
$md5->hexdigest, "\n";
|
||||
}
|
||||
last body;
|
||||
} elsif (/^\.\r$/) {
|
||||
print STDERR "no checksum\n" if $cs =~ /^r/;
|
||||
last body;
|
||||
}
|
||||
print LOG $_ if $log;
|
||||
$md5->add($_);
|
||||
}
|
||||
print LOG ".\r\n" if $log;
|
||||
} else {
|
||||
local ($/) = "\r\n.\r\n";
|
||||
$state->{conn}->getline;
|
||||
}
|
||||
millisleep($t_dot);
|
||||
if (rand() % 100 == 0) {
|
||||
$state->{conn}->print("451 ohshit\r\n");
|
||||
} else {
|
||||
$state->{conn}->print("250 2.0.0 I will deliver\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
sub do_ok
|
||||
{
|
||||
my ($state) = @_;
|
||||
$state->{conn}->print("220 uhhuh\r\n");
|
||||
}
|
||||
@@ -1,825 +0,0 @@
|
||||
# util.pl -- utilities which used to live in bin/args.pl
|
||||
|
||||
sub my_system {
|
||||
my ($file, $line);
|
||||
$file = shift;
|
||||
$line = shift;
|
||||
my $ret;
|
||||
if (($ret = system(@_)) != 0) {
|
||||
my $msg = "$file:$line: @_\n\t";
|
||||
my ($excode, $sig, $cored) = ($ret >> 8, $ret & 127, $ret & 128);
|
||||
if ($sig) {
|
||||
$msg .= "died with signal $sig";
|
||||
$msg .= ' (core dumped)' if ($cored);
|
||||
$msg .= "\n";
|
||||
} else {
|
||||
$msg .= "exited abnormally with code $excode\n";
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
undef;
|
||||
}
|
||||
|
||||
sub warn_system {
|
||||
my ($pack, $file, $line) = caller;
|
||||
my $msg = my_system($file, $line, @_);
|
||||
warn $msg if $msg;
|
||||
}
|
||||
|
||||
sub die_system {
|
||||
my ($pack, $file, $line) = caller;
|
||||
my $msg = my_system($file, $line, @_);
|
||||
die $msg if $msg;
|
||||
}
|
||||
|
||||
# Utility functions
|
||||
# Create a unique hash array. Programming Perl, 2nd edition, p291 (p217?)
|
||||
package ArrayInstance;
|
||||
sub new {
|
||||
my $type = shift;
|
||||
my %params = @_;
|
||||
my $self = {};
|
||||
return bless $self, $type;
|
||||
}
|
||||
|
||||
package main;
|
||||
|
||||
# run a command in the background, return its PID
|
||||
# Uses fork: will not run on NT in perl 5.004
|
||||
# if the server is "localhost", ignore the rcmd part
|
||||
# if stdin, stdout, and/or stderr is set, redirect those for the sub process
|
||||
sub forkproc {
|
||||
my $rcmd = shift;
|
||||
my $server = shift;
|
||||
my $command = shift;
|
||||
my $stdin = shift;
|
||||
my $stdout = shift;
|
||||
my $stderr = shift;
|
||||
|
||||
if (my $pid = fork()) {
|
||||
return $pid; # parent
|
||||
}
|
||||
|
||||
# rest of this is in the child
|
||||
if ($stdin) { # redirect stdin if needed
|
||||
close (STDIN);
|
||||
open STDIN, "<$stdin"
|
||||
|| die "Couldn't open $stdin for input\n";
|
||||
}
|
||||
|
||||
if ($stdout) { # redirect stdout if needed
|
||||
close (STDOUT);
|
||||
open STDOUT, ">>$stdout"
|
||||
|| die "Couldn't open $stdout for output\n";
|
||||
}
|
||||
|
||||
if ($stderr) { # redirect stderr if needed
|
||||
close (STDERR);
|
||||
open STDERR, ">>$stderr"
|
||||
|| die "Couldn't open $stderr for output\n";
|
||||
}
|
||||
|
||||
if ($server =~ /^localhost$/i) {
|
||||
exec $command;
|
||||
die "Coundn't exec $command:$!\n";
|
||||
} else {
|
||||
exec split (/\s+/, $rcmd), $server, $command;
|
||||
die "Coundn't exec $rcmd $server $command:$!\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Relocate file to tmp directory (if it is in the results directory),
|
||||
# and put a ~ on the end of it.
|
||||
# ASSUMES tmp and results are on the same partition (on NT, same drive).
|
||||
# Usage: fileBackup (filename)
|
||||
sub fileBackup {
|
||||
my $filename = shift;
|
||||
my $bfile = $filename;
|
||||
|
||||
(-f $filename) || return 0; # file doent exist
|
||||
$bfile =~ s/$resultbase/$tmpbase/; # move to tmp
|
||||
$bfile .= "~"; # indicate that this is a backup
|
||||
(-f $bfile) && unlink ($bfile);
|
||||
#print "Backing up $filename to $bfile\n"; # DEBUG
|
||||
rename ($filename, $bfile) || unlink ($filename);
|
||||
}
|
||||
|
||||
# Insert text into a file after a tagline
|
||||
# fileInsertAfter (filename, tagstring, newtext)
|
||||
sub fileInsertAfter {
|
||||
my $filename = shift || die "fileInsertAfter: missing filename";
|
||||
my $tagline = shift || die "fileInsertAfter: missing tagline";
|
||||
my $newtext = shift || die "fileInsertAfter: missing text";
|
||||
my $foundit = 0;
|
||||
|
||||
open(OLD, "<$filename") ||
|
||||
open(OLD, "gunzip -c $filename |") ||
|
||||
die "fileInsertAfter: Could not open input $filename: $!";
|
||||
open(NEW, ">$filename+") ||
|
||||
die "fileInsertAfter: Could not open output $filename+: $!";
|
||||
|
||||
while (<OLD>) {
|
||||
print NEW $_; # copy (including tagline)
|
||||
|
||||
next unless (/$tagline/); # matched tagline
|
||||
|
||||
print NEW $newtext; # insert new text
|
||||
$foundit++;
|
||||
last; # only change first occurance
|
||||
}
|
||||
|
||||
if ($foundit) { # copy rest of file
|
||||
while (<OLD>) {
|
||||
print NEW $_;
|
||||
}
|
||||
}
|
||||
|
||||
close (OLD);
|
||||
close (NEW);
|
||||
if ($foundit) {
|
||||
fileBackup ($filename);
|
||||
rename ("$filename+", "$filename");
|
||||
#print "Updated $filename\n"; # DEBUG
|
||||
return $foundit;
|
||||
} else {
|
||||
($params{DEBUG}) && print "No change to $filename\n"; # DEBUG
|
||||
unlink ("$filename+");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
# Do text for text replacements in a file.
|
||||
# Perl wildcards are automatically quoted.
|
||||
# fileReplace (filename, matchPat, oldtext, newtext)
|
||||
sub fileReplaceText {
|
||||
my $filename = shift || die "fileReplaceText: missing filename";
|
||||
my $tagline = shift || die "fileReplaceText: missing tagline ($filename)";
|
||||
my $oldtext = shift;
|
||||
my $newtext = shift;
|
||||
my $foundit = 0;
|
||||
|
||||
return if ($newtext eq ""); # nothing to do
|
||||
return if ($oldtext eq ""); # nothing can be done
|
||||
|
||||
open(OLD, "<$filename") ||
|
||||
open(OLD, "gunzip -c $filename |") ||
|
||||
die "fileReplaceText: Could not open input $filename: $!";
|
||||
open(NEW, ">$filename+") ||
|
||||
die "fileReplaceText: Could not open output $filename+: $!";
|
||||
|
||||
$oldtext =~ s/([][{}*+?^.\/])/\\$1/g; # quote regex syntax
|
||||
|
||||
while (<OLD>) {
|
||||
if (/$tagline/i) { # matched tagline
|
||||
$foundit++;
|
||||
s/$oldtext/$newtext/; # do the replace
|
||||
}
|
||||
print NEW $_;
|
||||
}
|
||||
|
||||
close (OLD);
|
||||
close (NEW);
|
||||
if ($foundit) {
|
||||
fileBackup ($filename);
|
||||
rename ("$filename+", "$filename");
|
||||
#print "Updated $filename\n"; # DEBUG
|
||||
return $foundit;
|
||||
} else {
|
||||
($params{DEBUG}) && print "No change to $filename\n"; # DEBUG
|
||||
unlink ("$filename+");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
# copy a file to a new name. Handles possible compression. OS independent.
|
||||
# fileCopy (filename, newname)
|
||||
sub fileCopy {
|
||||
my $filename = shift || die "fileReplaceText: missing filename";
|
||||
my $newname = shift || die "fileReplaceText: missing newname ($filename)";
|
||||
|
||||
open(OLD, "<$filename") ||
|
||||
open(OLD, "gunzip -c $filename |") ||
|
||||
die "fileReplaceText: Could not open input $filename: $!";
|
||||
open(NEW, ">$newname") ||
|
||||
die "fileReplaceText: Could not open output $newname: $!";
|
||||
|
||||
while (<OLD>) { # copy it
|
||||
print NEW $_;
|
||||
}
|
||||
|
||||
close (OLD);
|
||||
close (NEW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
# display a file to STDOUT. Handles possible compression
|
||||
sub fileShow {
|
||||
my $filename = shift || die "fileShow: missing filename";
|
||||
open(SHOWIT, "<$filename") ||
|
||||
open(SHOWIT, "gunzip -c $filename.gz |") ||
|
||||
die "fileShow: Couldn't open $filename: $!";
|
||||
while (<SHOWIT>) { print; }
|
||||
close(SHOWIT);
|
||||
}
|
||||
|
||||
# sub function to figure time extents
|
||||
# (start, end) = dataMinMax counterName \@protocols oldstarttime oldendtime
|
||||
# Use 0 for uninitialized start or end
|
||||
sub dataMinMax {
|
||||
my $name = shift;
|
||||
my $protos = shift;
|
||||
my $start = shift;
|
||||
my $end = shift;
|
||||
|
||||
# make global
|
||||
# create the plot script and data files
|
||||
# Figure out the encompassing time extent
|
||||
foreach $p (@$protos) { # create the plot data files
|
||||
my @times = sort numeric keys %{ $graphs{$p}->{$name}};
|
||||
if ($#times <= 0) {
|
||||
next;
|
||||
}
|
||||
if (($start == 0) || ($times[0] < $start)) {
|
||||
$start = $times[0];
|
||||
}
|
||||
if (($end == 0) || ($times[0] > $end)) {
|
||||
$end = $times[$#times];
|
||||
}
|
||||
}
|
||||
#printf ("Data $name start=$start end=$end (%d points)...\n",
|
||||
# $end - $start);
|
||||
return ($start, $end);
|
||||
}
|
||||
|
||||
# simple function to formatted a number into n, n K, n M, or n G
|
||||
sub kformat {
|
||||
my $n = shift;
|
||||
my $r = "";
|
||||
if ($n > (1024*1024*1024)) {
|
||||
$r = sprintf "%.2fG", $n / (1024*1024*1024);
|
||||
} elsif ($n > (1024*1024)) {
|
||||
$r = sprintf "%.2fM", $n / (1024*1024);
|
||||
} elsif ($n > 1024) {
|
||||
$r = sprintf "%.2fK", $n / 1024;
|
||||
} else {
|
||||
$r = sprintf "%d ", $n;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
# simple function to formatted a time into Ns, Nms, or Nus
|
||||
# the goal is to make a table of timss uncluttered and easy to read
|
||||
# I dont convert to minutes or hours because the non-1000x multipliers
|
||||
# are hard to back solve in your head for comparisons
|
||||
sub tformat {
|
||||
my $n = shift;
|
||||
my $r = "";
|
||||
if ($n == 0.0) {
|
||||
$r = "0.0"; # make exactly 0 explicit
|
||||
} elsif ($n < 0.001) {
|
||||
$r = sprintf "%.2fus", $n * 1000 * 1000;
|
||||
} elsif ($n < 1.0) {
|
||||
$r = sprintf "%.2fms", $n * 1000;
|
||||
} elsif ($n >= 1000.0) {
|
||||
$r = sprintf "%.0fs", $n;
|
||||
} elsif ($n >= 100.0) {
|
||||
$r = sprintf "%.1fs", $n;
|
||||
} else {
|
||||
$r = sprintf "%.3fs", $n;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
#Usage: commify (1234567) returns 1,234,567
|
||||
sub commify { # perl cookbook p64-65
|
||||
my $text = reverse $_[0];
|
||||
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
|
||||
return scalar reverse $text;
|
||||
}
|
||||
|
||||
# subroutine to enable numeric sorts. Programming Perl p218
|
||||
# Use: sort numeric ...
|
||||
sub numeric { $a <=> $b; }
|
||||
|
||||
# on NT, turn slash to backslash, then print. Else print.
|
||||
sub pathprint {
|
||||
my $str = shift;
|
||||
$str =~ s!/!\\!g if ($params{NT}); # turn slash to back slash
|
||||
print $str;
|
||||
}
|
||||
|
||||
# figureTimeNumber number
|
||||
# Given an number like: 60m, 1h, 100s, 4d, 200
|
||||
# Return 60, 1, 100, 4, 200
|
||||
sub figureTimeNumber {
|
||||
my $arg = shift;
|
||||
|
||||
($arg =~ /([0-9]+)(s|sec|second|seconds|m|min|minute|minutes|h|hr|hour|hours|d|day|days)$/i)
|
||||
&& return $1;
|
||||
return $arg; # return default
|
||||
}
|
||||
|
||||
# figureTimeUnits number, default
|
||||
# Given an number like: 60m, 1h, 100s, 4d
|
||||
# Return a string of minutes, hours, seconds, days
|
||||
# Else return the second argument
|
||||
sub figureTimeUnits {
|
||||
my $arg = shift;
|
||||
|
||||
($arg =~ /(s|sec|second|seconds)$/i) && return "seconds";
|
||||
($arg =~ /(m|min|minute|minutes)$/i) && return "minutes";
|
||||
($arg =~ /(h|hr|hour|hours)$/i) && return "hours";
|
||||
($arg =~ /(d|day|days)$/i) && return "days";
|
||||
|
||||
return shift; # return default
|
||||
}
|
||||
|
||||
# figureTimeSeconds number, defaultUnits
|
||||
# Given an number like: 60m, 2h, 100s, 4d
|
||||
# Return 60*60, 2*60*60, 100, 4*24*60*60
|
||||
sub figureTimeSeconds {
|
||||
my $arg = shift;
|
||||
|
||||
($arg =~ /([0-9]+)(s|sec|second|seconds)$/i) && return $1;
|
||||
($arg =~ /([0-9]+)(m|min|minute|minutes)$/i) && return (60*$1);
|
||||
($arg =~ /([0-9]+)(h|hr|hour|hours)$/i) && return (60*60*$1);
|
||||
($arg =~ /([0-9]+)(d|day|days)$/i) && return (24*60*60*$1);
|
||||
|
||||
if ($_) {
|
||||
my $def = shift;
|
||||
return $arg * figureTimeSeconds ("1$def"); # return scaled by default
|
||||
} else {
|
||||
return $arg; # return it
|
||||
}
|
||||
}
|
||||
|
||||
# BACK COMPATIBILITY (everything now in the workload file)
|
||||
# read the testbed conf file, convert to workload sections
|
||||
# machine, how many processes, how many threads/proc, arch
|
||||
# only the first 2 fields are required. Lines starting with # are ignored.
|
||||
# You can include other files using <include conf/filename.tbd>
|
||||
# exampe:
|
||||
# client1 5 10 SunOS5.5.1
|
||||
sub readTestbedFile {
|
||||
my $filename = shift;
|
||||
foreach $section (@workload) {
|
||||
next unless ($section->{sectionTitle} =~ /CLIENT/i);
|
||||
print "Testbed $filename skipped, clients read in workload\n";
|
||||
return 1; # clients already read in workload
|
||||
}
|
||||
|
||||
my $level = 0;
|
||||
if ($_) {
|
||||
$level = 1 + shift;
|
||||
die "Too many nested includes ($level) in $filename!"
|
||||
unless ($level < 100);
|
||||
}
|
||||
my $handle = "$filename$level";
|
||||
open($handle, "<$filename") ||
|
||||
open($handle, "gunzip -c $filename.gz |") ||
|
||||
die "Couldn't open testbed $filename: $!";
|
||||
|
||||
while(<$handle>) {
|
||||
chomp;
|
||||
|
||||
s/#.*//; # strip any comments from line
|
||||
|
||||
m/^\s*$/o && next; # continue if blank line
|
||||
|
||||
# handle include statement
|
||||
if (m/^<(include|INCLUDE)\s+([^\s]+)\s*>/o) {
|
||||
#print "Including $2 from $filename\n";
|
||||
readTestbedFile ($2, $level) || die;
|
||||
next;
|
||||
}
|
||||
|
||||
# get the server name and number of processes
|
||||
my @line = split(/\s+/);
|
||||
# create CLIENT entry in workload
|
||||
my $sparm = ArrayInstance->new();
|
||||
if ($line[1]) {
|
||||
$sparm->{"sectionTitle"} = "CLIENT";
|
||||
$sparm->{"sectionParams"} = "HOSTS=$line[0]";
|
||||
$sparm->{"PROCESSES"} = $line[1];
|
||||
$sparm->{"THREADS"} = $line[2] if ($line[2]);
|
||||
$sparm->{"ARCH"} = $line[3] if ($line[3]);
|
||||
} else {
|
||||
$sparm->{"sectionTitle"} = "MONITOR";
|
||||
$sparm->{"sectionParams"} = "HOSTS=$line[0]";
|
||||
$sparm->{"COMMAND"} = $line[2];
|
||||
}
|
||||
($params{DEBUG})
|
||||
&& print "<$sparm->{sectionTitle} $sparm->{sectionParams}>\n";
|
||||
push @workload, $sparm;
|
||||
}
|
||||
close ($handle);
|
||||
}
|
||||
|
||||
# BACK COMPATIBILITY (everything now in the saved workload file)
|
||||
# This is now only needed to process mailstone4.1 runs
|
||||
sub readConfigFile {
|
||||
my $filename = shift;
|
||||
open(CONFIG, "<$filename") ||
|
||||
open(CONFIG, "gunzip -c $filename.gz |") ||
|
||||
die "Couldn't open config file $filename: $!";
|
||||
|
||||
while(<CONFIG>) {
|
||||
chomp;
|
||||
|
||||
s/#.*//; # strip any comments from line
|
||||
|
||||
m/^\s*$/o && next; # continue if blank line
|
||||
|
||||
# get the property and value
|
||||
my @line = split(/=/);
|
||||
$params{$line[0]} = $line[1];
|
||||
}
|
||||
close CONFIG;
|
||||
}
|
||||
|
||||
# read the workload file and store it as a list of hashes
|
||||
# Each hash always has the fields: sectionTitle and sectionParams
|
||||
# usage: readWorkloadFile filename, \@list
|
||||
sub readWorkloadFile {
|
||||
my $filename = shift || die "readWorkloadFile: Missing file name";
|
||||
my $plist = shift || die "readWorkloadFile: Missing return list";
|
||||
my $level = 0; # file inclusion level
|
||||
my @handles;
|
||||
|
||||
my $fh = "$filename$level";
|
||||
|
||||
($params{DEBUG}) && print "Reading workload from $filename.\n";
|
||||
open($fh, "<$filename") ||
|
||||
open($fh, "gunzip -c $filename.gz |") ||
|
||||
die "readWorkloadFile Couldn't open testbed $filename: $!";
|
||||
$includedFiles{$filename} = 1; # mark file as included
|
||||
|
||||
my $sparm=0;
|
||||
my $conline = "";
|
||||
|
||||
while($fh) {
|
||||
while(<$fh>) {
|
||||
s/#.*//; # strip any comments from line (quoting?)
|
||||
s/\s*$//; # strip trailing white space
|
||||
if ($conline) { # utilize line continue
|
||||
$_ = $conline . "\\\n" . $_;
|
||||
$conline = "";
|
||||
}
|
||||
if (m/\\$/o) { # check for quoted line continue
|
||||
s/\\$//; #
|
||||
$conline = $_;
|
||||
next;
|
||||
}
|
||||
s/^\s*//; # strip initial white space
|
||||
m/^$/o && next; # continue if blank line
|
||||
|
||||
# handle include and includeOnce statements
|
||||
if ((m/^<(include)\s+(\S+)\s*>/i)
|
||||
|| (m/^<(includeonce)\s+(\S+)\s*>/i)) {
|
||||
my $incfile = $2;
|
||||
if (($1 =~ m/^includeonce/i) && ($includedFiles{$incfile})) {
|
||||
($params{DEBUG})
|
||||
&& print "readWorkloadFile:includeOnce $incfile already read.\n";
|
||||
next;
|
||||
}
|
||||
($params{DEBUG})
|
||||
&& print "readWorkloadFile include $incfile from $filename.\n";
|
||||
$includedFiles{$incfile} = 1; # mark file
|
||||
push @handles, $fh; # push current handle on to stack
|
||||
if ($level++ > 99) { # check recursion and make handles unique
|
||||
die "readWorkloadFile: include level too deep: $filename $level\n";
|
||||
}
|
||||
$fh = "$incfile$level";
|
||||
open($fh, "<$incfile") ||
|
||||
open($fh, "gunzip -c $incfile.gz |") ||
|
||||
die "readWorkloadFile Couldn't open testbed file $incfile: $!";
|
||||
$filename = $incfile; # for error messages
|
||||
next;
|
||||
}
|
||||
|
||||
if (m!^</(\w+)>$!o) { # end of section
|
||||
my $end = $1;
|
||||
unless ($sparm->{"sectionTitle"} =~ /$end/i) {
|
||||
die "readWorkloadFile Mismatched section $filename: $. '$sparm->{sectionTitle}' '$end'\n";
|
||||
return 0;
|
||||
}
|
||||
($params{DEBUG}) && print "</$sparm->{sectionTitle}>\n";
|
||||
push @$plist, $sparm;
|
||||
$sparm = 0;
|
||||
next;
|
||||
}
|
||||
|
||||
if (m!^<(\w+)\s*(.*)>$!o) { # start of section
|
||||
my $sec = $1;
|
||||
my $more = $2;
|
||||
|
||||
if ($sparm) {
|
||||
die "readWorkloadFile Missing section end $filename: $. '$sparm->{sectionTitle}'\n";
|
||||
}
|
||||
if ($sec =~ /CONFIG/i) { # special case, map to existing global
|
||||
$sparm = \%params;
|
||||
} elsif ($sec =~ /DEFAULT/i) { # special case, only one DEFAULT
|
||||
if ($defaultSection) { # use existing defaultSection
|
||||
$sparm = $defaultSection;
|
||||
} else { # create a new one
|
||||
$sparm = ArrayInstance->new();
|
||||
$sparm->{"sectionTitle"} = uc $sec; # ignore case
|
||||
$sparm->{"lineList"} = ();
|
||||
$defaultSection = $sparm;
|
||||
}
|
||||
} else {
|
||||
$sparm = ArrayInstance->new();
|
||||
$sparm->{"sectionTitle"} = uc $sec; # ignore case
|
||||
$sparm->{"lineList"} = ();
|
||||
}
|
||||
$sparm->{"sectionParams"} = $more; # take newest more info
|
||||
($params{DEBUG})
|
||||
&& print "<$sparm->{sectionTitle} $sparm->{sectionParams}>\n";
|
||||
next;
|
||||
}
|
||||
|
||||
# must be in a section, get parameters
|
||||
unless ($sparm) {
|
||||
die "readWorkloadFile Entry encountered outside a section $filename: $. $_\n";
|
||||
return 0;
|
||||
}
|
||||
my ($nm, $val) = split (/[\s=]+/, $_, 2);
|
||||
$nm = uc $nm; # ignore case
|
||||
($params{DEBUG}) && print " $nm = $val\n";
|
||||
if ($nm =~ /ACCOUNTFORMAT/) { # BACK COMPATIBILITY
|
||||
print "WARNING: 'accountFormat' is obsolete. Use 'addressFormat' and 'loginFormat'\n";
|
||||
$sparm->{"addressFormat"} = $val;
|
||||
push @{$sparm->{"lineList"}}, "addressFormat $val";
|
||||
$val =~ s/@.+$//; # strip at and everything after
|
||||
$sparm->{"loginFormat"} = $val;
|
||||
push @{$sparm->{"lineList"}}, "loginFormat $val";
|
||||
next;
|
||||
} elsif ($nm =~ /NUMACCOUNTS/) { # BACK COMPATIBILITY
|
||||
print "WARNING: 'numAccounts' is obsolete. Use 'numAddresses' and 'numLogins'\n";
|
||||
$sparm->{"numAddresses"} = $val;
|
||||
push @{$sparm->{"lineList"}}, "numAddresses $val";
|
||||
$sparm->{"numLogins"} = $val;
|
||||
push @{$sparm->{"lineList"}}, "numLogins $val";
|
||||
next;
|
||||
} elsif ($nm =~ /BEGINACCOUNTS/) { # BACK COMPATIBILITY
|
||||
print "WARNING: 'beginAccounts' is obsolete. Use 'firstAddress' and 'firstLogin'\n";
|
||||
$sparm->{"firstAddress"} = $val;
|
||||
push @{$sparm->{"lineList"}}, "firstAddress $val";
|
||||
$sparm->{"firstLogin"} = $val;
|
||||
push @{$sparm->{"lineList"}}, "firstLogin $val";
|
||||
next;
|
||||
}
|
||||
push @{$sparm->{"lineList"}}, $_; # save lines in original order
|
||||
$sparm->{$nm} = $val;
|
||||
next;
|
||||
}
|
||||
close ($fh);
|
||||
$fh = pop @handles || last; # empty include stack
|
||||
$filename = $fh;
|
||||
$sparm = 0; # can only include whole sections
|
||||
}
|
||||
return 1; # success
|
||||
}
|
||||
|
||||
# Write out a workload list to a file
|
||||
# Optionally, pass in a list of sectionTitle's it should ignore
|
||||
# usage: writeWorkloadFile filename \@list [\@skipList]
|
||||
sub writeWorkloadFile {
|
||||
my $filename = shift || die "writeWorkloadFile: Missing file name";
|
||||
my $plist = shift || die "writeWorkloadFile: Missing return list";
|
||||
my $skip = shift;
|
||||
my @skipH;
|
||||
my $configSeen = 0;
|
||||
my $defaultSeen = 0;
|
||||
my @paramH;
|
||||
|
||||
if ($skip) {
|
||||
foreach $s (@$skip) { # turn list into a hash
|
||||
$skipH{(uc $s)} = $s; # fix case for index
|
||||
}
|
||||
}
|
||||
foreach $s (@workloadParameters) { # turn list into a hash
|
||||
$paramH{(uc $s)} = $s; # fix case for index
|
||||
}
|
||||
|
||||
($params{DEBUG}) && print "Writing workload to $filename.\n";
|
||||
unless (open(WORKOUT, ">$filename")) {
|
||||
die "Couldn't open testbed $filename: $!";
|
||||
}
|
||||
|
||||
foreach $sparm (@$plist) { # each hash reference in the list
|
||||
if (($skip)
|
||||
&& ($skipH{$sparm->{"sectionTitle"}})) {
|
||||
#($params{DEBUG}) &&
|
||||
#print "Skipping section $sparm->{sectionTitle}\n";
|
||||
next;
|
||||
}
|
||||
|
||||
# all CONFIG,DEFAULT sections point to the same hash, output once only
|
||||
if ($sparm->{"sectionTitle"} =~ /^CONFIG$/) {
|
||||
next if $configSeen;
|
||||
$configSeen++;
|
||||
}
|
||||
if ($sparm->{"sectionTitle"} =~ /^DEFAULT$/) {
|
||||
next if $defaultSeen;
|
||||
$defaultSeen++;
|
||||
}
|
||||
if ($sparm->{sectionParams}) { # write section with extra args
|
||||
print WORKOUT "<$sparm->{sectionTitle} $sparm->{sectionParams}>\n";
|
||||
} else {
|
||||
print WORKOUT "<$sparm->{sectionTitle}>\n";
|
||||
}
|
||||
if ($sparm->{"sectionTitle"} =~ /^(CONFIG|CLIENT)$/) {
|
||||
# for Config or Client, output the hash to get computed config
|
||||
foreach $k (sort keys %$sparm) { # output each parameter
|
||||
# skip sectionTitle and sectionParams
|
||||
($k =~ /^(sectionTitle|sectionParams|lineList)$/) && next;
|
||||
printf WORKOUT " %s\t%s\n",
|
||||
($paramH{$k}) ? $paramH{$k} : $k,
|
||||
$sparm->{$k};
|
||||
}
|
||||
} else { # write out the line list
|
||||
foreach $l (@{$sparm->{"lineList"}}) {
|
||||
print WORKOUT " $l\n";
|
||||
}
|
||||
}
|
||||
print WORKOUT "</$sparm->{sectionTitle}>\n\n";
|
||||
}
|
||||
close WORKOUT;
|
||||
}
|
||||
|
||||
# Usage: getClientFilename hostname section
|
||||
sub getClientFilename {
|
||||
my $cli = shift || die "Missing client name";
|
||||
my $section = shift || die "Missing section hash";
|
||||
return "$tmpdir/$cli-$section->{GROUP}.out"
|
||||
if ($params{USEGROUPS} && $section->{GROUP});
|
||||
return "$tmpdir/$cli.out"
|
||||
}
|
||||
|
||||
sub setConfigDefaults { # set CONFIG defaults
|
||||
# These are set after writing out the test copy to avoid clutter
|
||||
|
||||
# Path to gnuplot executable
|
||||
$params{GNUPLOT}="gnuplot/gnuplot"
|
||||
unless ($params{GNUPLOT});
|
||||
|
||||
# This is the directory the client lives in
|
||||
$params{TEMPDIR} = "/var/tmp"
|
||||
unless($params{TEMPDIR});
|
||||
|
||||
# Set default remote shell
|
||||
#$params{RSH} = "rsh"
|
||||
$params{RSH} = "ssh"
|
||||
unless($params{RSH});
|
||||
|
||||
# Set default remote copy
|
||||
#$params{RCP} = "rcp"
|
||||
$params{RCP} = "scp"
|
||||
unless($params{RCP});
|
||||
|
||||
# Size of generated gifs
|
||||
$params{CHARTHEIGHT} = 480
|
||||
unless($params{CHARTHEIGHT});
|
||||
$params{CHARTWIDTH} = 640
|
||||
unless($params{CHARTWIDTH});
|
||||
$params{CHARTPOINTS} = int (($params{CHARTWIDTH}-60)*0.8)
|
||||
unless($params{CHARTPOINTS});
|
||||
|
||||
|
||||
# The name of the remote executable
|
||||
$params{CLIENTCOMMAND} = "mailclient"
|
||||
unless ($params{CLIENTCOMMAND});
|
||||
|
||||
# Set default monitoring command
|
||||
$params{MONITORCOMMAND} = "vmstat %f"
|
||||
unless($params{MONITORCOMMAND});
|
||||
|
||||
# Set default switches to makeusers
|
||||
$params{MAKEUSERSARGS} = "-4"
|
||||
unless ($params{MAKEUSERSARGS});
|
||||
|
||||
# Figure out @protocols, this sets the report order
|
||||
@protocols = ();
|
||||
{
|
||||
my %skipH;
|
||||
foreach $s (@nonProtocolSections) { # turn list into a hash
|
||||
#print "$s ";
|
||||
$skipH{(uc $s)} = $s; # fix case for index
|
||||
}
|
||||
print "\n";
|
||||
foreach $sparm (@workload) { # each hash reference in the list
|
||||
next if ($skipH{$sparm->{"sectionTitle"}});
|
||||
|
||||
($params{DEBUG}) &&
|
||||
print "Found protocol ". $sparm->{"sectionTitle"} . "\n";
|
||||
|
||||
push @protocols, $sparm->{"sectionTitle"};
|
||||
# add to skip list so only added once
|
||||
$skipH{(uc $sparm->{"sectionTitle"})} = $sparm->{"sectionTitle"};
|
||||
}
|
||||
}
|
||||
@protocolsAll = @protocols;
|
||||
push @protocolsAll, "Total";
|
||||
|
||||
# figure out the graphs ???
|
||||
}
|
||||
|
||||
sub parseArgs { # get args
|
||||
while (@ARGV) {
|
||||
my $arg = shift(@ARGV);
|
||||
|
||||
if ($arg =~ /^-a$/i) { # was undocumented feature in 4.1
|
||||
$params{ADDGRAPHS} = shift(@ARGV); # extra graphs
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-b$/i) {
|
||||
$params{TITLE} = shift(@ARGV); # banner
|
||||
next;
|
||||
}
|
||||
|
||||
# BACK COMPATIBILITY (everything now in the saved workload file)
|
||||
if ($arg =~ /^-c$/i) { # config file, read when encountered
|
||||
my $configFile = shift(@ARGV);
|
||||
readConfigFile ($configFile);
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg =~ /^-d$/i) {
|
||||
$params{DEBUG}++; # Debug
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg =~ /^-h$/i) { # Help
|
||||
print "Usage: -w workfile [-t time] [-r ramptime] [-l load] [-v] [-d]\n";
|
||||
print "\t[-b banner] [-n notes] [-s sysconfigfile] [-a add_graphs_file]\n";
|
||||
print "\t[-c configfile] [-m machinefile] [-z] [PARAM=value]...\n";
|
||||
|
||||
die "Usage";
|
||||
}
|
||||
|
||||
if ($arg =~ /^-l$/i) { # "load", FIX: naming conventions
|
||||
$params{CLIENTCOUNT} = shift(@ARGV); # desired client count
|
||||
next;
|
||||
}
|
||||
|
||||
# BACK COMPATIBILITY (everything now in the saved workload file)
|
||||
if ($arg =~ /^-m$/i) {
|
||||
$params{TESTBED} = shift(@ARGV); # testbed machines file
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg =~ /^-n$/i) {
|
||||
$params{COMMENTS} = shift(@ARGV); # notes
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg =~ /^-r$/i) {
|
||||
$params{RAMPTIME} = shift(@ARGV); # ramptime
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-s$/i) {
|
||||
$params{SYSCONFIG} = shift(@ARGV); # system config html file
|
||||
next;
|
||||
}
|
||||
if ($arg =~ /^-t$/i) {
|
||||
$params{TIME} = shift(@ARGV); # test time
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg =~ /^-v$/i) {
|
||||
$params{VERBOSE} = 1; # verbose mode
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg =~ /^-w$/i) { # workload file (may occur multiple times)
|
||||
my $f = shift(@ARGV);
|
||||
readWorkloadFile ($f, \@workload) || die "Error reading workload: $@\n";
|
||||
$params{WORKLOAD} = $f;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg =~ /^-z$/i) {
|
||||
$params{NT} = 1; # NT mode
|
||||
next;
|
||||
}
|
||||
|
||||
# any other CONFIG parameter: FIELD=value
|
||||
if ($arg =~ /^(\w+)=(\S.*)$/) {
|
||||
my $field = uc $1;
|
||||
$params{$field} = $2;
|
||||
next;
|
||||
}
|
||||
die "Unknown argument '$arg'";
|
||||
}
|
||||
|
||||
if ($params{NT}) { # should use Cwd module
|
||||
$cwd = `cd`; # NT get current directory
|
||||
$cwd = `pwd` unless ($cwd); # in case we are really on UNIX
|
||||
} else {
|
||||
$cwd = `pwd`; # in case we are really on UNIX
|
||||
}
|
||||
chomp $cwd; # strip NL
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -1,271 +0,0 @@
|
||||
I. Format
|
||||
II. Workload Configuration Sections
|
||||
III. Report Generation Sections
|
||||
|
||||
---------
|
||||
I. Format
|
||||
---------
|
||||
|
||||
The config-file format is very free-form -- for example, this text is
|
||||
skipped as a "comment" because it doesn't look like anything else. A
|
||||
section always starts with a line ending in a colon. Everything up to
|
||||
the next section, end-of-file, or `__END__' is part of the current
|
||||
section.
|
||||
|
||||
Name/value pairs within a section are pairs starting with whitespace,
|
||||
and separated by a colon followed by whitespace. So you can write
|
||||
something like this
|
||||
|
||||
# hello there: mister foo
|
||||
|
||||
and it will be ignored. Had the '#' before the "hello" not been
|
||||
there, the attribute name would have been `hello there' and its value
|
||||
would have been `mister foo'. Leading and trailing whitespace is
|
||||
skipped, but internal whitespace is perfectly OK. Note that the
|
||||
"comment" character doesn't have to be a '#', but can be anything you
|
||||
want (except whitespace).
|
||||
|
||||
Leading whitespace also denotes continued values. So
|
||||
|
||||
foo: blah blah
|
||||
and some more words which are part of foo's value.
|
||||
|
||||
creates a variable named 'foo' with this value (including the \n) --
|
||||
"blah blah
|
||||
and some more words which are part of foo's value."
|
||||
|
||||
Finally, anything after '__END__' on a line by itself gets inserted
|
||||
literally into each .wld file. This is the place to put <monitor>
|
||||
sections.
|
||||
|
||||
--------------------------
|
||||
II. Workload Configuration
|
||||
--------------------------
|
||||
|
||||
Parameters with no default are required.
|
||||
|
||||
Messages
|
||||
--------
|
||||
|
||||
Message attributes are defined in the `message' section.
|
||||
|
||||
Parameter Default Description
|
||||
--------- ------- -----------
|
||||
size size distribution (including headers).
|
||||
recipients number of recipients
|
||||
headers ~unif(10, 30) number of headers
|
||||
line length 60 line length
|
||||
mime 0 number of MIME parts
|
||||
|
||||
Users
|
||||
-----
|
||||
|
||||
User behavior parameters are described in the `user' section.
|
||||
|
||||
Parameter Default Description
|
||||
--------- ------- -----------
|
||||
messages per day
|
||||
protocol mail read
|
||||
activity `DURATION each TIME' or `START - STOP'
|
||||
check interval how often user checks mail when active
|
||||
read messages 0 number of old msgs each user has
|
||||
read time 0 how long user takes to `read' a message
|
||||
keep 0 proportion of messages kept on server
|
||||
connection type <unlimited> `latency = X ; bandwidth = X'
|
||||
drop rate 0 proportion of connections dropped before logout
|
||||
|
||||
Delivery
|
||||
--------
|
||||
|
||||
Delivery parameters are described in the `delivery' section.
|
||||
|
||||
Parameter Default Description
|
||||
--------- ------- -----------
|
||||
messages per connection 1 messages sent per SMTP session
|
||||
percent remote 0 % mail going to remote host (sink)
|
||||
connection type <unlimited>
|
||||
fluctuation <uniform> `START - END = X % ; ...'
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
The `test' section configures the number of users, the time of day to
|
||||
be simulated, etc.
|
||||
|
||||
Parameter Default Description
|
||||
--------- ------- -----------
|
||||
start time of day to start sim
|
||||
end end time of day.
|
||||
length duration. Either length or end
|
||||
must be specified.
|
||||
users total user base
|
||||
percent active percentage of total user base active
|
||||
during test period
|
||||
messages per second messages per second to delivery for
|
||||
SMTP-only simulation. Either
|
||||
`messages per second' or `users'
|
||||
and `percent active' must be
|
||||
specified.
|
||||
comments <nothing> notes on test.
|
||||
preparer Anonymous Name to use on reports.
|
||||
date <ctime(3)>
|
||||
configuration <nothing> Configuration name for report.
|
||||
|
||||
Environment Configuration
|
||||
-------------------------
|
||||
|
||||
Several sections describe the test environment:
|
||||
|
||||
Sink
|
||||
----
|
||||
|
||||
The `sink' section describes the remote mail sink.
|
||||
|
||||
Parameter Default Description
|
||||
--------- ------- -----------
|
||||
addressFormat smuser%ld@ Like addressFormat, but used to
|
||||
generate remote addresses.
|
||||
`hostname' will be appended if it
|
||||
ends in `@'.
|
||||
hostname host on which SMTP sink lives. Used
|
||||
for remote delivery.
|
||||
|
||||
Server
|
||||
------
|
||||
|
||||
The `server' section describes the mail server to be sized:
|
||||
|
||||
Parameter Default Description
|
||||
--------- ------- -----------
|
||||
smtp port 25
|
||||
pop port 110
|
||||
imap port 143
|
||||
web port 1066
|
||||
|
||||
hostname Mail server
|
||||
|
||||
addressFormat smuser%ld@ Passed to
|
||||
sprintf(recipient, addressFormat,
|
||||
userNum, domainNum). If
|
||||
addressFormat ends in `@', `server'
|
||||
is automatically appended.
|
||||
loginFormat smuser%ld@ Same as addressFormat, but used to
|
||||
generate usernames.
|
||||
passwdFormat twang passed to sprintf(passwd, passwdFormat,
|
||||
userNum, domainNum).
|
||||
firstAddress 0 first userNum for addresses
|
||||
firstLogin 0 first userNum for logins
|
||||
smtpMailFrom $USER@$HOST sending address on test mail.
|
||||
|
||||
name Printable server name for reports.
|
||||
hardware Brief hardware description.
|
||||
software Brief software description.
|
||||
|
||||
Clients
|
||||
-------
|
||||
|
||||
The `clients' section describes test client configuration.
|
||||
|
||||
Parameter Default Description
|
||||
--------- ------- -----------
|
||||
smtp localhost client machines for SMTP
|
||||
imap localhost for IMAP
|
||||
pop localhost for POP3
|
||||
web localhost for WEBMAIL
|
||||
|
||||
rsh rsh rsh program to start remote clients
|
||||
rcp rcp rcp program to distribute files
|
||||
command mailclient program to run to start clients
|
||||
|
||||
cert file file containing SSL certificate
|
||||
key file file containing SSL key
|
||||
|
||||
Ugly Mstone details
|
||||
-------------------
|
||||
|
||||
The `mstone' section controls low-level details of how the workload
|
||||
description is translated into mstone terms. The parameters make some
|
||||
assumptions about the size of both the test clients and the server, so
|
||||
they may have to be tweaked. For small- to mid-size configurations,
|
||||
the defaults should work.
|
||||
|
||||
Parameter Default Description
|
||||
--------- ------- -----------
|
||||
preload rate 5 msgs/sec to deliver during preload.
|
||||
preload per connection 100 messages per SMTP session
|
||||
preload delivery time 750 msec expected message delivery time.
|
||||
used to control throttling.
|
||||
preload throttle 500 msec faster/slower than expected at
|
||||
which to throttle
|
||||
throttleFactor 1.1 factor by which to increase/decrease
|
||||
delivery rate when throttling
|
||||
|
||||
read rate 40 msgs/sec to read when aging old
|
||||
messages.
|
||||
read clients 5 test clients to use for aging
|
||||
read protocol (user:protocol) protocol to age messages (e.g. imap)
|
||||
|
||||
rampTime 0 test rampup time
|
||||
smtp connection time 10s
|
||||
pop user spacing 10s MULTIPOP: time between users
|
||||
pop connections per client 10 MULTIPOP: connections per client
|
||||
no event queues false use 1 thread per client
|
||||
max threads per proc 250
|
||||
clientCount 10000 artificial global clientCount
|
||||
|
||||
----------------------
|
||||
III. Report Generation
|
||||
----------------------
|
||||
|
||||
There are several additional configuration sections to provide
|
||||
additional information for sizing reports. The code is in
|
||||
`lib/{sizing,hardware}_defaults.pm'.
|
||||
|
||||
QoS Constraints
|
||||
---------------
|
||||
|
||||
Quality of Service constraints are specified in the `qos' section.
|
||||
See reports/qos.in for an example. The qos section can have any
|
||||
number of members. The name of each member is a description which
|
||||
will appear in the sizing report. The value is a block of perl code
|
||||
which should return a pair of values when evaluated in a context where
|
||||
`$run' is a reference to a hash containing data on the test run to be
|
||||
evaluated. The first value is a value corresponding to this
|
||||
constraint which will be printed in the report. The second is true if
|
||||
the run passed this constraint.
|
||||
|
||||
Hardware
|
||||
--------
|
||||
|
||||
The `machine' section describes the hardware under test. Unlike
|
||||
previous, simple sections, it containts nested values (as hash refs).
|
||||
|
||||
Parameter Description
|
||||
--------- -----------
|
||||
|
||||
processors
|
||||
speed
|
||||
cache
|
||||
|
||||
network
|
||||
|
||||
storage
|
||||
controllers
|
||||
disks
|
||||
type
|
||||
speed
|
||||
model
|
||||
timing
|
||||
OS
|
||||
parameters
|
||||
disks
|
||||
logging
|
||||
|
||||
Software
|
||||
--------
|
||||
|
||||
The `software' section describes the software under test. If multiple
|
||||
types of software are in use, multiple software sections should be
|
||||
specified. The only default parameter for software is the `name'.
|
||||
Other parameters should describe configuration information, version,
|
||||
etc.
|
||||
@@ -1,53 +0,0 @@
|
||||
test:
|
||||
start: 8 AM
|
||||
length: 1h
|
||||
users: ** Number of users here ***
|
||||
|
||||
percent active: 100
|
||||
|
||||
comments: auto-generated Corporate workload.
|
||||
|
||||
-- mail server configuration --
|
||||
|
||||
server:
|
||||
hostname: ** SERVER **
|
||||
|
||||
# defaults given below --
|
||||
# addressFormat: smuser%ld@
|
||||
# loginFormat: smuser%ld@
|
||||
# passwdFormat: twang
|
||||
|
||||
-- test client configuration --
|
||||
|
||||
clients:
|
||||
smtp: ** SMTP clients here **
|
||||
imap: ** IMAP clients here **
|
||||
|
||||
# defaults are `rsh' and `rcp'
|
||||
# rsh: ssh
|
||||
# rcp: scp
|
||||
|
||||
-- Don't edit between here and the `__END__' marker --
|
||||
|
||||
mstone:
|
||||
rampTime: 30s
|
||||
|
||||
message:
|
||||
size: ~lognormal(4k,4.5)
|
||||
recipients: ~lognormal(1,2) : [1, ]
|
||||
mime: ~binomial(0.3)
|
||||
|
||||
delivery:
|
||||
fluctuation: 8 AM - 4 PM = 90%
|
||||
|
||||
user:
|
||||
messages per day: 50
|
||||
read messages: 50
|
||||
protocol: IMAP
|
||||
check interval: ~unif(5m, 8m)
|
||||
connection type: latency = 0; bandwidth = 56k
|
||||
keep: 100%
|
||||
activity: 8 AM - 4 PM; arrival rate = ~normal(20m, 10m)
|
||||
|
||||
__END__
|
||||
# your monitor sections go here...
|
||||
@@ -1,2 +0,0 @@
|
||||
<client HOSTS=localhost>
|
||||
</client>
|
||||
@@ -1,38 +0,0 @@
|
||||
# common setup info for tests
|
||||
# See sample.wld for detailed usage
|
||||
|
||||
# Information on how the test is distributed and reported
|
||||
# Test independent configuration
|
||||
<CONFIG>
|
||||
comments Netscape MSG4.15
|
||||
sysConfig conf/sample.html # File for additonal system config
|
||||
|
||||
# Debug with short runs and a few clients, then increase test time
|
||||
# These get overridden in the test specific files (or the command line)
|
||||
clientCount 5 # nominal clientCount (usually overriden)
|
||||
rampTime 10s
|
||||
time 30s
|
||||
|
||||
# each test should set a title in their CONFIG section
|
||||
# This is a reminder when using old test workloads
|
||||
title Need to set test title
|
||||
</CONFIG>
|
||||
|
||||
# Specify client machines
|
||||
<CLIENT HOSTS=localhost>
|
||||
</CLIENT>
|
||||
|
||||
# Information on the test itself
|
||||
|
||||
# Use the <Default> tag to set command defaults
|
||||
<DEFAULT>
|
||||
server mailhost.example.com
|
||||
smtpMailFrom mailtestuser0@mailhost.example.com
|
||||
loginFormat mailtestuser%ld
|
||||
addressFormat mailtestuser%ld@mailhost.example.com
|
||||
passwdFormat myPassword
|
||||
numLogins 100
|
||||
firstLogin 0
|
||||
numAddresses 100
|
||||
firstAddress 0
|
||||
</DEFAULT>
|
||||
@@ -1,10 +0,0 @@
|
||||
# MailStone workload configuration file. See sample.wld for detailed usage
|
||||
# Typical HTTP GETs
|
||||
|
||||
<includeOnce conf/general.wld>
|
||||
|
||||
<HTTP>
|
||||
weight 100
|
||||
numLoops 1
|
||||
httpcommand GET /
|
||||
</HTTP>
|
||||
@@ -1,74 +0,0 @@
|
||||
#!/bin/ksh
|
||||
# fire off the series of Mailstone IMAP tests
|
||||
|
||||
# To test series setup, do: go_imap -n
|
||||
|
||||
|
||||
# Look for testname$test_form, first. Override with: go_series -f <string>.
|
||||
export test_form="_mail02"
|
||||
|
||||
export test_host="mail02"
|
||||
|
||||
# string appended to every description. Override with: go_series -d <string>.
|
||||
export desc_conf="12 CPUs"
|
||||
|
||||
# Extra arguments common to all tests. Any other args go here.
|
||||
# Note that arguments with embedded spaces wont work here.
|
||||
# Instead use: go_series -- <args...>
|
||||
export extra_args=""
|
||||
|
||||
# error limit to abort sequence
|
||||
export error_limit=500
|
||||
|
||||
# time to allow the server to calm down after each run (seconds)
|
||||
export sleep_time=120
|
||||
|
||||
# who to mail results to
|
||||
#export mail_list="me@example.com,you@example.com"
|
||||
export mail_list=""
|
||||
|
||||
# Get all the helper functions
|
||||
. test_utils.ksh
|
||||
|
||||
### This is where the series of tests is defined
|
||||
|
||||
# clean and re-start server
|
||||
if [[ $only_show_it -gt 0 ]] ; then
|
||||
echo "Would run:" "$@"
|
||||
return 0
|
||||
else
|
||||
# BUG: rsh never returns.
|
||||
# individual commands in clean work fine, but fail as a whole
|
||||
rsh -n $test_host /bin/ksh /iplanet/bin/clean$test_form &
|
||||
sleep 300 && kill -9 $!
|
||||
wait
|
||||
fi
|
||||
|
||||
# check our setup
|
||||
run timesync
|
||||
|
||||
###echo "DEBUG exit" && exit 0
|
||||
|
||||
run_test popdel 'Create mailboxes (random order)' -t 60m maxblocks=100000 "$@"
|
||||
run_test allpop 'Create mailboxes (exhaustive)' "$@"
|
||||
|
||||
run_test imaplogin 'IMAP login rate' "$@"
|
||||
|
||||
run_test smtp10k-5-5k 'Deliver 5, 5k messages to 10k users' "$@"
|
||||
sleep 200 # let queue drain (2000/(10 msg/sec))
|
||||
run_test imapread10k 'IMAP Message downloads 5k from 10k users' "$@"
|
||||
|
||||
run_test smtp10k-5-5k 'Deliver 5, 5k messages to 10k users' "$@"
|
||||
sleep 200 # let queue drain (2000/(10 msg/sec))
|
||||
run_test imapread 'IMAP Message downloads 5k' "$@"
|
||||
|
||||
run_test imapsmtp-throttle 'Combined IMAP-SMTP load (1 of 3)' "$@"
|
||||
run_test imapsmtp-throttle 'Combined IMAP-SMTP load (2 of 3)' "$@"
|
||||
run_test imapsmtp-throttle 'Combined IMAP-SMTP load (3 of 3)' "$@"
|
||||
|
||||
# Some messages will be left from previous test
|
||||
run_test imapmaxusers 'IMAP 30K simultaneous users' "$@"
|
||||
|
||||
# e-mail the whole batch
|
||||
[[ -n "$mail_list" ]] && \
|
||||
mail_series "DotCom IMAP: `date`" "$mail_list"
|
||||
@@ -1,19 +0,0 @@
|
||||
# MailStone workload configuration file. See sample.wld for detailed usage
|
||||
# Typical IMAP checks/reads
|
||||
|
||||
<includeOnce conf/general.wld>
|
||||
|
||||
<CONFIG> # test specific config
|
||||
title IMAP reads
|
||||
clientCount 100 # since IMAP has long sleeps, use lots of clients
|
||||
</CONFIG>
|
||||
|
||||
<IMAP4>
|
||||
weight 100
|
||||
#leaveMailOnServer 1
|
||||
|
||||
idleTime 2s # time between login and first download check
|
||||
loopDelay 5m # time between download checks
|
||||
numLoops 10 # how many check to do before closing the connection
|
||||
blockTime 2s # time between logout and next login (or other block)
|
||||
</IMAP4>
|
||||
@@ -1,51 +0,0 @@
|
||||
-- test size --
|
||||
|
||||
test:
|
||||
length: 90m
|
||||
users: ** Number of users here ***
|
||||
percent active: 10
|
||||
|
||||
comments: Auto-generated ISP workload.
|
||||
|
||||
-- mail server configuration --
|
||||
|
||||
server:
|
||||
hostname: ** SERVER **
|
||||
|
||||
# defaults --
|
||||
# addressFormat: smuser%ld@
|
||||
# firstAddress: 0
|
||||
# loginFormat: smuser%ld@
|
||||
# firstLogin: 0
|
||||
# passwdFormat: twang
|
||||
#
|
||||
|
||||
-- test client configuration --
|
||||
|
||||
clients:
|
||||
smtp: ** SMTP clients here **
|
||||
pop: ** POP clients go here **
|
||||
|
||||
# defaults are `rsh' and `rcp'
|
||||
# rsh: rsh
|
||||
# rcp: rcp
|
||||
|
||||
-- Do not edit between here and the `__END__' marker
|
||||
|
||||
message:
|
||||
size: ~lognormal(3k,4.5)
|
||||
recipients: ~lognormal(1,1.5) : [1, ]
|
||||
mime: 30 %
|
||||
|
||||
user:
|
||||
messages per day: 5
|
||||
read messages: 0
|
||||
protocol: POP
|
||||
check interval: ~unif(5m, 8m)
|
||||
connection type: latency = 0; bandwidth = 56k
|
||||
keep: 5%
|
||||
activity: 30 m each 24 h
|
||||
drop rate: 0.5%
|
||||
|
||||
__END__
|
||||
# other things (e.g. <monitor> sections) can go here...
|
||||
@@ -1,36 +0,0 @@
|
||||
<default>
|
||||
addressFormat smuser%ld@** DOMAIN **
|
||||
loginFormat smuser%ld@** DOMAIN **
|
||||
passwdFormat twang
|
||||
server ** SERVER **
|
||||
</default>
|
||||
|
||||
<smtp HOSTS=smtp>
|
||||
blockTime 0
|
||||
file auto
|
||||
firstAddress 0
|
||||
headers ~unif(10, 30)
|
||||
mime ~binomial(0.3)
|
||||
numAddresses 1000
|
||||
numLoops 1
|
||||
numRecips ~lognormal(1,2) : [1, ]
|
||||
size ~lognormal(4k,4.5)
|
||||
smtpMailFrom sender0@** DOMAIN **
|
||||
useEHLO 2
|
||||
portNum 2003
|
||||
</smtp>
|
||||
|
||||
<client HOSTS=localhost>
|
||||
clients 50
|
||||
group smtp
|
||||
</client>
|
||||
<config>
|
||||
comments lmtp delivery
|
||||
rampTime 0
|
||||
time 5m
|
||||
title lmtp delivery - IMAP
|
||||
useGroups 1
|
||||
</config>
|
||||
|
||||
# other things (e.g. <monitor> sections) can go here...
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<default>
|
||||
addressFormat smuser%ld@** DOMAIN **
|
||||
loginFormat smuser%ld@** DOMAIN **
|
||||
passwdFormat twang
|
||||
server ** SERVER **
|
||||
</default>
|
||||
|
||||
<smtp HOSTS=smtp>
|
||||
blockTime 0
|
||||
file auto
|
||||
firstAddress 0
|
||||
headers ~unif(10, 30)
|
||||
mime 30 %
|
||||
numAddresses 1000
|
||||
numLoops 1
|
||||
numRecips ~lognormal(1,1.5) : [1, ]
|
||||
size ~lognormal(3k,4.5)
|
||||
smtpMailFrom sender0@** DOMAIN **
|
||||
useEHLO 2
|
||||
portNum 2003
|
||||
</smtp>
|
||||
|
||||
<client HOSTS=localhost>
|
||||
clients 50
|
||||
group smtp
|
||||
</client>
|
||||
<config>
|
||||
comments lmtp delivery
|
||||
rampTime 0
|
||||
time 5m
|
||||
title lmtp delivery - POP
|
||||
useGroups 1
|
||||
</config>
|
||||
|
||||
# other things (e.g. <monitor> sections) can go here...
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
#!/bin/ksh
|
||||
# fire off the series of Mailstone tests
|
||||
|
||||
# To test series, do: go_series -n
|
||||
|
||||
|
||||
# Look for testname$test_form, first. Override with: go_series -f <string>.
|
||||
export test_form="_mail02"
|
||||
|
||||
export test_host="mail02"
|
||||
|
||||
# string appended to every description. Override with: go_series -d <string>.
|
||||
export desc_conf="12 CPUs"
|
||||
|
||||
# Extra arguments common to all tests. Any other args go here.
|
||||
# Note that arguments with embedded spaces wont work here.
|
||||
# Instead use: go_series -- <args...>
|
||||
export extra_args=""
|
||||
|
||||
# error limit to abort sequence
|
||||
export error_limit=500
|
||||
|
||||
# time to allow the server to calm down after each run (seconds)
|
||||
export sleep_time=120
|
||||
|
||||
# who to mail results to
|
||||
#export mail_list="me@example.com,you@example.com"
|
||||
export mail_list=""
|
||||
|
||||
# Get all the helper functions
|
||||
. test_utils.ksh
|
||||
|
||||
### This is where the series of tests is defined
|
||||
|
||||
# clean and re-start server
|
||||
if [[ $only_show_it -gt 0 ]] ; then
|
||||
echo "Would run:" "$@"
|
||||
return 0
|
||||
else
|
||||
# BUG: this never returns. rsh never returns
|
||||
# individual commands in clean work fine, but fail as a whole
|
||||
rsh -n $test_host /bin/ksh /iplanet/bin/clean$test_form &
|
||||
sleep 300 && kill -9 $!
|
||||
wait
|
||||
fi
|
||||
|
||||
# check our setup
|
||||
run timesync
|
||||
|
||||
###echo "DEBUG exit" && exit 0
|
||||
|
||||
run_test popdel 'Create mailboxes (random order)' -t 60m maxblocks=100000 "$@"
|
||||
run_test allpop 'Create mailboxes (exhaustive)' "$@"
|
||||
|
||||
run_test popdel 'Empty checks: never used (1 of 3)' "$@"
|
||||
run_test popdel 'Empty checks: never used (2 of 3)' "$@"
|
||||
run_test popdel 'Empty checks: never used (3 of 3)' "$@"
|
||||
|
||||
run_test smtp10k-5-5k 'Deliver 5, 5k messages to 10k users' "$@"
|
||||
sleep 200 # let queue drain (2000/(10 msg/sec))
|
||||
|
||||
run_test popsave10k 'Message downloads 5k from 10k users (1 of 3)' "$@"
|
||||
run_test popsave10k 'Message downloads 5k from 10k users (2 of 3)' "$@"
|
||||
run_test popsave10k 'Message downloads 5k from 10k users (3 of 3)' "$@"
|
||||
|
||||
run_test popsave 'Message downloads 5k (1 of 3)' "$@"
|
||||
run_test popsave 'Message downloads 5k (2 of 3)' "$@"
|
||||
run_test popsave 'Message downloads 5k (3 of 3)' "$@"
|
||||
|
||||
run_test popsmtp-throttle 'Combined load (1 of 3)' "$@"
|
||||
run_test popsmtp-throttle 'Combined load (2 of 3)' "$@"
|
||||
run_test popsmtp-throttle 'Combined load (3 of 3)' "$@"
|
||||
|
||||
run_test smtp100k 'SMTP delivery rate' "$@"
|
||||
|
||||
run_test popclean 'Message downloads/delete 5k ' "$@"
|
||||
|
||||
run_test popdel 'Empty checks (1 of 3)' "$@"
|
||||
run_test popdel 'Empty checks (2 of 3)' "$@"
|
||||
run_test popdel 'Empty checks (3 of 3)' "$@"
|
||||
|
||||
# e-mail the whole batch
|
||||
[[ -n "$mail_list" ]] && \
|
||||
mail_series "DotCom POP: `date`" "$mail_list"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user