+nsHTMLStyleElement::GetStyleSheetURL(PRBool* aIsInline)
{
- *aURI = nsnull;
- *aIsInline = !HasAttr(kNameSpaceID_None, nsGkAtoms::src);
- if (*aIsInline) {
- return;
- }
- if (!IsInHTMLDocument()) {
- // We stopped supporting
-
-
@@ -47,10 +28,7 @@
hello
-
- Click me!
-
-
+
Now I am
higher.
diff --git a/layout/reftests/bugs/449362-1.html b/layout/reftests/bugs/449362-1.html
index 533c7c92f637..3da4e4ac76b9 100644
--- a/layout/reftests/bugs/449362-1.html
+++ b/layout/reftests/bugs/449362-1.html
@@ -31,14 +31,10 @@
}
function doTest()
{
+ toggleElements('B', 'A');
document.documentElement.removeAttribute("class");
}
- function toggleElements2()
- {
- toggleElements('B', 'A');
- }
- document.addEventListener("MozReftestInvalidate", doTest, false);
- setTimeout(toggleElements2, 200);
+ window.addEventListener("MozReftestInvalidate", doTest, false);
@@ -58,10 +54,10 @@
hello
-
+
Click me!
-
+
Now I am
higher.
diff --git a/layout/reftests/font-face/reftest.list b/layout/reftests/font-face/reftest.list
index 0059487a8d29..358c2bae3091 100644
--- a/layout/reftests/font-face/reftest.list
+++ b/layout/reftests/font-face/reftest.list
@@ -79,10 +79,10 @@ HTTP(..) == ahem-metrics-1.html ahem-metrics-1-ref.html
HTTP(..) == ex-unit-1.html ex-unit-1-ref.html
HTTP(..) == ex-unit-1-dynamic.html ex-unit-1-ref.html
-# bug 493976 - testing to see if tinderbox timeouts are really due to this test or not (i.e. reftest whack-a-mole)
+# bug 493976 - for some reason the Arabic tests below cause Tinderbox timeouts
# Arabic support requires AAT fonts under Mac OS, OpenType otherwise
-random-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == src-format-arabic.html src-format-arabic-aat-ref.html
-random-if(MOZ_WIDGET_TOOLKIT=="cocoa") HTTP(..) == src-format-arabic.html src-format-arabic-ot-ref.html
+# random-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == src-format-arabic.html src-format-arabic-aat-ref.html
+# random-if(MOZ_WIDGET_TOOLKIT=="cocoa") HTTP(..) == src-format-arabic.html src-format-arabic-ot-ref.html
== local-1.html local-1-ref.html
HTTP(..) == synthetic-weight-style.html synthetic-weight-style-ref.html
diff --git a/layout/reftests/svg/dynamic-marker-02-ref.svg b/layout/reftests/svg/dynamic-marker-02-ref.svg
new file mode 100644
index 000000000000..71d3e63802cb
--- /dev/null
+++ b/layout/reftests/svg/dynamic-marker-02-ref.svg
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/layout/reftests/svg/dynamic-marker-02.svg b/layout/reftests/svg/dynamic-marker-02.svg
new file mode 100644
index 000000000000..2d053ad540ee
--- /dev/null
+++ b/layout/reftests/svg/dynamic-marker-02.svg
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list
index e8e39f350c00..9d0ad92f5f6f 100644
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -32,6 +32,7 @@ include moz-only/reftest.list
== dynamic-gradient-contents-01.svg pass.svg
== dynamic-link-style-01.svg pass.svg
== dynamic-marker-01.svg pass.svg
+== dynamic-marker-02.svg dynamic-marker-02-ref.svg
== dynamic-mask-contents-01.svg pass.svg
== dynamic-pattern-01.svg pass.svg
== dynamic-pattern-02.svg pass.svg
diff --git a/layout/tables/nsTableColGroupFrame.cpp b/layout/tables/nsTableColGroupFrame.cpp
index 2794191008c3..8c4cb91c9350 100644
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -174,7 +174,7 @@ nsTableColGroupFrame::GetLastRealColGroup(nsTableFrame* aTableFrame,
// don't set mColCount here, it is done in AddColsToTable
NS_IMETHODIMP
nsTableColGroupFrame::SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList)
+ nsFrameList& aChildList)
{
if (!mFrames.IsEmpty()) {
// We already have child frames which means we've already been
@@ -191,13 +191,9 @@ nsTableColGroupFrame::SetInitialChildList(nsIAtom* aListName,
if (!tableFrame)
return NS_ERROR_NULL_POINTER;
- if (!aChildList) {
- nsIFrame* firstChild;
- tableFrame->CreateAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup,
- PR_FALSE, nsnull, &firstChild);
- if (firstChild) {
- SetInitialChildList(aListName, firstChild);
- }
+ if (aChildList.IsEmpty()) {
+ tableFrame->AppendAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup,
+ PR_FALSE);
return NS_OK;
}
diff --git a/layout/tables/nsTableColGroupFrame.h b/layout/tables/nsTableColGroupFrame.h
index 750d89059764..7873c9da342e 100644
--- a/layout/tables/nsTableColGroupFrame.h
+++ b/layout/tables/nsTableColGroupFrame.h
@@ -73,7 +73,7 @@ public:
* @see nsIFrame::SetInitialChildList
*/
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList);
+ nsFrameList& aChildList);
/**
* ColGroups never paint anything, nor receive events.
@@ -207,7 +207,7 @@ public:
/** provide access to the mFrames list
*/
- nsFrameList& GetChildList();
+ nsFrameList& GetWritableChildList();
/** set the column index for all frames starting at aStartColFrame, it
* will also reset the column indices in all subsequent colgroups
@@ -275,7 +275,7 @@ inline PRInt32 nsTableColGroupFrame::GetColCount() const
return mColCount;
}
-inline nsFrameList& nsTableColGroupFrame::GetChildList()
+inline nsFrameList& nsTableColGroupFrame::GetWritableChildList()
{
return mFrames;
}
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
index 5ea2cc43578b..cf5b04b1596b 100644
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -306,7 +306,7 @@ nsTableFrame::PageBreakAfter(nsIFrame& aSourceFrame,
// frames into a separate child list, bug 343048.
NS_IMETHODIMP
nsTableFrame::SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList)
+ nsFrameList& aChildList)
{
if (!mFrames.IsEmpty() || !mColGroups.IsEmpty()) {
@@ -320,48 +320,34 @@ nsTableFrame::SetInitialChildList(nsIAtom* aListName,
NS_NOTREACHED("unknown frame list");
return NS_ERROR_INVALID_ARG;
}
-
- nsIFrame *childFrame = aChildList;
+
+ // XXXbz the below code is an icky cesspit that's only needed in its current
+ // form for two reasons:
+ // 1) Both rowgroups and column groups come in on the principal child list.
+ // 2) Getting the last frame of a frame list is slow.
+ // Once #2 is fixed, it should be pretty easy to get rid of the
+ // SetNextSibling usage here, at least.
nsIFrame *prevMainChild = nsnull;
nsIFrame *prevColGroupChild = nsnull;
- for ( ; nsnull!=childFrame; )
+ while (aChildList.NotEmpty())
{
+ nsIFrame* childFrame = aChildList.FirstChild();
+ aChildList.RemoveFrame(childFrame);
const nsStyleDisplay* childDisplay = childFrame->GetStyleDisplay();
- // XXX this if should go away
- if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
- {
- if (mFrames.IsEmpty())
- mFrames.SetFrames(childFrame);
- else
- prevMainChild->SetNextSibling(childFrame);
- prevMainChild = childFrame;
- }
- else if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
+
+ if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
{
NS_ASSERTION(nsGkAtoms::tableColGroupFrame == childFrame->GetType(),
"This is not a colgroup");
- if (mColGroups.IsEmpty())
- mColGroups.SetFrames(childFrame);
- else
- prevColGroupChild->SetNextSibling(childFrame);
+ mColGroups.InsertFrame(nsnull, prevColGroupChild, childFrame);
prevColGroupChild = childFrame;
}
else
- { // unknown frames go on the main list for now
- if (mFrames.IsEmpty())
- mFrames.SetFrames(childFrame);
- else
- prevMainChild->SetNextSibling(childFrame);
+ { // row groups and unknown frames go on the main list for now
+ mFrames.InsertFrame(nsnull, prevMainChild, childFrame);
prevMainChild = childFrame;
}
- nsIFrame *prevChild = childFrame;
- childFrame = childFrame->GetNextSibling();
- prevChild->SetNextSibling(nsnull);
}
- if (nsnull!=prevMainChild)
- prevMainChild->SetNextSibling(nsnull);
- if (nsnull!=prevColGroupChild)
- prevColGroupChild->SetNextSibling(nsnull);
// If we have a prev-in-flow, then we're a table that has been split and
// so don't treat this like an append
@@ -713,23 +699,12 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsTableColGroupType aColGroupType)
void
nsTableFrame::AppendAnonymousColFrames(PRInt32 aNumColsToAdd)
{
- nsTableColFrame* prevCol = nsnull;
// get the last col group frame
- nsTableColGroupFrame* colGroupFrame = nsnull;
- nsIFrame* childFrame = mColGroups.FirstChild();
- while (childFrame) {
- if (nsGkAtoms::tableColGroupFrame == childFrame->GetType()) {
- colGroupFrame = (nsTableColGroupFrame *)childFrame;
- }
- childFrame = childFrame->GetNextSibling();
- }
+ nsTableColGroupFrame* colGroupFrame =
+ static_cast(mColGroups.LastChild());
- if (colGroupFrame &&
- (colGroupFrame->GetColType() == eColGroupAnonymousCell)) {
- prevCol =
- static_cast (colGroupFrame->GetChildList().LastChild());
- }
- else {
+ if (!colGroupFrame ||
+ (colGroupFrame->GetColType() != eColGroupAnonymousCell)) {
PRInt32 colIndex = (colGroupFrame) ?
colGroupFrame->GetStartColumnIndex() +
colGroupFrame->GetColCount() : 0;
@@ -741,38 +716,26 @@ nsTableFrame::AppendAnonymousColFrames(PRInt32 aNumColsToAdd)
mColGroups.AppendFrame(this, colGroupFrame);
colGroupFrame->SetStartColumnIndex(colIndex);
}
- nsIFrame* firstNewFrame;
- CreateAnonymousColFrames(colGroupFrame, aNumColsToAdd, eColAnonymousCell,
- PR_TRUE, prevCol, &firstNewFrame);
+ AppendAnonymousColFrames(colGroupFrame, aNumColsToAdd, eColAnonymousCell,
+ PR_TRUE);
}
// XXX this needs to be moved to nsCSSFrameConstructor
// Right now it only creates the col frames at the end
void
-nsTableFrame::CreateAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
+nsTableFrame::AppendAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
PRInt32 aNumColsToAdd,
nsTableColType aColType,
- PRBool aAddToColGroupAndTable,
- nsIFrame* aPrevFrameIn,
- nsIFrame** aFirstNewFrame)
+ PRBool aAddToTable)
{
NS_PRECONDITION(aColGroupFrame, "null frame");
NS_PRECONDITION(aColType != eColAnonymousCol, "Shouldn't happen");
- *aFirstNewFrame = nsnull;
- nsIFrame* lastColFrame = nsnull;
- nsPresContext* presContext = PresContext();
- nsIPresShell *shell = presContext->PresShell();
+ nsIPresShell *shell = PresContext()->PresShell();
// Get the last col frame
- nsIFrame* childFrame = aColGroupFrame->GetFirstChild(nsnull);
- while (childFrame) {
- if (nsGkAtoms::tableColFrame == childFrame->GetType()) {
- lastColFrame = (nsTableColGroupFrame *)childFrame;
- }
- childFrame = childFrame->GetNextSibling();
- }
+ nsFrameItems newColFrames;
PRInt32 startIndex = mColFrames.Length();
PRInt32 lastIndex = startIndex + aNumColsToAdd - 1;
@@ -796,35 +759,26 @@ nsTableFrame::CreateAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
nsIFrame* colFrame = NS_NewTableColFrame(shell, styleContext);
((nsTableColFrame *) colFrame)->SetColType(aColType);
colFrame->Init(iContent, aColGroupFrame, nsnull);
- colFrame->SetInitialChildList(nsnull, nsnull);
- // Add the col to the sibling chain
- if (lastColFrame) {
- lastColFrame->SetNextSibling(colFrame);
- }
- lastColFrame = colFrame;
- if (childX == startIndex) {
- *aFirstNewFrame = colFrame;
- }
+ newColFrames.AddChild(colFrame);
}
- if (aAddToColGroupAndTable) {
- nsFrameList& cols = aColGroupFrame->GetChildList();
- // the chain already exists, now add it to the col group child list
- if (!aPrevFrameIn) {
- cols.AppendFrames(aColGroupFrame, *aFirstNewFrame);
- }
+ nsFrameList& cols = aColGroupFrame->GetWritableChildList();
+ nsIFrame* oldLastCol = cols.LastChild();
+ nsIFrame* firstNewCol = newColFrames.FirstChild();
+ nsIFrame* lastNewCol = newColFrames.lastChild;
+ cols.InsertFrames(nsnull, oldLastCol, newColFrames);
+ if (aAddToTable) {
// get the starting col index in the cache
- PRInt32 startColIndex = aColGroupFrame->GetStartColumnIndex();
- if (aPrevFrameIn) {
- nsTableColFrame* colFrame =
- (nsTableColFrame*)nsTableFrame::GetFrameAtOrBefore((nsIFrame*) aColGroupFrame, aPrevFrameIn,
- nsGkAtoms::tableColFrame);
- if (colFrame) {
- startColIndex = colFrame->GetColIndex() + 1;
- }
+ PRInt32 startColIndex;
+ if (oldLastCol) {
+ startColIndex =
+ static_cast(oldLastCol)->GetColIndex() + 1;
+ } else {
+ startColIndex = aColGroupFrame->GetStartColumnIndex();
}
+
aColGroupFrame->AddColsToTable(startColIndex, PR_TRUE,
- *aFirstNewFrame, lastColFrame);
+ firstNewCol, lastNewCol);
}
}
@@ -1214,14 +1168,14 @@ nsTableFrame::InsertRowGroups(nsIFrame* aFirstRowGroupFrame,
/////////////////////////////////////////////////////////////////////////////
// Child frame enumeration
-nsIFrame*
-nsTableFrame::GetFirstChild(nsIAtom* aListName) const
+nsFrameList
+nsTableFrame::GetChildList(nsIAtom* aListName) const
{
if (aListName == nsGkAtoms::colGroupList) {
- return mColGroups.FirstChild();
+ return mColGroups;
}
- return nsHTMLContainerFrame::GetFirstChild(aListName);
+ return nsHTMLContainerFrame::GetChildList(aListName);
}
nsIAtom*
@@ -2071,50 +2025,12 @@ nsTableFrame::PushChildren(const FrameArray& aFrames,
}
nextInFlow->mFrames.InsertFrames(GetNextInFlow(), prevSibling, frames.FirstChild());
}
- else {
+ else if (frames.NotEmpty()) {
// Add the frames to our overflow list
- SetOverflowFrames(PresContext(), frames.FirstChild());
+ SetOverflowFrames(PresContext(), frames);
}
}
-// Table specific version that takes into account header and footer row group
-// frames that are repeated for continuing table frames
-//
-// Appends the overflow frames to the end of the child list, just like the
-// nsContainerFrame version does, except that there are no assertions that
-// the child list is empty (it may not be empty, because there may be repeated
-// header/footer frames)
-PRBool
-nsTableFrame::MoveOverflowToChildList(nsPresContext* aPresContext)
-{
- PRBool result = PR_FALSE;
-
- // Check for an overflow list with our prev-in-flow
- nsTableFrame* prevInFlow = (nsTableFrame*)GetPrevInFlow();
- if (prevInFlow) {
- nsIFrame* prevOverflowFrames = prevInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
- if (prevOverflowFrames) {
- // When pushing and pulling frames we need to check for whether any
- // views need to be reparented.
- for (nsIFrame* f = prevOverflowFrames; f; f = f->GetNextSibling()) {
- nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
- }
- mFrames.AppendFrames(this, prevOverflowFrames);
- result = PR_TRUE;
- }
- }
-
- // It's also possible that we have an overflow list for ourselves
- nsIFrame* overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
- if (overflowFrames) {
- mFrames.AppendFrames(nsnull, overflowFrames);
- result = PR_TRUE;
- }
- return result;
-}
-
-
-
// collapsing row groups, rows, col groups and cols are accounted for after both passes of
// reflow so that it has no effect on the calculations of reflow.
void
diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h
index 3931ef7987c0..19d39b4937f2 100644
--- a/layout/tables/nsTableFrame.h
+++ b/layout/tables/nsTableFrame.h
@@ -258,12 +258,9 @@ public:
* @see nsIFrame::SetInitialChildList
*/
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList);
+ nsFrameList& aChildList);
- /** return the first child belonging to the list aListName.
- * @see nsIFrame::GetFirstChild
- */
- virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
+ virtual nsFrameList GetChildList(nsIAtom* aListName) const;
/** @see nsIFrame::GetAdditionalChildListName */
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
@@ -454,14 +451,18 @@ public:
PRInt32 DestroyAnonymousColFrames(PRInt32 aNumFrames);
+ // Append aNumColsToAdd anonymous col frames of type eColAnonymousCell to our
+ // last eColGroupAnonymousCell colgroup. If we have no such colgroup, then
+ // create one.
void AppendAnonymousColFrames(PRInt32 aNumColsToAdd);
- void CreateAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
+ // Append aNumColsToAdd anonymous col frames of type aColType to
+ // aColGroupFrame. If aAddToTable is true, also call AddColsToTable on the
+ // new cols.
+ void AppendAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
PRInt32 aNumColsToAdd,
nsTableColType aColType,
- PRBool aAddToColGroupAndTable,
- nsIFrame* aPrevCol,
- nsIFrame** aFirstNewFrame);
+ PRBool aAddToTable);
void MatchCellMapToColCache(nsTableCellMap* aCellMap);
/** empty the column frame cache */
@@ -638,7 +639,6 @@ protected:
const nsRect& aOriginalKidOverflowRect);
nsIFrame* GetFirstBodyRowGroupFrame();
- PRBool MoveOverflowToChildList(nsPresContext* aPresContext);
/**
* Push all our child frames from the aFrames array, in order, starting from the
* frame at aPushFrom to the end of the array. The frames are put on our overflow
diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp
index 0ffaabedab13..5706b60bc26c 100644
--- a/layout/tables/nsTableOuterFrame.cpp
+++ b/layout/tables/nsTableOuterFrame.cpp
@@ -215,16 +215,16 @@ nsTableOuterFrame::Destroy()
nsHTMLContainerFrame::Destroy();
}
-nsIFrame*
-nsTableOuterFrame::GetFirstChild(nsIAtom* aListName) const
+nsFrameList
+nsTableOuterFrame::GetChildList(nsIAtom* aListName) const
{
if (nsGkAtoms::captionList == aListName) {
- return mCaptionFrames.FirstChild();
+ return mCaptionFrames;
}
if (!aListName) {
- return mFrames.FirstChild();
+ return mFrames;
}
- return nsnull;
+ return nsFrameList::EmptyList();
}
nsIAtom*
@@ -238,21 +238,21 @@ nsTableOuterFrame::GetAdditionalChildListName(PRInt32 aIndex) const
NS_IMETHODIMP
nsTableOuterFrame::SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList)
+ nsFrameList& aChildList)
{
if (nsGkAtoms::captionList == aListName) {
// the frame constructor already checked for table-caption display type
mCaptionFrames.SetFrames(aChildList);
- mCaptionFrame = mCaptionFrames.FirstChild();
+ mCaptionFrame = mCaptionFrames.FirstChild();
}
else {
NS_ASSERTION(!aListName, "wrong childlist");
NS_ASSERTION(mFrames.IsEmpty(), "Frame leak!");
- mFrames.SetFrames(aChildList);
mInnerTableFrame = nsnull;
- if (aChildList) {
- if (nsGkAtoms::tableFrame == aChildList->GetType()) {
- mInnerTableFrame = (nsTableFrame*)aChildList;
+ if (aChildList.NotEmpty()) {
+ if (nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType()) {
+ mInnerTableFrame = (nsTableFrame*)aChildList.FirstChild();
+ mFrames.SetFrames(aChildList);
}
else {
NS_ERROR("expected a table frame");
diff --git a/layout/tables/nsTableOuterFrame.h b/layout/tables/nsTableOuterFrame.h
index e27f0bf7c7d1..b45736e647c9 100644
--- a/layout/tables/nsTableOuterFrame.h
+++ b/layout/tables/nsTableOuterFrame.h
@@ -103,9 +103,9 @@ public:
virtual PRBool IsContainingBlock() const;
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList);
+ nsFrameList& aChildList);
- virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
+ virtual nsFrameList GetChildList(nsIAtom* aListName) const;
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp
index 5449b18fcc76..8d894535ca8c 100644
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -1030,19 +1030,22 @@ nsTableRowGroupFrame::UndoContinuedRow(nsPresContext* aPresContext,
// rowBefore was the prev-sibling of aRow's next-sibling before aRow was created
nsTableRowFrame* rowBefore = (nsTableRowFrame*)aRow->GetPrevInFlow();
+ NS_PRECONDITION(mFrames.ContainsFrame(rowBefore),
+ "rowBefore not in our frame list?");
- nsIFrame* firstOverflow = GetOverflowFrames(aPresContext, PR_TRUE);
- if (!rowBefore || !firstOverflow || (firstOverflow != aRow)) {
- NS_ASSERTION(PR_FALSE, "invalid continued row");
+ nsAutoPtr overflows(StealOverflowFrames());
+ if (!rowBefore || !overflows || overflows->IsEmpty() ||
+ overflows->FirstChild() != aRow) {
+ NS_ERROR("invalid continued row");
return;
}
- // Remove aRow from the sibling chain and hook its next-sibling up with rowBefore
- rowBefore->SetNextSibling(aRow->GetNextSibling());
-
- // Destroy the row, its cells, and their cell blocks. Cell blocks that have split
+ // Destroy aRow, its cells, and their cell blocks. Cell blocks that have split
// will not have reflowed yet to pick up content from any overflow lines.
- aRow->Destroy();
+ overflows->DestroyFrame(aRow);
+
+ // Put the overflow rows into our child list
+ mFrames.InsertFrames(nsnull, rowBefore, *overflows);
}
static nsTableRowFrame*
diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp
index 23a2131dffda..5b2e4cefb11d 100644
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -166,7 +166,7 @@ nsBoxFrame::~nsBoxFrame()
NS_IMETHODIMP
nsBoxFrame::SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList)
+ nsFrameList& aChildList)
{
nsresult r = nsContainerFrame::SetInitialChildList(aListName, aChildList);
if (r == NS_OK) {
diff --git a/layout/xul/base/src/nsBoxFrame.h b/layout/xul/base/src/nsBoxFrame.h
index afb7038b08ee..40524eb8a2ec 100644
--- a/layout/xul/base/src/nsBoxFrame.h
+++ b/layout/xul/base/src/nsBoxFrame.h
@@ -141,7 +141,7 @@ public:
virtual nsIFrame* GetContentInsertionFrame();
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList);
+ nsFrameList& aChildList);
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp
index e58ea87e2270..8853780c3be9 100644
--- a/layout/xul/base/src/nsMenuFrame.cpp
+++ b/layout/xul/base/src/nsMenuFrame.cpp
@@ -325,13 +325,13 @@ nsMenuFrame::~nsMenuFrame()
// The following methods are all overridden to ensure that the menupopup frame
// is placed in the appropriate list.
-nsIFrame*
-nsMenuFrame::GetFirstChild(nsIAtom* aListName) const
+nsFrameList
+nsMenuFrame::GetChildList(nsIAtom* aListName) const
{
if (nsGkAtoms::popupList == aListName) {
return mPopupFrame;
}
- return nsBoxFrame::GetFirstChild(aListName);
+ return nsBoxFrame::GetChildList(aListName);
}
nsIFrame*
@@ -339,28 +339,30 @@ nsMenuFrame::SetPopupFrame(nsIFrame* aChildList)
{
// Check for a menupopup and move it to mPopupFrame
nsFrameList frames(aChildList);
- nsIFrame* frame = frames.FirstChild();
- while (frame) {
- if (frame->GetType() == nsGkAtoms::menuPopupFrame) {
+ SetPopupFrame(frames);
+ return frames.FirstChild();
+}
+
+void
+nsMenuFrame::SetPopupFrame(nsFrameList& aFrameList)
+{
+ for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
+ if (e.get()->GetType() == nsGkAtoms::menuPopupFrame) {
// Remove this frame from the list and set it as mPopupFrame
- frames.RemoveFrame(frame);
- mPopupFrame = (nsMenuPopupFrame *)frame;
- aChildList = frames.FirstChild();
+ mPopupFrame = (nsMenuPopupFrame *)e.get();
+ aFrameList.RemoveFrame(e.get());
break;
}
- frame = frame->GetNextSibling();
}
-
- return aChildList;
}
NS_IMETHODIMP
nsMenuFrame::SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList)
+ nsFrameList& aChildList)
{
NS_ASSERTION(!mPopupFrame, "already have a popup frame set");
if (!aListName || aListName == nsGkAtoms::popupList)
- aChildList = SetPopupFrame(aChildList);
+ SetPopupFrame(aChildList);
return nsBoxFrame::SetInitialChildList(aListName, aChildList);
}
diff --git a/layout/xul/base/src/nsMenuFrame.h b/layout/xul/base/src/nsMenuFrame.h
index bc7d9aa91a3a..b29d24446f73 100644
--- a/layout/xul/base/src/nsMenuFrame.h
+++ b/layout/xul/base/src/nsMenuFrame.h
@@ -130,9 +130,9 @@ public:
// The following methods are all overridden so that the menupopup
// can be stored in a separate list, so that it doesn't impact reflow of the
// actual menu item at all.
- virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
+ virtual nsFrameList GetChildList(nsIAtom* aListName) const;
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList);
+ nsFrameList& aChildList);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
virtual void Destroy();
@@ -233,6 +233,9 @@ protected:
// aChildList with the popup frame removed.
nsIFrame* SetPopupFrame(nsIFrame* aChildList);
+ // As above, but using an nsFrameList; modifies the passed-in list.
+ void SetPopupFrame(nsFrameList& aChildList);
+
// set mMenuParent to the nearest enclosing menu bar or menupopup frame of
// aParent (or aParent itself). This is called when initializing the frame,
// so aParent should be the expected parent of this frame.
diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp
index e0f6f9198162..8853c97a6761 100644
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -317,10 +317,10 @@ private:
NS_IMETHODIMP
nsMenuPopupFrame::SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList)
+ nsFrameList& aChildList)
{
// unless the list is empty, indicate that children have been generated.
- if (aChildList)
+ if (aChildList.NotEmpty())
mGeneratedChildren = PR_TRUE;
return nsBoxFrame::SetInitialChildList(aListName, aChildList);
}
diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h
index e18d9f44863e..a02cbdfd00b0 100644
--- a/layout/xul/base/src/nsMenuPopupFrame.h
+++ b/layout/xul/base/src/nsMenuPopupFrame.h
@@ -189,7 +189,7 @@ public:
virtual nsresult CreateWidgetForView(nsIView* aView);
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList);
+ nsFrameList& aChildList);
virtual PRBool IsLeaf() const;
diff --git a/layout/xul/base/src/nsPopupSetFrame.cpp b/layout/xul/base/src/nsPopupSetFrame.cpp
index bdc1a61dc1a4..3819b885318f 100644
--- a/layout/xul/base/src/nsPopupSetFrame.cpp
+++ b/layout/xul/base/src/nsPopupSetFrame.cpp
@@ -95,7 +95,8 @@ nsPopupSetFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
{
if (aListName == nsGkAtoms::popupList) {
- return AddPopupFrameList(aFrameList);
+ nsFrameList temp(aFrameList);
+ return AddPopupFrameList(temp);
}
return nsBoxFrame::AppendFrames(aListName, aFrameList);
}
@@ -116,14 +117,15 @@ nsPopupSetFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
{
if (aListName == nsGkAtoms::popupList) {
- return AddPopupFrameList(aFrameList);
+ nsFrameList temp(aFrameList);
+ return AddPopupFrameList(temp);
}
return nsBoxFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
}
NS_IMETHODIMP
nsPopupSetFrame::SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList)
+ nsFrameList& aChildList)
{
if (aListName == nsGkAtoms::popupList) {
return AddPopupFrameList(aChildList);
@@ -263,12 +265,13 @@ nsPopupSetFrame::RemovePopupFrame(nsIFrame* aPopup)
}
nsresult
-nsPopupSetFrame::AddPopupFrameList(nsIFrame* aPopupFrameList)
+nsPopupSetFrame::AddPopupFrameList(nsFrameList& aPopupFrameList)
{
- for (nsIFrame* kid = aPopupFrameList; kid; kid = kid->GetNextSibling()) {
- nsresult rv = AddPopupFrame(kid);
+ for (nsFrameList::Enumerator e(aPopupFrameList); !e.AtEnd(); e.Next()) {
+ nsresult rv = AddPopupFrame(e.get());
NS_ENSURE_SUCCESS(rv, rv);
}
+ aPopupFrameList.Clear();
return NS_OK;
}
diff --git a/layout/xul/base/src/nsPopupSetFrame.h b/layout/xul/base/src/nsPopupSetFrame.h
index 92a65bb84687..7c607c4dd56f 100644
--- a/layout/xul/base/src/nsPopupSetFrame.h
+++ b/layout/xul/base/src/nsPopupSetFrame.h
@@ -80,7 +80,7 @@ public:
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList);
+ nsFrameList& aChildList);
// nsIBox
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
@@ -100,7 +100,7 @@ public:
protected:
- nsresult AddPopupFrameList(nsIFrame* aPopupFrameList);
+ nsresult AddPopupFrameList(nsFrameList& aPopupFrameList);
nsresult AddPopupFrame(nsIFrame* aPopup);
nsresult RemovePopupFrame(nsIFrame* aPopup);
diff --git a/layout/xul/base/src/nsScrollbarButtonFrame.h b/layout/xul/base/src/nsScrollbarButtonFrame.h
index 1cb88136ece7..0f8c04946ece 100644
--- a/layout/xul/base/src/nsScrollbarButtonFrame.h
+++ b/layout/xul/base/src/nsScrollbarButtonFrame.h
@@ -75,8 +75,9 @@ public:
nsEventStatus* aEventStatus);
NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
- nsGUIEvent * aEvent,
- nsEventStatus* aEventStatus) { return NS_OK; }
+ nsGUIEvent * aEvent,
+ nsEventStatus* aEventStatus,
+ PRBool aControlHeld) { return NS_OK; }
NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
nsGUIEvent * aEvent,
diff --git a/layout/xul/base/src/nsScrollbarFrame.cpp b/layout/xul/base/src/nsScrollbarFrame.cpp
index 95d7738ede79..f4ad833fabe7 100644
--- a/layout/xul/base/src/nsScrollbarFrame.cpp
+++ b/layout/xul/base/src/nsScrollbarFrame.cpp
@@ -149,8 +149,9 @@ nsScrollbarFrame::HandlePress(nsPresContext* aPresContext,
NS_IMETHODIMP
nsScrollbarFrame::HandleMultiplePress(nsPresContext* aPresContext,
- nsGUIEvent* aEvent,
- nsEventStatus* aEventStatus)
+ nsGUIEvent* aEvent,
+ nsEventStatus* aEventStatus,
+ PRBool aControlHeld)
{
return NS_OK;
}
diff --git a/layout/xul/base/src/nsScrollbarFrame.h b/layout/xul/base/src/nsScrollbarFrame.h
index 7ea70b53781b..63b299baa2dd 100644
--- a/layout/xul/base/src/nsScrollbarFrame.h
+++ b/layout/xul/base/src/nsScrollbarFrame.h
@@ -73,8 +73,9 @@ public:
nsEventStatus* aEventStatus);
NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
- nsGUIEvent * aEvent,
- nsEventStatus* aEventStatus);
+ nsGUIEvent * aEvent,
+ nsEventStatus* aEventStatus,
+ PRBool aControlHeld);
NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
nsGUIEvent * aEvent,
diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp
index 18696eebcd47..996eb0507d55 100644
--- a/layout/xul/base/src/nsSliderFrame.cpp
+++ b/layout/xul/base/src/nsSliderFrame.cpp
@@ -887,7 +887,7 @@ nsSliderFrame::GetType() const
NS_IMETHODIMP
nsSliderFrame::SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList)
+ nsFrameList& aChildList)
{
nsresult r = nsBoxFrame::SetInitialChildList(aListName, aChildList);
diff --git a/layout/xul/base/src/nsSliderFrame.h b/layout/xul/base/src/nsSliderFrame.h
index 9887d6ce5c11..d630da86331b 100644
--- a/layout/xul/base/src/nsSliderFrame.h
+++ b/layout/xul/base/src/nsSliderFrame.h
@@ -167,7 +167,7 @@ public:
nsEventStatus* aEventStatus);
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
- nsIFrame* aChildList);
+ nsFrameList& aChildList);
virtual nsIAtom* GetType() const;
@@ -191,8 +191,9 @@ public:
nsEventStatus* aEventStatus);
NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
- nsGUIEvent * aEvent,
- nsEventStatus* aEventStatus) { return NS_OK; }
+ nsGUIEvent * aEvent,
+ nsEventStatus* aEventStatus,
+ PRBool aControlHeld) { return NS_OK; }
NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
nsGUIEvent * aEvent,
diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp
index 2998a4858c8d..e561634428c2 100644
--- a/layout/xul/base/src/nsSplitterFrame.cpp
+++ b/layout/xul/base/src/nsSplitterFrame.cpp
@@ -394,8 +394,9 @@ nsSplitterFrame::HandlePress(nsPresContext* aPresContext,
NS_IMETHODIMP
nsSplitterFrame::HandleMultiplePress(nsPresContext* aPresContext,
- nsGUIEvent * aEvent,
- nsEventStatus* aEventStatus)
+ nsGUIEvent * aEvent,
+ nsEventStatus* aEventStatus,
+ PRBool aControlHeld)
{
return NS_OK;
}
diff --git a/layout/xul/base/src/nsSplitterFrame.h b/layout/xul/base/src/nsSplitterFrame.h
index 935dd61525bc..2c91e6e38f17 100644
--- a/layout/xul/base/src/nsSplitterFrame.h
+++ b/layout/xul/base/src/nsSplitterFrame.h
@@ -80,8 +80,9 @@ public:
nsEventStatus* aEventStatus);
NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
- nsGUIEvent * aEvent,
- nsEventStatus* aEventStatus);
+ nsGUIEvent * aEvent,
+ nsEventStatus* aEventStatus,
+ PRBool aControlHeld);
NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
nsGUIEvent * aEvent,
diff --git a/media/liboggz/endian.patch b/media/liboggz/endian.patch
index f33e26c43e7a..e7593933dfbe 100644
--- a/media/liboggz/endian.patch
+++ b/media/liboggz/endian.patch
@@ -1,11 +1,10 @@
diff --git a/media/liboggz/include/oggz/config.h b/media/liboggz/include/oggz/config.h
index d645685..19d20f5 100644
---- a/media/liboggz/include/oggz/config.h
-+++ b/media/liboggz/include/oggz/config.h
+--- a/media/liboggz/include/oggz/config_gcc.h
++++ b/media/liboggz/include/oggz/config_gcc.h
@@ -126,3 +126,8 @@
/* Define to `unsigned int' if does not define. */
/* #undef size_t */
- #undef DEBUG
+
+#include "prcpucfg.h"
+#ifdef IS_BIG_ENDIAN
diff --git a/media/liboggz/include/oggz/config.h b/media/liboggz/include/oggz/config.h
index e477c382545d..3b4f6cff39c8 100644
--- a/media/liboggz/include/oggz/config.h
+++ b/media/liboggz/include/oggz/config.h
@@ -1,154 +1,6 @@
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define if building universal (internal helper macro) */
-/* #undef AC_APPLE_UNIVERSAL_BUILD */
-
-/* Define if the compiler implements enums as signed values. */
-/* #undef ALLOW_SIGNED_ENUMS */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the 'getopt_long' function */
-#define HAVE_GETOPT_LONG /**/
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `memmove' function. */
-#define HAVE_MEMMOVE 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
- and to 0 otherwise. */
-#define HAVE_REALLOC 1
-
-/* Define to 1 if the system has the type `ssize_t'. */
-#define HAVE_SSIZE_T 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#define LT_OBJDIR ".libs/"
-
-/* Define to build experimental code */
-/* #undef OGGZ_CONFIG_EXPERIMENTAL */
-
-/* Do not build reading support */
-#define OGGZ_CONFIG_READ 1
-
-/* Do not build writing support */
-#define OGGZ_CONFIG_WRITE 1
-
-/* Set to maximum allowed value of sf_count_t type. */
-#define OGGZ_OFF_MAX 0x7FFFFFFFFFFFFFFFLL
-
-/* Define if is const-correct */
-#define OGG_H_CONST_CORRECT /**/
-
-/* Name of package */
-#define PACKAGE "liboggz"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME ""
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION ""
-
-/* The size of `loff_t', as computed by sizeof. */
-#define SIZEOF_LOFF_T 8
-
-/* The size of `off64_t', as computed by sizeof. */
-#define SIZEOF_OFF64_T 0
-
-/* The size of `off_t', as computed by sizeof. */
-#define SIZEOF_OFF_T 8
-
-/* Set to sizeof (long) if unknown. */
-#define SIZEOF_OGGZ_OFF_T 8
-
-/* The size of `ssize_t', as computed by sizeof. */
-#define SIZEOF_SSIZE_T 4
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "0.9.9"
-
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
- significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
+#if defined(WIN32) && !defined(__GNUC__)
+#include "config_win32.h"
#else
-# ifndef WORDS_BIGENDIAN
-/* # undef WORDS_BIGENDIAN */
-# endif
+#include "config_gcc.h"
#endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#define _FILE_OFFSET_BITS 64
-
-/* Define to make fseeko etc. visible, on some hosts. */
-#define _LARGEFILE_SOURCE 1
-
-/* Define for large files, on AIX-style hosts. */
-/* #undef _LARGE_FILES */
-
-/* Some systems need _XOPEN_SOURCE for timezone */
-/* #undef _XOPEN_SOURCE */
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to `long int' if does not define. */
-/* #undef off_t */
-
-/* Define to rpl_realloc if the replacement function should be used. */
-/* #undef realloc */
-
-/* Define to `unsigned int' if does not define. */
-/* #undef size_t */
#undef DEBUG
-
-#include "prcpucfg.h"
-#ifdef IS_BIG_ENDIAN
-#define WORDS_BIGENDIAN
-#endif
diff --git a/media/liboggz/include/oggz/config_gcc.h b/media/liboggz/include/oggz/config_gcc.h
new file mode 100644
index 000000000000..470beea0ed4c
--- /dev/null
+++ b/media/liboggz/include/oggz/config_gcc.h
@@ -0,0 +1,153 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
+/* Define if the compiler implements enums as signed values. */
+/* #undef ALLOW_SIGNED_ENUMS */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the 'getopt_long' function */
+#define HAVE_GETOPT_LONG /**/
+
+/* Define to 1 if you have the header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `memmove' function. */
+#define HAVE_MEMMOVE 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if your system has a GNU libc compatible `realloc' function,
+ and to 0 otherwise. */
+#define HAVE_REALLOC 1
+
+/* Define to 1 if the system has the type `ssize_t'. */
+#define HAVE_SSIZE_T 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
+
+/* Define to build experimental code */
+/* #undef OGGZ_CONFIG_EXPERIMENTAL */
+
+/* Do not build reading support */
+#define OGGZ_CONFIG_READ 1
+
+/* Do not build writing support */
+#define OGGZ_CONFIG_WRITE 1
+
+/* Set to maximum allowed value of sf_count_t type. */
+#define OGGZ_OFF_MAX 0x7FFFFFFFFFFFFFFFLL
+
+/* Define if is const-correct */
+#define OGG_H_CONST_CORRECT /**/
+
+/* Name of package */
+#define PACKAGE "liboggz"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION ""
+
+/* The size of `loff_t', as computed by sizeof. */
+#define SIZEOF_LOFF_T 8
+
+/* The size of `off64_t', as computed by sizeof. */
+#define SIZEOF_OFF64_T 0
+
+/* The size of `off_t', as computed by sizeof. */
+#define SIZEOF_OFF_T 8
+
+/* Set to sizeof (long) if unknown. */
+#define SIZEOF_OGGZ_OFF_T 8
+
+/* The size of `ssize_t', as computed by sizeof. */
+#define SIZEOF_SSIZE_T 4
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "0.9.9"
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* # undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#define _FILE_OFFSET_BITS 64
+
+#include "prcpucfg.h"
+#ifdef IS_BIG_ENDIAN
+#define WORDS_BIGENDIAN
+#endif
+
+/* Define to make fseeko etc. visible, on some hosts. */
+#define _LARGEFILE_SOURCE 1
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Some systems need _XOPEN_SOURCE for timezone */
+/* #undef _XOPEN_SOURCE */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `long int' if does not define. */
+/* #undef off_t */
+
+/* Define to rpl_realloc if the replacement function should be used. */
+/* #undef realloc */
+
+/* Define to `unsigned int' if does not define. */
+/* #undef size_t */
diff --git a/media/liboggz/include/oggz/config_win32.h b/media/liboggz/include/oggz/config_win32.h
index 381c2089cf27..5d5c80c7be8d 100644
--- a/media/liboggz/include/oggz/config_win32.h
+++ b/media/liboggz/include/oggz/config_win32.h
@@ -135,5 +135,4 @@
/* Define for MSVC as is unavailable there */
typedef unsigned char uint8_t;
-#define inline __inline // MSVC
-#undef DEBUG
+#define inline __inline // MSVC
\ No newline at end of file
diff --git a/media/liboggz/src/liboggz/dirac.c b/media/liboggz/src/liboggz/dirac.c
index 6698ea156d20..40b3c3d860c1 100644
--- a/media/liboggz/src/liboggz/dirac.c
+++ b/media/liboggz/src/liboggz/dirac.c
@@ -2,11 +2,7 @@
dirac.c
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
-#include "config.h"
-#endif
+#include "config.h"
#ifdef HAVE_STDINT_H
#include
diff --git a/media/liboggz/src/liboggz/metric_internal.c b/media/liboggz/src/liboggz/metric_internal.c
index faf4a68501c4..d7c188bc5729 100644
--- a/media/liboggz/src/liboggz/metric_internal.c
+++ b/media/liboggz/src/liboggz/metric_internal.c
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include "oggz_private.h"
diff --git a/media/liboggz/src/liboggz/oggz.c b/media/liboggz/src/liboggz/oggz.c
index 231ac8ffbb4d..97023d812a64 100644
--- a/media/liboggz/src/liboggz/oggz.c
+++ b/media/liboggz/src/liboggz/oggz.c
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include
#include
diff --git a/media/liboggz/src/liboggz/oggz_auto.c b/media/liboggz/src/liboggz/oggz_auto.c
index b9ebbd19d1d0..e7d81f54e43d 100644
--- a/media/liboggz/src/liboggz/oggz_auto.c
+++ b/media/liboggz/src/liboggz/oggz_auto.c
@@ -36,11 +36,7 @@
* Conrad Parker
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include
#include
diff --git a/media/liboggz/src/liboggz/oggz_byteorder.h b/media/liboggz/src/liboggz/oggz_byteorder.h
index 0e3d080c69e6..e4e94849e824 100644
--- a/media/liboggz/src/liboggz/oggz_byteorder.h
+++ b/media/liboggz/src/liboggz/oggz_byteorder.h
@@ -33,11 +33,7 @@
#ifndef __OGGZ_BYTEORDER_H__
#define __OGGZ_BYTEORDER_H__
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#ifdef _UNUSED_
static unsigned short
diff --git a/media/liboggz/src/liboggz/oggz_comments.c b/media/liboggz/src/liboggz/oggz_comments.c
index 9b4378d8e973..a0e736e4ce48 100644
--- a/media/liboggz/src/liboggz/oggz_comments.c
+++ b/media/liboggz/src/liboggz/oggz_comments.c
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include
#include
diff --git a/media/liboggz/src/liboggz/oggz_compat.h b/media/liboggz/src/liboggz/oggz_compat.h
index c07be5de6426..c0da1a379211 100644
--- a/media/liboggz/src/liboggz/oggz_compat.h
+++ b/media/liboggz/src/liboggz/oggz_compat.h
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#ifndef WIN32
# define oggz_stat_regular(mode) (S_ISREG((mode)) || S_ISLNK((mode)))
diff --git a/media/liboggz/src/liboggz/oggz_dlist.c b/media/liboggz/src/liboggz/oggz_dlist.c
index 541563ac5ada..5702c529fe92 100644
--- a/media/liboggz/src/liboggz/oggz_dlist.c
+++ b/media/liboggz/src/liboggz/oggz_dlist.c
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include
#include "oggz_dlist.h"
diff --git a/media/liboggz/src/liboggz/oggz_io.c b/media/liboggz/src/liboggz/oggz_io.c
index 48941b1a4702..4cf550bdd63f 100644
--- a/media/liboggz/src/liboggz/oggz_io.c
+++ b/media/liboggz/src/liboggz/oggz_io.c
@@ -36,11 +36,7 @@
* Conrad Parker
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include
#include
diff --git a/media/liboggz/src/liboggz/oggz_read.c b/media/liboggz/src/liboggz/oggz_read.c
index 98e25e8a814f..138e4c9d0e03 100644
--- a/media/liboggz/src/liboggz/oggz_read.c
+++ b/media/liboggz/src/liboggz/oggz_read.c
@@ -36,11 +36,7 @@
* Conrad Parker
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#if OGGZ_CONFIG_READ
diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c
index f457244d570e..e4917f28019d 100644
--- a/media/liboggz/src/liboggz/oggz_seek.c
+++ b/media/liboggz/src/liboggz/oggz_seek.c
@@ -36,11 +36,7 @@
* Conrad Parker
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#if OGGZ_CONFIG_READ
diff --git a/media/liboggz/src/liboggz/oggz_stream.c b/media/liboggz/src/liboggz/oggz_stream.c
index accbbd29f9f7..30cdce14ddf3 100644
--- a/media/liboggz/src/liboggz/oggz_stream.c
+++ b/media/liboggz/src/liboggz/oggz_stream.c
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include "oggz_private.h"
diff --git a/media/liboggz/src/liboggz/oggz_table.c b/media/liboggz/src/liboggz/oggz_table.c
index 985328da02d7..7a64c0208285 100644
--- a/media/liboggz/src/liboggz/oggz_table.c
+++ b/media/liboggz/src/liboggz/oggz_table.c
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include
#include "oggz_macros.h"
diff --git a/media/liboggz/src/liboggz/oggz_vector.c b/media/liboggz/src/liboggz/oggz_vector.c
index ba613cfec7da..8f43fed9eacf 100644
--- a/media/liboggz/src/liboggz/oggz_vector.c
+++ b/media/liboggz/src/liboggz/oggz_vector.c
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#include
#include
diff --git a/media/liboggz/src/liboggz/oggz_write.c b/media/liboggz/src/liboggz/oggz_write.c
index b2944f86ef77..ca6a1ecfed38 100644
--- a/media/liboggz/src/liboggz/oggz_write.c
+++ b/media/liboggz/src/liboggz/oggz_write.c
@@ -30,11 +30,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WIN32
-#include "config_win32.h"
-#else
#include "config.h"
-#endif
#if OGGZ_CONFIG_WRITE
diff --git a/media/liboggz/update.sh b/media/liboggz/update.sh
index 3f514a616c66..28300c6b3762 100644
--- a/media/liboggz/update.sh
+++ b/media/liboggz/update.sh
@@ -2,11 +2,16 @@
#
# Copies the needed files from a directory containing the original
# liboggz source that we need for the Mozilla HTML5 media support.
-cp $1/config.h ./include/oggz/config.h
-echo "#undef DEBUG" >>./include/oggz/config.h
+cp $1/config.h ./include/oggz/config_gcc.h
cp $1/win32/config.h ./include/oggz/config_win32.h
-echo >>./include/oggz/config_win32.h
-echo "#undef DEBUG" >>./include/oggz/config_win32.h
+cat >./include/oggz/config.h <./src/liboggz/oggz_write.c
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_table.c >./src/liboggz/oggz_table.c
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_dlist.c >./src/liboggz/oggz_dlist.c
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_auto.c >./src/liboggz/oggz_auto.c
+cp $1/src/liboggz/oggz_write.c ./src/liboggz/oggz_write.c
+cp $1/src/liboggz/oggz_table.c ./src/liboggz/oggz_table.c
+cp $1/src/liboggz/oggz_dlist.c ./src/liboggz/oggz_dlist.c
+cp $1/src/liboggz/oggz_auto.c ./src/liboggz/oggz_auto.c
cp $1/src/liboggz/oggz_private.h ./src/liboggz/oggz_private.h
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz.c >./src/liboggz/oggz.c
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_compat.h >./src/liboggz/oggz_compat.h
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_read.c >./src/liboggz/oggz_read.c
+cp $1/src/liboggz/oggz.c ./src/liboggz/oggz.c
+cp $1/src/liboggz/oggz_compat.h ./src/liboggz/oggz_compat.h
+cp $1/src/liboggz/oggz_read.c ./src/liboggz/oggz_read.c
cp $1/src/liboggz/oggz_macros.h ./src/liboggz/oggz_macros.h
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_comments.c >./src/liboggz/oggz_comments.c
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_byteorder.h >./src/liboggz/oggz_byteorder.h
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_stream.c >./src/liboggz/oggz_stream.c
+cp $1/src/liboggz/oggz_comments.c ./src/liboggz/oggz_comments.c
+cp $1/src/liboggz/oggz_byteorder.h ./src/liboggz/oggz_byteorder.h
+cp $1/src/liboggz/oggz_stream.c ./src/liboggz/oggz_stream.c
cp $1/src/liboggz/oggz_stream_private.h ./src/liboggz/oggz_stream_private.h
cp $1/src/liboggz/oggz_vector.h ./src/liboggz/oggz_vector.h
cp $1/src/liboggz/oggz_auto.h ./src/liboggz/oggz_auto.h
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_io.c >./src/liboggz/oggz_io.c
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_vector.c >./src/liboggz/oggz_vector.c
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_seek.c >./src/liboggz/oggz_seek.c
+cp $1/src/liboggz/oggz_io.c ./src/liboggz/oggz_io.c
+cp $1/src/liboggz/oggz_vector.c ./src/liboggz/oggz_vector.c
+cp $1/src/liboggz/oggz_seek.c ./src/liboggz/oggz_seek.c
cp $1/src/liboggz/oggz_dlist.h ./src/liboggz/oggz_dlist.h
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/metric_internal.c >./src/liboggz/metric_internal.c
+cp $1/src/liboggz/metric_internal.c ./src/liboggz/metric_internal.c
cp $1/src/liboggz/dirac.h ./src/liboggz/dirac.h
-sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/dirac.c >./src/liboggz/dirac.c
+cp $1/src/liboggz/dirac.c ./src/liboggz/dirac.c
cp $1/AUTHORS ./AUTHORS
patch -p3
#include
@@ -298,12 +302,13 @@ static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFOW* aSFI
static UINT GetSizeInfoFlag(PRUint32 aDesiredImageSize)
{
UINT infoFlag;
-#ifndef WINCE
- // SHGFI_SHELLICONSIZE does not exist on windows mobile.
if (aDesiredImageSize > 16)
+#ifndef WINCE
infoFlag = SHGFI_SHELLICONSIZE;
- else
+#else
+ infoFlag = SHGFI_LARGEICON;
#endif
+ else
infoFlag = SHGFI_SMALLICON;
return infoFlag;
@@ -311,7 +316,7 @@ static UINT GetSizeInfoFlag(PRUint32 aDesiredImageSize)
nsresult nsIconChannel::GetHIconFromFile(HICON *hIcon)
{
-#ifdef WINCE
+#ifdef WINCE_WINDOWS_MOBILE
// GetDIBits does not exist on windows mobile.
return NS_ERROR_NOT_AVAILABLE;
#else
@@ -336,8 +341,15 @@ nsresult nsIconChannel::GetHIconFromFile(HICON *hIcon)
NS_ENSURE_SUCCESS(rv, rv);
localFile->GetPath(filePath);
+#ifndef WINCE
if (filePath.Length() < 2 || filePath[1] != ':')
return NS_ERROR_MALFORMED_URI; // UNC
+#else
+ // WinCE paths don't have drive letters
+ if (filePath.Length() < 2 ||
+ filePath[0] != '\\' || filePath[1] == '\\')
+ return NS_ERROR_MALFORMED_URI; // UNC
+#endif
if (filePath.Last() == ':')
filePath.Append('\\');
@@ -368,12 +380,21 @@ nsresult nsIconChannel::GetHIconFromFile(HICON *hIcon)
filePath = NS_LITERAL_STRING(".") + NS_ConvertUTF8toUTF16(defFileExt);
}
+#ifndef WINCE
// Is this the "Desktop" folder?
DWORD shellResult = GetSpecialFolderIcon(localFile, CSIDL_DESKTOP, &sfi, infoFlags);
if (!shellResult) {
// Is this the "My Documents" folder?
shellResult = GetSpecialFolderIcon(localFile, CSIDL_PERSONAL, &sfi, infoFlags);
}
+#else
+ DWORD shellResult = 0;
+ // Fantastic. On WinCE, ::SHGetFileInfo (with a localFile) fails
+ // unless I also set another flag like this. We don't actually need
+ // the display name.
+ if (localFile)
+ infoFlags |= SHGFI_DISPLAYNAME;
+#endif
// There are other "Special Folders" and Namespace entities that we are not
// fetching icons for, see:
@@ -439,13 +460,88 @@ nsresult nsIconChannel::GetStockHIcon(nsIMozIconURI *aIconURI, HICON *hIcon)
}
#endif
+#ifdef WINCE
+int GetDIBits(HDC hdc,
+ HBITMAP hbmp,
+ UINT uStartScan,
+ UINT cScanLines,
+ LPVOID lpvBits,
+ LPBITMAPINFO lpbi,
+ UINT uUsage)
+{
+ // Enforce some assumptions this simplified implementation makes
+ if (!hdc || !hbmp || uStartScan != 0 ||
+ !lpbi || uUsage != DIB_RGB_COLORS ||
+ lpvBits == NULL && lpbi->bmiHeader.biSize != sizeof(BITMAPINFOHEADER))
+ return 0;
+
+ BITMAP bmpInfo;
+ if (!::GetObject(hbmp, sizeof(BITMAP), &bmpInfo))
+ return 0;
+
+ lpbi->bmiHeader.biWidth = bmpInfo.bmWidth;
+ lpbi->bmiHeader.biHeight = bmpInfo.bmHeight;
+ lpbi->bmiHeader.biPlanes = bmpInfo.bmPlanes;
+ lpbi->bmiHeader.biBitCount = bmpInfo.bmBitsPixel;
+ lpbi->bmiHeader.biCompression = BI_RGB; // 0
+ lpbi->bmiHeader.biSizeImage = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
+ lpbi->bmiHeader.biXPelsPerMeter = 0;
+ lpbi->bmiHeader.biYPelsPerMeter = 0;
+ lpbi->bmiHeader.biClrUsed = 0;
+ lpbi->bmiHeader.biClrImportant = 0;
+
+ if (lpbi->bmiHeader.biBitCount == 1) {
+ // Need to set this or else the mask is inverted.
+ lpbi->bmiHeader.biClrUsed = 2;
+ lpbi->bmiHeader.biClrImportant = 2;
+ lpbi->bmiColors[0].rgbRed = lpbi->bmiColors[0].rgbGreen =
+ lpbi->bmiColors[0].rgbBlue = lpbi->bmiColors[0].rgbReserved = 0;
+ lpbi->bmiColors[1].rgbRed = lpbi->bmiColors[1].rgbGreen =
+ lpbi->bmiColors[1].rgbBlue = lpbi->bmiColors[1].rgbReserved = 255;
+ }
+
+ if (lpvBits == NULL)
+ return bmpInfo.bmHeight;
+
+ // We just want to pull out the image bits, but Windows CE makes
+ // this stupidly difficult to do...
+ HBITMAP hTargetBitmap;
+ void *pBuffer;
+ HDC someDC = ::GetDC(NULL);
+ hTargetBitmap = ::CreateDIBSection(someDC, lpbi, DIB_RGB_COLORS,
+ (void**)&pBuffer, NULL, 0);
+ ::ReleaseDC(NULL, someDC);
+
+ HDC memDc = ::CreateCompatibleDC(NULL);
+ HDC targetDc = ::CreateCompatibleDC(NULL);
+ if (!memDc || !targetDc)
+ return 0;
+
+ HBITMAP hOldMemBitmap = (HBITMAP)::SelectObject(memDc, hbmp);
+ HBITMAP hOldTgtBitmap = (HBITMAP)::SelectObject(targetDc, hTargetBitmap);
+
+ // BitBlt into the target bitmap, then copy the bits into our buffer.
+ ::BitBlt(targetDc, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, memDc, 0, 0, SRCCOPY);
+ memcpy(lpvBits, pBuffer, lpbi->bmiHeader.biSizeImage);
+
+ // Cleanup
+ ::SelectObject(memDc, hOldMemBitmap);
+ ::SelectObject(targetDc, hOldTgtBitmap);
+ ::DeleteDC(memDc);
+ ::DeleteDC(targetDc);
+ ::DeleteObject(hTargetBitmap);
+
+ return bmpInfo.bmHeight;
+}
+#endif
+
nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking)
{
// Check whether the icon requested's a file icon or a stock icon
nsresult rv = NS_ERROR_NOT_AVAILABLE;
// GetDIBits does not exist on windows mobile.
-#ifndef WINCE
+#ifndef WINCE_WINDOWS_MOBILE
HICON hIcon = NULL;
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
@@ -470,44 +566,72 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc
{
// we got the bitmaps, first find out their size
HDC hDC = CreateCompatibleDC(NULL); // get a device context for the screen.
- BITMAPINFO maskInfo = {{sizeof(BITMAPINFOHEADER)}};
- if (GetDIBits(hDC, iconInfo.hbmMask, 0, 0, NULL, &maskInfo, DIB_RGB_COLORS) &&
+ BITMAPINFO maskInfo = {{sizeof(BITMAPINFOHEADER)}};
+ BITMAPINFO colorInfo = {{sizeof(BITMAPINFOHEADER)}};
+ if (GetDIBits(hDC, iconInfo.hbmMask, 0, 0, NULL, &maskInfo, DIB_RGB_COLORS) &&
+ GetDIBits(hDC, iconInfo.hbmColor, 0, 0, NULL, &colorInfo, DIB_RGB_COLORS) &&
+ maskInfo.bmiHeader.biHeight == colorInfo.bmiHeader.biHeight &&
+ maskInfo.bmiHeader.biWidth == colorInfo.bmiHeader.biWidth &&
+ colorInfo.bmiHeader.biBitCount > 8 &&
+ colorInfo.bmiHeader.biSizeImage > 0 &&
maskInfo.bmiHeader.biSizeImage > 0) {
- PRUint32 colorSize = maskInfo.bmiHeader.biWidth * maskInfo.bmiHeader.biHeight * 4;
- PRUint32 iconSize = sizeof(ICONFILEHEADER) + sizeof(ICONENTRY) + sizeof(BITMAPINFOHEADER) + colorSize + maskInfo.bmiHeader.biSizeImage;
+
+ PRUint32 iconSize = sizeof(ICONFILEHEADER) +
+ sizeof(ICONENTRY) +
+ sizeof(BITMAPINFOHEADER) +
+ colorInfo.bmiHeader.biSizeImage +
+ maskInfo.bmiHeader.biSizeImage;
+
char *buffer = new char[iconSize];
if (!buffer)
rv = NS_ERROR_OUT_OF_MEMORY;
else {
- // the data starts with an icon file header
- ICONFILEHEADER *iconHeader = (ICONFILEHEADER *)buffer;
- iconHeader->ifhReserved = 0;
- iconHeader->ifhType = 1;
- iconHeader->ifhCount = 1;
- // followed by the single icon entry
- ICONENTRY *iconEntry = (ICONENTRY *)(buffer + sizeof(ICONFILEHEADER));
- iconEntry->ieWidth = maskInfo.bmiHeader.biWidth;
- iconEntry->ieHeight = maskInfo.bmiHeader.biHeight;
- iconEntry->ieColors = 0;
- iconEntry->ieReserved = 0;
- iconEntry->iePlanes = 1;
- iconEntry->ieBitCount = 32;
- iconEntry->ieSizeImage = sizeof(BITMAPINFOHEADER) + colorSize + maskInfo.bmiHeader.biSizeImage;
- iconEntry->ieFileOffset = sizeof(ICONFILEHEADER) + sizeof(ICONENTRY);
- // followed by the bitmap info header and the bits
- LPBITMAPINFO lpBitmapInfo = (LPBITMAPINFO)(buffer + sizeof(ICONFILEHEADER) + sizeof(ICONENTRY));
- memcpy(lpBitmapInfo, &maskInfo.bmiHeader, sizeof(BITMAPINFOHEADER));
- if (GetDIBits(hDC, iconInfo.hbmMask, 0, maskInfo.bmiHeader.biHeight, buffer + sizeof(ICONFILEHEADER) + sizeof(ICONENTRY) + sizeof(BITMAPINFOHEADER) + colorSize, lpBitmapInfo, DIB_RGB_COLORS)) {
- PRUint32 maskSize = lpBitmapInfo->bmiHeader.biSizeImage;
- lpBitmapInfo->bmiHeader.biBitCount = 32;
- lpBitmapInfo->bmiHeader.biSizeImage = colorSize;
- lpBitmapInfo->bmiHeader.biClrUsed = 0;
- lpBitmapInfo->bmiHeader.biClrImportant = 0;
- if (GetDIBits(hDC, iconInfo.hbmColor, 0, maskInfo.bmiHeader.biHeight, buffer + sizeof(ICONFILEHEADER) + sizeof(ICONENTRY) + sizeof(BITMAPINFOHEADER), lpBitmapInfo, DIB_RGB_COLORS)) {
- // doubling the height because icons have two bitmaps
- lpBitmapInfo->bmiHeader.biHeight *= 2;
- lpBitmapInfo->bmiHeader.biSizeImage += maskSize;
+ char *whereTo = buffer;
+ int howMuch;
+ // the data starts with an icon file header
+ ICONFILEHEADER iconHeader;
+ iconHeader.ifhReserved = 0;
+ iconHeader.ifhType = 1;
+ iconHeader.ifhCount = 1;
+ howMuch = sizeof(ICONFILEHEADER);
+ memcpy(whereTo, &iconHeader, howMuch);
+ whereTo += howMuch;
+
+ // followed by the single icon entry
+ ICONENTRY iconEntry;
+ iconEntry.ieWidth = colorInfo.bmiHeader.biWidth;
+ iconEntry.ieHeight = colorInfo.bmiHeader.biHeight;
+ iconEntry.ieColors = 0;
+ iconEntry.ieReserved = 0;
+ iconEntry.iePlanes = 1;
+ iconEntry.ieBitCount = colorInfo.bmiHeader.biBitCount;
+ iconEntry.ieSizeImage = sizeof(BITMAPINFOHEADER) +
+ colorInfo.bmiHeader.biSizeImage +
+ maskInfo.bmiHeader.biSizeImage;
+ iconEntry.ieFileOffset = sizeof(ICONFILEHEADER) + sizeof(ICONENTRY);
+ howMuch = sizeof(ICONENTRY);
+ memcpy(whereTo, &iconEntry, howMuch);
+ whereTo += howMuch;
+
+ // followed by the bitmap info header
+ // (doubling the height because icons have two bitmaps)
+ colorInfo.bmiHeader.biHeight *= 2;
+ colorInfo.bmiHeader.biSizeImage += maskInfo.bmiHeader.biSizeImage;
+ howMuch = sizeof(BITMAPINFOHEADER);
+ memcpy(whereTo, &colorInfo.bmiHeader, howMuch);
+ whereTo += howMuch;
+ colorInfo.bmiHeader.biHeight /= 2;
+ colorInfo.bmiHeader.biSizeImage -= maskInfo.bmiHeader.biSizeImage;
+
+ // followed by the bitmap data
+ if (GetDIBits(hDC, iconInfo.hbmColor, 0,
+ colorInfo.bmiHeader.biHeight, whereTo,
+ &colorInfo, DIB_RGB_COLORS)) {
+ whereTo += colorInfo.bmiHeader.biSizeImage;
+ if (GetDIBits(hDC, iconInfo.hbmMask, 0,
+ maskInfo.bmiHeader.biHeight, whereTo,
+ &maskInfo, DIB_RGB_COLORS)) {
// Now, create a pipe and stuff our data into it
nsCOMPtr inStream;
nsCOMPtr outStream;
@@ -534,6 +658,9 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc
DestroyIcon(hIcon);
} // if we got an hIcon
+ // If we didn't make a stream, then fail.
+ if (!*_retval && NS_SUCCEEDED(rv))
+ rv = NS_ERROR_NOT_AVAILABLE;
#endif
return rv;
}
diff --git a/modules/libpr0n/decoders/xbm/Makefile.in b/modules/libpr0n/decoders/xbm/Makefile.in
deleted file mode 100644
index cf1f80283329..000000000000
--- a/modules/libpr0n/decoders/xbm/Makefile.in
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# 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 the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Christian Biesinger
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH = ../../../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE = imgxbm
-LIBRARY_NAME = imgxbm_s
-FORCE_STATIC_LIB = 1
-MODULE_NAME = nsXBMModule
-LIBXUL_LIBRARY = 1
-
-REQUIRES = xpcom \
- string \
- gfx \
- thebes \
- imglib2 \
- $(NULL)
-
-CPPSRCS = nsXBMDecoder.cpp
-
-include $(topsrcdir)/config/rules.mk
diff --git a/modules/libpr0n/decoders/xbm/nsXBMDecoder.cpp b/modules/libpr0n/decoders/xbm/nsXBMDecoder.cpp
deleted file mode 100644
index b872d0e8fa73..000000000000
--- a/modules/libpr0n/decoders/xbm/nsXBMDecoder.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/* vim:set tw=80 expandtab softtabstop=4 ts=4 sw=4: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * 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 the Mozilla XBM Decoder.
- *
- * The Initial Developer of the Original Code is
- * Christian Biesinger .
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Aaron Kaluszka
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* KNOWN BUGS:
- * o first #define line is assumed to be width, second height */
-
-#include
-#include
-#include
-
-#include "nsXBMDecoder.h"
-
-#include "nsIInputStream.h"
-#include "nsIComponentManager.h"
-#include "nsIInterfaceRequestorUtils.h"
-
-#include "imgILoad.h"
-
-#include "nsIProperties.h"
-#include "nsISupportsPrimitives.h"
-
-#include "gfxColor.h"
-#include "nsIInterfaceRequestorUtils.h"
-
-// Static colormap
-static const PRUint32 kColors[2] = {
- GFX_PACKED_PIXEL(0, 0, 0, 0), // Transparent
- GFX_PACKED_PIXEL(255, 0, 0, 0) // Black
-};
-
-NS_IMPL_ISUPPORTS1(nsXBMDecoder, imgIDecoder)
-
-nsXBMDecoder::nsXBMDecoder() : mBuf(nsnull), mPos(nsnull), mImageData(nsnull)
-{
-}
-
-nsXBMDecoder::~nsXBMDecoder()
-{
- if (mBuf)
- free(mBuf);
-}
-
-NS_IMETHODIMP nsXBMDecoder::Init(imgILoad *aLoad)
-{
- nsresult rv;
- mObserver = do_QueryInterface(aLoad);
-
- mImage = do_CreateInstance("@mozilla.org/image/container;2", &rv);
- if (NS_FAILED(rv))
- return rv;
-
- aLoad->SetImage(mImage);
-
- mCurRow = mBufSize = mWidth = mHeight = 0;
- mState = RECV_HEADER;
-
- return NS_OK;
-}
-
-NS_IMETHODIMP nsXBMDecoder::Close()
-{
- mImage->DecodingComplete();
-
- mObserver->OnStopContainer(nsnull, mImage);
- mObserver->OnStopDecode(nsnull, NS_OK, nsnull);
- mObserver = nsnull;
- mImage = nsnull;
- mImageData = nsnull;
-
- return NS_OK;
-}
-
-NS_IMETHODIMP nsXBMDecoder::Flush()
-{
- return NS_OK;
-}
-
-NS_METHOD nsXBMDecoder::ReadSegCb(nsIInputStream* aIn, void* aClosure,
- const char* aFromRawSegment, PRUint32 aToOffset,
- PRUint32 aCount, PRUint32 *aWriteCount) {
- nsXBMDecoder *decoder = reinterpret_cast(aClosure);
- *aWriteCount = aCount;
-
- nsresult rv = decoder->ProcessData(aFromRawSegment, aCount);
-
- if (NS_FAILED(rv)) {
- *aWriteCount = 0;
- }
-
- return rv;
-}
-
-NS_IMETHODIMP nsXBMDecoder::WriteFrom(nsIInputStream *aInStr, PRUint32 aCount, PRUint32 *aRetval)
-{
- nsresult rv = aInStr->ReadSegments(ReadSegCb, this, aCount, aRetval);
-
- if (aCount != *aRetval) {
- *aRetval = aCount;
- return NS_ERROR_FAILURE;
- }
-
- return rv;
-}
-
-nsresult nsXBMDecoder::ProcessData(const char* aData, PRUint32 aCount) {
- char *endPtr;
- // calculate the offset since the absolute position might no longer
- // be valid after realloc
- const PRPtrdiff posOffset = mPos ? (mPos - mBuf) : 0;
-
- // expand the buffer to hold the new data
- char* oldbuf = mBuf;
- PRUint32 newbufsize = mBufSize + aCount + 1;
- if (newbufsize < mBufSize)
- mBuf = nsnull; // size wrapped around, give up
- else
- mBuf = (char*)realloc(mBuf, newbufsize);
-
- if (!mBuf) {
- mState = RECV_DONE;
- if (oldbuf)
- free(oldbuf);
- return NS_ERROR_OUT_OF_MEMORY;
- }
- memcpy(mBuf + mBufSize, aData, aCount);
- mBufSize += aCount;
- mBuf[mBufSize] = 0;
- mPos = mBuf + posOffset;
-
- // process latest data according to current state
- if (mState == RECV_HEADER) {
- mPos = strstr(mBuf, "#define");
- if (!mPos)
- // #define not found. return for now, waiting for more data.
- return NS_OK;
-
- // Convert width and height to numbers. Convert hotspot for cursor functionality, if present
- if (sscanf(mPos, "#define %*s %u #define %*s %u #define %*s %u #define %*s %u unsigned", &mWidth, &mHeight, &mXHotspot, &mYHotspot) == 4)
- mIsCursor = PR_TRUE;
- else if (sscanf(mPos, "#define %*s %u #define %*s %u unsigned", &mWidth, &mHeight) == 2)
- mIsCursor = PR_FALSE;
- else
- // No identifiers found. Return for now, waiting for more data.
- return NS_OK;
-
- // Check for X11 flavor
- if (strstr(mPos, " char "))
- mIsX10 = PR_FALSE;
- // Check for X10 flavor
- else if (strstr(mPos, " short "))
- mIsX10 = PR_TRUE;
- else
- // Neither identifier found. Return for now, waiting for more data.
- return NS_OK;
-
- mImage->Init(mWidth, mHeight, mObserver);
- mObserver->OnStartContainer(nsnull, mImage);
-
- PRUint32 imageLen;
- nsresult rv = mImage->AppendFrame(0, 0, mWidth, mHeight, gfxASurface::ImageFormatARGB32,
- (PRUint8**)&mImageData, &imageLen);
- if (NS_FAILED(rv))
- return rv;
-
- if (mIsCursor) {
- nsCOMPtr props(do_QueryInterface(mImage));
- if (props) {
- nsCOMPtr intwrapx = do_CreateInstance("@mozilla.org/supports-PRUint32;1");
- nsCOMPtr intwrapy = do_CreateInstance("@mozilla.org/supports-PRUint32;1");
-
- if (intwrapx && intwrapy) {
- intwrapx->SetData(mXHotspot);
- intwrapy->SetData(mYHotspot);
-
- props->Set("hotspotX", intwrapx);
- props->Set("hotspotY", intwrapy);
- }
- }
- }
-
- mObserver->OnStartFrame(nsnull, 0);
-
- mState = RECV_SEEK;
-
- mCurRow = 0;
- mCurCol = 0;
-
- }
- if (mState == RECV_SEEK) {
- if ((endPtr = strchr(mPos, '{')) != NULL) {
- mPos = endPtr+1;
- mState = RECV_DATA;
- } else {
- mPos = mBuf + mBufSize;
- return NS_OK;
- }
- }
- if (mState == RECV_DATA) {
- PRUint32 *ar = mImageData + mCurRow * mWidth + mCurCol;
-
- do {
- PRUint32 pixel = strtoul(mPos, &endPtr, 0);
- if (endPtr == mPos)
- return NS_OK; // no number to be found - need more data
- if (!*endPtr)
- return NS_OK; // number at the end - might be missing a digit
- if (pixel == 0 && *endPtr == 'x')
- return NS_OK; // 0x at the end, actual number is missing
- while (*endPtr && isspace(*endPtr))
- endPtr++; // skip whitespace looking for comma
-
- if (!*endPtr) {
- // Need more data
- return NS_OK;
- }
- if (*endPtr != ',') {
- *endPtr = '\0';
- mState = RECV_DONE; // strange character (or ending '}')
- } else {
- // Skip the comma
- endPtr++;
- }
- mPos = endPtr;
- PRUint32 numPixels = 8;
- if (mIsX10) { // X10 use 16bits values, but bytes are swapped
- pixel = (pixel >> 8) | ((pixel&0xFF) << 8);
- numPixels = 16;
- }
- numPixels = PR_MIN(numPixels, mWidth - mCurCol);
- for (PRUint32 i = numPixels; i > 0; --i) {
- *ar++ = kColors[pixel & 1];
- pixel >>= 1;
- }
- mCurCol += numPixels;
- if (mCurCol == mWidth || mState == RECV_DONE) {
- nsIntRect r(0, mCurRow, mWidth, 1);
- nsresult rv = mImage->FrameUpdated(0, r);
- if (NS_FAILED(rv)) {
- return rv;
- }
-
- mObserver->OnDataAvailable(nsnull, PR_TRUE, &r);
-
- mCurRow++;
- if (mCurRow == mHeight) {
- mState = RECV_DONE;
- return mObserver->OnStopFrame(nsnull, 0);
- }
- mCurCol = 0;
- }
- } while ((mState == RECV_DATA) && *mPos);
- }
-
- return NS_OK;
-}
-
-
diff --git a/modules/libpr0n/decoders/xbm/nsXBMDecoder.h b/modules/libpr0n/decoders/xbm/nsXBMDecoder.h
deleted file mode 100644
index 2e0cc0346806..000000000000
--- a/modules/libpr0n/decoders/xbm/nsXBMDecoder.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* vim:set tw=80 expandtab softtabstop=4 ts=4 sw=4: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * 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 the Mozilla XBM Decoder.
- *
- * The Initial Developer of the Original Code is
- * Christian Biesinger .
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Aaron Kaluszka
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef _nsXBMDecoder_h
-#define _nsXBMDecoder_h
-
-#include "nsCOMPtr.h"
-#include "imgIDecoder.h"
-#include "imgIContainer.h"
-#include "imgIDecoderObserver.h"
-
-#define NS_XBMDECODER_CID \
-{ /* {dbfd145d-3298-4f3c-902f-2c5e1a1494ce} */ \
- 0xdbfd145d, \
- 0x3298, \
- 0x4f3c, \
- { 0x90, 0x2f, 0x2c, 0x5e, 0x1a, 0x14, 0x94, 0xce } \
-}
-
-class nsXBMDecoder : public imgIDecoder
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_IMGIDECODER
-
- nsXBMDecoder();
- virtual ~nsXBMDecoder();
-
- nsresult ProcessData(const char* aData, PRUint32 aCount);
-private:
- static NS_METHOD ReadSegCb(nsIInputStream* aIn, void* aClosure,
- const char* aFromRawSegment, PRUint32 aToOffset,
- PRUint32 aCount, PRUint32 *aWriteCount);
-
- nsCOMPtr mObserver;
-
- nsCOMPtr mImage;
-
- PRUint32 mCurRow;
- PRUint32 mCurCol;
-
- char* mBuf; // Holds the received data
- char* mPos;
- PRUint32 mBufSize; // number of bytes in mBuf
-
- PRUint32 mWidth;
- PRUint32 mHeight;
- PRUint32 mXHotspot;
- PRUint32 mYHotspot;
-
- PRUint32* mImageData; // Pointer into the Cairo image data
-
- PRPackedBool mIsCursor;
- PRPackedBool mIsX10; // X10 flavor XBM?
-
- enum {
- RECV_HEADER,
- RECV_SEEK,
- RECV_DATA,
- RECV_DONE
- } mState;
-};
-
-
-#endif
diff --git a/modules/libpr0n/public/imgIContainer.idl b/modules/libpr0n/public/imgIContainer.idl
index 304acc2f0c3b..dd2c3a32d85d 100644
--- a/modules/libpr0n/public/imgIContainer.idl
+++ b/modules/libpr0n/public/imgIContainer.idl
@@ -124,8 +124,8 @@ interface imgIContainer : nsISupports
* appunits) to image space.
* @param aFill The area in the context to draw pixels to. Image will be
* automatically tiled as necessary.
- * @param @aSubimage The area of the image, in pixels, that we are allowed to
- * sample from.
+ * @param aSubimage The area of the image, in pixels, that we are allowed to
+ * sample from.
*/
[noscript] void draw(in gfxContext aContext, in gfxGraphicsFilter aFilter,
in gfxMatrix aUserSpaceToImageSpace, in gfxRect aFill,
diff --git a/modules/libpr0n/src/imgLoader.cpp b/modules/libpr0n/src/imgLoader.cpp
index df0a75043cf3..d14b011f342d 100644
--- a/modules/libpr0n/src/imgLoader.cpp
+++ b/modules/libpr0n/src/imgLoader.cpp
@@ -45,8 +45,10 @@
#include "nsNetUtil.h"
#include "nsIHttpChannel.h"
#include "nsICachingChannel.h"
+#include "nsIInterfaceRequestor.h"
#include "nsIPrefBranch2.h"
#include "nsIPrefService.h"
+#include "nsIProgressEventSink.h"
#include "nsIProxyObjectManager.h"
#include "nsIServiceManager.h"
#include "nsIFileURL.h"
@@ -109,6 +111,86 @@ static void PrintImageDecoders()
}
#endif
+/**
+ * A class that implements nsIProgressEventSink and forwards all calls to it to
+ * the original notification callbacks of the channel. Also implements
+ * nsIInterfaceRequestor and gives out itself for nsIProgressEventSink calls,
+ * and forwards everything else to the channel's notification callbacks.
+ */
+class nsProgressNotificationProxy : public nsIProgressEventSink
+ , public nsIInterfaceRequestor
+{
+ public:
+ nsProgressNotificationProxy(nsIChannel* channel,
+ imgIRequest* proxy)
+ : mChannel(channel), mImageRequest(proxy) {
+ channel->GetNotificationCallbacks(getter_AddRefs(mOriginalCallbacks));
+ }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIPROGRESSEVENTSINK
+ NS_DECL_NSIINTERFACEREQUESTOR
+ private:
+ ~nsProgressNotificationProxy() {}
+
+ nsCOMPtr mChannel;
+ nsCOMPtr mOriginalCallbacks;
+ nsCOMPtr mImageRequest;
+};
+
+NS_IMPL_ISUPPORTS2(nsProgressNotificationProxy,
+ nsIProgressEventSink,
+ nsIInterfaceRequestor)
+
+NS_IMETHODIMP
+nsProgressNotificationProxy::OnProgress(nsIRequest* request,
+ nsISupports* ctxt,
+ PRUint64 progress,
+ PRUint64 progressMax) {
+ nsCOMPtr loadGroup;
+ mChannel->GetLoadGroup(getter_AddRefs(loadGroup));
+
+ nsCOMPtr target;
+ NS_QueryNotificationCallbacks(mOriginalCallbacks,
+ loadGroup,
+ NS_GET_IID(nsIProgressEventSink),
+ getter_AddRefs(target));
+ if (!target)
+ return NS_OK;
+ return target->OnProgress(mImageRequest, ctxt, progress, progressMax);
+}
+
+NS_IMETHODIMP
+nsProgressNotificationProxy::OnStatus(nsIRequest* request,
+ nsISupports* ctxt,
+ nsresult status,
+ const PRUnichar* statusArg) {
+ nsCOMPtr loadGroup;
+ mChannel->GetLoadGroup(getter_AddRefs(loadGroup));
+
+ nsCOMPtr target;
+ NS_QueryNotificationCallbacks(mOriginalCallbacks,
+ loadGroup,
+ NS_GET_IID(nsIProgressEventSink),
+ getter_AddRefs(target));
+ if (!target)
+ return NS_OK;
+ return target->OnStatus(mImageRequest, ctxt, status, statusArg);
+}
+
+NS_IMETHODIMP
+nsProgressNotificationProxy::GetInterface(const nsIID& iid,
+ void** result) {
+ if (iid.Equals(NS_GET_IID(nsIProgressEventSink))) {
+ *result = static_cast(this);
+ NS_ADDREF_THIS();
+ return NS_OK;
+ }
+ if (mOriginalCallbacks)
+ return mOriginalCallbacks->GetInterface(iid, result);
+ return NS_NOINTERFACE;
+}
+
static PRBool NewRequestAndEntry(nsIURI *uri, imgRequest **request, imgCacheEntry **entry)
{
// If file, force revalidation on expiration
@@ -923,6 +1005,13 @@ PRBool imgLoader::ValidateRequestWithNewChannel(imgRequest *request,
return PR_FALSE;
}
+ // Make sure that OnStatus/OnProgress calls have the right request set...
+ nsCOMPtr requestor(
+ new nsProgressNotificationProxy(newChannel, req));
+ if (!requestor)
+ return PR_FALSE;
+ newChannel->SetNotificationCallbacks(requestor);
+
imgCacheValidator *hvc = new imgCacheValidator(request, aCX);
if (!hvc) {
return PR_FALSE;
@@ -1294,11 +1383,13 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
}
}
+ // Keep the channel in this scope, so we can adjust its notificationCallbacks
+ // later when we create the proxy.
+ nsCOMPtr newChannel;
// If we didn't get a cache hit, we need to load from the network.
if (!request) {
LOG_SCOPE(gImgLog, "imgLoader::LoadImage |cache miss|");
- nsCOMPtr newChannel;
rv = NewImageChannel(getter_AddRefs(newChannel),
aURI,
aInitialDocumentURI,
@@ -1369,6 +1460,16 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
requestFlags, aRequest, _retval);
imgRequestProxy *proxy = static_cast(*_retval);
+ // Make sure that OnStatus/OnProgress calls have the right request set, if
+ // we did create a channel here.
+ if (newChannel) {
+ nsCOMPtr requestor(
+ new nsProgressNotificationProxy(newChannel, proxy));
+ if (!requestor)
+ return NS_ERROR_OUT_OF_MEMORY;
+ newChannel->SetNotificationCallbacks(requestor);
+ }
+
// Note that it's OK to add here even if the request is done. If it is,
// it'll send a OnStopRequest() to the proxy in NotifyProxyListener and the
// proxy will be removed from the loadgroup.
@@ -1580,9 +1681,6 @@ nsresult imgLoader::GetMimeTypeFromContent(const char* aContents, PRUint32 aLeng
aContentType.AssignLiteral("image/x-icon");
}
- else if (aLength >= 8 && !nsCRT::strncmp(aContents, "#define ", 8)) {
- aContentType.AssignLiteral("image/x-xbitmap");
- }
else {
/* none of the above? I give up */
return NS_ERROR_NOT_AVAILABLE;
diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js
index 5468365115aa..a5bae40372b3 100644
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -104,6 +104,7 @@ pref("browser.visited_color", "#551A8B");
pref("browser.underline_anchors", true);
pref("browser.blink_allowed", true);
pref("browser.enable_automatic_image_resizing", false);
+pref("browser.enable_click_image_resizing", true);
// See http://whatwg.org/specs/web-apps/current-work/#ping
pref("browser.send_pings", false);
diff --git a/modules/plugin/test/testplugin/README b/modules/plugin/test/testplugin/README
index 9b03b8cb75da..bf5255381d76 100644
--- a/modules/plugin/test/testplugin/README
+++ b/modules/plugin/test/testplugin/README
@@ -117,3 +117,9 @@ Throws an exception if there is no watch.
* stopWatchingInstanceCount()
Stops watching. Throws an exception if there is no watch.
+
+== NPAPI Timers ==
+
+* unscheduleAllTimers()
+Instructs the plugin instance to cancel all timers created via
+NPN_ScheduleTimer.
diff --git a/netwerk/mime/src/nsMIMEHeaderParamImpl.cpp b/netwerk/mime/src/nsMIMEHeaderParamImpl.cpp
index 95cee21806ab..58dbc8034e4b 100644
--- a/netwerk/mime/src/nsMIMEHeaderParamImpl.cpp
+++ b/netwerk/mime/src/nsMIMEHeaderParamImpl.cpp
@@ -602,7 +602,11 @@ void CopyRawHeader(const char *aInput, PRUint32 aLen,
aOutput.Append(utf8Text);
} else { // replace each octet with Unicode replacement char in UTF-8.
for (PRUint32 i = 0; i < aLen; i++) {
- aOutput.Append(REPLACEMENT_CHAR);
+ c = PRUint8(*aInput++);
+ if (c & 0x80)
+ aOutput.Append(REPLACEMENT_CHAR);
+ else
+ aOutput.Append(char(c));
}
}
}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/AnnotationHelperVisitor.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/AnnotationHelperVisitor.java
new file mode 100644
index 000000000000..f9ac89495a63
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/AnnotationHelperVisitor.java
@@ -0,0 +1,121 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+import java.util.List;
+
+import japa.parser.ast.expr.AnnotationExpr;
+import japa.parser.ast.expr.MarkerAnnotationExpr;
+import japa.parser.ast.type.ReferenceType;
+import japa.parser.ast.visitor.VoidVisitorAdapter;
+
+public class AnnotationHelperVisitor extends VoidVisitorAdapter {
+
+ protected List currentAnnotations;
+
+ protected boolean nsUri() {
+ return hasAnnotation("NsUri");
+ }
+
+ protected boolean prefix() {
+ return hasAnnotation("Prefix");
+ }
+
+ protected boolean local() {
+ return hasAnnotation("Local");
+ }
+
+ protected boolean literal() {
+ return hasAnnotation("Literal");
+ }
+
+ protected boolean inline() {
+ return hasAnnotation("Inline");
+ }
+
+ protected boolean noLength() {
+ return hasAnnotation("NoLength");
+ }
+
+ protected boolean virtual() {
+ return hasAnnotation("Virtual");
+ }
+
+ private boolean hasAnnotation(String anno) {
+ if (currentAnnotations == null) {
+ return false;
+ }
+ for (AnnotationExpr ann : currentAnnotations) {
+ if (ann instanceof MarkerAnnotationExpr) {
+ MarkerAnnotationExpr marker = (MarkerAnnotationExpr) ann;
+ if (marker.getName().getName().equals(anno)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected Type convertType(japa.parser.ast.type.Type type, int modifiers) {
+ if (type instanceof ReferenceType) {
+ ReferenceType referenceType = (ReferenceType) type;
+ return new Type(convertTypeName(referenceType.getType().toString()), referenceType.getArrayCount(), noLength(), modifiers);
+ } else {
+ return new Type(convertTypeName(type.toString()), 0, false, modifiers);
+ }
+ }
+
+ private String convertTypeName(String name) {
+ if ("String".equals(name)) {
+ if (local()) {
+ return "@Local";
+ }
+ if (nsUri()) {
+ return "@NsUri";
+ }
+ if (prefix()) {
+ return "@Prefix";
+ }
+ if (literal()) {
+ return "@Literal";
+ }
+ }
+ return name;
+ }
+
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/CppTypes.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/CppTypes.java
new file mode 100644
index 000000000000..158f3521883f
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/CppTypes.java
@@ -0,0 +1,309 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008-2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class CppTypes {
+
+ private static Set reservedWords = new HashSet();
+
+ static {
+ reservedWords.add("small");
+ reservedWords.add("for");
+ reservedWords.add("false");
+ reservedWords.add("true");
+ reservedWords.add("default");
+ reservedWords.add("class");
+ reservedWords.add("switch");
+ reservedWords.add("union");
+ reservedWords.add("template");
+ reservedWords.add("int");
+ reservedWords.add("char");
+ reservedWords.add("operator");
+ reservedWords.add("or");
+ reservedWords.add("and");
+ reservedWords.add("not");
+ reservedWords.add("xor");
+ reservedWords.add("unicode");
+ }
+
+ private static final String[] TREE_BUILDER_INCLUDES = { "prtypes",
+ "nsIAtom", "nsITimer", "nsString", "nsINameSpaceManager", "nsIContent",
+ "nsIDocument", "nsTraceRefcnt", "jArray", "nsHtml5DocumentMode",
+ "nsHtml5ArrayCopy", "nsHtml5NamedCharacters", "nsHtml5Parser",
+ "nsHtml5Atoms", "nsHtml5ByteReadable", "nsHtml5TreeOperation",
+ "nsHtml5PendingNotification", "nsHtml5StateSnapshot", "nsHtml5StackNode" };
+
+ private static final String[] INCLUDES = { "prtypes", "nsIAtom",
+ "nsString", "nsINameSpaceManager", "nsIContent", "nsIDocument",
+ "nsTraceRefcnt", "jArray", "nsHtml5DocumentMode",
+ "nsHtml5ArrayCopy", "nsHtml5NamedCharacters",
+ "nsHtml5Atoms", "nsHtml5ByteReadable", };
+
+ private static final String[] OTHER_DECLATIONS = {};
+
+ private static final String[] TREE_BUILDER_OTHER_DECLATIONS = { "typedef nsIContent* nsIContentPtr;" };
+
+ private static final String[] NAMED_CHARACTERS_INCLUDES = { "prtypes",
+ "jArray", "nscore" };
+
+ private static final String[] FORWARD_DECLARATIONS = { "nsHtml5Parser", };
+
+ private static final String[] CLASSES_THAT_NEED_SUPPLEMENT = {
+ "MetaScanner",
+ "StackNode",
+ "TreeBuilder",
+ "UTF16Buffer",
+ };
+
+ private final Map atomMap = new HashMap();
+
+ private final Writer atomWriter;
+
+ public CppTypes(File atomList) {
+ if (atomList == null) {
+ atomWriter = null;
+ } else {
+ try {
+ atomWriter = new OutputStreamWriter(new FileOutputStream(
+ atomList), "utf-8");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public void finished() {
+ try {
+ if (atomWriter != null) {
+ atomWriter.flush();
+ atomWriter.close();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String classPrefix() {
+ return "nsHtml5";
+ }
+
+ public String booleanType() {
+ return "PRBool";
+ }
+
+ public String charType() {
+ return "PRUnichar";
+ }
+
+ public String intType() {
+ return "PRInt32";
+ }
+
+ public String stringType() {
+ return "nsString*";
+ }
+
+ public String localType() {
+ return "nsIAtom*";
+ }
+
+ public String prefixType() {
+ return "nsIAtom*";
+ }
+
+ public String nsUriType() {
+ return "PRInt32";
+ }
+
+ public String falseLiteral() {
+ return "PR_FALSE";
+ }
+
+ public String trueLiteral() {
+ return "PR_TRUE";
+ }
+
+ public String nullLiteral() {
+ return "nsnull";
+ }
+
+ public String encodingDeclarationHandlerType() {
+ return "nsHtml5Parser*";
+ }
+
+ public String nodeType() {
+ return "nsIContent*";
+ }
+
+ public String xhtmlNamespaceLiteral() {
+ return "kNameSpaceID_XHTML";
+ }
+
+ public String svgNamespaceLiteral() {
+ return "kNameSpaceID_SVG";
+ }
+
+ public String xmlnsNamespaceLiteral() {
+ return "kNameSpaceID_XMLNS";
+ }
+
+ public String xmlNamespaceLiteral() {
+ return "kNameSpaceID_XML";
+ }
+
+ public String noNamespaceLiteral() {
+ return "kNameSpaceID_None";
+ }
+
+ public String xlinkNamespaceLiteral() {
+ return "kNameSpaceID_XLink";
+ }
+
+ public String mathmlNamespaceLiteral() {
+ return "kNameSpaceID_MathML";
+ }
+
+ public String arrayTemplate() {
+ return "jArray";
+ }
+
+ public String localForLiteral(String literal) {
+ String atom = atomMap.get(literal);
+ if (atom == null) {
+ atom = createAtomName(literal);
+ atomMap.put(literal, atom);
+ if (atomWriter != null) {
+ try {
+ atomWriter.write("HTML5_ATOM(" + atom + ", \"" + literal
+ + "\")\n");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ return "nsHtml5Atoms::" + atom;
+ }
+
+ private String createAtomName(String literal) {
+ String candidate = literal.replaceAll("[^a-zA-Z0-9_]", "_");
+ if ("".equals(candidate)) {
+ candidate = "emptystring";
+ }
+ while (atomMap.values().contains(candidate)
+ || reservedWords.contains(candidate)) {
+ candidate = candidate + '_';
+ }
+ return candidate;
+ }
+
+ public String stringForLiteral(String literal) {
+ return '"' + literal + '"';
+ }
+
+ public String staticArrayMacro() {
+ return "J_ARRAY_STATIC";
+ }
+
+ public String[] boilerplateIncludes(String javaClass) {
+ if ("TreeBuilder".equals(javaClass)) {
+ return TREE_BUILDER_INCLUDES;
+ } else {
+ return INCLUDES;
+ }
+ }
+
+ public String[] boilerplateDeclarations(String javaClass) {
+ if ("TreeBuilder".equals(javaClass)) {
+ return TREE_BUILDER_OTHER_DECLATIONS;
+ } else {
+ return OTHER_DECLATIONS;
+ }
+ }
+
+ public String[] namedCharactersIncludes() {
+ return NAMED_CHARACTERS_INCLUDES;
+ }
+
+ public String[] boilerplateForwardDeclarations() {
+ return FORWARD_DECLARATIONS;
+ }
+
+ public String documentModeHandlerType() {
+ return "nsHtml5Parser*";
+ }
+
+ public String documentModeType() {
+ return "nsHtml5DocumentMode";
+ }
+
+ public String arrayCopy() {
+ return "nsHtml5ArrayCopy::arraycopy";
+ }
+
+ public String maxInteger() {
+ return "PR_INT32_MAX";
+ }
+
+ public String constructorBoilerplate(String className) {
+ return "MOZ_COUNT_CTOR(" + className + ");";
+ }
+
+ public String destructorBoilderplate(String className) {
+ return "MOZ_COUNT_DTOR(" + className + ");";
+ }
+
+ public String literalType() {
+ return "const char*";
+ }
+
+ public boolean hasSupplement(String javaClass) {
+ return Arrays.binarySearch(CLASSES_THAT_NEED_SUPPLEMENT, javaClass) > -1;
+ }
+
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/CppVisitor.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/CppVisitor.java
new file mode 100755
index 000000000000..f104a0d6bc0c
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/CppVisitor.java
@@ -0,0 +1,2095 @@
+/*
+ * Copyright (C) 2007 Júlio Vilmar Gesser.
+ * Copyright (C) 2008 Mozilla Foundation
+ *
+ * This file is part of HTML Parser C++ Translator. It was derived from DumpVisitor
+ * which was part of Java 1.5 parser and Abstract Syntax Tree and came with the following notice:
+ *
+ * Java 1.5 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Java 1.5 parser and Abstract Syntax Tree is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Java 1.5 parser and Abstract Syntax Tree. If not, see .
+ */
+/*
+ * Created on 05/10/2006
+ */
+package nu.validator.htmlparser.cpptranslate;
+
+import japa.parser.ast.BlockComment;
+import japa.parser.ast.CompilationUnit;
+import japa.parser.ast.ImportDeclaration;
+import japa.parser.ast.LineComment;
+import japa.parser.ast.Node;
+import japa.parser.ast.PackageDeclaration;
+import japa.parser.ast.TypeParameter;
+import japa.parser.ast.body.AnnotationDeclaration;
+import japa.parser.ast.body.AnnotationMemberDeclaration;
+import japa.parser.ast.body.BodyDeclaration;
+import japa.parser.ast.body.ClassOrInterfaceDeclaration;
+import japa.parser.ast.body.ConstructorDeclaration;
+import japa.parser.ast.body.EmptyMemberDeclaration;
+import japa.parser.ast.body.EmptyTypeDeclaration;
+import japa.parser.ast.body.EnumConstantDeclaration;
+import japa.parser.ast.body.EnumDeclaration;
+import japa.parser.ast.body.FieldDeclaration;
+import japa.parser.ast.body.InitializerDeclaration;
+import japa.parser.ast.body.JavadocComment;
+import japa.parser.ast.body.MethodDeclaration;
+import japa.parser.ast.body.ModifierSet;
+import japa.parser.ast.body.Parameter;
+import japa.parser.ast.body.TypeDeclaration;
+import japa.parser.ast.body.VariableDeclarator;
+import japa.parser.ast.body.VariableDeclaratorId;
+import japa.parser.ast.expr.ArrayAccessExpr;
+import japa.parser.ast.expr.ArrayCreationExpr;
+import japa.parser.ast.expr.ArrayInitializerExpr;
+import japa.parser.ast.expr.AssignExpr;
+import japa.parser.ast.expr.BinaryExpr;
+import japa.parser.ast.expr.BooleanLiteralExpr;
+import japa.parser.ast.expr.CastExpr;
+import japa.parser.ast.expr.CharLiteralExpr;
+import japa.parser.ast.expr.ClassExpr;
+import japa.parser.ast.expr.ConditionalExpr;
+import japa.parser.ast.expr.DoubleLiteralExpr;
+import japa.parser.ast.expr.EnclosedExpr;
+import japa.parser.ast.expr.Expression;
+import japa.parser.ast.expr.FieldAccessExpr;
+import japa.parser.ast.expr.InstanceOfExpr;
+import japa.parser.ast.expr.IntegerLiteralExpr;
+import japa.parser.ast.expr.IntegerLiteralMinValueExpr;
+import japa.parser.ast.expr.LongLiteralExpr;
+import japa.parser.ast.expr.LongLiteralMinValueExpr;
+import japa.parser.ast.expr.MarkerAnnotationExpr;
+import japa.parser.ast.expr.MemberValuePair;
+import japa.parser.ast.expr.MethodCallExpr;
+import japa.parser.ast.expr.NameExpr;
+import japa.parser.ast.expr.NormalAnnotationExpr;
+import japa.parser.ast.expr.NullLiteralExpr;
+import japa.parser.ast.expr.ObjectCreationExpr;
+import japa.parser.ast.expr.QualifiedNameExpr;
+import japa.parser.ast.expr.SingleMemberAnnotationExpr;
+import japa.parser.ast.expr.StringLiteralExpr;
+import japa.parser.ast.expr.SuperExpr;
+import japa.parser.ast.expr.ThisExpr;
+import japa.parser.ast.expr.UnaryExpr;
+import japa.parser.ast.expr.VariableDeclarationExpr;
+import japa.parser.ast.stmt.AssertStmt;
+import japa.parser.ast.stmt.BlockStmt;
+import japa.parser.ast.stmt.BreakStmt;
+import japa.parser.ast.stmt.CatchClause;
+import japa.parser.ast.stmt.ContinueStmt;
+import japa.parser.ast.stmt.DoStmt;
+import japa.parser.ast.stmt.EmptyStmt;
+import japa.parser.ast.stmt.ExplicitConstructorInvocationStmt;
+import japa.parser.ast.stmt.ExpressionStmt;
+import japa.parser.ast.stmt.ForStmt;
+import japa.parser.ast.stmt.ForeachStmt;
+import japa.parser.ast.stmt.IfStmt;
+import japa.parser.ast.stmt.LabeledStmt;
+import japa.parser.ast.stmt.ReturnStmt;
+import japa.parser.ast.stmt.Statement;
+import japa.parser.ast.stmt.SwitchEntryStmt;
+import japa.parser.ast.stmt.SwitchStmt;
+import japa.parser.ast.stmt.SynchronizedStmt;
+import japa.parser.ast.stmt.ThrowStmt;
+import japa.parser.ast.stmt.TryStmt;
+import japa.parser.ast.stmt.TypeDeclarationStmt;
+import japa.parser.ast.stmt.WhileStmt;
+import japa.parser.ast.type.ClassOrInterfaceType;
+import japa.parser.ast.type.PrimitiveType;
+import japa.parser.ast.type.ReferenceType;
+import japa.parser.ast.type.Type;
+import japa.parser.ast.type.VoidType;
+import japa.parser.ast.type.WildcardType;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Julio Vilmar Gesser
+ * @author Henri Sivonen
+ */
+
+public class CppVisitor extends AnnotationHelperVisitor {
+
+ private static final String[] CLASS_NAMES = { "AttributeName",
+ "ElementName", "HtmlAttributes", "LocatorImpl", "MetaScanner",
+ "NamedCharacters", "Portability", "StackNode", "Tokenizer",
+ "TreeBuilder", "UTF16Buffer" };
+
+ public class SourcePrinter {
+
+ private int level = 0;
+
+ private boolean indented = false;
+
+ private final StringBuilder buf = new StringBuilder();
+
+ public void indent() {
+ level++;
+ }
+
+ public void unindent() {
+ level--;
+ }
+
+ private void makeIndent() {
+ for (int i = 0; i < level; i++) {
+ buf.append(" ");
+ }
+ }
+
+ public void print(String arg) {
+ if (!indented) {
+ makeIndent();
+ indented = true;
+ }
+ buf.append(arg);
+ }
+
+ public void printLn(String arg) {
+ print(arg);
+ printLn();
+ }
+
+ public void printLn() {
+ buf.append("\n");
+ indented = false;
+ }
+
+ public String getSource() {
+ return buf.toString();
+ }
+
+ @Override public String toString() {
+ return getSource();
+ }
+ }
+
+ protected SourcePrinter printer = new SourcePrinter();
+
+ private SourcePrinter staticInitializerPrinter = new SourcePrinter();
+
+ private SourcePrinter tempPrinterHolder;
+
+ protected final CppTypes cppTypes;
+
+ protected String className = "";
+
+ protected int currentArrayCount;
+
+ protected Set forLoopsWithCondition = new HashSet();
+
+ protected boolean inPrimitiveNoLengthFieldDeclarator = false;
+
+ protected final SymbolTable symbolTable;
+
+ protected String definePrefix;
+
+ protected String javaClassName;
+
+ protected boolean suppressPointer = false;
+
+ private final List staticReleases = new LinkedList();
+
+ private boolean inConstructorBody = false;
+
+ private String currentMethod = null;
+
+ private Set labels = null;
+
+ private boolean destructor;
+
+ /**
+ * @param cppTypes
+ */
+ public CppVisitor(CppTypes cppTypes, SymbolTable symbolTable) {
+ this.cppTypes = cppTypes;
+ this.symbolTable = symbolTable;
+ staticInitializerPrinter.indent();
+ }
+
+ public String getSource() {
+ return printer.getSource();
+ }
+
+ private String classNameFromExpression(Expression e) {
+ if (e instanceof NameExpr) {
+ NameExpr nameExpr = (NameExpr) e;
+ String name = nameExpr.getName();
+ if (Arrays.binarySearch(CLASS_NAMES, name) > -1) {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ protected void printModifiers(int modifiers) {
+ }
+
+ private void printMembers(List members, LocalSymbolTable arg) {
+ for (BodyDeclaration member : members) {
+ member.accept(this, arg);
+ }
+ }
+
+ private void printTypeArgs(List args, LocalSymbolTable arg) {
+ // if (args != null) {
+ // printer.print("<");
+ // for (Iterator i = args.iterator(); i.hasNext();) {
+ // Type t = i.next();
+ // t.accept(this, arg);
+ // if (i.hasNext()) {
+ // printer.print(", ");
+ // }
+ // }
+ // printer.print(">");
+ // }
+ }
+
+ private void printTypeParameters(List args, LocalSymbolTable arg) {
+ // if (args != null) {
+ // printer.print("<");
+ // for (Iterator i = args.iterator(); i.hasNext();) {
+ // TypeParameter t = i.next();
+ // t.accept(this, arg);
+ // if (i.hasNext()) {
+ // printer.print(", ");
+ // }
+ // }
+ // printer.print(">");
+ // }
+ }
+
+ public void visit(Node n, LocalSymbolTable arg) {
+ throw new IllegalStateException(n.getClass().getName());
+ }
+
+ public void visit(CompilationUnit n, LocalSymbolTable arg) {
+ if (n.getTypes() != null) {
+ for (Iterator i = n.getTypes().iterator(); i.hasNext();) {
+ i.next().accept(this, arg);
+ printer.printLn();
+ if (i.hasNext()) {
+ printer.printLn();
+ }
+ }
+ }
+ }
+
+ public void visit(PackageDeclaration n, LocalSymbolTable arg) {
+ throw new IllegalStateException(n.getClass().getName());
+ }
+
+ public void visit(NameExpr n, LocalSymbolTable arg) {
+ if ("mappingLangToXmlLang".equals(n.getName())) {
+ printer.print("0");
+ } else if ("LANG_NS".equals(n.getName())) {
+ printer.print("ALL_NO_NS");
+ } else if ("LANG_PREFIX".equals(n.getName())) {
+ printer.print("ALL_NO_PREFIX");
+ } else if ("HTML_LOCAL".equals(n.getName())) {
+ printer.print(cppTypes.localForLiteral("html"));
+ } else if ("documentModeHandler".equals(n.getName())) {
+ printer.print("parser");
+ } else {
+ String prefixedName = javaClassName + "." + n.getName();
+ String constant = symbolTable.cppDefinesByJavaNames.get(prefixedName);
+ if (constant != null) {
+ printer.print(constant);
+ } else {
+ printer.print(n.getName());
+ }
+ }
+ }
+
+ public void visit(QualifiedNameExpr n, LocalSymbolTable arg) {
+ n.getQualifier().accept(this, arg);
+ printer.print(".");
+ printer.print(n.getName());
+ }
+
+ public void visit(ImportDeclaration n, LocalSymbolTable arg) {
+ throw new IllegalStateException(n.getClass().getName());
+ }
+
+ public void visit(ClassOrInterfaceDeclaration n, LocalSymbolTable arg) {
+ javaClassName = n.getName();
+ className = cppTypes.classPrefix() + javaClassName;
+ definePrefix = makeDefinePrefix(className);
+
+ startClassDeclaration();
+
+ if (n.getMembers() != null) {
+ printMembers(n.getMembers(), arg);
+ }
+
+ endClassDeclaration();
+ }
+
+ private String makeDefinePrefix(String name) {
+ StringBuilder sb = new StringBuilder();
+ boolean prevWasLowerCase = true;
+ for (int i = 0; i < name.length(); i++) {
+ char c = name.charAt(i);
+ if (c >= 'a' && c <= 'z') {
+ sb.append((char) (c - 0x20));
+ prevWasLowerCase = true;
+ } else if (c >= 'A' && c <= 'Z') {
+ if (prevWasLowerCase) {
+ sb.append('_');
+ }
+ sb.append(c);
+ prevWasLowerCase = false;
+ } else if (c >= '0' && c <= '9') {
+ sb.append(c);
+ prevWasLowerCase = false;
+ }
+ }
+ sb.append('_');
+ return sb.toString();
+ }
+
+ protected void endClassDeclaration() {
+ printer.printLn("void");
+ printer.print(className);
+ printer.printLn("::initializeStatics()");
+ printer.printLn("{");
+ printer.print(staticInitializerPrinter.getSource());
+ printer.printLn("}");
+ printer.printLn();
+
+ printer.printLn("void");
+ printer.print(className);
+ printer.printLn("::releaseStatics()");
+ printer.printLn("{");
+ printer.indent();
+ for (String del : staticReleases) {
+ printer.print(del);
+ printer.printLn(";");
+ }
+ printer.unindent();
+ printer.printLn("}");
+ printer.printLn();
+
+ if (cppTypes.hasSupplement(javaClassName)) {
+ printer.printLn();
+ printer.print("#include \"");
+ printer.print(className);
+ printer.printLn("CppSupplement.h\"");
+ }
+ }
+
+ protected void startClassDeclaration() {
+ printer.print("#define ");
+ printer.print(className);
+ printer.printLn("_cpp__");
+ printer.printLn();
+
+ String[] incs = cppTypes.boilerplateIncludes(javaClassName);
+ for (int i = 0; i < incs.length; i++) {
+ String inc = incs[i];
+ printer.print("#include \"");
+ printer.print(inc);
+ printer.printLn(".h\"");
+ }
+
+ printer.printLn();
+
+ for (int i = 0; i < Main.H_LIST.length; i++) {
+ String klazz = Main.H_LIST[i];
+ if (!klazz.equals(javaClassName)) {
+ printer.print("#include \"");
+ printer.print(cppTypes.classPrefix());
+ printer.print(klazz);
+ printer.printLn(".h\"");
+ }
+ }
+
+ printer.printLn();
+ printer.print("#include \"");
+ printer.print(className);
+ printer.printLn(".h\"");
+ if ("AttributeName".equals(javaClassName)
+ || "ElementName".equals(javaClassName)) {
+ printer.print("#include \"");
+ printer.print(cppTypes.classPrefix());
+ printer.print("Releasable");
+ printer.print(javaClassName);
+ printer.printLn(".h\"");
+ }
+ printer.printLn();
+ }
+
+ public void visit(EmptyTypeDeclaration n, LocalSymbolTable arg) {
+ if (n.getJavaDoc() != null) {
+ n.getJavaDoc().accept(this, arg);
+ }
+ printer.print(";");
+ }
+
+ public void visit(JavadocComment n, LocalSymbolTable arg) {
+ printer.print("/**");
+ printer.print(n.getContent());
+ printer.printLn("*/");
+ }
+
+ public void visit(ClassOrInterfaceType n, LocalSymbolTable arg) {
+ if (n.getScope() != null) {
+ n.getScope().accept(this, arg);
+ printer.print(".");
+ throw new IllegalStateException("Can't translate nested classes.");
+ }
+ String name = n.getName();
+ if ("String".equals(name)) {
+ if (local()) {
+ name = cppTypes.localType();
+ } else if (prefix()) {
+ name = cppTypes.prefixType();
+ } else if (nsUri()) {
+ name = cppTypes.nsUriType();
+ } else if (literal()) {
+ name = cppTypes.literalType();
+ } else {
+ name = cppTypes.stringType();
+ }
+ } else if ("T".equals(name) || "Object".equals(name)) {
+ name = cppTypes.nodeType();
+ } else if ("TokenHandler".equals(name)) {
+ name = cppTypes.classPrefix() + "TreeBuilder*";
+ } else if ("EncodingDeclarationHandler".equals(name)) {
+ name = cppTypes.encodingDeclarationHandlerType();
+ } else if ("DocumentModeHandler".equals(name)) {
+ name = cppTypes.documentModeHandlerType();
+ } else if ("DocumentMode".equals(name)) {
+ name = cppTypes.documentModeType();
+ } else {
+ name = cppTypes.classPrefix() + name + (suppressPointer ? "" : "*");
+ }
+ printer.print(name);
+ printTypeArgs(n.getTypeArgs(), arg);
+ }
+
+ protected boolean inHeader() {
+ return false;
+ }
+
+ public void visit(TypeParameter n, LocalSymbolTable arg) {
+ printer.print(n.getName());
+ if (n.getTypeBound() != null) {
+ printer.print(" extends ");
+ for (Iterator i = n.getTypeBound().iterator(); i.hasNext();) {
+ ClassOrInterfaceType c = i.next();
+ c.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(" & ");
+ }
+ }
+ }
+ }
+
+ public void visit(PrimitiveType n, LocalSymbolTable arg) {
+ switch (n.getType()) {
+ case Boolean:
+ printer.print(cppTypes.booleanType());
+ break;
+ case Byte:
+ throw new IllegalStateException("Unsupported primitive.");
+ case Char:
+ printer.print(cppTypes.charType());
+ break;
+ case Double:
+ throw new IllegalStateException("Unsupported primitive.");
+ case Float:
+ throw new IllegalStateException("Unsupported primitive.");
+ case Int:
+ printer.print(cppTypes.intType());
+ break;
+ case Long:
+ throw new IllegalStateException("Unsupported primitive.");
+ case Short:
+ throw new IllegalStateException("Unsupported primitive.");
+ }
+ }
+
+ public void visit(ReferenceType n, LocalSymbolTable arg) {
+ if (noLength()) {
+ n.getType().accept(this, arg);
+ for (int i = 0; i < n.getArrayCount(); i++) {
+ if (!inPrimitiveNoLengthFieldDeclarator) {
+ printer.print("*");
+ }
+ }
+ } else {
+ for (int i = 0; i < n.getArrayCount(); i++) {
+ printer.print(cppTypes.arrayTemplate());
+ printer.print("<");
+ }
+ n.getType().accept(this, arg);
+ for (int i = 0; i < n.getArrayCount(); i++) {
+ printer.print(",");
+ printer.print(cppTypes.intType());
+ printer.print(">");
+ }
+ }
+ }
+
+ public void visit(WildcardType n, LocalSymbolTable arg) {
+ printer.print("?");
+ if (n.getExtends() != null) {
+ printer.print(" extends ");
+ n.getExtends().accept(this, arg);
+ }
+ if (n.getSuper() != null) {
+ printer.print(" super ");
+ n.getSuper().accept(this, arg);
+ }
+ }
+
+ public void visit(FieldDeclaration n, LocalSymbolTable arg) {
+ currentAnnotations = n.getAnnotations();
+ fieldDeclaration(n, arg);
+ currentAnnotations = null;
+ }
+
+ protected boolean isNonToCharArrayMethodCall(Expression exp) {
+ if (exp instanceof MethodCallExpr) {
+ MethodCallExpr mce = (MethodCallExpr) exp;
+ return !"toCharArray".equals(mce.getName());
+ } else {
+ return false;
+ }
+ }
+
+ protected void fieldDeclaration(FieldDeclaration n, LocalSymbolTable arg) {
+ tempPrinterHolder = printer;
+ printer = staticInitializerPrinter;
+ int modifiers = n.getModifiers();
+ List variables = n.getVariables();
+ VariableDeclarator declarator = variables.get(0);
+ if (ModifierSet.isStatic(modifiers) && ModifierSet.isFinal(modifiers)
+ && !(n.getType() instanceof PrimitiveType)
+ && declarator.getInit() != null) {
+ if (n.getType() instanceof ReferenceType) {
+ ReferenceType rt = (ReferenceType) n.getType();
+ currentArrayCount = rt.getArrayCount();
+ if (currentArrayCount > 0) {
+ if (currentArrayCount != 1) {
+ throw new IllegalStateException(
+ "Multidimensional arrays not supported. " + n);
+ }
+ if (noLength()) {
+ if (rt.getType() instanceof PrimitiveType) {
+ // do nothing
+ } else {
+ staticReleases.add("delete[] "
+ + declarator.getId().getName());
+
+ ArrayInitializerExpr aie = (ArrayInitializerExpr) declarator.getInit();
+
+ declarator.getId().accept(this, arg);
+ printer.print(" = new ");
+ // suppressPointer = true;
+ rt.getType().accept(this, arg);
+ // suppressPointer = false;
+ printer.print("[");
+ printer.print("" + aie.getValues().size());
+ printer.printLn("];");
+
+ printArrayInit(declarator.getId(), aie.getValues(),
+ arg);
+ }
+ } else if (isNonToCharArrayMethodCall(declarator.getInit())
+ || !(rt.getType() instanceof PrimitiveType)) {
+ staticReleases.add(declarator.getId().getName()
+ + ".release()");
+ declarator.getId().accept(this, arg);
+ printer.print(" = ");
+ if (declarator.getInit() instanceof ArrayInitializerExpr) {
+
+ ArrayInitializerExpr aie = (ArrayInitializerExpr) declarator.getInit();
+ printer.print(cppTypes.arrayTemplate());
+ printer.print("<");
+ suppressPointer = true;
+ rt.getType().accept(this, arg);
+ suppressPointer = false;
+ printer.print(",");
+ printer.print(cppTypes.intType());
+ printer.print(">(");
+ printer.print("" + aie.getValues().size());
+ printer.printLn(");");
+ printArrayInit(declarator.getId(), aie.getValues(),
+ arg);
+ } else {
+ declarator.getInit().accept(this, arg);
+ printer.printLn(";");
+ }
+ } else if ((rt.getType() instanceof PrimitiveType)) {
+ printer = tempPrinterHolder;
+ printer.print("static ");
+ rt.getType().accept(this, arg);
+ printer.print(" const ");
+ declarator.getId().accept(this, arg);
+ printer.print("_DATA[] = ");
+ declarator.getInit().accept(this, arg);
+ printer.printLn(";");
+ printer = staticInitializerPrinter;
+
+ declarator.getId().accept(this, arg);
+ printer.print(" = ");
+ printer.print(cppTypes.arrayTemplate());
+ printer.print("<");
+ rt.getType().accept(this, arg);
+ printer.print(",");
+ printer.print(cppTypes.intType());
+ printer.print(">((");
+ rt.getType().accept(this, arg);
+ printer.print("*)");
+ declarator.getId().accept(this, arg);
+ printer.print("_DATA, ");
+ printer.print(Integer.toString(((ArrayInitializerExpr) declarator.getInit()).getValues().size()));
+ printer.printLn(");");
+ }
+ } else {
+
+ if ("AttributeName".equals(n.getType().toString())) {
+ printer.print("ATTR_");
+ staticReleases.add("delete ATTR_"
+ + declarator.getId().getName());
+ } else if ("ElementName".equals(n.getType().toString())) {
+ printer.print("ELT_");
+ staticReleases.add("delete ELT_"
+ + declarator.getId().getName());
+ } else {
+ staticReleases.add("delete "
+ + declarator.getId().getName());
+ }
+ declarator.accept(this, arg);
+ printer.printLn(";");
+ }
+ } else {
+ throw new IllegalStateException(
+ "Non-reference, non-primitive fields not supported.");
+ }
+ }
+ currentArrayCount = 0;
+ printer = tempPrinterHolder;
+ }
+
+ private void printArrayInit(VariableDeclaratorId variableDeclaratorId,
+ List values, LocalSymbolTable arg) {
+ for (int i = 0; i < values.size(); i++) {
+ Expression exp = values.get(i);
+ variableDeclaratorId.accept(this, arg);
+ printer.print("[");
+ printer.print("" + i);
+ printer.print("] = ");
+ if (exp instanceof NameExpr) {
+ if ("AttributeName".equals(javaClassName)) {
+ printer.print("ATTR_");
+ } else if ("ElementName".equals(javaClassName)) {
+ printer.print("ELT_");
+ }
+ }
+ exp.accept(this, arg);
+ printer.printLn(";");
+ }
+ }
+
+ public void visit(VariableDeclarator n, LocalSymbolTable arg) {
+ n.getId().accept(this, arg);
+
+ if (n.getInit() != null) {
+ printer.print(" = ");
+ n.getInit().accept(this, arg);
+ }
+ }
+
+ public void visit(VariableDeclaratorId n, LocalSymbolTable arg) {
+ String name = n.getName();
+ if ("documentModeHandler".equals(name)) {
+ printer.print("parser");
+ } else {
+ printer.print(n.getName());
+ }
+ if (noLength()) {
+ for (int i = 0; i < currentArrayCount; i++) {
+ if (inPrimitiveNoLengthFieldDeclarator) {
+ printer.print("[]");
+ }
+ }
+ }
+ for (int i = 0; i < n.getArrayCount(); i++) {
+ printer.print("[]");
+ }
+ }
+
+ public void visit(ArrayInitializerExpr n, LocalSymbolTable arg) {
+ printer.print("{");
+ if (n.getValues() != null) {
+ printer.print(" ");
+ for (Iterator i = n.getValues().iterator(); i.hasNext();) {
+ Expression expr = i.next();
+ expr.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ printer.print(" ");
+ }
+ printer.print("}");
+ }
+
+ public void visit(VoidType n, LocalSymbolTable arg) {
+ printer.print("void");
+ }
+
+ public void visit(ArrayAccessExpr n, LocalSymbolTable arg) {
+ n.getName().accept(this, arg);
+ printer.print("[");
+ n.getIndex().accept(this, arg);
+ printer.print("]");
+ }
+
+ public void visit(ArrayCreationExpr n, LocalSymbolTable arg) {
+ // printer.print("new ");
+ // n.getType().accept(this, arg);
+ // printTypeArgs(n.getTypeArgs(), arg);
+
+ if (n.getDimensions() != null) {
+ if (noLength()) {
+ for (Expression dim : n.getDimensions()) {
+ printer.print("new ");
+ n.getType().accept(this, arg);
+ printer.print("[");
+ dim.accept(this, arg);
+ printer.print("]");
+ }
+ } else {
+ for (Expression dim : n.getDimensions()) {
+ printer.print(cppTypes.arrayTemplate());
+ printer.print("<");
+ n.getType().accept(this, arg);
+ printer.print(",");
+ printer.print(cppTypes.intType());
+ printer.print(">(");
+ dim.accept(this, arg);
+ printer.print(")");
+ }
+ }
+ if (n.getArrayCount() > 0) {
+ throw new IllegalStateException(
+ "Nested array allocation not supported. "
+ + n.toString());
+ }
+ } else {
+ throw new IllegalStateException(
+ "Array initializer as part of array creation not supported. "
+ + n.toString());
+ }
+ }
+
+ public void visit(AssignExpr n, LocalSymbolTable arg) {
+ if (inConstructorBody) {
+ n.getTarget().accept(this, arg);
+ printer.print("(");
+ n.getValue().accept(this, arg);
+ printer.print(")");
+ } else {
+ n.getTarget().accept(this, arg);
+ printer.print(" ");
+ switch (n.getOperator()) {
+ case assign:
+ printer.print("=");
+ break;
+ case and:
+ printer.print("&=");
+ break;
+ case or:
+ printer.print("|=");
+ break;
+ case xor:
+ printer.print("^=");
+ break;
+ case plus:
+ printer.print("+=");
+ break;
+ case minus:
+ printer.print("-=");
+ break;
+ case rem:
+ printer.print("%=");
+ break;
+ case slash:
+ printer.print("/=");
+ break;
+ case star:
+ printer.print("*=");
+ break;
+ case lShift:
+ printer.print("<<=");
+ break;
+ case rSignedShift:
+ printer.print(">>=");
+ break;
+ case rUnsignedShift:
+ printer.print(">>>=");
+ break;
+ }
+ printer.print(" ");
+ n.getValue().accept(this, arg);
+ }
+ }
+
+ public void visit(BinaryExpr n, LocalSymbolTable arg) {
+ Expression right = n.getRight();
+ switch (n.getOperator()) {
+ case notEquals:
+ if (right instanceof NullLiteralExpr) {
+ printer.print("!!");
+ n.getLeft().accept(this, arg);
+ return;
+ } else if (right instanceof IntegerLiteralExpr) {
+ IntegerLiteralExpr ile = (IntegerLiteralExpr) right;
+ if ("0".equals(ile.getValue())) {
+ n.getLeft().accept(this, arg);
+ return;
+ }
+ }
+ case equals:
+ if (right instanceof NullLiteralExpr) {
+ printer.print("!");
+ n.getLeft().accept(this, arg);
+ return;
+ } else if (right instanceof IntegerLiteralExpr) {
+ IntegerLiteralExpr ile = (IntegerLiteralExpr) right;
+ if ("0".equals(ile.getValue())) {
+ printer.print("!");
+ n.getLeft().accept(this, arg);
+ return;
+ }
+ }
+ default:
+ // fall thru
+ }
+
+ n.getLeft().accept(this, arg);
+ printer.print(" ");
+ switch (n.getOperator()) {
+ case or:
+ printer.print("||");
+ break;
+ case and:
+ printer.print("&&");
+ break;
+ case binOr:
+ printer.print("|");
+ break;
+ case binAnd:
+ printer.print("&");
+ break;
+ case xor:
+ printer.print("^");
+ break;
+ case equals:
+ printer.print("==");
+ break;
+ case notEquals:
+ printer.print("!=");
+ break;
+ case less:
+ printer.print("<");
+ break;
+ case greater:
+ printer.print(">");
+ break;
+ case lessEquals:
+ printer.print("<=");
+ break;
+ case greaterEquals:
+ printer.print(">=");
+ break;
+ case lShift:
+ printer.print("<<");
+ break;
+ case rSignedShift:
+ printer.print(">>");
+ break;
+ case rUnsignedShift:
+ printer.print(">>>");
+ break;
+ case plus:
+ printer.print("+");
+ break;
+ case minus:
+ printer.print("-");
+ break;
+ case times:
+ printer.print("*");
+ break;
+ case divide:
+ printer.print("/");
+ break;
+ case remainder:
+ printer.print("%");
+ break;
+ }
+ printer.print(" ");
+ n.getRight().accept(this, arg);
+ }
+
+ public void visit(CastExpr n, LocalSymbolTable arg) {
+ printer.print("(");
+ n.getType().accept(this, arg);
+ printer.print(") ");
+ n.getExpr().accept(this, arg);
+ }
+
+ public void visit(ClassExpr n, LocalSymbolTable arg) {
+ n.getType().accept(this, arg);
+ printer.print(".class");
+ }
+
+ public void visit(ConditionalExpr n, LocalSymbolTable arg) {
+ n.getCondition().accept(this, arg);
+ printer.print(" ? ");
+ n.getThenExpr().accept(this, arg);
+ printer.print(" : ");
+ n.getElseExpr().accept(this, arg);
+ }
+
+ public void visit(EnclosedExpr n, LocalSymbolTable arg) {
+ printer.print("(");
+ n.getInner().accept(this, arg);
+ printer.print(")");
+ }
+
+ public void visit(FieldAccessExpr n, LocalSymbolTable arg) {
+ Expression scope = n.getScope();
+ String field = n.getField();
+ if (inConstructorBody && (scope instanceof ThisExpr)) {
+ printer.print(field);
+ } else if ("length".equals(field) && !(scope instanceof ThisExpr)) {
+ scope.accept(this, arg);
+ printer.print(".length");
+ } else if ("MAX_VALUE".equals(field)
+ && "Integer".equals(scope.toString())) {
+ printer.print(cppTypes.maxInteger());
+ } else {
+ String clazzName = classNameFromExpression(scope);
+ if (clazzName == null) {
+ if ("DocumentMode".equals(scope.toString())) {
+ // printer.print(cppTypes.documentModeType());
+ // printer.print(".");
+ } else {
+ scope.accept(this, arg);
+ printer.print("->");
+ }
+ } else {
+ String prefixedName = clazzName + "." + field;
+ String constant = symbolTable.cppDefinesByJavaNames.get(prefixedName);
+ if (constant != null) {
+ printer.print(constant);
+ return;
+ } else {
+ printer.print(cppTypes.classPrefix());
+ printer.print(clazzName);
+ printer.print("::");
+ if (symbolTable.isNotAnAttributeOrElementName(field)) {
+ if ("AttributeName".equals(clazzName)) {
+ printer.print("ATTR_");
+ } else if ("ElementName".equals(clazzName)) {
+ printer.print("ELT_");
+ }
+ }
+ }
+ }
+ printer.print(field);
+ }
+ }
+
+ public void visit(InstanceOfExpr n, LocalSymbolTable arg) {
+ n.getExpr().accept(this, arg);
+ printer.print(" instanceof ");
+ n.getType().accept(this, arg);
+ }
+
+ public void visit(CharLiteralExpr n, LocalSymbolTable arg) {
+ printCharLiteral(n.getValue());
+ }
+
+ private void printCharLiteral(String val) {
+ if (val.length() != 1) {
+ printer.print("'");
+ printer.print(val);
+ printer.print("'");
+ return;
+ }
+ char c = val.charAt(0);
+ switch (c) {
+ case 0:
+ printer.print("'\\0'");
+ break;
+ case '\n':
+ printer.print("'\\n'");
+ break;
+ case '\t':
+ printer.print("'\\t'");
+ break;
+ case 0xB:
+ printer.print("'\\v'");
+ break;
+ case '\b':
+ printer.print("'\\b'");
+ break;
+ case '\r':
+ printer.print("'\\r'");
+ break;
+ case 0xC:
+ printer.print("'\\f'");
+ break;
+ case 0x7:
+ printer.print("'\\a'");
+ break;
+ case '\\':
+ printer.print("'\\\\'");
+ break;
+ case '?':
+ printer.print("'\\?'");
+ break;
+ case '\'':
+ printer.print("'\\''");
+ break;
+ case '"':
+ printer.print("'\\\"'");
+ break;
+ default:
+ if (c >= 0x20 && c <= 0x7F) {
+ printer.print("'" + c);
+ printer.print("'");
+ } else {
+ printer.print("0x");
+ printer.print(Integer.toHexString(c));
+ }
+ break;
+ }
+ }
+
+ public void visit(DoubleLiteralExpr n, LocalSymbolTable arg) {
+ printer.print(n.getValue());
+ }
+
+ public void visit(IntegerLiteralExpr n, LocalSymbolTable arg) {
+ printer.print(n.getValue());
+ }
+
+ public void visit(LongLiteralExpr n, LocalSymbolTable arg) {
+ printer.print(n.getValue());
+ }
+
+ public void visit(IntegerLiteralMinValueExpr n, LocalSymbolTable arg) {
+ printer.print(n.getValue());
+ }
+
+ public void visit(LongLiteralMinValueExpr n, LocalSymbolTable arg) {
+ printer.print(n.getValue());
+ }
+
+ public void visit(StringLiteralExpr n, LocalSymbolTable arg) {
+ String val = n.getValue();
+ if ("http://www.w3.org/1999/xhtml".equals(val)) {
+ printer.print(cppTypes.xhtmlNamespaceLiteral());
+ } else if ("http://www.w3.org/2000/svg".equals(val)) {
+ printer.print(cppTypes.svgNamespaceLiteral());
+ } else if ("http://www.w3.org/2000/xmlns/".equals(val)) {
+ printer.print(cppTypes.xmlnsNamespaceLiteral());
+ } else if ("http://www.w3.org/XML/1998/namespace".equals(val)) {
+ printer.print(cppTypes.xmlNamespaceLiteral());
+ } else if ("http://www.w3.org/1999/xlink".equals(val)) {
+ printer.print(cppTypes.xlinkNamespaceLiteral());
+ } else if ("http://www.w3.org/1998/Math/MathML".equals(val)) {
+ printer.print(cppTypes.mathmlNamespaceLiteral());
+ } else if ("".equals(val) && "AttributeName".equals(javaClassName)) {
+ printer.print(cppTypes.noNamespaceLiteral());
+ } else if (val.startsWith("-/") || val.startsWith("+//")
+ || val.startsWith("http://") || val.startsWith("XSLT")) {
+ printer.print(cppTypes.stringForLiteral(val));
+ } else if (("hidden".equals(val) || "isindex".equals(val))
+ && "TreeBuilder".equals(javaClassName)) {
+ printer.print(cppTypes.stringForLiteral(val));
+ } else if ("isQuirky".equals(currentMethod) && "html".equals(val)) {
+ printer.print(cppTypes.stringForLiteral(val));
+ } else {
+ printer.print(cppTypes.localForLiteral(val));
+ }
+ }
+
+ public void visit(BooleanLiteralExpr n, LocalSymbolTable arg) {
+ if (n.getValue()) {
+ printer.print(cppTypes.trueLiteral());
+ } else {
+ printer.print(cppTypes.falseLiteral());
+ }
+ }
+
+ public void visit(NullLiteralExpr n, LocalSymbolTable arg) {
+ printer.print(cppTypes.nullLiteral());
+ }
+
+ public void visit(ThisExpr n, LocalSymbolTable arg) {
+ if (n.getClassExpr() != null) {
+ n.getClassExpr().accept(this, arg);
+ printer.print(".");
+ }
+ printer.print("this");
+ }
+
+ public void visit(SuperExpr n, LocalSymbolTable arg) {
+ if (n.getClassExpr() != null) {
+ n.getClassExpr().accept(this, arg);
+ printer.print(".");
+ }
+ printer.print("super");
+ }
+
+ public void visit(MethodCallExpr n, LocalSymbolTable arg) {
+ if ("releaseArray".equals(n.getName())
+ && "Portability".equals(n.getScope().toString())) {
+ n.getArgs().get(0).accept(this, arg);
+ printer.print(".release()");
+ } else if ("deleteArray".equals(n.getName())
+ && "Portability".equals(n.getScope().toString())) {
+ printer.print("delete[] ");
+ n.getArgs().get(0).accept(this, arg);
+ } else if ("delete".equals(n.getName())
+ && "Portability".equals(n.getScope().toString())) {
+ printer.print("delete ");
+ n.getArgs().get(0).accept(this, arg);
+ } else if ("arraycopy".equals(n.getName())
+ && "System".equals(n.getScope().toString())) {
+ printer.print(cppTypes.arrayCopy());
+ printer.print("(");
+ if (n.getArgs().get(0).toString().equals(
+ n.getArgs().get(2).toString())) {
+ n.getArgs().get(0).accept(this, arg);
+ printer.print(", ");
+ n.getArgs().get(1).accept(this, arg);
+ printer.print(", ");
+ n.getArgs().get(3).accept(this, arg);
+ printer.print(", ");
+ n.getArgs().get(4).accept(this, arg);
+ } else if (n.getArgs().get(1).toString().equals("0")
+ && n.getArgs().get(3).toString().equals("0")) {
+ n.getArgs().get(0).accept(this, arg);
+ printer.print(", ");
+ n.getArgs().get(2).accept(this, arg);
+ printer.print(", ");
+ n.getArgs().get(4).accept(this, arg);
+ } else {
+ for (Iterator i = n.getArgs().iterator(); i.hasNext();) {
+ Expression e = i.next();
+ e.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print(")");
+ } else if ("binarySearch".equals(n.getName())
+ && "Arrays".equals(n.getScope().toString())) {
+ n.getArgs().get(0).accept(this, arg);
+ printer.print(".binarySearch(");
+ n.getArgs().get(1).accept(this, arg);
+ printer.print(")");
+ } else {
+ Expression scope = n.getScope();
+ if (scope != null) {
+ if (scope instanceof StringLiteralExpr) {
+ StringLiteralExpr strLit = (StringLiteralExpr) scope;
+ String str = strLit.getValue();
+ if (!"toCharArray".equals(n.getName())) {
+ throw new IllegalStateException(
+ "Unsupported method call on string literal: "
+ + n.getName());
+ }
+ printer.print("{ ");
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+ if (i != 0) {
+ printer.print(", ");
+ }
+ printCharLiteral("" + c);
+ }
+ printer.print(" }");
+ return;
+ } else {
+ String clazzName = classNameFromExpression(scope);
+ if (clazzName == null) {
+ scope.accept(this, arg);
+ printer.print("->");
+ } else {
+ printer.print(cppTypes.classPrefix());
+ printer.print(clazzName);
+ printer.print("::");
+ }
+ }
+ }
+ printTypeArgs(n.getTypeArgs(), arg);
+ printer.print(n.getName());
+ printer.print("(");
+ if (n.getArgs() != null) {
+ for (Iterator i = n.getArgs().iterator(); i.hasNext();) {
+ Expression e = i.next();
+ e.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print(")");
+ }
+ }
+
+ public void visit(ObjectCreationExpr n, LocalSymbolTable arg) {
+ if (n.getScope() != null) {
+ n.getScope().accept(this, arg);
+ printer.print(".");
+ }
+
+ printer.print("new ");
+
+ suppressPointer = true;
+ printTypeArgs(n.getTypeArgs(), arg);
+ if ("createAttributeName".equals(currentMethod)
+ || "elementNameByBuffer".equals(currentMethod)) {
+ printer.print(cppTypes.classPrefix());
+ printer.print("Releasable");
+ printer.print(n.getType().getName());
+ } else {
+ n.getType().accept(this, arg);
+ }
+ suppressPointer = false;
+
+ if ("AttributeName".equals(n.getType().getName())) {
+ List args = n.getArgs();
+ while (args.size() > 3) {
+ args.remove(3);
+ }
+ }
+
+ printer.print("(");
+ if (n.getArgs() != null) {
+ for (Iterator i = n.getArgs().iterator(); i.hasNext();) {
+ Expression e = i.next();
+ e.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print(")");
+
+ if (n.getAnonymousClassBody() != null) {
+ printer.printLn(" {");
+ printer.indent();
+ printMembers(n.getAnonymousClassBody(), arg);
+ printer.unindent();
+ printer.print("}");
+ }
+ }
+
+ public void visit(UnaryExpr n, LocalSymbolTable arg) {
+ switch (n.getOperator()) {
+ case positive:
+ printer.print("+");
+ break;
+ case negative:
+ printer.print("-");
+ break;
+ case inverse:
+ printer.print("~");
+ break;
+ case not:
+ printer.print("!");
+ break;
+ case preIncrement:
+ printer.print("++");
+ break;
+ case preDecrement:
+ printer.print("--");
+ break;
+ }
+
+ n.getExpr().accept(this, arg);
+
+ switch (n.getOperator()) {
+ case posIncrement:
+ printer.print("++");
+ break;
+ case posDecrement:
+ printer.print("--");
+ break;
+ }
+ }
+
+ public void visit(ConstructorDeclaration n, LocalSymbolTable arg) {
+ if ("TreeBuilder".equals(javaClassName)
+ || "MetaScanner".equals(javaClassName)) {
+ return;
+ }
+
+ arg = new LocalSymbolTable(javaClassName, symbolTable);
+
+ // if (n.getJavaDoc() != null) {
+ // n.getJavaDoc().accept(this, arg);
+ // }
+ currentAnnotations = n.getAnnotations();
+
+ printModifiers(n.getModifiers());
+
+ printMethodNamespace();
+ printer.print(className);
+ currentAnnotations = null;
+
+ printer.print("(");
+ if (n.getParameters() != null) {
+ for (Iterator i = n.getParameters().iterator(); i.hasNext();) {
+ Parameter p = i.next();
+ p.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print(")");
+
+ printConstructorBody(n.getBlock(), arg);
+ }
+
+ protected void printConstructorBody(BlockStmt block, LocalSymbolTable arg) {
+ inConstructorBody = true;
+ List statements = block.getStmts();
+ List nonAssigns = new LinkedList();
+ int i = 0;
+ boolean needOutdent = false;
+ for (Statement statement : statements) {
+ if (statement instanceof ExpressionStmt
+ && ((ExpressionStmt) statement).getExpression() instanceof AssignExpr) {
+ if (i == 0) {
+ printer.printLn();
+ printer.indent();
+ printer.print(": ");
+ needOutdent = true;
+ } else {
+ printer.print(",");
+ printer.printLn();
+ printer.print(" ");
+ }
+ statement.accept(this, arg);
+ i++;
+ } else {
+ nonAssigns.add(statement);
+ }
+ }
+ if (needOutdent) {
+ printer.unindent();
+ }
+ inConstructorBody = false;
+ printer.printLn();
+ printer.printLn("{");
+ printer.indent();
+ String boilerplate = cppTypes.constructorBoilerplate(className);
+ if (boilerplate != null) {
+ printer.printLn(boilerplate);
+ }
+ for (Statement statement : nonAssigns) {
+ statement.accept(this, arg);
+ printer.printLn();
+ }
+ printer.unindent();
+ printer.printLn("}");
+ printer.printLn();
+ }
+
+ public void visit(MethodDeclaration n, LocalSymbolTable arg) {
+ arg = new LocalSymbolTable(javaClassName, symbolTable);
+ if (isPrintableMethod(n.getModifiers())
+ && !(n.getName().equals("endCoalescing") || n.getName().equals(
+ "startCoalescing"))) {
+ printMethodDeclaration(n, arg);
+ }
+ }
+
+ private boolean isPrintableMethod(int modifiers) {
+ return !(ModifierSet.isAbstract(modifiers) || (ModifierSet.isProtected(modifiers) && !(ModifierSet.isFinal(modifiers) || "Tokenizer".equals(javaClassName))));
+ }
+
+ protected void printMethodDeclaration(MethodDeclaration n, LocalSymbolTable arg) {
+ if (n.getName().startsWith("fatal") || n.getName().startsWith("err")
+ || n.getName().startsWith("warn")
+ || n.getName().startsWith("maybeErr")
+ || n.getName().startsWith("maybeWarn")
+ || "releaseArray".equals(n.getName())
+ || "deleteArray".equals(n.getName())
+ || "delete".equals(n.getName())) {
+ return;
+ }
+
+ currentMethod = n.getName();
+
+ destructor = "destructor".equals(n.getName());
+
+ // if (n.getJavaDoc() != null) {
+ // n.getJavaDoc().accept(this, arg);
+ // }
+ currentAnnotations = n.getAnnotations();
+ boolean isInline = inline();
+ if (isInline && !inHeader()) {
+ return;
+ }
+
+ if (destructor) {
+ printModifiers(ModifierSet.PUBLIC);
+ } else {
+ printModifiers(n.getModifiers());
+ }
+
+ printTypeParameters(n.getTypeParameters(), arg);
+ if (n.getTypeParameters() != null) {
+ printer.print(" ");
+ }
+ if (!destructor) {
+ n.getType().accept(this, arg);
+ printer.print(" ");
+ }
+ printMethodNamespace();
+ if (destructor) {
+ printer.print("~");
+ printer.print(className);
+ } else {
+ printer.print(n.getName());
+ }
+
+ currentAnnotations = null;
+ printer.print("(");
+ if (n.getParameters() != null) {
+ for (Iterator i = n.getParameters().iterator(); i.hasNext();) {
+ Parameter p = i.next();
+ p.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print(")");
+
+ for (int i = 0; i < n.getArrayCount(); i++) {
+ printer.print("[]");
+ }
+
+ if (inHeader() == isInline) {
+ printMethodBody(n.getBody(), arg);
+ } else {
+ printer.printLn(";");
+ }
+ }
+
+ private void printMethodBody(BlockStmt n, LocalSymbolTable arg) {
+ if (n == null) {
+ printer.print(";");
+ } else {
+ printer.printLn();
+ printer.printLn("{");
+ printer.indent();
+ if (destructor) {
+ String boilerplate = cppTypes.destructorBoilderplate(className);
+ if (boilerplate != null) {
+ printer.printLn(boilerplate);
+ }
+ }
+ if (n.getStmts() != null) {
+ for (Statement s : n.getStmts()) {
+ s.accept(this, arg);
+ printer.printLn();
+ }
+ }
+ printer.unindent();
+ printer.print("}");
+ }
+ printer.printLn();
+ printer.printLn();
+ }
+
+ protected void printMethodNamespace() {
+ printer.printLn();
+ printer.print(className);
+ printer.print("::");
+ }
+
+ public void visit(Parameter n, LocalSymbolTable arg) {
+ currentAnnotations = n.getAnnotations();
+
+ arg.putLocalType(n.getId().getName(), convertType(n.getType(), n.getModifiers()));
+
+ n.getType().accept(this, arg);
+ if (n.isVarArgs()) {
+ printer.print("...");
+ }
+ printer.print(" ");
+ n.getId().accept(this, arg);
+ currentAnnotations = null;
+ }
+
+ public void visit(ExplicitConstructorInvocationStmt n, LocalSymbolTable arg) {
+ if (n.isThis()) {
+ printTypeArgs(n.getTypeArgs(), arg);
+ printer.print("this");
+ } else {
+ if (n.getExpr() != null) {
+ n.getExpr().accept(this, arg);
+ printer.print(".");
+ }
+ printTypeArgs(n.getTypeArgs(), arg);
+ printer.print("super");
+ }
+ printer.print("(");
+ if (n.getArgs() != null) {
+ for (Iterator i = n.getArgs().iterator(); i.hasNext();) {
+ Expression e = i.next();
+ e.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print(");");
+ }
+
+ public void visit(VariableDeclarationExpr n, LocalSymbolTable arg) {
+ currentAnnotations = n.getAnnotations();
+
+ arg.putLocalType(n.getVars().get(0).toString(), convertType(n.getType(), n.getModifiers()));
+
+ n.getType().accept(this, arg);
+ printer.print(" ");
+
+ for (Iterator i = n.getVars().iterator(); i.hasNext();) {
+ VariableDeclarator v = i.next();
+ v.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ currentAnnotations = null;
+ }
+
+ public void visit(TypeDeclarationStmt n, LocalSymbolTable arg) {
+ n.getTypeDeclaration().accept(this, arg);
+ }
+
+ public void visit(AssertStmt n, LocalSymbolTable arg) {
+ }
+
+ public void visit(BlockStmt n, LocalSymbolTable arg) {
+ printer.printLn("{");
+ if (n.getStmts() != null) {
+ printer.indent();
+ for (Statement s : n.getStmts()) {
+ s.accept(this, arg);
+ printer.printLn();
+ }
+ printer.unindent();
+ }
+ printer.print("}");
+
+ }
+
+ public void visit(LabeledStmt n, LocalSymbolTable arg) {
+ // Only conditionless for loops are needed and supported
+ // Not implementing general Java continue semantics in order
+ // to keep the generated C++ more readable.
+ Statement stmt = n.getStmt();
+ if (stmt instanceof ForStmt) {
+ ForStmt forLoop = (ForStmt) stmt;
+ if (!(forLoop.getInit() == null && forLoop.getCompare() == null && forLoop.getUpdate() == null)) {
+ forLoopsWithCondition.add(n.getLabel());
+ }
+ } else {
+ throw new IllegalStateException(
+ "Only for loop supported as labeled statement. Line: "
+ + n.getBeginLine());
+ }
+ String label = n.getLabel();
+ if (labels.contains(label)) {
+ printer.print(label);
+ printer.print(": ");
+ }
+ stmt.accept(this, arg);
+ printer.printLn();
+ label += "_end";
+ if (labels.contains(label)) {
+ printer.print(label);
+ printer.print(": ;");
+ }
+ }
+
+ public void visit(EmptyStmt n, LocalSymbolTable arg) {
+ printer.print(";");
+ }
+
+ public void visit(ExpressionStmt n, LocalSymbolTable arg) {
+ Expression e = n.getExpression();
+ if (isDroppedExpression(e)) {
+ return;
+ }
+ e.accept(this, arg);
+ if (!inConstructorBody) {
+ printer.print(";");
+ }
+ }
+
+ private boolean isDroppedExpression(Expression e) {
+ if (e instanceof MethodCallExpr) {
+ MethodCallExpr methodCallExpr = (MethodCallExpr) e;
+ String name = methodCallExpr.getName();
+ if (name.startsWith("fatal") || name.startsWith("err")
+ || name.startsWith("warn") || name.startsWith("maybeErr")
+ || name.startsWith("maybeWarn")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void visit(SwitchStmt n, LocalSymbolTable arg) {
+ printer.print("switch(");
+ n.getSelector().accept(this, arg);
+ printer.printLn(") {");
+ if (n.getEntries() != null) {
+ printer.indent();
+ for (SwitchEntryStmt e : n.getEntries()) {
+ e.accept(this, arg);
+ }
+ printer.unindent();
+ }
+ printer.print("}");
+
+ }
+
+ public void visit(SwitchEntryStmt n, LocalSymbolTable arg) {
+ if (n.getLabel() != null) {
+ printer.print("case ");
+ n.getLabel().accept(this, arg);
+ printer.print(":");
+ } else {
+ printer.print("default:");
+ }
+ if (isNoStatement(n.getStmts())) {
+ printer.printLn();
+ printer.indent();
+ if (n.getLabel() == null) {
+ printer.printLn("; // fall through");
+ }
+ printer.unindent();
+ } else {
+ printer.printLn(" {");
+ printer.indent();
+ for (Statement s : n.getStmts()) {
+ s.accept(this, arg);
+ printer.printLn();
+ }
+ printer.unindent();
+ printer.printLn("}");
+ }
+ }
+
+ private boolean isNoStatement(List stmts) {
+ if (stmts == null) {
+ return true;
+ }
+ for (Statement statement : stmts) {
+ if (!isDroppableStatement(statement)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean isDroppableStatement(Statement statement) {
+ if (statement instanceof AssertStmt) {
+ return true;
+ } else if (statement instanceof ExpressionStmt) {
+ ExpressionStmt es = (ExpressionStmt) statement;
+ if (isDroppedExpression(es.getExpression())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void visit(BreakStmt n, LocalSymbolTable arg) {
+ if (n.getId() != null) {
+ printer.print("goto ");
+ printer.print(n.getId());
+ printer.print("_end");
+ } else {
+ printer.print("break");
+ }
+ printer.print(";");
+ }
+
+ public void visit(ReturnStmt n, LocalSymbolTable arg) {
+ printer.print("return");
+ if (n.getExpr() != null) {
+ printer.print(" ");
+ n.getExpr().accept(this, arg);
+ }
+ printer.print(";");
+ }
+
+ public void visit(EnumDeclaration n, LocalSymbolTable arg) {
+ if (n.getJavaDoc() != null) {
+ n.getJavaDoc().accept(this, arg);
+ }
+ currentAnnotations = n.getAnnotations();
+ // if (annotations != null) {
+ // for (AnnotationExpr a : annotations) {
+ // a.accept(this, arg);
+ // printer.printLn();
+ // }
+ // }
+ printModifiers(n.getModifiers());
+
+ printer.print("enum ");
+ printer.print(n.getName());
+
+ currentAnnotations = null;
+
+ if (n.getImplements() != null) {
+ printer.print(" implements ");
+ for (Iterator i = n.getImplements().iterator(); i.hasNext();) {
+ ClassOrInterfaceType c = i.next();
+ c.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+
+ printer.printLn(" {");
+ printer.indent();
+ if (n.getEntries() != null) {
+ printer.printLn();
+ for (Iterator i = n.getEntries().iterator(); i.hasNext();) {
+ EnumConstantDeclaration e = i.next();
+ e.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ if (n.getMembers() != null) {
+ printer.printLn(";");
+ printMembers(n.getMembers(), arg);
+ } else {
+ if (n.getEntries() != null) {
+ printer.printLn();
+ }
+ }
+ printer.unindent();
+ printer.print("}");
+ }
+
+ public void visit(EnumConstantDeclaration n, LocalSymbolTable arg) {
+ if (n.getJavaDoc() != null) {
+ n.getJavaDoc().accept(this, arg);
+ }
+ currentAnnotations = n.getAnnotations();
+ // if (annotations != null) {
+ // for (AnnotationExpr a : annotations) {
+ // a.accept(this, arg);
+ // printer.printLn();
+ // }
+ // }
+ printer.print(n.getName());
+
+ currentAnnotations = null;
+
+ if (n.getArgs() != null) {
+ printer.print("(");
+ for (Iterator i = n.getArgs().iterator(); i.hasNext();) {
+ Expression e = i.next();
+ e.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ printer.print(")");
+ }
+
+ if (n.getClassBody() != null) {
+ printer.printLn(" {");
+ printer.indent();
+ printMembers(n.getClassBody(), arg);
+ printer.unindent();
+ printer.printLn("}");
+ }
+ }
+
+ public void visit(EmptyMemberDeclaration n, LocalSymbolTable arg) {
+ if (n.getJavaDoc() != null) {
+ n.getJavaDoc().accept(this, arg);
+ }
+ printer.print(";");
+ }
+
+ public void visit(InitializerDeclaration n, LocalSymbolTable arg) {
+ if (n.getJavaDoc() != null) {
+ n.getJavaDoc().accept(this, arg);
+ }
+ if (n.isStatic()) {
+ printer.print("static ");
+ }
+ n.getBlock().accept(this, arg);
+ }
+
+ public void visit(IfStmt n, LocalSymbolTable arg) {
+ if (!isErrorHandlerIf(n.getCondition())) {
+ printer.print("if (");
+ n.getCondition().accept(this, arg);
+ printer.print(") ");
+ n.getThenStmt().accept(this, arg);
+ if (n.getElseStmt() != null) {
+ printer.print(" else ");
+ n.getElseStmt().accept(this, arg);
+ }
+ }
+ }
+
+ private boolean isErrorHandlerIf(Expression condition) {
+ if (condition instanceof BinaryExpr) {
+ BinaryExpr be = (BinaryExpr) condition;
+ return be.getLeft().toString().equals("errorHandler");
+ }
+ return false;
+ }
+
+ public void visit(WhileStmt n, LocalSymbolTable arg) {
+ printer.print("while (");
+ n.getCondition().accept(this, arg);
+ printer.print(") ");
+ n.getBody().accept(this, arg);
+ }
+
+ public void visit(ContinueStmt n, LocalSymbolTable arg) {
+ // Not supporting the general Java continue semantics.
+ // Instead, making the generated code more readable for the
+ // case at hand.
+ if (n.getId() != null) {
+ printer.print("goto ");
+ printer.print(n.getId());
+ if (forLoopsWithCondition.contains(n.getId())) {
+ throw new IllegalStateException(
+ "Continue attempted with a loop that has a condition. "
+ + className + " " + n.getId());
+ }
+ } else {
+ printer.print("continue");
+ }
+ printer.print(";");
+ }
+
+ public void visit(DoStmt n, LocalSymbolTable arg) {
+ printer.print("do ");
+ n.getBody().accept(this, arg);
+ printer.print(" while (");
+ n.getCondition().accept(this, arg);
+ printer.print(");");
+ }
+
+ public void visit(ForeachStmt n, LocalSymbolTable arg) {
+ printer.print("for (");
+ n.getVariable().accept(this, arg);
+ printer.print(" : ");
+ n.getIterable().accept(this, arg);
+ printer.print(") ");
+ n.getBody().accept(this, arg);
+ }
+
+ public void visit(ForStmt n, LocalSymbolTable arg) {
+ printer.print("for (");
+ if (n.getInit() != null) {
+ for (Iterator i = n.getInit().iterator(); i.hasNext();) {
+ Expression e = i.next();
+ e.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print("; ");
+ if (n.getCompare() != null) {
+ n.getCompare().accept(this, arg);
+ }
+ printer.print("; ");
+ if (n.getUpdate() != null) {
+ for (Iterator i = n.getUpdate().iterator(); i.hasNext();) {
+ Expression e = i.next();
+ e.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print(") ");
+ n.getBody().accept(this, arg);
+ }
+
+ public void visit(ThrowStmt n, LocalSymbolTable arg) {
+ printer.print("throw ");
+ n.getExpr().accept(this, arg);
+ printer.print(";");
+ }
+
+ public void visit(SynchronizedStmt n, LocalSymbolTable arg) {
+ printer.print("synchronized (");
+ n.getExpr().accept(this, arg);
+ printer.print(") ");
+ n.getBlock().accept(this, arg);
+ }
+
+ public void visit(TryStmt n, LocalSymbolTable arg) {
+ printer.print("try ");
+ n.getTryBlock().accept(this, arg);
+ if (n.getCatchs() != null) {
+ for (CatchClause c : n.getCatchs()) {
+ c.accept(this, arg);
+ }
+ }
+ if (n.getFinallyBlock() != null) {
+ printer.print(" finally ");
+ n.getFinallyBlock().accept(this, arg);
+ }
+ }
+
+ public void visit(CatchClause n, LocalSymbolTable arg) {
+ printer.print(" catch (");
+ n.getExcept().accept(this, arg);
+ printer.print(") ");
+ n.getCatchBlock().accept(this, arg);
+
+ }
+
+ public void visit(AnnotationDeclaration n, LocalSymbolTable arg) {
+ if (n.getJavaDoc() != null) {
+ n.getJavaDoc().accept(this, arg);
+ }
+ currentAnnotations = n.getAnnotations();
+ // if (annotations != null) {
+ // for (AnnotationExpr a : annotations) {
+ // a.accept(this, arg);
+ // printer.printLn();
+ // }
+ // }
+ printModifiers(n.getModifiers());
+
+ printer.print("@interface ");
+ printer.print(n.getName());
+ currentAnnotations = null;
+ printer.printLn(" {");
+ printer.indent();
+ if (n.getMembers() != null) {
+ printMembers(n.getMembers(), arg);
+ }
+ printer.unindent();
+ printer.print("}");
+ }
+
+ public void visit(AnnotationMemberDeclaration n, LocalSymbolTable arg) {
+ if (n.getJavaDoc() != null) {
+ n.getJavaDoc().accept(this, arg);
+ }
+ currentAnnotations = n.getAnnotations();
+ // if (annotations != null) {
+ // for (AnnotationExpr a : annotations) {
+ // a.accept(this, arg);
+ // printer.printLn();
+ // }
+ // }
+ printModifiers(n.getModifiers());
+
+ n.getType().accept(this, arg);
+ printer.print(" ");
+ printer.print(n.getName());
+ currentAnnotations = null;
+ printer.print("()");
+ if (n.getDefaultValue() != null) {
+ printer.print(" default ");
+ n.getDefaultValue().accept(this, arg);
+ }
+ printer.print(";");
+ }
+
+ public void visit(MarkerAnnotationExpr n, LocalSymbolTable arg) {
+ printer.print("@");
+ n.getName().accept(this, arg);
+ }
+
+ public void visit(SingleMemberAnnotationExpr n, LocalSymbolTable arg) {
+ printer.print("@");
+ n.getName().accept(this, arg);
+ printer.print("(");
+ n.getMemberValue().accept(this, arg);
+ printer.print(")");
+ }
+
+ public void visit(NormalAnnotationExpr n, LocalSymbolTable arg) {
+ printer.print("@");
+ n.getName().accept(this, arg);
+ printer.print("(");
+ if (n.getPairs() != null) {
+ for (Iterator i = n.getPairs().iterator(); i.hasNext();) {
+ MemberValuePair m = i.next();
+ m.accept(this, arg);
+ if (i.hasNext()) {
+ printer.print(", ");
+ }
+ }
+ }
+ printer.print(")");
+ }
+
+ public void visit(MemberValuePair n, LocalSymbolTable arg) {
+ printer.print(n.getName());
+ printer.print(" = ");
+ n.getValue().accept(this, arg);
+ }
+
+ public void visit(LineComment n, LocalSymbolTable arg) {
+ printer.print("//");
+ printer.printLn(n.getContent());
+ }
+
+ public void visit(BlockComment n, LocalSymbolTable arg) {
+ printer.print("/*");
+ printer.print(n.getContent());
+ printer.printLn("*/");
+ }
+
+ public void setLabels(Set labels) {
+ this.labels = labels;
+ }
+
+}
diff --git a/embedding/qa/mozembed/src/mozEmbed.h b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/GkAtomParser.java
similarity index 61%
rename from embedding/qa/mozembed/src/mozEmbed.h
rename to parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/GkAtomParser.java
index bff8855500c7..3d642c0e0fb6 100644
--- a/embedding/qa/mozembed/src/mozEmbed.h
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/GkAtomParser.java
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -12,14 +11,15 @@
* for the specific language governing rights and limitations under the
* License.
*
- * The Original Code is mozilla.org Code.
+ * The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
+ * Henri Sivonen
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -35,12 +35,36 @@
*
* ***** END LICENSE BLOCK ***** */
-#include "prtypes.h"
+package nu.validator.htmlparser.cpptranslate;
-class nsIWebBrowserChrome;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
-namespace AppCallbacks {
- void EnableChromeWindow(nsIWebBrowserChrome *aWindow, PRBool aEnabled);
+public class GkAtomParser {
- PRUint32 RunEventLoop(PRBool &aRunCondition);
+ private static final Pattern ATOM = Pattern.compile("^GK_ATOM\\(([^,]+),\\s*\"([^\"]*)\"\\).*$");
+
+ private final BufferedReader reader;
+
+ public GkAtomParser(Reader reader) {
+ this.reader = new BufferedReader(reader);
+ }
+
+ public Map parse() throws IOException {
+ Map map = new HashMap();
+ String line;
+ while((line = reader.readLine()) != null) {
+ Matcher m = ATOM.matcher(line);
+ if (m.matches()) {
+ map.put(m.group(2), m.group(1));
+ }
+ }
+ return map;
+ }
+
}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/HVisitor.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/HVisitor.java
new file mode 100644
index 000000000000..4afc36b4580c
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/HVisitor.java
@@ -0,0 +1,352 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import japa.parser.ast.body.FieldDeclaration;
+import japa.parser.ast.body.MethodDeclaration;
+import japa.parser.ast.body.ModifierSet;
+import japa.parser.ast.body.VariableDeclarator;
+import japa.parser.ast.expr.IntegerLiteralExpr;
+import japa.parser.ast.expr.MethodCallExpr;
+import japa.parser.ast.stmt.BlockStmt;
+import japa.parser.ast.type.PrimitiveType;
+import japa.parser.ast.type.ReferenceType;
+import japa.parser.ast.type.Type;
+
+public class HVisitor extends CppVisitor {
+
+ private enum Visibility {
+ NONE, PRIVATE, PUBLIC, PROTECTED,
+ }
+
+ private Visibility previousVisibility = Visibility.NONE;
+
+ private List defines = new LinkedList();
+
+ private SourcePrinter arrayInitPrinter = new SourcePrinter();
+ private SourcePrinter mainPrinterHolder;
+
+ /**
+ * @see nu.validator.htmlparser.cpptranslate.CppVisitor#printMethodNamespace()
+ */
+ @Override protected void printMethodNamespace() {
+ }
+
+ public HVisitor(CppTypes cppTypes, SymbolTable symbolTable) {
+ super(cppTypes, symbolTable);
+ }
+
+ /**
+ * @see nu.validator.htmlparser.cpptranslate.CppVisitor#startClassDeclaration()
+ */
+ @Override protected void startClassDeclaration() {
+ printer.print("#ifndef ");
+ printer.print(className);
+ printer.printLn("_h__");
+ printer.print("#define ");
+ printer.print(className);
+ printer.printLn("_h__");
+
+ printer.printLn();
+
+ String[] incs = cppTypes.boilerplateIncludes(javaClassName);
+ for (int i = 0; i < incs.length; i++) {
+ String inc = incs[i];
+ if (className.equals(inc)) {
+ continue;
+ }
+ printer.print("#include \"");
+ printer.print(inc);
+ printer.printLn(".h\"");
+ }
+
+ printer.printLn();
+
+ String[] forwDecls = cppTypes.boilerplateForwardDeclarations();
+ for (int i = 0; i < forwDecls.length; i++) {
+ String decl = forwDecls[i];
+ printer.print("class ");
+ printer.print(decl);
+ printer.printLn(";");
+ }
+
+ printer.printLn();
+
+ for (int i = 0; i < Main.H_LIST.length; i++) {
+ String klazz = Main.H_LIST[i];
+ if (!(klazz.equals(javaClassName) || klazz.equals("StackNode"))) {
+ printer.print("class ");
+ printer.print(cppTypes.classPrefix());
+ printer.print(klazz);
+ printer.printLn(";");
+ }
+ }
+
+ printer.printLn();
+
+ String[] otherDecls = cppTypes.boilerplateDeclarations(javaClassName);
+ for (int i = 0; i < otherDecls.length; i++) {
+ String decl = otherDecls[i];
+ printer.printLn(decl);
+ }
+
+ printer.printLn();
+
+ printer.print("class ");
+ printer.printLn(className);
+ printer.printLn("{");
+ printer.indent();
+ printer.indent();
+ }
+
+ /**
+ * @see nu.validator.htmlparser.cpptranslate.CppVisitor#endClassDeclaration()
+ */
+ @Override protected void endClassDeclaration() {
+ printModifiers(ModifierSet.PUBLIC | ModifierSet.STATIC);
+ printer.printLn("void initializeStatics();");
+ printModifiers(ModifierSet.PUBLIC | ModifierSet.STATIC);
+ printer.printLn("void releaseStatics();");
+
+ printer.unindent();
+ printer.unindent();
+
+ if (cppTypes.hasSupplement(javaClassName)) {
+ printer.printLn();
+ printer.print("#include \"");
+ printer.print(className);
+ printer.printLn("HSupplement.h\"");
+ }
+
+ printer.printLn("};");
+ printer.printLn();
+
+ // This stuff should probably go into the .cpp anyway. sigh.
+ printer.print("#ifdef ");
+ printer.print(className);
+ printer.printLn("_cpp__");
+ printer.print(arrayInitPrinter.getSource());
+ printer.printLn("#endif");
+ printer.printLn();
+
+ for (String define : defines) {
+ printer.printLn(define);
+ }
+
+ printer.printLn();
+ printer.printLn();
+ printer.printLn("#endif");
+ }
+
+ /**
+ * @see nu.validator.htmlparser.cpptranslate.CppVisitor#printModifiers(int)
+ */
+ @Override protected void printModifiers(int modifiers) {
+ if (ModifierSet.isPrivate(modifiers)) {
+ if (previousVisibility != Visibility.PRIVATE) {
+ printer.unindent();
+ printer.printLn("private:");
+ printer.indent();
+ previousVisibility = Visibility.PRIVATE;
+ }
+ } else if (ModifierSet.isProtected(modifiers)) {
+ if (previousVisibility != Visibility.PROTECTED) {
+ printer.unindent();
+ printer.printLn("protected:");
+ printer.indent();
+ previousVisibility = Visibility.PROTECTED;
+ }
+ } else {
+ if (previousVisibility != Visibility.PUBLIC) {
+ printer.unindent();
+ printer.printLn("public:");
+ printer.indent();
+ previousVisibility = Visibility.PUBLIC;
+ }
+ }
+ if (inline()) {
+ printer.print("inline ");
+ }
+ if (virtual()) {
+ printer.print("virtual ");
+ }
+ if (ModifierSet.isStatic(modifiers)) {
+ printer.print("static ");
+ }
+ }
+
+ /**
+ * @see nu.validator.htmlparser.cpptranslate.CppVisitor#fieldDeclaration(japa.parser.ast.body.FieldDeclaration, java.lang.LocalSymbolTable)
+ */
+ @Override protected void fieldDeclaration(FieldDeclaration n, LocalSymbolTable arg) {
+ int modifiers = n.getModifiers();
+ List variables = n.getVariables();
+ VariableDeclarator declarator = variables.get(0);
+ if (ModifierSet.isStatic(modifiers) && ModifierSet.isFinal(modifiers)
+ && n.getType() instanceof PrimitiveType) {
+ PrimitiveType type = (PrimitiveType) n.getType();
+ if (type.getType() != PrimitiveType.Primitive.Int) {
+ throw new IllegalStateException(
+ "Only int constant #defines supported.");
+ }
+ if (variables.size() != 1) {
+ throw new IllegalStateException(
+ "More than one variable declared by one declarator.");
+ }
+ String name = javaClassName + "." + declarator.getId().getName();
+ String value = declarator.getInit().toString();
+ if ("Integer.MAX_VALUE".equals(value)) {
+ value = cppTypes.maxInteger();
+ }
+ String longName = definePrefix + declarator.getId().getName();
+ if (symbolTable.cppDefinesByJavaNames.containsKey(name)) {
+ throw new IllegalStateException(
+ "Duplicate #define constant local name: " + name);
+ }
+ symbolTable.cppDefinesByJavaNames.put(name, longName);
+ defines.add("#define " + longName + " " + value);
+ } else {
+ if (n.getType() instanceof ReferenceType) {
+ ReferenceType rt = (ReferenceType) n.getType();
+ currentArrayCount = rt.getArrayCount();
+ if (currentArrayCount > 0
+ && (rt.getType() instanceof PrimitiveType) && declarator.getInit() != null) {
+ if (!ModifierSet.isStatic(modifiers)) {
+ throw new IllegalStateException(
+ "Non-static array case not supported here." + declarator);
+ }
+ if (noLength()) {
+ inPrimitiveNoLengthFieldDeclarator = true;
+
+ mainPrinterHolder = printer;
+ printer = arrayInitPrinter;
+ n.getType().accept(this, arg);
+ printer.print(" ");
+ printer.print(className);
+ printer.print("::");
+ declarator.getId().accept(this, arg);
+
+ printer.print(" = ");
+
+ declarator.getInit().accept(this, arg);
+
+ printer.printLn(";");
+ printer = mainPrinterHolder;
+ } else if (!isNonToCharArrayMethodCall(declarator.getInit())) {
+ mainPrinterHolder = printer;
+ printer = arrayInitPrinter;
+
+ printer.print(cppTypes.arrayTemplate());
+ printer.print("<");
+ suppressPointer = true;
+ rt.getType().accept(this, arg);
+ suppressPointer = false;
+ printer.print(",");
+ printer.print(cppTypes.intType());
+ printer.print("> ");
+ printer.print(className);
+ printer.print("::");
+ declarator.getId().accept(this, arg);
+ printer.printLn(" = 0;");
+
+ printer = mainPrinterHolder;
+ }
+ } else if (ModifierSet.isStatic(modifiers)) {
+ mainPrinterHolder = printer;
+ printer = arrayInitPrinter;
+
+ n.getType().accept(this, arg);
+ printer.print(" ");
+ printer.print(className);
+ printer.print("::");
+ if ("AttributeName".equals(n.getType().toString())) {
+ printer.print("ATTR_");
+ } else if ("ElementName".equals(n.getType().toString())) {
+ printer.print("ELT_");
+ }
+ declarator.getId().accept(this, arg);
+ printer.print(" = ");
+ printer.print(cppTypes.nullLiteral());
+ printer.printLn(";");
+
+ printer = mainPrinterHolder;
+ }
+ }
+ printModifiers(modifiers);
+ n.getType().accept(this, arg);
+ printer.print(" ");
+ if (ModifierSet.isStatic(modifiers)) {
+ if ("AttributeName".equals(n.getType().toString())) {
+ printer.print("ATTR_");
+ } else if ("ElementName".equals(n.getType().toString())) {
+ printer.print("ELT_");
+ }
+ }
+ declarator.getId().accept(this, arg);
+ printer.printLn(";");
+ currentArrayCount = 0;
+ inPrimitiveNoLengthFieldDeclarator = false;
+ }
+ }
+
+ /**
+ * @see nu.validator.htmlparser.cpptranslate.CppVisitor#printConstructorBody(japa.parser.ast.stmt.BlockStmt, java.lang.LocalSymbolTable)
+ */
+ @Override protected void printConstructorBody(BlockStmt block, LocalSymbolTable arg) {
+ printer.printLn(";");
+ }
+
+ /**
+ * @see nu.validator.htmlparser.cpptranslate.CppVisitor#visit(japa.parser.ast.body.MethodDeclaration, java.lang.LocalSymbolTable)
+ */
+ @Override public void visit(MethodDeclaration n, LocalSymbolTable arg) {
+ arg = new LocalSymbolTable(javaClassName, symbolTable);
+ printMethodDeclaration(n, arg);
+ }
+
+ /**
+ * @see nu.validator.htmlparser.cpptranslate.CppVisitor#inHeader()
+ */
+ @Override protected boolean inHeader() {
+ return true;
+ }
+
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LabelVisitor.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LabelVisitor.java
new file mode 100644
index 000000000000..f27d465a3c1d
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LabelVisitor.java
@@ -0,0 +1,84 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+import japa.parser.ast.stmt.BreakStmt;
+import japa.parser.ast.stmt.ContinueStmt;
+import japa.parser.ast.visitor.VoidVisitorAdapter;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class LabelVisitor extends VoidVisitorAdapter {
+
+ private final Set labels = new HashSet();
+
+ public LabelVisitor() {
+ }
+
+ /**
+ * @see japa.parser.ast.visitor.VoidVisitorAdapter#visit(japa.parser.ast.stmt.BreakStmt, java.lang.Object)
+ */
+ @Override
+ public void visit(BreakStmt n, Object arg) {
+ String label = n.getId();
+ if (label != null) {
+ labels.add(label + "_end");
+ }
+ }
+
+ /**
+ * @see japa.parser.ast.visitor.VoidVisitorAdapter#visit(japa.parser.ast.stmt.ContinueStmt, java.lang.Object)
+ */
+ @Override
+ public void visit(ContinueStmt n, Object arg) {
+ String label = n.getId();
+ if (label != null) {
+ labels.add(label);
+ }
+ }
+
+ /**
+ * Returns the labels.
+ *
+ * @return the labels
+ */
+ public Set getLabels() {
+ return labels;
+ }
+}
diff --git a/embedding/qa/mozembed/src/StdAfx.h b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LicenseExtractor.java
similarity index 57%
rename from embedding/qa/mozembed/src/StdAfx.h
rename to parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LicenseExtractor.java
index 0613097c8490..e4030f438831 100644
--- a/embedding/qa/mozembed/src/StdAfx.h
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LicenseExtractor.java
@@ -11,14 +11,15 @@
* for the specific language governing rights and limitations under the
* License.
*
- * The Original Code is mozilla.org Code.
+ * The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
+ * Henri Sivonen
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -34,35 +35,41 @@
*
* ***** END LICENSE BLOCK ***** */
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
+package nu.validator.htmlparser.cpptranslate;
-#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
-#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
+public class LicenseExtractor {
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-
-
-// Windows Header Files:
-#include
-
-// C RunTime Header Files
-#include
-#include
-#include
-#include
-
-// Local Header Files
-
-// TODO: reference additional headers your program requires here
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+ private final Reader reader;
+
+ public LicenseExtractor(File file) throws IOException {
+ this.reader = new InputStreamReader(new FileInputStream(file), "utf-8");
+ }
+
+ public String extract() throws IOException {
+ boolean prevWasAsterisk = false;
+ StringBuilder sb = new StringBuilder();
+ int c;
+ while ((c = reader.read()) != -1) {
+ sb.append((char)c);
+ switch (c) {
+ case '*':
+ prevWasAsterisk = true;
+ continue;
+ case '/':
+ if (prevWasAsterisk) {
+ return sb.toString();
+ }
+ default:
+ prevWasAsterisk = false;
+ continue;
+ }
+ }
+ return "";
+ }
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LocalSymbolTable.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LocalSymbolTable.java
new file mode 100644
index 000000000000..a9375e88a3a1
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/LocalSymbolTable.java
@@ -0,0 +1,89 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class LocalSymbolTable {
+
+ private final Map locals = new HashMap();
+
+ private final String javaClassName;
+
+ private final SymbolTable delegate;
+
+ /**
+ * @param javaClassName
+ * @param delegate
+ */
+ public LocalSymbolTable(String javaClassName, SymbolTable delegate) {
+ this.javaClassName = javaClassName;
+ this.delegate = delegate;
+ }
+
+ public void putLocalType(String name, Type type) {
+ locals.put(name, type);
+ }
+
+ /**
+ * @param klazz
+ * @param variable
+ * @return
+ * @see nu.validator.htmlparser.cpptranslate.SymbolTable#getFieldType(java.lang.String, java.lang.String)
+ */
+ public Type getVariableType(String klazz, String variable) {
+ if (klazz == null) {
+ Type type = locals.get(variable);
+ if (type != null) {
+ return type;
+ }
+ }
+ return delegate.getFieldType(((klazz == null || "this".equals(klazz)) ? javaClassName : klazz), variable);
+ }
+
+ /**
+ * @param klazz may be null
or "this"
+ * @param method
+ * @return
+ * @see nu.validator.htmlparser.cpptranslate.SymbolTable#getMethodReturnType(java.lang.String, java.lang.String)
+ */
+ public Type getMethodReturnType(String klazz, String method) {
+ return delegate.getMethodReturnType(((klazz == null || "this".equals(klazz)) ? javaClassName : klazz), method);
+ }
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/Main.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/Main.java
new file mode 100644
index 000000000000..14d43fd3525e
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/Main.java
@@ -0,0 +1,137 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+import japa.parser.JavaParser;
+import japa.parser.ParseException;
+import japa.parser.ast.CompilationUnit;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+
+public class Main {
+
+ static final String[] H_LIST = {
+ "Tokenizer",
+ "TreeBuilder",
+ "MetaScanner",
+ "AttributeName",
+ "ElementName",
+ "HtmlAttributes",
+ "StackNode",
+ "UTF16Buffer",
+ "StateSnapshot",
+ "Portability",
+ };
+
+ private static final String[] CPP_LIST = {
+ "Tokenizer",
+ "TreeBuilder",
+ "MetaScanner",
+ "AttributeName",
+ "ElementName",
+ "HtmlAttributes",
+ "StackNode",
+ "UTF16Buffer",
+ "StateSnapshot",
+ };
+
+ /**
+ * @param args
+ * @throws ParseException
+ * @throws IOException
+ */
+ public static void main(String[] args) throws ParseException, IOException {
+ CppTypes cppTypes = new CppTypes(new File(args[2]));
+ SymbolTable symbolTable = new SymbolTable();
+
+ File javaDirectory = new File(args[0]);
+ File targetDirectory = new File(args[1]);
+ File cppDirectory = targetDirectory;
+ File javaCopyDirectory = new File(targetDirectory, "javasrc");
+
+ for (int i = 0; i < H_LIST.length; i++) {
+ parseFile(cppTypes, javaDirectory, cppDirectory, H_LIST[i], ".h", new HVisitor(cppTypes, symbolTable));
+// copyFile(new File(javaDirectory, H_LIST[i] + ".java"), new File(javaCopyDirectory, H_LIST[i] + ".java"));
+ }
+ for (int i = 0; i < CPP_LIST.length; i++) {
+ parseFile(cppTypes, javaDirectory, cppDirectory, CPP_LIST[i], ".cpp", new CppVisitor(cppTypes, symbolTable));
+ }
+ cppTypes.finished();
+ }
+
+ private static void copyFile(File input, File output) throws IOException {
+ if (input.getCanonicalFile().equals(output.getCanonicalFile())) {
+ return; // files are the same!
+ }
+ // This is horribly inefficient, but perf is not really much of a concern here.
+ FileInputStream in = new FileInputStream(input);
+ FileOutputStream out = new FileOutputStream(output);
+ int b;
+ while ((b = in.read()) != -1) {
+ out.write(b);
+ }
+ out.flush();
+ out.close();
+ in.close();
+ }
+
+ private static void parseFile(CppTypes cppTypes, File javaDirectory, File cppDirectory, String className, String fne, CppVisitor visitor) throws ParseException,
+ FileNotFoundException, UnsupportedEncodingException, IOException {
+ File file = new File(javaDirectory, className + ".java");
+ String license = new LicenseExtractor(file).extract();
+ CompilationUnit cu = JavaParser.parse(new NoCppInputStream(new FileInputStream(file)), "utf-8");
+ LabelVisitor labelVisitor = new LabelVisitor();
+ cu.accept(labelVisitor, null);
+ visitor.setLabels(labelVisitor.getLabels());
+ cu.accept(visitor, null);
+ FileOutputStream out = new FileOutputStream(new File(cppDirectory, cppTypes.classPrefix() + className + fne));
+ OutputStreamWriter w = new OutputStreamWriter(out, "utf-8");
+ w.write(license);
+ w.write("\n\n/*\n * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.\n * Please edit " + className + ".java instead and regenerate.\n */\n\n");
+ w.write(visitor.getSource());
+ w.close();
+ }
+
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/NoCppInputStream.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/NoCppInputStream.java
new file mode 100644
index 000000000000..86f9ae7ff788
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/NoCppInputStream.java
@@ -0,0 +1,86 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class NoCppInputStream extends InputStream {
+
+ private final static char[] START = "[NOCPP[".toCharArray();
+
+ private final static char[] END = "]NOCPP]".toCharArray();
+
+ private int state;
+
+ private final InputStream delegate;
+
+
+
+ /**
+ * @param delegate
+ */
+ public NoCppInputStream(InputStream delegate) {
+ this.delegate = delegate;
+ this.state = 0;
+ }
+
+ @Override public int read() throws IOException {
+ int c;
+ if (state == START.length) {
+ int endState = 0;
+ while (endState != END.length) {
+ c = delegate.read();
+ if (END[endState] == c) {
+ endState++;
+ } else {
+ endState = 0;
+ }
+ }
+ state = 0;
+ }
+ c = delegate.read();
+ if (START[state] == c) {
+ state++;
+ } else {
+ state = 0;
+ }
+ return c;
+ }
+
+}
diff --git a/embedding/qa/mozembed/src/nsQAWindowCreator.cpp b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/StringLiteralParser.java
similarity index 59%
rename from embedding/qa/mozembed/src/nsQAWindowCreator.cpp
rename to parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/StringLiteralParser.java
index 87aed2073633..305f516a7c9d 100644
--- a/embedding/qa/mozembed/src/nsQAWindowCreator.cpp
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/StringLiteralParser.java
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -12,14 +11,15 @@
* for the specific language governing rights and limitations under the
* License.
*
- * The Original Code is mozilla.org Code.
+ * The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
+ * Henri Sivonen
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -35,33 +35,36 @@
*
* ***** END LICENSE BLOCK ***** */
-#include "nsCOMPtr.h"
-#include "nsServiceManagerUtils.h"
-#include "nsIWebBrowserChrome.h"
-#include "nsQAWindowCreator.h"
-#include "nsIQABrowserUIGlue.h"
-#include "nsQABrowserCID.h"
+package nu.validator.htmlparser.cpptranslate;
-WindowCreator::WindowCreator()
-{
-}
-
-WindowCreator::~WindowCreator()
-{
-}
-
-NS_IMPL_ISUPPORTS1(WindowCreator, nsIWindowCreator)
-
-NS_IMETHODIMP
-WindowCreator::CreateChromeWindow(nsIWebBrowserChrome *parent,
- PRUint32 chromeFlags,
- nsIWebBrowserChrome **_retval)
-{
- NS_ENSURE_ARG_POINTER(_retval);
- nsresult rv;
- nsCOMPtr glue(do_CreateInstance(NS_QABROWSERUIGLUE_CONTRACTID, &rv));
- if (glue)
- glue->CreateNewBrowserWindow(PRInt32(chromeFlags), parent, _retval);
- //AppCallbacks::CreateBrowserWindow(PRInt32(chromeFlags), parent, _retval);
- return *_retval ? NS_OK : NS_ERROR_FAILURE;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class StringLiteralParser {
+
+ private static final Pattern STRING_DECL = Pattern.compile("^.*\\(([^ ]+) = new nsString\\(\\)\\)->Assign\\(NS_LITERAL_STRING\\(\"([^\"]*)\"\\)\\);.*$");
+
+ private final BufferedReader reader;
+
+ public StringLiteralParser(Reader reader) {
+ this.reader = new BufferedReader(reader);
+ }
+
+ public Map parse() throws IOException {
+ Map map = new HashMap();
+ String line;
+ while((line = reader.readLine()) != null) {
+ Matcher m = STRING_DECL.matcher(line);
+ if (m.matches()) {
+ map.put(m.group(2), m.group(1));
+ }
+ }
+ return map;
+ }
+
}
diff --git a/embedding/qa/testembed/components/PromptService.h b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/StringPair.java
similarity index 64%
rename from embedding/qa/testembed/components/PromptService.h
rename to parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/StringPair.java
index 231c0716afe1..e24247f7e2f7 100644
--- a/embedding/qa/testembed/components/PromptService.h
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/StringPair.java
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -12,14 +11,15 @@
* for the specific language governing rights and limitations under the
* License.
*
- * The Original Code is mozilla.org Code.
+ * The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
+ * Henri Sivonen
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -35,26 +35,39 @@
*
* ***** END LICENSE BLOCK ***** */
-#ifndef __PromptService_h
-#define __PromptService_h
+package nu.validator.htmlparser.cpptranslate;
-#include "nsError.h"
+public class StringPair {
-// this component is for an MFC app; it's Windows. make sure this is defined.
-#ifndef XP_WIN
-#define XP_WIN
-#endif
+ /**
+ * @param first
+ * @param second
+ */
+ public StringPair(String first, String second) {
+ this.first = first;
+ this.second = second;
+ }
-class nsIFactory;
+ private final String first;
-// factory creator, in hard and soft link formats
-extern "C" NS_EXPORT nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory);
-typedef nsresult (__cdecl *MakeFactoryType)(nsIFactory **);
-#define kPromptServiceFactoryFuncName "NS_NewPromptServiceFactory"
+ private final String second;
-// initialization function, in hard and soft link formats
-extern "C" NS_EXPORT void InitPromptService(HINSTANCE instance);
-typedef nsresult (__cdecl *InitPromptServiceType)(HINSTANCE instance);
-#define kPromptServiceInitFuncName "InitPromptService"
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override public boolean equals(Object o) {
+ if (o instanceof StringPair) {
+ StringPair other = (StringPair) o;
+ return first.equals(other.first) && second.equals(other.second);
+ }
+ return false;
+ }
-#endif
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override public int hashCode() {
+ return first.hashCode() ^ second.hashCode();
+ }
+
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/SymbolTable.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/SymbolTable.java
new file mode 100644
index 000000000000..970a2b64b2da
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/SymbolTable.java
@@ -0,0 +1,80 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class SymbolTable {
+
+ public final Map cppDefinesByJavaNames = new HashMap();
+
+ private final Map fields = new HashMap();
+
+ private final Map methodReturns = new HashMap();
+
+ /**
+ * This is a sad hack to work around the fact the there's no real symbol
+ * table yet.
+ *
+ * @param name
+ * @return
+ */
+ public boolean isNotAnAttributeOrElementName(String name) {
+ return !("ATTRIBUTE_HASHES".equals(name)
+ || "ATTRIBUTE_NAMES".equals(name)
+ || "ELEMENT_HASHES".equals(name)
+ || "ELEMENT_NAMES".equals(name) || "ALL_NO_NS".equals(name));
+ }
+
+ public void putFieldType(String klazz, String field, Type type) {
+ fields.put(new StringPair(klazz, field), type);
+ }
+
+ public void putMethodReturnType(String klazz, String method, Type type) {
+ methodReturns.put(new StringPair(klazz, method), type);
+ }
+
+ public Type getFieldType(String klazz, String field) {
+ return fields.get(new StringPair(klazz, field));
+ }
+
+ public Type getMethodReturnType(String klazz, String method) {
+ return methodReturns.get(new StringPair(klazz, method));
+ }
+}
diff --git a/embedding/qa/testembed/BrowserToolTip.h b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/SymbolTableVisitor.java
similarity index 52%
rename from embedding/qa/testembed/BrowserToolTip.h
rename to parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/SymbolTableVisitor.java
index 5059974d3201..00f7c57415b7 100644
--- a/embedding/qa/testembed/BrowserToolTip.h
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/SymbolTableVisitor.java
@@ -11,15 +11,15 @@
* for the specific language governing rights and limitations under the
* License.
*
- * The Original Code is mozilla.org Code.
+ * The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Adam Lock
+ * Henri Sivonen
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -35,59 +35,37 @@
*
* ***** END LICENSE BLOCK ***** */
-#if !defined(AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_)
-#define AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_
+package nu.validator.htmlparser.cpptranslate;
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-// BrowserToolTip.h : header file
-//
+import japa.parser.ast.body.ClassOrInterfaceDeclaration;
+import japa.parser.ast.body.FieldDeclaration;
+import japa.parser.ast.body.MethodDeclaration;
-/////////////////////////////////////////////////////////////////////////////
-// CBrowserToolTip window
+public class SymbolTableVisitor extends AnnotationHelperVisitor {
-class CBrowserToolTip : public CWnd
-{
-// Construction
-public:
- CBrowserToolTip();
+ private String javaClassName;
+
+ /**
+ * @see japa.parser.ast.visitor.VoidVisitorAdapter#visit(japa.parser.ast.body.FieldDeclaration, java.lang.Object)
+ */
+ @Override public void visit(FieldDeclaration n, SymbolTable arg) {
+ currentAnnotations = n.getAnnotations();
+ arg.putFieldType(javaClassName, n.getVariables().get(0).getId().getName(), convertType(n.getType(), n.getModifiers()));
+ }
-// Attributes
-public:
+ /**
+ * @see japa.parser.ast.visitor.VoidVisitorAdapter#visit(japa.parser.ast.body.MethodDeclaration, java.lang.Object)
+ */
+ @Override public void visit(MethodDeclaration n, SymbolTable arg) {
+ currentAnnotations = n.getAnnotations();
+ arg.putMethodReturnType(javaClassName, n.getName(), convertType(n.getType(), n.getModifiers()));
+ }
-// Operations
-public:
+ /**
+ * @see japa.parser.ast.visitor.VoidVisitorAdapter#visit(japa.parser.ast.body.ClassOrInterfaceDeclaration, java.lang.Object)
+ */
+ @Override public void visit(ClassOrInterfaceDeclaration n, SymbolTable arg) {
+ javaClassName = n.getName();
+ }
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CBrowserToolTip)
- protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- //}}AFX_VIRTUAL
-
- CString m_szTipText;
-// Implementation
-public:
- virtual ~CBrowserToolTip();
-
- BOOL Create(CWnd *pParentWnd);
- void SetTipText(const CString &szTipText);
- void Show(CWnd *pOverWnd, long left, long top);
- void Hide();
-
-
- // Generated message map functions
-protected:
- //{{AFX_MSG(CBrowserToolTip)
- afx_msg void OnPaint();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_)
\ No newline at end of file
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/Type.java b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/Type.java
new file mode 100644
index 000000000000..783a3bbd0bb7
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/cpptranslate/Type.java
@@ -0,0 +1,99 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.cpptranslate;
+
+public class Type {
+
+ /**
+ * @param type
+ * @param arrayCount
+ * @param noLength
+ * @param modifiers
+ */
+ public Type(String type, int arrayCount, boolean noLength, int modifiers) {
+ this.type = type;
+ this.arrayCount = arrayCount;
+ this.noLength = noLength;
+ this.modifiers = modifiers;
+ }
+
+ private final String type;
+
+ private final int arrayCount;
+
+ private final boolean noLength;
+
+ private final int modifiers;
+
+ /**
+ * Returns the type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Returns the arrayCount.
+ *
+ * @return the arrayCount
+ */
+ public int getArrayCount() {
+ return arrayCount;
+ }
+
+ /**
+ * Returns the noLength.
+ *
+ * @return the noLength
+ */
+ public boolean isNoLength() {
+ return noLength;
+ }
+
+ /**
+ * Returns the modifiers.
+ *
+ * @return the modifiers
+ */
+ public int getModifiers() {
+ return modifiers;
+ }
+
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/generator/GenerateNamedCharacters.java b/parser/html/java/translator/src/nu/validator/htmlparser/generator/GenerateNamedCharacters.java
new file mode 100644
index 000000000000..6732f78cb543
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/generator/GenerateNamedCharacters.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2008 Mozilla Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.htmlparser.generator;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class GenerateNamedCharacters {
+
+ private static final int LEAD_OFFSET = 0xD800 - (0x10000 >> 10);
+
+ private static final Pattern LINE_PATTERN = Pattern.compile("^\\s* ([^<]*)
U\\+(\\S*) .*$");
+
+ private static String toUString(int c) {
+ String hexString = Integer.toHexString(c);
+ switch (hexString.length()) {
+ case 1:
+ return "\\u000" + hexString;
+ case 2:
+ return "\\u00" + hexString;
+ case 3:
+ return "\\u0" + hexString;
+ case 4:
+ return "\\u" + hexString;
+ default:
+ throw new RuntimeException("Unreachable.");
+ }
+ }
+
+
+ /**
+ * @param args
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+ TreeMap entities = new TreeMap();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, "utf-8"));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ Matcher m = LINE_PATTERN.matcher(line);
+ if (m.matches()) {
+ entities.put(m.group(1), m.group(2));
+ }
+ }
+ System.out.println("static final char[][] NAMES = {");
+ for (Map.Entry entity : entities.entrySet()) {
+ String name = entity.getKey();
+ System.out.print("\"");
+ System.out.print(name);
+ System.out.println("\".toCharArray(),");
+ }
+ System.out.println("};");
+
+ System.out.println("static final @NoLength char[][] VALUES = {");
+ for (Map.Entry entity : entities.entrySet()) {
+ String value = entity.getValue();
+ int intVal = Integer.parseInt(value, 16);
+ System.out.print("{");
+ if (intVal == '\'') {
+ System.out.print("\'\\\'\'");
+ } else if (intVal == '\n') {
+ System.out.print("\'\\n\'");
+ } else if (intVal == '\\') {
+ System.out.print("\'\\\\\'");
+ } else if (intVal <= 0xFFFF) {
+ System.out.print("\'");
+ System.out.print(toUString(intVal));
+ System.out.print("\'");
+ } else {
+ int hi = (LEAD_OFFSET + (intVal >> 10));
+ int lo = (0xDC00 + (intVal & 0x3FF));
+ System.out.print("\'");
+ System.out.print(toUString(hi));
+ System.out.print("\', \'");
+ System.out.print(toUString(lo));
+ System.out.print("\'");
+ }
+ System.out.println("},");
+ }
+ System.out.println("};");
+
+ }
+
+}
diff --git a/parser/html/java/translator/src/nu/validator/htmlparser/generator/GenerateNamedCharactersCpp.java b/parser/html/java/translator/src/nu/validator/htmlparser/generator/GenerateNamedCharactersCpp.java
new file mode 100644
index 000000000000..14f110e23598
--- /dev/null
+++ b/parser/html/java/translator/src/nu/validator/htmlparser/generator/GenerateNamedCharactersCpp.java
@@ -0,0 +1,295 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 HTML Parser C++ Translator code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Henri Sivonen
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package nu.validator.htmlparser.generator;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import nu.validator.htmlparser.cpptranslate.CppTypes;
+
+public class GenerateNamedCharactersCpp {
+
+ private static final int LEAD_OFFSET = 0xD800 - (0x10000 >> 10);
+
+ private static final Pattern LINE_PATTERN = Pattern.compile("^\\s* ([^<]*)
U\\+(\\S*) .*$");
+
+ private static String toHexString(int c) {
+ String hexString = Integer.toHexString(c);
+ switch (hexString.length()) {
+ case 1:
+ return "0x000" + hexString;
+ case 2:
+ return "0x00" + hexString;
+ case 3:
+ return "0x0" + hexString;
+ case 4:
+ return "0x" + hexString;
+ default:
+ throw new RuntimeException("Unreachable.");
+ }
+ }
+
+ /**
+ * @param args
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+ TreeMap entities = new TreeMap();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(args[0]), "utf-8"));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ Matcher m = LINE_PATTERN.matcher(line);
+ if (m.matches()) {
+ entities.put(m.group(1), m.group(2));
+ }
+ }
+
+ CppTypes cppTypes = new CppTypes(null);
+ File targetDirectory = new File(args[1]);
+
+ generateH(targetDirectory, cppTypes, entities);
+ generateCpp(targetDirectory, cppTypes, entities);
+ }
+
+ private static void generateH(File targetDirectory, CppTypes cppTypes,
+ Map entities) throws IOException {
+ File hFile = new File(targetDirectory, cppTypes.classPrefix()
+ + "NamedCharacters.h");
+ Writer out = new OutputStreamWriter(new FileOutputStream(hFile),
+ "utf-8");
+ out.write("#ifndef " + cppTypes.classPrefix() + "NamedCharacters_h__\n");
+ out.write("#define " + cppTypes.classPrefix() + "NamedCharacters_h__\n");
+ out.write('\n');
+
+ String[] includes = cppTypes.namedCharactersIncludes();
+ for (int i = 0; i < includes.length; i++) {
+ String include = includes[i];
+ out.write("#include \"" + include + ".h\"\n");
+ }
+
+ out.write('\n');
+
+ out.write("class " + cppTypes.classPrefix() + "NamedCharacters\n");
+ out.write("{\n");
+ out.write(" public:\n");
+ out.write(" static " + cppTypes.arrayTemplate() + "<"
+ + cppTypes.arrayTemplate() + "<" + cppTypes.charType() + ","
+ + cppTypes.intType() + ">," + cppTypes.intType() + "> NAMES;\n");
+ out.write(" static " + cppTypes.arrayTemplate() + "<"
+ + cppTypes.charType() + "," + cppTypes.intType()
+ + ">* VALUES;\n");
+ out.write(" static " + cppTypes.charType() + "** WINDOWS_1252;\n");
+ out.write(" static void initializeStatics();\n");
+ out.write(" static void releaseStatics();\n");
+ out.write("};\n");
+
+ out.write("\n#endif // " + cppTypes.classPrefix()
+ + "NamedCharacters_h__\n");
+ out.flush();
+ out.close();
+ }
+
+ private static void generateCpp(File targetDirectory, CppTypes cppTypes,
+ Map entities) throws IOException {
+ File hFile = new File(targetDirectory, cppTypes.classPrefix()
+ + "NamedCharacters.cpp");
+ Writer out = new OutputStreamWriter(new FileOutputStream(hFile),
+ "utf-8");
+
+ out.write("#define " + cppTypes.classPrefix()
+ + "NamedCharacters_cpp__\n");
+
+ String[] includes = cppTypes.namedCharactersIncludes();
+ for (int i = 0; i < includes.length; i++) {
+ String include = includes[i];
+ out.write("#include \"" + include + ".h\"\n");
+ }
+
+ out.write('\n');
+ out.write("#include \"" + cppTypes.classPrefix()
+ + "NamedCharacters.h\"\n");
+ out.write("\n");
+
+ out.write("" + cppTypes.arrayTemplate() + "<"
+ + cppTypes.arrayTemplate() + "<" + cppTypes.charType() + ","
+ + cppTypes.intType() + ">," + cppTypes.intType() + "> "
+ + cppTypes.classPrefix() + "NamedCharacters::NAMES;\n");
+
+ out.write("static " + cppTypes.charType() + " const WINDOWS_1252_DATA[] = {\n");
+ out.write(" 0x20AC,\n");
+ out.write(" 0xFFFD,\n");
+ out.write(" 0x201A,\n");
+ out.write(" 0x0192,\n");
+ out.write(" 0x201E,\n");
+ out.write(" 0x2026,\n");
+ out.write(" 0x2020,\n");
+ out.write(" 0x2021,\n");
+ out.write(" 0x02C6,\n");
+ out.write(" 0x2030,\n");
+ out.write(" 0x0160,\n");
+ out.write(" 0x2039,\n");
+ out.write(" 0x0152,\n");
+ out.write(" 0xFFFD,\n");
+ out.write(" 0x017D,\n");
+ out.write(" 0xFFFD,\n");
+ out.write(" 0xFFFD,\n");
+ out.write(" 0x2018,\n");
+ out.write(" 0x2019,\n");
+ out.write(" 0x201C,\n");
+ out.write(" 0x201D,\n");
+ out.write(" 0x2022,\n");
+ out.write(" 0x2013,\n");
+ out.write(" 0x2014,\n");
+ out.write(" 0x02DC,\n");
+ out.write(" 0x2122,\n");
+ out.write(" 0x0161,\n");
+ out.write(" 0x203A,\n");
+ out.write(" 0x0153,\n");
+ out.write(" 0xFFFD,\n");
+ out.write(" 0x017E,\n");
+ out.write(" 0x0178\n");
+ out.write("};\n");
+
+ int k = 0;
+ for (Map.Entry entity : entities.entrySet()) {
+ String name = entity.getKey();
+ int value = Integer.parseInt(entity.getValue(), 16);
+
+ out.write("static " + cppTypes.charType() + " const NAME_" + k
+ + "[] = {\n");
+ out.write(" ");
+
+ for (int j = 0; j < name.length(); j++) {
+ char c = name.charAt(j);
+ if (j != 0) {
+ out.write(", ");
+ }
+ out.write('\'');
+ out.write(c);
+ out.write('\'');
+ }
+
+ out.write("\n};\n");
+
+ out.write("static " + cppTypes.charType() + " const VALUE_" + k
+ + "[] = {\n");
+ out.write(" ");
+
+ if (value <= 0xFFFF) {
+ out.write(toHexString(value));
+ } else {
+ int hi = (LEAD_OFFSET + (value >> 10));
+ int lo = (0xDC00 + (value & 0x3FF));
+ out.write(toHexString(hi));
+ out.write(", ");
+ out.write(toHexString(lo));
+ }
+
+ out.write("\n};\n");
+
+ k++;
+ }
+
+ out.write("\n// XXX bug 501082: for some reason, msvc takes forever to optimize this function\n");
+ out.write("#ifdef _MSC_VER\n");
+ out.write("#pragma optimize(\"\", off)\n");
+ out.write("#endif\n\n");
+
+ out.write("void\n");
+ out.write(cppTypes.classPrefix()
+ + "NamedCharacters::initializeStatics()\n");
+ out.write("{\n");
+ out.write(" NAMES = " + cppTypes.arrayTemplate() + "<"
+ + cppTypes.arrayTemplate() + "<" + cppTypes.charType() + ","
+ + cppTypes.intType() + ">," + cppTypes.intType() + ">("
+ + entities.size() + ");\n");
+ int i = 0;
+ for (Map.Entry entity : entities.entrySet()) {
+ out.write(" NAMES[" + i + "] = " + cppTypes.arrayTemplate() + "<"
+ + cppTypes.charType() + "," + cppTypes.intType() + ">(("
+ + cppTypes.charType() + "*)NAME_" + i + ", "
+ + entity.getKey().length() + ");\n");
+ i++;
+ }
+ out.write(" VALUES = new " + cppTypes.arrayTemplate() + "<"
+ + cppTypes.charType() + "," + cppTypes.intType() + ">["
+ + entities.size() + "];\n");
+ i = 0;
+ for (Map.Entry entity : entities.entrySet()) {
+ int value = Integer.parseInt(entity.getValue(), 16);
+ out.write(" VALUES[" + i + "] = " + cppTypes.arrayTemplate() + "<"
+ + cppTypes.charType() + "," + cppTypes.intType() + ">(("
+ + cppTypes.charType() + "*)VALUE_" + i + ", "
+ + ((value <= 0xFFFF) ? "1" : "2") + ");\n");
+ i++;
+ }
+ out.write("\n");
+ out.write(" WINDOWS_1252 = new " + cppTypes.charType() + "*[32];\n");
+ out.write(" for (" + cppTypes.intType() + " i = 0; i < 32; ++i) {\n");
+ out.write(" WINDOWS_1252[i] = (" + cppTypes.charType() + "*)&(WINDOWS_1252_DATA[i]);\n");
+ out.write(" }\n");
+ out.write("}\n");
+ out.write("\n");
+
+ out.write("#ifdef _MSC_VER\n");
+ out.write("#pragma optimize(\"\", on)\n");
+ out.write("#endif\n\n");
+
+ out.write("void\n");
+ out.write(cppTypes.classPrefix()
+ + "NamedCharacters::releaseStatics()\n");
+ out.write("{\n");
+ out.write(" NAMES.release();\n");
+ out.write(" delete[] VALUES;\n");
+ out.write(" delete[] WINDOWS_1252;\n");
+ out.write("}\n");
+ out.flush();
+ out.close();
+ }
+}
diff --git a/security/coreconf/HP-UX.mk b/security/coreconf/HP-UX.mk
index ef895337ddc3..5355339144fc 100644
--- a/security/coreconf/HP-UX.mk
+++ b/security/coreconf/HP-UX.mk
@@ -76,7 +76,7 @@ endif
LDFLAGS = -z -Wl,+s
-MKSHLIB = $(LD) $(DSO_LDOPTS)
+MKSHLIB = $(LD) $(DSO_LDOPTS) $(RPATH)
ifdef MAPFILE
MKSHLIB += -c $(MAPFILE)
endif
@@ -84,8 +84,8 @@ PROCESS_MAP_FILE = grep -v ';+' $< | grep -v ';-' | \
sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,+e ,' > $@
DSO_LDOPTS = -b +h $(notdir $@)
-ifeq ($(OS_TEST),ia64)
- DSO_LDOPTS += +b '$$ORIGIN'
+ifeq ($(USE_64), 1)
+RPATH = +b '$$ORIGIN'
endif
DSO_LDFLAGS =
diff --git a/security/coreconf/Linux.mk b/security/coreconf/Linux.mk
index 7725a97cc4b1..f6239085e809 100644
--- a/security/coreconf/Linux.mk
+++ b/security/coreconf/Linux.mk
@@ -52,10 +52,6 @@ RANLIB = ranlib
DEFAULT_COMPILER = gcc
-ifeq ($(OS_TEST),m68k)
- OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
- CPU_ARCH = m68k
-else
ifeq ($(OS_TEST),ppc64)
OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
CPU_ARCH = ppc
@@ -63,18 +59,10 @@ ifeq ($(USE_64),1)
ARCHFLAG = -m64
endif
else
-ifeq ($(OS_TEST),ppc)
- OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
- CPU_ARCH = ppc
-else
ifeq ($(OS_TEST),alpha)
OS_REL_CFLAGS = -D_ALPHA_ -DLINUX1_2 -D_XOPEN_SOURCE
CPU_ARCH = alpha
else
-ifeq ($(OS_TEST),ia64)
- OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
- CPU_ARCH = ia64
-else
ifeq ($(OS_TEST),x86_64)
ifeq ($(USE_64),1)
OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
@@ -85,10 +73,6 @@ else
ARCHFLAG = -m32
endif
else
-ifeq ($(OS_TEST),sparc)
- OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
- CPU_ARCH = sparc
-else
ifeq ($(OS_TEST),sparc64)
OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
CPU_ARCH = sparc
@@ -97,30 +81,19 @@ ifeq (,$(filter-out arm% sa110,$(OS_TEST)))
OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
CPU_ARCH = arm
else
-ifeq ($(OS_TEST),parisc)
+ifeq (,$(filter-out parisc%,$(OS_TEST)))
OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
CPU_ARCH = hppa
else
-ifeq ($(OS_TEST),parisc64)
- OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
- CPU_ARCH = hppa
-else
-ifeq ($(OS_TEST),s390)
- OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
- CPU_ARCH = s390
-else
-ifeq ($(OS_TEST),s390x)
- OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
- CPU_ARCH = s390x
-else
-ifeq ($(OS_TEST),mips)
- OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
- CPU_ARCH = mips
-else
ifeq (,$(filter-out i%86,$(OS_TEST)))
OS_REL_CFLAGS = -DLINUX1_2 -Di386 -D_XOPEN_SOURCE
CPU_ARCH = x86
else
+ifeq ($(OS_TEST),sh4a)
+ OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
+ CPU_ARCH = sh4
+else
+# $(OS_TEST) == m68k, ppc, ia64, sparc, s390, s390x, mips, sh3, sh4
OS_REL_CFLAGS = -DLINUX1_2 -D_XOPEN_SOURCE
CPU_ARCH = $(OS_TEST)
endif
@@ -131,20 +104,13 @@ endif
endif
endif
endif
-endif
-endif
-endif
-endif
-endif
-endif
-endif
LIBC_TAG = _glibc
ifeq ($(OS_RELEASE),2.0)
OS_REL_CFLAGS += -DLINUX2_0
- MKSHLIB = $(CC) -shared -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so)
+ MKSHLIB = $(CC) -shared -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH)
ifdef MAPFILE
MKSHLIB += -Wl,--version-script,$(MAPFILE)
endif
@@ -182,9 +148,20 @@ LDFLAGS += $(ARCHFLAG)
G++INCLUDES = -I/usr/include/g++
#
-# Always set CPU_TAG on Linux, OpenVMS, WINCE.
+# Always set CPU_TAG on Linux, WINCE.
#
CPU_TAG = _$(CPU_ARCH)
USE_SYSTEM_ZLIB = 1
ZLIB_LIBS = -lz
+
+# The -rpath '$$ORIGIN' linker option instructs this library to search for its
+# dependencies in the same directory where it resides.
+ifeq ($(BUILD_SUN_PKG), 1)
+ifeq ($(USE_64), 1)
+RPATH = -Wl,-rpath,'$$ORIGIN:/opt/sun/private/lib64:/opt/sun/private/lib'
+else
+RPATH = -Wl,-rpath,'$$ORIGIN:/opt/sun/private/lib'
+endif
+endif
+
diff --git a/security/coreconf/Linux2.1.mk b/security/coreconf/Linux2.1.mk
index 7569e1b1004e..e92503aab3c5 100644
--- a/security/coreconf/Linux2.1.mk
+++ b/security/coreconf/Linux2.1.mk
@@ -38,7 +38,7 @@
include $(CORE_DEPTH)/coreconf/Linux.mk
ifeq ($(OS_RELEASE),2.1)
OS_REL_CFLAGS += -DLINUX2_1
- MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so)
+ MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH)
ifdef MAPFILE
MKSHLIB += -Wl,--version-script,$(MAPFILE)
endif
diff --git a/security/coreconf/Linux2.2.mk b/security/coreconf/Linux2.2.mk
index 86bffef75fea..4a6cc1e6ca1f 100644
--- a/security/coreconf/Linux2.2.mk
+++ b/security/coreconf/Linux2.2.mk
@@ -38,7 +38,7 @@
include $(CORE_DEPTH)/coreconf/Linux.mk
OS_REL_CFLAGS += -DLINUX2_1
-MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so)
+MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH)
ifdef MAPFILE
MKSHLIB += -Wl,--version-script,$(MAPFILE)
diff --git a/security/coreconf/Linux2.4.mk b/security/coreconf/Linux2.4.mk
index 86bffef75fea..4a6cc1e6ca1f 100644
--- a/security/coreconf/Linux2.4.mk
+++ b/security/coreconf/Linux2.4.mk
@@ -38,7 +38,7 @@
include $(CORE_DEPTH)/coreconf/Linux.mk
OS_REL_CFLAGS += -DLINUX2_1
-MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so)
+MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH)
ifdef MAPFILE
MKSHLIB += -Wl,--version-script,$(MAPFILE)
diff --git a/security/coreconf/Linux2.5.mk b/security/coreconf/Linux2.5.mk
index 86bffef75fea..4a6cc1e6ca1f 100644
--- a/security/coreconf/Linux2.5.mk
+++ b/security/coreconf/Linux2.5.mk
@@ -38,7 +38,7 @@
include $(CORE_DEPTH)/coreconf/Linux.mk
OS_REL_CFLAGS += -DLINUX2_1
-MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so)
+MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH)
ifdef MAPFILE
MKSHLIB += -Wl,--version-script,$(MAPFILE)
diff --git a/security/coreconf/Linux2.6.mk b/security/coreconf/Linux2.6.mk
index 86bffef75fea..4a6cc1e6ca1f 100644
--- a/security/coreconf/Linux2.6.mk
+++ b/security/coreconf/Linux2.6.mk
@@ -38,7 +38,7 @@
include $(CORE_DEPTH)/coreconf/Linux.mk
OS_REL_CFLAGS += -DLINUX2_1
-MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so)
+MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH)
ifdef MAPFILE
MKSHLIB += -Wl,--version-script,$(MAPFILE)
diff --git a/security/coreconf/OS2.mk b/security/coreconf/OS2.mk
index 73c223110e21..4dd01a0f9ad3 100644
--- a/security/coreconf/OS2.mk
+++ b/security/coreconf/OS2.mk
@@ -97,7 +97,7 @@ PROCESS_MAP_FILE = \
endif #NO_SHARED_LIB
-OS_CFLAGS = -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -Wno-switch -Zomf -DDEBUG -DTRACING -g
+OS_CFLAGS = -Wall -Wno-unused -Wpointer-arith -Wcast-align -Wno-switch -Zomf -DDEBUG -DTRACING -g
ifdef BUILD_OPT
ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
diff --git a/security/coreconf/OpenVMS.mk b/security/coreconf/OpenVMS.mk
deleted file mode 100755
index 6d9b0168b1a3..000000000000
--- a/security/coreconf/OpenVMS.mk
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# 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 the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-#
-# Config stuff for Compaq OpenVMS
-#
-
-include $(CORE_DEPTH)/coreconf/UNIX.mk
-
-CC = cc
-CCC = cxx
-
-RANLIB = /gnu/bin/true
-
-CPU_ARCH := $(shell uname -Wh)
-
-OS_CFLAGS = -DVMS
-OS_CXXFLAGS = -DVMS
-
-#
-# XCFLAGS are the only CFLAGS that are used during a link operation. Defining
-# OPTIMIZER in XCFLAGS means that each compilation line gets OPTIMIZER
-# included twice, but at least we get OPTIMIZER included in the link
-# operations; and OpenVMS needs it!
-#
-XCFLAGS += $(OPTIMIZER)
-
-DSO_LDOPTS = -shared -auto_symvec
-MKSHLIB = $(CC) $(OPTIMIZER) $(LDFLAGS) $(DSO_LDOPTS)
-
-ifdef MAPFILE
-# Add LD options to restrict exported symbols to those in the map file
-endif
-# Change PROCESS to put the mapfile in the correct format for this platform
-PROCESS_MAP_FILE = cp $< $@
-
-
-#
-# Always set CPU_TAG on Linux, OpenVMS, WINCE.
-#
-CPU_TAG = _$(CPU_ARCH)
diff --git a/security/coreconf/OpenVMSV7.1-2.mk b/security/coreconf/OpenVMSV7.1-2.mk
deleted file mode 100755
index 5e99888a1e9c..000000000000
--- a/security/coreconf/OpenVMSV7.1-2.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# 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 the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-#
-# Config stuff for Compaq OpenVMS
-#
-
-include $(CORE_DEPTH)/coreconf/OpenVMS.mk
diff --git a/security/coreconf/SunOS5.mk b/security/coreconf/SunOS5.mk
index 549e110f582f..c3f8e182533d 100644
--- a/security/coreconf/SunOS5.mk
+++ b/security/coreconf/SunOS5.mk
@@ -113,7 +113,7 @@ OS_DEFINES += -DSVR4 -DSYSV -D__svr4 -D__svr4__ -DSOLARIS -D_REENTRANT
# Purify doesn't like -MDupdate
NOMD_OS_CFLAGS += $(DSO_CFLAGS) $(OS_DEFINES) $(SOL_CFLAGS)
-MKSHLIB = $(CC) $(DSO_LDOPTS)
+MKSHLIB = $(CC) $(DSO_LDOPTS) $(RPATH)
ifdef NS_USE_GCC
ifeq (GNU,$(findstring GNU,$(shell `$(CC) -print-prog-name=ld` -v 2>&1)))
GCC_USE_GNU_LD = 1
@@ -166,3 +166,15 @@ endif
NOSUCHFILE = /solaris-rm-f-sucks
+ifeq ($(BUILD_SUN_PKG), 1)
+# The -R '$ORIGIN' linker option instructs this library to search for its
+# dependencies in the same directory where it resides.
+ifeq ($(USE_64), 1)
+RPATH = -R '$$ORIGIN:/usr/lib/mps/secv1/64:/usr/lib/mps/64'
+else
+RPATH = -R '$$ORIGIN:/usr/lib/mps/secv1:/usr/lib/mps'
+endif
+else
+RPATH = -R '$$ORIGIN'
+endif
+
diff --git a/security/coreconf/WINCE.mk b/security/coreconf/WINCE.mk
index c931258461fd..af23a8ee0d48 100644
--- a/security/coreconf/WINCE.mk
+++ b/security/coreconf/WINCE.mk
@@ -83,6 +83,8 @@ LIB_SUFFIX = lib
DLL_SUFFIX = dll
OS_DLLFLAGS += -DLL
+EXTRA_EXE_LD_FLAGS += -ENTRY:mainWCRTStartup
+
ifdef BUILD_OPT
# OS_CFLAGS += -MD
OPTIMIZER += -O2
@@ -206,7 +208,7 @@ endif
#
-# Always set CPU_TAG on Linux, OpenVMS, WINCE.
+# Always set CPU_TAG on Linux, WINCE.
#
CPU_TAG = _$(CPU_ARCH)
diff --git a/security/coreconf/arch.mk b/security/coreconf/arch.mk
index 4381dc850aab..bd3c02cc34fd 100644
--- a/security/coreconf/arch.mk
+++ b/security/coreconf/arch.mk
@@ -165,11 +165,6 @@ ifeq ($(OS_ARCH),OS_2)
OS_RELEASE := $(shell uname -v)
endif
-ifneq (,$(findstring OpenVMS,$(OS_ARCH)))
- OS_ARCH = OpenVMS
- OS_RELEASE := $(shell uname -v)
-endif
-
#######################################################################
# Master "Core Components" macros for getting the OS target #
#######################################################################
diff --git a/security/coreconf/config.mk b/security/coreconf/config.mk
index a45eb8ca9e92..5b560fbbc188 100644
--- a/security/coreconf/config.mk
+++ b/security/coreconf/config.mk
@@ -63,7 +63,7 @@ endif
#######################################################################
TARGET_OSES = FreeBSD BSD_OS NetBSD OpenUNIX OS2 QNX Darwin BeOS OpenBSD \
- OpenVMS AIX RISCOS WINNT WIN95 WINCE
+ AIX RISCOS WINNT WIN95 WINCE
ifeq (,$(filter-out $(TARGET_OSES),$(OS_TARGET)))
include $(CORE_DEPTH)/coreconf/$(OS_TARGET).mk
diff --git a/security/coreconf/coreconf.dep b/security/coreconf/coreconf.dep
index 831d1c16ee58..6ceac3773496 100644
--- a/security/coreconf/coreconf.dep
+++ b/security/coreconf/coreconf.dep
@@ -44,3 +44,4 @@
#error "Do not include this header file."
/* NSS 3.12.4 Beta */
+
diff --git a/security/coreconf/nsinstall/nsinstall.c b/security/coreconf/nsinstall/nsinstall.c
index 67850411d5f5..647f1111d4fa 100644
--- a/security/coreconf/nsinstall/nsinstall.c
+++ b/security/coreconf/nsinstall/nsinstall.c
@@ -58,7 +58,7 @@ typedef unsigned int mode_t;
#define HAVE_LCHOWN
-#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(VMS) || defined(NTO) || defined(DARWIN) || defined(BEOS) || defined(__riscos__)
+#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(NTO) || defined(DARWIN) || defined(BEOS) || defined(__riscos__)
#undef HAVE_LCHOWN
#endif
@@ -407,11 +407,6 @@ retry:
if (ftruncate(tofd, sb.st_size) < 0)
fail("cannot truncate %s", toname);
- /*
- ** On OpenVMS we can't chmod() until the file is closed, and we
- ** have to utime() last since fchown/chmod alter the timestamps.
- */
-#ifndef VMS
if (dotimes) {
utb.actime = sb.st_atime;
utb.modtime = sb.st_mtime;
@@ -424,7 +419,7 @@ retry:
if (chmod(toname, mode) < 0)
#endif
fail("cannot change mode of %s", toname);
-#endif
+
if ((owner || group) && fchown(tofd, uid, gid) < 0)
fail("cannot change owner of %s", toname);
@@ -432,16 +427,6 @@ retry:
if (close(tofd) < 0)
fail("close reports write error on %s", toname);
close(fromfd);
-#ifdef VMS
- if (chmod(toname, mode) < 0)
- fail("cannot change mode of %s", toname);
- if (dotimes) {
- utb.actime = sb.st_atime;
- utb.modtime = sb.st_mtime;
- if (utime(toname, &utb) < 0)
- fail("cannot set times of %s", toname);
- }
-#endif
}
free(toname);
diff --git a/security/coreconf/rules.mk b/security/coreconf/rules.mk
index 0f347b5aa9ef..d3738c43ad63 100644
--- a/security/coreconf/rules.mk
+++ b/security/coreconf/rules.mk
@@ -273,7 +273,7 @@ alltags:
$(PROGRAM): $(OBJS) $(EXTRA_LIBS)
@$(MAKE_OBJDIR)
ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
- $(MKPROG) $(subst /,\\,$(OBJS)) -Fe$@ -link $(LDFLAGS) $(subst /,\\,$(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS))
+ $(MKPROG) $(subst /,\\,$(OBJS)) -Fe$@ -link $(LDFLAGS) $(subst /,\\,$(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)) $(EXTRA_EXE_LD_FLAGS)
ifdef MT
if test -f $@.manifest; then \
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
@@ -373,7 +373,7 @@ $(OBJDIR)/$(PROG_PREFIX)%$(PROG_SUFFIX): $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX)
@$(MAKE_OBJDIR)
ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
$(MKPROG) $< -Fe$@ -link \
- $(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
+ $(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS) $(EXTRA_EXE_LD_FLAGS)
ifdef MT
if test -f $@.manifest; then \
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
@@ -878,7 +878,7 @@ endif
-include $(DEPENDENCIES)
-ifneq (,$(filter-out OpenVMS OS2 WIN%,$(OS_TARGET)))
+ifneq (,$(filter-out OS2 WIN%,$(OS_TARGET)))
# Can't use sed because of its 4000-char line length limit, so resort to perl
PERL_DEPENDENCIES_PROGRAM = \
open(MD, "< $(DEPENDENCIES)"); \
diff --git a/security/coreconf/ruleset.mk b/security/coreconf/ruleset.mk
index f9b594433bf6..c083378a6fc4 100644
--- a/security/coreconf/ruleset.mk
+++ b/security/coreconf/ruleset.mk
@@ -210,12 +210,8 @@ endif
endif #NS_USE_JDK
-#
-# If this is an "official" build, try to build everything.
-# I.e., don't exit on errors.
-#
-
-ifdef BUILD_OFFICIAL
+ifdef NSS_BUILD_CONTINUE_ON_ERROR
+# Try to build everything. I.e., don't exit on errors.
EXIT_ON_ERROR = +e
CLICK_STOPWATCH = date
else
diff --git a/security/manager/ssl/src/nsNSSComponent.cpp b/security/manager/ssl/src/nsNSSComponent.cpp
index 6e3756e0745d..abaf64b2f6aa 100644
--- a/security/manager/ssl/src/nsNSSComponent.cpp
+++ b/security/manager/ssl/src/nsNSSComponent.cpp
@@ -280,7 +280,7 @@ nsTokenEventRunnable::Run()
PRBool EnsureNSSInitialized(EnsureNSSOperator op)
{
static PRBool loading = PR_FALSE;
- static PRBool haveLoaded = PR_FALSE;
+ static PRInt32 haveLoaded = 0;
switch (op)
{
@@ -296,7 +296,7 @@ PRBool EnsureNSSInitialized(EnsureNSSOperator op)
case nssInitSucceeded:
NS_ASSERTION(loading, "Bad call to EnsureNSSInitialized(nssInitSucceeded)");
loading = PR_FALSE;
- haveLoaded = PR_TRUE;
+ PR_AtomicSet(&haveLoaded, 1);
return PR_TRUE;
case nssInitFailed:
@@ -305,7 +305,7 @@ PRBool EnsureNSSInitialized(EnsureNSSOperator op)
// no break
case nssShutdown:
- haveLoaded = PR_FALSE;
+ PR_AtomicSet(&haveLoaded, 0);
return PR_FALSE;
// In this case we are called from a component to ensure nss initilization.
@@ -313,7 +313,7 @@ PRBool EnsureNSSInitialized(EnsureNSSOperator op)
// call do_GetService for nss component to ensure it.
case nssEnsure:
// We are reentered during nss component creation or nss component is already up
- if (haveLoaded || loading)
+ if (PR_AtomicAdd(&haveLoaded, 0) || loading)
return PR_TRUE;
{
@@ -1751,6 +1751,7 @@ nsNSSComponent::ShutdownNSS()
CleanupIdentityInfo();
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("evaporating psm resources\n"));
mShutdownObjectList->evaporateAllNSSResources();
+ EnsureNSSInitialized(nssShutdown);
if (SECSuccess != ::NSS_Shutdown()) {
PR_LOG(gPIPNSSLog, PR_LOG_ALWAYS, ("NSS SHUTDOWN FAILURE\n"));
rv = NS_ERROR_FAILURE;
@@ -2556,8 +2557,28 @@ nsCryptoHash::nsCryptoHash()
nsCryptoHash::~nsCryptoHash()
{
+ nsNSSShutDownPreventionLock locker;
+
+ if (isAlreadyShutDown())
+ return;
+
+ destructorSafeDestroyNSSReference();
+ shutdown(calledFromObject);
+}
+
+void nsCryptoHash::virtualDestroyNSSReference()
+{
+ destructorSafeDestroyNSSReference();
+}
+
+void nsCryptoHash::destructorSafeDestroyNSSReference()
+{
+ if (isAlreadyShutDown())
+ return;
+
if (mHashContext)
HASH_Destroy(mHashContext);
+ mHashContext = nsnull;
}
NS_IMPL_ISUPPORTS1(nsCryptoHash, nsICryptoHash)
@@ -2565,6 +2586,8 @@ NS_IMPL_ISUPPORTS1(nsCryptoHash, nsICryptoHash)
NS_IMETHODIMP
nsCryptoHash::Init(PRUint32 algorithm)
{
+ nsNSSShutDownPreventionLock locker;
+
HASH_HashType hashType = (HASH_HashType)algorithm;
if (mHashContext)
{
@@ -2617,6 +2640,8 @@ nsCryptoHash::InitWithString(const nsACString & aAlgorithm)
NS_IMETHODIMP
nsCryptoHash::Update(const PRUint8 *data, PRUint32 len)
{
+ nsNSSShutDownPreventionLock locker;
+
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
@@ -2675,6 +2700,8 @@ nsCryptoHash::UpdateFromStream(nsIInputStream *data, PRUint32 len)
NS_IMETHODIMP
nsCryptoHash::Finish(PRBool ascii, nsACString & _retval)
{
+ nsNSSShutDownPreventionLock locker;
+
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
@@ -2715,13 +2742,35 @@ nsCryptoHMAC::nsCryptoHMAC()
nsCryptoHMAC::~nsCryptoHMAC()
{
+ nsNSSShutDownPreventionLock locker;
+
+ if (isAlreadyShutDown())
+ return;
+
+ destructorSafeDestroyNSSReference();
+ shutdown(calledFromObject);
+}
+
+void nsCryptoHMAC::virtualDestroyNSSReference()
+{
+ destructorSafeDestroyNSSReference();
+}
+
+void nsCryptoHMAC::destructorSafeDestroyNSSReference()
+{
+ if (isAlreadyShutDown())
+ return;
+
if (mHMACContext)
PK11_DestroyContext(mHMACContext, PR_TRUE);
+ mHMACContext = nsnull;
}
/* void init (in unsigned long aAlgorithm, in nsIKeyObject aKeyObject); */
NS_IMETHODIMP nsCryptoHMAC::Init(PRUint32 aAlgorithm, nsIKeyObject *aKeyObject)
{
+ nsNSSShutDownPreventionLock locker;
+
if (mHMACContext)
{
PK11_DestroyContext(mHMACContext, PR_TRUE);
@@ -2778,6 +2827,8 @@ NS_IMETHODIMP nsCryptoHMAC::Init(PRUint32 aAlgorithm, nsIKeyObject *aKeyObject)
/* void update ([array, size_is (aLen), const] in octet aData, in unsigned long aLen); */
NS_IMETHODIMP nsCryptoHMAC::Update(const PRUint8 *aData, PRUint32 aLen)
{
+ nsNSSShutDownPreventionLock locker;
+
if (!mHMACContext)
return NS_ERROR_NOT_INITIALIZED;
@@ -2843,6 +2894,8 @@ NS_IMETHODIMP nsCryptoHMAC::UpdateFromStream(nsIInputStream *aStream, PRUint32 a
/* ACString finish (in PRBool aASCII); */
NS_IMETHODIMP nsCryptoHMAC::Finish(PRBool aASCII, nsACString & _retval)
{
+ nsNSSShutDownPreventionLock locker;
+
if (!mHMACContext)
return NS_ERROR_NOT_INITIALIZED;
@@ -2870,6 +2923,8 @@ NS_IMETHODIMP nsCryptoHMAC::Finish(PRBool aASCII, nsACString & _retval)
/* void reset (); */
NS_IMETHODIMP nsCryptoHMAC::Reset()
{
+ nsNSSShutDownPreventionLock locker;
+
SECStatus ss = PK11_DigestBegin(mHMACContext);
NS_ENSURE_TRUE(ss == SECSuccess, NS_ERROR_FAILURE);
diff --git a/security/manager/ssl/src/nsNSSComponent.h b/security/manager/ssl/src/nsNSSComponent.h
index 4ff716236c38..ff457d5df7fd 100644
--- a/security/manager/ssl/src/nsNSSComponent.h
+++ b/security/manager/ssl/src/nsNSSComponent.h
@@ -67,6 +67,7 @@
#include "nsICryptoHMAC.h"
#include "hasht.h"
#include "nsNSSCallbacks.h"
+#include "nsNSSShutDown.h"
#include "nsNSSHelper.h"
#include "nsClientAuthRemember.h"
@@ -192,7 +193,7 @@ class NS_NO_VTABLE nsINSSComponent : public nsISupports {
NS_DEFINE_STATIC_IID_ACCESSOR(nsINSSComponent, NS_INSSCOMPONENT_IID)
-class nsCryptoHash : public nsICryptoHash
+class nsCryptoHash : public nsICryptoHash, public nsNSSShutDownObject
{
public:
NS_DECL_ISUPPORTS
@@ -205,9 +206,12 @@ private:
HASHContext* mHashContext;
PRBool mInitialized;
+
+ virtual void virtualDestroyNSSReference();
+ void destructorSafeDestroyNSSReference();
};
-class nsCryptoHMAC : public nsICryptoHMAC
+class nsCryptoHMAC : public nsICryptoHMAC, public nsNSSShutDownObject
{
public:
NS_DECL_ISUPPORTS
@@ -217,8 +221,10 @@ public:
private:
~nsCryptoHMAC();
-
PK11Context* mHMACContext;
+
+ virtual void virtualDestroyNSSReference();
+ void destructorSafeDestroyNSSReference();
};
struct PRLock;
diff --git a/security/manager/ssl/src/nsNTLMAuthModule.cpp b/security/manager/ssl/src/nsNTLMAuthModule.cpp
index 0653b0383b77..0bd544d14d97 100644
--- a/security/manager/ssl/src/nsNTLMAuthModule.cpp
+++ b/security/manager/ssl/src/nsNTLMAuthModule.cpp
@@ -534,18 +534,34 @@ ParseType2Msg(const void *inBuf, PRUint32 inLen, Type2Msg *msg)
// verify NTLMSSP signature
if (memcmp(cursor, NTLM_SIGNATURE, sizeof(NTLM_SIGNATURE)) != 0)
return NS_ERROR_UNEXPECTED;
+
cursor += sizeof(NTLM_SIGNATURE);
// verify Type-2 marker
if (memcmp(cursor, NTLM_TYPE2_MARKER, sizeof(NTLM_TYPE2_MARKER)) != 0)
return NS_ERROR_UNEXPECTED;
+
cursor += sizeof(NTLM_TYPE2_MARKER);
- // read target name security buffer
- msg->targetLen = ReadUint16(cursor);
- ReadUint16(cursor); // discard next 16-bit value
- PRUint32 offset = ReadUint32(cursor); // get offset from inBuf
- msg->target = ((const PRUint8 *) inBuf) + offset;
+ // Read target name security buffer: ...
+ // ... read target length.
+ PRUint32 targetLen = ReadUint16(cursor);
+ // ... skip next 16-bit "allocated space" value.
+ ReadUint16(cursor);
+ // ... read offset from inBuf.
+ PRUint32 offset = ReadUint32(cursor);
+ // Check the offset / length combo is in range of the input buffer, including
+ // integer overflow checking.
+ if (NS_LIKELY(offset < offset + targetLen && offset + targetLen <= inLen)) {
+ msg->targetLen = targetLen;
+ msg->target = ((const PRUint8 *) inBuf) + offset;
+ }
+ else
+ {
+ // Do not error out, for (conservative) backward compatibility.
+ msg->targetLen = 0;
+ msg->target = NULL;
+ }
// read flags
msg->flags = ReadUint32(cursor);
diff --git a/security/nss/cmd/bltest/blapitest.c b/security/nss/cmd/bltest/blapitest.c
index 0b156d716052..051ea7c43dfc 100644
--- a/security/nss/cmd/bltest/blapitest.c
+++ b/security/nss/cmd/bltest/blapitest.c
@@ -3246,7 +3246,7 @@ int main(int argc, char **argv)
double totalTime;
PRIntervalTime time1, time2;
- PRFileDesc *outfile;
+ PRFileDesc *outfile = NULL;
bltestCipherInfo *cipherInfoListHead, *cipherInfo;
bltestIOMode ioMode;
int bufsize, exponent, curThrdNum;
diff --git a/security/nss/cmd/certutil/certext.c b/security/nss/cmd/certutil/certext.c
index ee7b00ddc947..97399c7503ca 100644
--- a/security/nss/cmd/certutil/certext.c
+++ b/security/nss/cmd/certutil/certext.c
@@ -1730,7 +1730,7 @@ AddExtensions(void *extHandle, const char *emailAddrs, const char *dnsNames,
}
if (extList[ext_NSCertType].activated) {
- rv = AddNscpCertType(extHandle, extList[ext_extKeyUsage].arg);
+ rv = AddNscpCertType(extHandle, extList[ext_NSCertType].arg);
if (rv) {
errstring = "NSCertType";
break;
diff --git a/security/nss/cmd/certutil/keystuff.c b/security/nss/cmd/certutil/keystuff.c
index ae4003141bcc..1b1852d2737b 100644
--- a/security/nss/cmd/certutil/keystuff.c
+++ b/security/nss/cmd/certutil/keystuff.c
@@ -47,8 +47,10 @@
#if defined(XP_WIN) || defined (XP_PC)
#include
+#ifndef WINCE
#include
#endif
+#endif
#if defined(__sun) && !defined(SVR4)
extern int fclose(FILE*);
@@ -112,7 +114,7 @@ UpdateRNG(void)
/* turn off echo on stdin & return on 1 char instead of NL */
fd = fileno(stdin);
-#if defined(XP_UNIX) && !defined(VMS)
+#if defined(XP_UNIX)
tcgetattr(fd, &tio);
orig_lflag = tio.c_lflag;
orig_cc_min = tio.c_cc[VMIN];
@@ -127,9 +129,7 @@ UpdateRNG(void)
/* Get random noise from keyboard strokes */
count = 0;
while (count < sizeof randbuf) {
-#ifdef VMS
- c = GENERIC_GETCHAR_NOECHO();
-#elif XP_UNIX
+#if defined(XP_UNIX) || defined(WINCE)
c = getc(stdin);
#else
c = getch();
@@ -149,20 +149,15 @@ UpdateRNG(void)
FPS "\n\n");
FPS "Finished. Press enter to continue: ");
-#if defined(VMS)
- while((c = GENERIC_GETCHAR_NO_ECHO()) != '\r' && c != EOF)
- ;
-#else
while ((c = getc(stdin)) != '\n' && c != EOF)
;
-#endif
if (c == EOF)
rv = -1;
FPS "\n");
#undef FPS
-#if defined(XP_UNIX) && !defined(VMS)
+#if defined(XP_UNIX)
/* set back termio the way it was */
tio.c_lflag = orig_lflag;
tio.c_cc[VMIN] = orig_cc_min;
diff --git a/security/nss/cmd/fipstest/fipstest.c b/security/nss/cmd/fipstest/fipstest.c
index 85bb8cfc6ce8..cec04bcce593 100644
--- a/security/nss/cmd/fipstest/fipstest.c
+++ b/security/nss/cmd/fipstest/fipstest.c
@@ -3519,16 +3519,21 @@ hmac_calc(unsigned char *hmac_computed,
void hmac_test(char *reqfn)
{
unsigned int i, j;
- size_t bufSize = 288; /* MAX buffer size */
+ size_t bufSize = 400; /* MAX buffer size */
char *buf = NULL; /* holds one line from the input REQUEST file.*/
unsigned int keyLen; /* Key Length */
- unsigned char key[140]; /* key MAX size = 140 */
+ unsigned char key[200]; /* key MAX size = 184 */
unsigned int msgLen = 128; /* the length of the input */
/* Message is always 128 Bytes */
unsigned char *msg = NULL; /* holds the message to digest.*/
unsigned int HMACLen; /* the length of the HMAC Bytes */
+ unsigned int TLen; /* the length of the requested */
+ /* truncated HMAC Bytes */
unsigned char HMAC[HASH_LENGTH_MAX]; /* computed HMAC */
+ unsigned char expectedHMAC[HASH_LENGTH_MAX]; /* for .fax files that have */
+ /* supplied known answer */
HASH_HashType hash_alg; /* HMAC type */
+
FILE *req = NULL; /* input stream from the REQUEST file */
FILE *resp; /* output stream to the RESPONSE file */
@@ -3546,6 +3551,28 @@ void hmac_test(char *reqfn)
req = fopen(reqfn, "r");
resp = stdout;
while (fgets(buf, bufSize, req) != NULL) {
+ if (strncmp(buf, "Mac", 3) == 0) {
+ i = 3;
+ while (isspace(buf[i]) || buf[i] == '=') {
+ i++;
+ }
+ memset(expectedHMAC, 0, HASH_LENGTH_MAX);
+ for (j=0; isxdigit(buf[i]); i+=2,j++) {
+ hex_to_byteval(&buf[i], &expectedHMAC[j]);
+ }
+ if (memcmp(HMAC, expectedHMAC, TLen) != 0) {
+ fprintf(stderr, "Generate failed:\n");
+ fputs( " expected=", stderr);
+ to_hex_str(buf, expectedHMAC,
+ TLen);
+ fputs(buf, stderr);
+ fputs("\n generated=", stderr);
+ to_hex_str(buf, HMAC,
+ TLen);
+ fputs(buf, stderr);
+ fputc('\n', stderr);
+ }
+ }
/* a comment or blank line */
if (buf[0] == '#' || buf[0] == '\n') {
@@ -3583,7 +3610,7 @@ void hmac_test(char *reqfn)
fputs(buf, resp);
/* zeroize the variables for the test with this data set */
keyLen = 0;
- HMACLen = 0;
+ TLen = 0;
memset(key, 0, sizeof key);
memset(msg, 0, sizeof msg);
memset(HMAC, 0, sizeof HMAC);
@@ -3616,7 +3643,7 @@ void hmac_test(char *reqfn)
while (isspace(buf[i]) || buf[i] == '=') {
i++;
}
- HMACLen = atoi(&buf[i]); /* in bytes */
+ TLen = atoi(&buf[i]); /* in bytes */
fputs(buf, resp);
continue;
}
@@ -3636,7 +3663,7 @@ void hmac_test(char *reqfn)
goto loser;
}
fputs("MAC = ", resp);
- to_hex_str(buf, HMAC, HMACLen);
+ to_hex_str(buf, HMAC, TLen);
fputs(buf, resp);
fputc('\n', resp);
continue;
diff --git a/security/nss/cmd/lib/config.mk b/security/nss/cmd/lib/config.mk
index 665828c63202..1c82d6487285 100644
--- a/security/nss/cmd/lib/config.mk
+++ b/security/nss/cmd/lib/config.mk
@@ -45,3 +45,7 @@ SHARED_LIBRARY =
IMPORT_LIBRARY =
PROGRAM =
+ifeq (WINCE,$(OS_ARCH))
+CSRCS += wincemain.c
+endif
+
diff --git a/security/nss/cmd/lib/secpwd.c b/security/nss/cmd/lib/secpwd.c
index ea4bc31d733d..422fc0a41c8f 100644
--- a/security/nss/cmd/lib/secpwd.c
+++ b/security/nss/cmd/lib/secpwd.c
@@ -63,7 +63,7 @@ static char * quiet_fgets (char *buf, int length, FILE *input);
static void echoOff(int fd)
{
-#if defined(XP_UNIX) && !defined(VMS)
+#if defined(XP_UNIX)
if (isatty(fd)) {
struct termios tio;
tcgetattr(fd, &tio);
@@ -75,7 +75,7 @@ static void echoOff(int fd)
static void echoOn(int fd)
{
-#if defined(XP_UNIX) && !defined(VMS)
+#if defined(XP_UNIX)
if (isatty(fd)) {
struct termios tio;
tcgetattr(fd, &tio);
diff --git a/security/nss/cmd/lib/secutil.c b/security/nss/cmd/lib/secutil.c
index 7a53723e8c62..e9059b44cf2e 100644
--- a/security/nss/cmd/lib/secutil.c
+++ b/security/nss/cmd/lib/secutil.c
@@ -73,11 +73,7 @@
static char consoleName[] = {
#ifdef XP_UNIX
-#ifdef VMS
- "TT"
-#else
"/dev/tty"
-#endif
#else
#ifdef XP_OS2
"\\DEV\\CON"
@@ -3315,6 +3311,56 @@ SEC_PrintCertificateAndTrust(CERTCertificate *cert,
return(SECSuccess);
}
+#if defined(DEBUG) || defined(FORCE_PR_ASSERT)
+/* Returns true iff a[i].flag has a duplicate in a[i+1 : count-1] */
+static PRBool HasShortDuplicate(int i, secuCommandFlag *a, int count)
+{
+ char target = a[i].flag;
+ int j;
+
+ /* duplicate '\0' flags are okay, they are used with long forms */
+ for (j = i+1; j < count; j++) {
+ if (a[j].flag && a[j].flag == target) {
+ return PR_TRUE;
+ }
+ }
+ return PR_FALSE;
+}
+
+/* Returns true iff a[i].longform has a duplicate in a[i+1 : count-1] */
+static PRBool HasLongDuplicate(int i, secuCommandFlag *a, int count)
+{
+ int j;
+ char *target = a[i].longform;
+
+ if (!target)
+ return PR_FALSE;
+
+ for (j = i+1; j < count; j++) {
+ if (a[j].longform && strcmp(a[j].longform, target) == 0) {
+ return PR_TRUE;
+ }
+ }
+ return PR_FALSE;
+}
+
+/* Returns true iff a has no short or long form duplicates
+ */
+PRBool HasNoDuplicates(secuCommandFlag *a, int count)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ if (a[i].flag && HasShortDuplicate(i, a, count)) {
+ return PR_FALSE;
+ }
+ if (a[i].longform && HasLongDuplicate(i, a, count)) {
+ return PR_FALSE;
+ }
+ }
+ return PR_TRUE;
+}
+#endif
SECStatus
SECU_ParseCommandLine(int argc, char **argv, char *progName,
@@ -3328,6 +3374,9 @@ SECU_ParseCommandLine(int argc, char **argv, char *progName,
int i, j;
int lcmd = 0, lopt = 0;
+ PR_ASSERT(HasNoDuplicates(cmd->commands, cmd->numCommands));
+ PR_ASSERT(HasNoDuplicates(cmd->options, cmd->numOptions));
+
optstring = (char *)PORT_Alloc(cmd->numCommands + 2*cmd->numOptions+1);
if (optstring == NULL)
return SECFailure;
diff --git a/embedding/qa/testembed/StdAfx.cpp b/security/nss/cmd/lib/wincemain.c
similarity index 73%
rename from embedding/qa/testembed/StdAfx.cpp
rename to security/nss/cmd/lib/wincemain.c
index 445f03d71c0c..8bb4ca34cce4 100644
--- a/embedding/qa/testembed/StdAfx.cpp
+++ b/security/nss/cmd/lib/wincemain.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -12,15 +11,14 @@
* for the specific language governing rights and limitations under the
* License.
*
- * The Original Code is mozilla.org code.
+ * The Original Code is the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
+ * Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Chak Nanga
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -36,11 +34,32 @@
*
* ***** END LICENSE BLOCK ***** */
-// stdafx.cpp : source file that includes just the standard includes
-// mozembed.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
+#ifdef WINCE
+#include
-#include "stdafx.h"
+int
+wmain(int argc, WCHAR **wargv)
+{
+ char **argv;
+ int i, ret;
+ argv = malloc(argc * sizeof(char*));
+ for (i = 0; i < argc; i++) {
+ int len = WideCharToMultiByte(CP_ACP, 0, wargv[i], -1, NULL, 0, 0, 0);
+ argv[i] = malloc(len * sizeof(char));
+ WideCharToMultiByte(CP_ACP, 0, wargv[i], -1, argv[i], len, 0, 0);
+ }
+
+ ret = main(argc, argv);
+
+ for (i = 0; i < argc; i++) {
+ free(argv[i]);
+ }
+ free(argv);
+
+ return ret;
+}
+
+#endif
diff --git a/security/nss/cmd/pk11mode/pk11mode.c b/security/nss/cmd/pk11mode/pk11mode.c
index 623c6672370c..710e7d01e19d 100644
--- a/security/nss/cmd/pk11mode/pk11mode.c
+++ b/security/nss/cmd/pk11mode/pk11mode.c
@@ -780,7 +780,7 @@ cleanup:
free(dbPrefix);
}
if (moduleSpec) {
- free(moduleSpec);
+ PR_smprintf_free(moduleSpec);
}
#ifdef _WIN32
diff --git a/security/nss/cmd/pk12util/pk12util.c b/security/nss/cmd/pk12util/pk12util.c
index d1b6e8c4298b..dc08a60098e7 100644
--- a/security/nss/cmd/pk12util/pk12util.c
+++ b/security/nss/cmd/pk12util/pk12util.c
@@ -57,18 +57,22 @@ static void
Usage(char *progName)
{
#define FPS PR_fprintf(PR_STDERR,
- FPS "Usage: %s -i importfile [-d certdir] [-P dbprefix] [-h tokenname] [-v]\n",
+ FPS "Usage: %s -i importfile [-d certdir] [-P dbprefix] [-h tokenname]\n",
progName);
FPS "\t\t [-k slotpwfile | -K slotpw] [-w p12filepwfile | -W p12filepw]\n");
+ FPS "\t\t [-v]\n");
- FPS "Usage: %s -l listfile [-d certdir] [-P dbprefix] [-h tokenname] [-r]\n",
+ FPS "Usage: %s -l listfile [-d certdir] [-P dbprefix] [-h tokenname]\n",
progName);
FPS "\t\t [-k slotpwfile | -K slotpw] [-w p12filepwfile | -W p12filepw]\n");
+ FPS "\t\t [-v]\n");
- FPS "Usage: %s -o exportfile -n certname [-d certdir] [-P dbprefix] [-v]\n",
- progName);
- FPS "\t\t [-c key_cipher] [-C cert_cipher] [-m | --key_len keyLen] [-n | --cert_key_len certKeyLen]\n");
- FPS "\t\t [-k slotpwfile | -K slotpw] [-w p12filepwfile | -W p12filefilepw]\n");
+ FPS "Usage: %s -o exportfile -n certname [-d certdir] [-P dbprefix]\n",
+ progName);
+ FPS "\t\t [-c key_cipher] [-C cert_cipher]\n"
+ "\t\t [-m | --key_len keyLen] [--cert_key_len certKeyLen] [-v]\n");
+ FPS "\t\t [-k slotpwfile | -K slotpw]\n"
+ "\t\t [-w p12filepwfile | -W p12filefilepw]\n");
exit(PK12UERR_USAGE);
}
@@ -955,7 +959,7 @@ static secuCommandFlag pk12util_options[] =
{ /* opt_Cipher */ 'c', PR_TRUE, 0, PR_FALSE },
{ /* opt_CertCipher */ 'C', PR_TRUE, 0, PR_FALSE },
{ /* opt_KeyLength */ 'm', PR_TRUE, 0, PR_FALSE, "key_len" },
- { /* opt_CertKeyLength */ 'n', PR_TRUE, 0, PR_FALSE, "cert_key_len" }
+ { /* opt_CertKeyLength */ 0, PR_TRUE, 0, PR_FALSE, "cert_key_len" }
};
int
diff --git a/security/nss/cmd/platlibs.mk b/security/nss/cmd/platlibs.mk
index 18b480e438a9..ab8024386bda 100644
--- a/security/nss/cmd/platlibs.mk
+++ b/security/nss/cmd/platlibs.mk
@@ -51,12 +51,20 @@ endif
endif
ifeq ($(OS_ARCH), Linux)
+ifeq ($(BUILD_SUN_PKG), 1)
+ifeq ($(USE_64), 1)
+EXTRA_SHARED_LIBS += -Wl,-rpath,'$$ORIGIN/../lib64:/opt/sun/private/lib64:$$ORIGIN/../lib'
+else
+EXTRA_SHARED_LIBS += -Wl,-rpath,'$$ORIGIN/../lib:/opt/sun/private/lib'
+endif
+else
ifeq ($(USE_64), 1)
EXTRA_SHARED_LIBS += -Wl,-rpath,'$$ORIGIN/../lib64:$$ORIGIN/../lib'
else
EXTRA_SHARED_LIBS += -Wl,-rpath,'$$ORIGIN/../lib'
endif
endif
+endif
ifeq ($(OS_ARCH), HP-UX)
ifeq ($(OS_TEST), ia64)
@@ -83,7 +91,7 @@ endif
ifdef USE_STATIC_LIBS
# can't do this in manifest.mn because OS_ARCH isn't defined there.
-ifeq ($(OS_ARCH), WINNT)
+ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
DEFINES += -DNSS_USE_STATIC_LIBS
# $(PROGRAM) has explicit dependencies on $(EXTRA_LIBS)
@@ -203,7 +211,7 @@ endif
else # USE_STATIC_LIBS
# can't do this in manifest.mn because OS_ARCH isn't defined there.
-ifeq ($(OS_ARCH), WINNT)
+ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
# $(PROGRAM) has explicit dependencies on $(EXTRA_LIBS)
EXTRA_LIBS += \
diff --git a/security/nss/cmd/sdrtest/sdrtest.c b/security/nss/cmd/sdrtest/sdrtest.c
index 35199dadb3c1..abdbab418fb4 100644
--- a/security/nss/cmd/sdrtest/sdrtest.c
+++ b/security/nss/cmd/sdrtest/sdrtest.c
@@ -37,7 +37,7 @@
/*
* Test program for SDR (Secret Decoder Ring) functions.
*
- * $Id: sdrtest.c,v 1.14 2008/03/10 20:16:44 rrelyea%redhat.com Exp $
+ * $Id: sdrtest.c,v 1.16 2009/07/08 21:37:43 julien.pierre.boogz%sun.com Exp $
*/
#include "nspr.h"
@@ -113,7 +113,7 @@ readStdin(SECItem * result)
result->data = NULL;
do {
if (bufsize < wanted) {
- unsigned char * tmpData = (unsigned char *)realloc(result->data, wanted);
+ unsigned char * tmpData = (unsigned char *)PR_Realloc(result->data, wanted);
if (!tmpData) {
if (verbose) PR_fprintf(pr_stderr, "Allocation of buffer failed\n");
return -1;
@@ -153,7 +153,7 @@ readInputFile(const char * filename, SECItem * result)
}
result->len = info.size;
- result->data = (unsigned char *)malloc(result->len);
+ result->data = (unsigned char *)PR_Malloc(result->len);
if (!result->data) {
if (verbose) PR_fprintf(pr_stderr, "Allocation of buffer failed\n");
goto file_loser;
@@ -313,7 +313,7 @@ main (int argc, char **argv)
retval = -1;
goto loser;
}
- free(result.data);
+ SECITEM_ZfreeItem(&result, PR_FALSE);
result = *ok;
}
}
@@ -436,8 +436,8 @@ main (int argc, char **argv)
}
loser:
- if (text.data) free(text.data);
- if (result.data) free(result.data);
+ if (text.data) SECITEM_ZfreeItem(&text, PR_FALSE);
+ if (result.data) SECITEM_ZfreeItem(&result, PR_FALSE);
if (NSS_Shutdown() != SECSuccess) {
exit(1);
}
diff --git a/security/nss/cmd/shlibsign/sign.sh b/security/nss/cmd/shlibsign/sign.sh
index 764012d7b8c2..26cc73ad341a 100644
--- a/security/nss/cmd/shlibsign/sign.sh
+++ b/security/nss/cmd/shlibsign/sign.sh
@@ -21,24 +21,6 @@ WIN*)
echo ${2}/shlibsign -v -i ${5}
${2}/shlibsign -v -i ${5}
;;
-OpenVMS)
- temp="tmp$$.tmp"
- temp2="tmp$$.tmp2"
- cd ${1}/lib
- vmsdir=`dcl show default`
- ls *.so > $temp
- sed -e "s/\([^\.]*\)\.so/\$ define\/job \1 ${vmsdir}\1.so/" $temp > $temp2
- echo '$ define/job getipnodebyname xxx' >> $temp2
- echo '$ define/job vms_null_dl_name sys$share:decc$shr' >> $temp2
- dcl @$temp2
- echo ${2}/shlibsign -v -i ${5}
- ${2}/shlibsign -v -i ${5}
- sed -e "s/\([^\.]*\)\.so/\$ deass\/job \1/" $temp > $temp2
- echo '$ deass/job getipnodebyname' >> $temp2
- echo '$ deass/job vms_null_dl_name' >> $temp2
- dcl @$temp2
- rm $temp $temp2
- ;;
*)
LIBPATH=`(cd ${1}/lib; pwd)`:`(cd ${4}; pwd)`:$LIBPATH
export LIBPATH
diff --git a/embedding/qa/mozembed/src/nsQAWindowCreator.h b/security/nss/cmd/tests/baddbdir.c
similarity index 68%
rename from embedding/qa/mozembed/src/nsQAWindowCreator.h
rename to security/nss/cmd/tests/baddbdir.c
index 8baf4b1354f8..c676a7f59bc3 100644
--- a/embedding/qa/mozembed/src/nsQAWindowCreator.h
+++ b/security/nss/cmd/tests/baddbdir.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -12,11 +11,11 @@
* for the specific language governing rights and limitations under the
* License.
*
- * The Original Code is mozilla.org Code.
+ * The Original Code is the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
+ * Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
@@ -35,21 +34,35 @@
*
* ***** END LICENSE BLOCK ***** */
-#ifndef __WindowCreator_h_
-#define __WindowCreator_h_
+#include
+#include
-#include "nsIWindowCreator.h"
+#include "nss.h"
+#include "secerr.h"
-class WindowCreator :
- public nsIWindowCreator
+/*
+ * Regression test for bug 495097.
+ *
+ * NSS_InitReadWrite("sql:") should fail with SEC_ERROR_BAD_DATABASE
+ * if the directory doesn't exist.
+ */
+
+int main()
{
-public:
- WindowCreator();
- virtual ~WindowCreator();
-
- NS_DECL_ISUPPORTS
- NS_DECL_NSIWINDOWCREATOR
-};
-
-#endif
+ SECStatus status;
+ int error;
+ status = NSS_InitReadWrite("sql:/no/such/db/dir");
+ if (status == SECSuccess) {
+ fprintf(stderr, "NSS_InitReadWrite succeeded unexpectedly\n");
+ exit(1);
+ }
+ error = PORT_GetError();
+ if (error != SEC_ERROR_BAD_DATABASE) {
+ fprintf(stderr, "NSS_InitReadWrite failed with the wrong error code: "
+ "%d\n", error);
+ exit(1);
+ }
+ printf("PASS\n");
+ return 0;
+}
diff --git a/security/nss/cmd/tests/manifest.mn b/security/nss/cmd/tests/manifest.mn
index 1418d08f3462..e53c06c281fc 100644
--- a/security/nss/cmd/tests/manifest.mn
+++ b/security/nss/cmd/tests/manifest.mn
@@ -41,6 +41,7 @@ CORE_DEPTH = ../../..
MODULE = nss
CSRCS = \
+ baddbdir.c \
conflict.c \
nonspr10.c \
remtest.c \
diff --git a/security/nss/cmd/zlib/README b/security/nss/cmd/zlib/README
index 758cc50020df..92639fcea000 100644
--- a/security/nss/cmd/zlib/README
+++ b/security/nss/cmd/zlib/README
@@ -17,7 +17,7 @@ minigzip.c.
To compile all files and run the test program, follow the instructions given at
the top of Makefile. In short "make test; make install" should work for most
machines. For Unix: "./configure; make test; make install". For MSDOS, use one
-of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
+of the special makefiles such as Makefile.msc.
Questions about zlib should be sent to , or to Gilles Vollant
for the Windows DLL version. The zlib home page is
diff --git a/security/nss/cmd/zlib/example.c b/security/nss/cmd/zlib/example.c
index 60af6555d258..7a0dd53d6b57 100644
--- a/security/nss/cmd/zlib/example.c
+++ b/security/nss/cmd/zlib/example.c
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id: example.c,v 1.5 2005/07/20 20:32:42 wtchang%redhat.com Exp $ */
+/* @(#) $Id: example.c,v 1.6 2009/06/05 02:22:16 nelson%bolyard.com Exp $ */
#include
#include "zlib.h"
@@ -13,7 +13,7 @@
# include
#endif
-#if defined(VMS) || defined(RISCOS)
+#if defined(RISCOS)
# define TESTFILE "foo-gz"
#else
# define TESTFILE "foo.gz"
diff --git a/security/nss/cmd/zlib/minigzip.c b/security/nss/cmd/zlib/minigzip.c
index 1ba90511b9ee..6a2cb1e348be 100644
--- a/security/nss/cmd/zlib/minigzip.c
+++ b/security/nss/cmd/zlib/minigzip.c
@@ -13,7 +13,7 @@
* or in pipe mode.
*/
-/* @(#) $Id: minigzip.c,v 1.5 2005/07/20 20:32:42 wtchang%redhat.com Exp $ */
+/* @(#) $Id: minigzip.c,v 1.6 2009/06/05 02:22:16 nelson%bolyard.com Exp $ */
#include
#include "zlib.h"
@@ -37,10 +37,6 @@
# define SET_BINARY_MODE(file)
#endif
-#ifdef VMS
-# define unlink delete
-# define GZ_SUFFIX "-gz"
-#endif
#ifdef RISCOS
# define unlink remove
# define GZ_SUFFIX "-gz"
diff --git a/security/nss/cmd/zlib/zconf.h b/security/nss/cmd/zlib/zconf.h
index 8bd43a0bdde8..b82426c68fc2 100644
--- a/security/nss/cmd/zlib/zconf.h
+++ b/security/nss/cmd/zlib/zconf.h
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id: zconf.h,v 1.6 2005/07/20 20:32:42 wtchang%redhat.com Exp $ */
+/* @(#) $Id: zconf.h,v 1.7 2009/06/05 02:22:17 nelson%bolyard.com Exp $ */
#ifndef ZCONF_H
#define ZCONF_H
@@ -284,14 +284,6 @@ typedef uLong FAR uLongf;
typedef Byte *voidp;
#endif
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
-# include /* for off_t */
-# include /* for SEEK_* and off_t */
-# ifdef VMS
-# include /* for off_t */
-# endif
-# define z_off_t off_t
-#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
diff --git a/security/nss/cmd/zlib/zutil.h b/security/nss/cmd/zlib/zutil.h
index 1129e1db5445..1f700ada4e65 100644
--- a/security/nss/cmd/zlib/zutil.h
+++ b/security/nss/cmd/zlib/zutil.h
@@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h.
*/
-/* @(#) $Id: zutil.h,v 1.7 2007/12/01 02:16:10 julien.pierre.boogz%sun.com Exp $ */
+/* @(#) $Id: zutil.h,v 1.8 2009/06/05 02:22:17 nelson%bolyard.com Exp $ */
#ifndef ZUTIL_H
#define ZUTIL_H
@@ -105,7 +105,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define OS_CODE 0x01
#endif
-#if defined(VAXC) || defined(VMS)
+#if defined(VAXC)
# define OS_CODE 0x02
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
@@ -205,9 +205,6 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define NO_vsnprintf
# endif
#endif
-#ifdef VMS
-# define NO_vsnprintf
-#endif
#if defined(pyr)
# define NO_MEMCPY
diff --git a/security/nss/lib/certdb/cert.h b/security/nss/lib/certdb/cert.h
index 0e934a57f4e6..9152583ca16a 100644
--- a/security/nss/lib/certdb/cert.h
+++ b/security/nss/lib/certdb/cert.h
@@ -37,7 +37,7 @@
/*
* cert.h - public data structures and prototypes for the certificate library
*
- * $Id: cert.h,v 1.77 2009/04/17 22:46:27 julien.pierre.boogz%sun.com Exp $
+ * $Id: cert.h,v 1.78 2009/05/14 01:33:36 julien.pierre.boogz%sun.com Exp $
*/
#ifndef _CERT_H_
@@ -1610,25 +1610,25 @@ CERT_EncodeNoticeReference(PLArenaPool *arena,
* Returns a pointer to a static structure.
*/
extern const CERTRevocationFlags*
-CERT_GetPKIXVerifyNistRevocationPolicy();
+CERT_GetPKIXVerifyNistRevocationPolicy(void);
/*
* Returns a pointer to a static structure.
*/
extern const CERTRevocationFlags*
-CERT_GetClassicOCSPEnabledSoftFailurePolicy();
+CERT_GetClassicOCSPEnabledSoftFailurePolicy(void);
/*
* Returns a pointer to a static structure.
*/
extern const CERTRevocationFlags*
-CERT_GetClassicOCSPEnabledHardFailurePolicy();
+CERT_GetClassicOCSPEnabledHardFailurePolicy(void);
/*
* Returns a pointer to a static structure.
*/
extern const CERTRevocationFlags*
-CERT_GetClassicOCSPDisabledPolicy();
+CERT_GetClassicOCSPDisabledPolicy(void);
/*
* Verify a Cert with libpkix
@@ -1662,7 +1662,7 @@ SECStatus CERT_SetUsePKIXForValidation(PRBool enable);
/* The function return PR_TRUE if cert validation should use
* libpkix cert validation engine. */
-PRBool CERT_GetUsePKIXForValidation();
+PRBool CERT_GetUsePKIXForValidation(void);
SEC_END_PROTOS
diff --git a/security/nss/lib/certdb/certdb.c b/security/nss/lib/certdb/certdb.c
index 54b6420b2830..481b64bd71e5 100644
--- a/security/nss/lib/certdb/certdb.c
+++ b/security/nss/lib/certdb/certdb.c
@@ -39,7 +39,7 @@
/*
* Certificate handling code
*
- * $Id: certdb.c,v 1.100 2009/03/23 02:18:19 nelson%bolyard.com Exp $
+ * $Id: certdb.c,v 1.101 2009/05/18 21:33:25 nelson%bolyard.com Exp $
*/
#include "nssilock.h"
@@ -1739,7 +1739,7 @@ cert_GetDNSPatternsFromGeneralNames(CERTGeneralName *firstName,
return SECFailure;
PORT_Memcpy(cn, currentInput->name.other.data,
currentInput->name.other.len);
- cn[currentInput->name.other.len + 1] = 0;
+ cn[currentInput->name.other.len] = 0;
break;
case certIPAddress:
if (currentInput->name.other.len == 4) {
@@ -1751,7 +1751,7 @@ cert_GetDNSPatternsFromGeneralNames(CERTGeneralName *firstName,
memcpy(&addr.ipv6.ip, currentInput->name.other.data,
currentInput->name.other.len);
}
- if (PR_NetAddrToString(&addr, ipbuf, sizeof(ipbuf) == PR_FAILURE))
+ if (PR_NetAddrToString(&addr, ipbuf, sizeof(ipbuf)) == PR_FAILURE)
return SECFailure;
cn = PORT_ArenaStrdup(nickNames->arena, ipbuf);
if (!cn)
diff --git a/security/nss/lib/certdb/certdb.h b/security/nss/lib/certdb/certdb.h
index 966d665f3e66..c489b0f89ee1 100644
--- a/security/nss/lib/certdb/certdb.h
+++ b/security/nss/lib/certdb/certdb.h
@@ -63,7 +63,7 @@ CERTSignedCrl *
SEC_FindCrlByDERCert(CERTCertDBHandle *handle, SECItem *derCrl, int type);
PRBool
-SEC_CertNicknameConflict(char *nickname, SECItem *derSubject,
+SEC_CertNicknameConflict(const char *nickname, SECItem *derSubject,
CERTCertDBHandle *handle);
CERTSignedCrl *
SEC_NewCrl(CERTCertDBHandle *handle, char *url, SECItem *derCrl, int type);
diff --git a/security/nss/lib/certdb/certt.h b/security/nss/lib/certdb/certt.h
index b75d76872b1a..64cbb8757dcc 100644
--- a/security/nss/lib/certdb/certt.h
+++ b/security/nss/lib/certdb/certt.h
@@ -36,7 +36,7 @@
/*
* certt.h - public data structures for the certificate library
*
- * $Id: certt.h,v 1.50 2009/04/24 19:18:32 nelson%bolyard.com Exp $
+ * $Id: certt.h,v 1.52 2009/05/29 18:10:38 alexei.volkov.bugs%sun.com Exp $
*/
#ifndef _CERTT_H_
#define _CERTT_H_
@@ -940,12 +940,17 @@ typedef enum {
cert_pi_certStores = 10,/* Bitmask of Cert Store flags (see below)
* Set in value.scalar.ui */
cert_pi_trustAnchors = 11,/* Specify the list of trusted roots to
- * validate against. If the list in NULL all
- * default trusted roots are used.
+ * validate against.
+ * The default set of trusted roots, these are
+ * root CA certs from libnssckbi.so or CA
+ * certs trusted by user, are used in any of
+ * the following cases:
+ * * when the parameter is not set.
+ * * when the list of trust anchors is empty.
* Specified in value.pointer.chain */
cert_pi_useAIACertFetch = 12, /* Enables cert fetching using AIA extension.
- * Default is off.
- * Value is in value.scalar.b */
+ * In NSS 3.12.1 or later. Default is off.
+ * Value is in value.scalar.b */
cert_pi_max /* SPECIAL: signifies maximum allowed value,
* can increase in future releases */
} CERTValParamInType;
diff --git a/security/nss/lib/certdb/crl.c b/security/nss/lib/certdb/crl.c
index 4f52bc7c1bdd..f79b913d9d7c 100644
--- a/security/nss/lib/certdb/crl.c
+++ b/security/nss/lib/certdb/crl.c
@@ -37,7 +37,7 @@
/*
* Moved from secpkcs7.c
*
- * $Id: crl.c,v 1.66 2009/04/21 22:53:58 julien.pierre.boogz%sun.com Exp $
+ * $Id: crl.c,v 1.67 2009/05/13 22:47:28 julien.pierre.boogz%sun.com Exp $
*/
#include "cert.h"
@@ -3136,6 +3136,7 @@ static SECStatus addCRLToCache(CERTCertDBHandle* dbhandle, SECItem* crl,
rv = SECFailure;
/* no need to keep unused CRL around */
SECITEM_ZfreeItem(entry->crl, PR_TRUE);
+ entry->crl = NULL;
}
return rv;
}
@@ -3206,6 +3207,10 @@ SECStatus cert_CacheCRLByGeneralName(CERTCertDBHandle* dbhandle, SECItem* crl,
if (!removed)
{
rv = SECFailure;
+ /* leak old entry since we couldn't remove it from the hash table */
+ }
+ else
+ {
rv2 = NamedCRLCacheEntry_Destroy(oldEntry);
PORT_Assert(SECSuccess == rv2);
}
@@ -3249,7 +3254,11 @@ SECStatus cert_CacheCRLByGeneralName(CERTCertDBHandle* dbhandle, SECItem* crl,
PORT_Assert(removed);
if (!removed)
{
+ /* leak old entry since we couldn't remove it from the hash table */
rv = SECFailure;
+ }
+ else
+ {
rv2 = NamedCRLCacheEntry_Destroy(oldEntry);
PORT_Assert(SECSuccess == rv2);
}
diff --git a/security/nss/lib/certdb/stanpcertdb.c b/security/nss/lib/certdb/stanpcertdb.c
index 6dde1b1bd688..da0d7bc0371d 100644
--- a/security/nss/lib/certdb/stanpcertdb.c
+++ b/security/nss/lib/certdb/stanpcertdb.c
@@ -63,7 +63,7 @@
#include "dev.h"
PRBool
-SEC_CertNicknameConflict(char *nickname, SECItem *derSubject,
+SEC_CertNicknameConflict(const char *nickname, SECItem *derSubject,
CERTCertDBHandle *handle)
{
CERTCertificate *cert;
diff --git a/security/nss/lib/certhigh/certvfypkix.c b/security/nss/lib/certhigh/certvfypkix.c
index 45065c074266..e437953eee3f 100644
--- a/security/nss/lib/certhigh/certvfypkix.c
+++ b/security/nss/lib/certhigh/certvfypkix.c
@@ -1690,7 +1690,11 @@ cert_pkixSetParam(PKIX_ProcessingParams *procParams,
case cert_pi_trustAnchors:
certList = param->value.pointer.chain;
-
+ if (!certList) {
+ PORT_SetError(errCode);
+ r = SECFailure;
+ break;
+ }
error = PKIX_List_Create(&certListPkix, plContext);
if (error != NULL) {
break;
diff --git a/security/nss/lib/certhigh/ocsp.c b/security/nss/lib/certhigh/ocsp.c
index 76a571767fbf..1516b1bdf50b 100644
--- a/security/nss/lib/certhigh/ocsp.c
+++ b/security/nss/lib/certhigh/ocsp.c
@@ -39,7 +39,7 @@
* Implementation of OCSP services, for both client and server.
* (XXX, really, mostly just for client right now, but intended to do both.)
*
- * $Id: ocsp.c,v 1.58 2009/03/21 01:40:35 nelson%bolyard.com Exp $
+ * $Id: ocsp.c,v 1.59 2009/06/10 22:59:09 julien.pierre.boogz%sun.com Exp $
*/
#include "prerror.h"
@@ -730,7 +730,7 @@ ocsp_FreshenCacheItemNextFetchAttemptTime(OCSPCacheItem *cacheItem)
}
if (cacheItem->haveNextUpdate) {
- OCSP_TRACE_TIME("have nextUpdate:", cacheItem->thisUpdate);
+ OCSP_TRACE_TIME("have nextUpdate:", cacheItem->nextUpdate);
}
if (cacheItem->haveNextUpdate &&
diff --git a/security/nss/lib/ckfw/Makefile b/security/nss/lib/ckfw/Makefile
index cf42da56583a..f686f59f73f4 100644
--- a/security/nss/lib/ckfw/Makefile
+++ b/security/nss/lib/ckfw/Makefile
@@ -34,14 +34,14 @@
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
-MAKEFILE_CVS_ID = "@(#) $RCSfile: Makefile,v $ $Revision: 1.16 $ $Date: 2008/12/03 18:44:24 $"
+MAKEFILE_CVS_ID = "@(#) $RCSfile: Makefile,v $ $Revision: 1.17 $ $Date: 2009/05/22 01:03:30 $"
include manifest.mn
include $(CORE_DEPTH)/coreconf/config.mk
include config.mk
include $(CORE_DEPTH)/coreconf/rules.mk
-ifdef MOZILLA_CLIENT
+ifdef NOTDEF # was ifdef MOZILLA_CLIENT
NSS_BUILD_CAPI = 1
endif
diff --git a/security/nss/lib/ckfw/builtins/config.mk b/security/nss/lib/ckfw/builtins/config.mk
index c28c02b1c1a5..fc7779a61e37 100644
--- a/security/nss/lib/ckfw/builtins/config.mk
+++ b/security/nss/lib/ckfw/builtins/config.mk
@@ -34,7 +34,7 @@
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
-CONFIG_CVS_ID = "@(#) $RCSfile: config.mk,v $ $Revision: 1.13 $ $Date: 2009/03/20 07:19:36 $"
+CONFIG_CVS_ID = "@(#) $RCSfile: config.mk,v $ $Revision: 1.14 $ $Date: 2009/06/11 00:55:34 $"
#
# Override TARGETS variable so that only shared libraries
@@ -65,17 +65,3 @@ DSO_LDOPTS = -bundle
endif
endif
-ifeq ($(OS_TARGET),SunOS)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-MKSHLIB += -R '$$ORIGIN'
-endif
-
-ifeq ($(OS_ARCH), HP-UX)
-ifneq ($(OS_TEST), ia64)
-# pa-risc
-ifeq ($(USE_64), 1)
-MKSHLIB += +b '$$ORIGIN'
-endif
-endif
-endif
diff --git a/security/nss/lib/ckfw/capi/config.mk b/security/nss/lib/ckfw/capi/config.mk
index 589b4a39356d..b9ae8038d522 100644
--- a/security/nss/lib/ckfw/capi/config.mk
+++ b/security/nss/lib/ckfw/capi/config.mk
@@ -34,7 +34,7 @@
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
-CONFIG_CVS_ID = "@(#) $RCSfile: config.mk,v $ $Revision: 1.2 $ $Date: 2009/03/20 07:19:45 $"
+CONFIG_CVS_ID = "@(#) $RCSfile: config.mk,v $ $Revision: 1.3 $ $Date: 2009/06/11 00:55:42 $"
#
# Override TARGETS variable so that only shared libraries
@@ -65,9 +65,3 @@ DSO_LDOPTS = -bundle
endif
endif
-ifeq ($(OS_TARGET),SunOS)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-MKSHLIB += -R '$$ORIGIN'
-endif
-
diff --git a/security/nss/lib/ckfw/sessobj.c b/security/nss/lib/ckfw/sessobj.c
index 206f3d4f0364..66a16d2dbf48 100644
--- a/security/nss/lib/ckfw/sessobj.c
+++ b/security/nss/lib/ckfw/sessobj.c
@@ -35,7 +35,7 @@
* ***** END LICENSE BLOCK ***** */
#ifdef DEBUG
-static const char CVS_ID[] = "@(#) $RCSfile: sessobj.c,v $ $Revision: 1.14 $ $Date: 2009/02/09 07:55:53 $";
+static const char CVS_ID[] = "@(#) $RCSfile: sessobj.c,v $ $Revision: 1.15 $ $Date: 2009/06/05 00:22:04 $";
#endif /* DEBUG */
/*
@@ -706,18 +706,15 @@ nss_ckmdSessionObject_SetAttribute
nss_ZFreeIf(n.data);
return CKR_HOST_MEMORY;
}
+ obj->attributes = ra;
- rt = (CK_ATTRIBUTE_TYPE_PTR)nss_ZRealloc(obj->types, (obj->n + 1));
- if( (CK_ATTRIBUTE_TYPE_PTR)NULL == rt ) {
+ rt = (CK_ATTRIBUTE_TYPE_PTR)nss_ZRealloc(obj->types,
+ sizeof(CK_ATTRIBUTE_TYPE) * (obj->n + 1));
+ if (!rt) {
nss_ZFreeIf(n.data);
- obj->attributes = (NSSItem *)nss_ZRealloc(ra, sizeof(NSSItem) * obj->n);
- if (!obj->attributes) {
- return CKR_GENERAL_ERROR;
- }
return CKR_HOST_MEMORY;
}
- obj->attributes = ra;
obj->types = rt;
obj->attributes[obj->n] = n;
obj->types[obj->n] = attribute;
diff --git a/security/nss/lib/cryptohi/seckey.c b/security/nss/lib/cryptohi/seckey.c
index 963b985de5dd..b1ddf93d960a 100644
--- a/security/nss/lib/cryptohi/seckey.c
+++ b/security/nss/lib/cryptohi/seckey.c
@@ -258,11 +258,17 @@ SECKEY_CreateECPrivateKey(SECKEYECParams *param, SECKEYPublicKey **pubk, void *c
return NULL;
}
- privk = PK11_GenerateKeyPair(slot, CKM_EC_KEY_PAIR_GEN, param,
- pubk, PR_FALSE, PR_FALSE, cx);
+ privk = PK11_GenerateKeyPairWithOpFlags(slot, CKM_EC_KEY_PAIR_GEN,
+ param, pubk,
+ PK11_ATTR_SESSION | PK11_ATTR_INSENSITIVE |
+ PK11_ATTR_PUBLIC,
+ CKF_DERIVE, CKF_DERIVE|CKF_SIGN,cx);
if (!privk)
- privk = PK11_GenerateKeyPair(slot, CKM_EC_KEY_PAIR_GEN, param,
- pubk, PR_FALSE, PR_TRUE, cx);
+ privk = PK11_GenerateKeyPairWithOpFlags(slot, CKM_EC_KEY_PAIR_GEN,
+ param, pubk,
+ PK11_ATTR_SESSION | PK11_ATTR_SENSITIVE |
+ PK11_ATTR_PRIVATE,
+ CKF_DERIVE, CKF_DERIVE|CKF_SIGN,cx);
PK11_FreeSlot(slot);
return(privk);
diff --git a/security/nss/lib/freebl/Makefile b/security/nss/lib/freebl/Makefile
index 27848ce25300..32714966bf8c 100644
--- a/security/nss/lib/freebl/Makefile
+++ b/security/nss/lib/freebl/Makefile
@@ -94,6 +94,14 @@ ifeq ($(OS_TARGET),OSF1)
MPI_SRCS += mpvalpha.c
endif
+ifeq (OS2,$(OS_TARGET))
+ ASFILES = mpi_x86_os2.s
+ DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
+ DEFINES += -DMP_ASSEMBLY_DIV_2DX1D
+ DEFINES += -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD
+ DEFINES += -DMP_CHAR_STORE_SLOW -DMP_IS_LITTLE_ENDIAN
+endif
+
ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET))) #omits WINCE
ifndef USE_64
# 32-bit Windows
@@ -222,9 +230,6 @@ endif
ifeq ($(OS_TARGET),SunOS)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-MKSHLIB += -R '$$ORIGIN'
ifdef NS_USE_GCC
ifdef GCC_USE_GNU_LD
MKSHLIB += -Wl,-Bsymbolic,-z,now,-z,text
diff --git a/security/nss/lib/freebl/des.c b/security/nss/lib/freebl/des.c
index 9eee162a5603..a3541ba7a7a2 100644
--- a/security/nss/lib/freebl/des.c
+++ b/security/nss/lib/freebl/des.c
@@ -403,6 +403,11 @@ static const HALF PC2[8][64] = {
#if defined(__GNUC__) && defined(NSS_X86_OR_X64)
#define BYTESWAP(word, temp) \
__asm("bswap %0" : "+r" (word));
+#elif (_MSC_VER >= 1300) && defined(NSS_X86_OR_X64)
+#include
+#pragma intrinsic(_byteswap_ulong)
+#define BYTESWAP(word, temp) \
+ word = _byteswap_ulong(word);
#else
#define BYTESWAP(word, temp) \
word = (word >> 16) | (word << 16); \
diff --git a/security/nss/lib/freebl/drbg.c b/security/nss/lib/freebl/drbg.c
index bd9339629449..fb8513386dfe 100644
--- a/security/nss/lib/freebl/drbg.c
+++ b/security/nss/lib/freebl/drbg.c
@@ -36,7 +36,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-/* $Id: drbg.c,v 1.8 2009/04/01 03:37:29 wtc%google.com Exp $ */
+/* $Id: drbg.c,v 1.9 2009/06/10 03:24:01 rrelyea%redhat.com Exp $ */
#ifdef FREEBL_NO_DEPEND
#include "stubs.h"
@@ -381,6 +381,9 @@ static PRStatus rng_init(void)
PRUint8 bytes[PRNG_SEEDLEN*2]; /* entropy + nonce */
unsigned int numBytes;
if (globalrng == NULL) {
+ /* bytes needs to have enough space to hold
+ * a SHA256 hash value. Blow up at compile time if this isn't true */
+ PR_STATIC_ASSERT(sizeof(bytes) >= SHA256_LENGTH);
/* create a new global RNG context */
globalrng = &theGlobalRng;
PORT_Assert(NULL == globalrng->lock);
@@ -414,6 +417,10 @@ static PRStatus rng_init(void)
/* the RNG is in a valid state */
globalrng->isValid = PR_TRUE;
+ /* fetch one random value so that we can populate rng->oldV for our
+ * continous random number test. */
+ prng_generateNewBytes(globalrng, bytes, SHA256_LENGTH, NULL, 0);
+
/* Fetch more entropy into the PRNG */
RNG_SystemInfoForRNG();
}
diff --git a/security/nss/lib/freebl/mpi/mpi_x86_os2.s b/security/nss/lib/freebl/mpi/mpi_x86_os2.s
new file mode 100644
index 000000000000..c0fabc2b72de
--- /dev/null
+++ b/security/nss/lib/freebl/mpi/mpi_x86_os2.s
@@ -0,0 +1,573 @@
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# 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 the Netscape security libraries.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2000
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# $Id: mpi_x86_os2.s,v 1.1 2009/06/04 23:53:42 julien.pierre.boogz%sun.com Exp $
+#
+
+.data
+.align 4
+ #
+ # -1 means to call _s_mpi_is_sse to determine if we support sse
+ # instructions.
+ # 0 means to use x86 instructions
+ # 1 means to use sse2 instructions
+.type is_sse,@object
+.size is_sse,4
+is_sse: .long -1
+
+#
+# sigh, handle the difference between -fPIC and not PIC
+# default to pic, since this file seems to be exclusively
+# linux right now (solaris uses mpi_i86pc.s and windows uses
+# mpi_x86_asm.c)
+#
+#.ifndef NO_PIC
+#.macro GET var,reg
+# movl \var@GOTOFF(%ebx),\reg
+#.endm
+#.macro PUT reg,var
+# movl \reg,\var@GOTOFF(%ebx)
+#.endm
+#.else
+.macro GET var,reg
+ movl \var,\reg
+.endm
+.macro PUT reg,var
+ movl \reg,\var
+.endm
+#.endif
+
+.text
+
+
+ # ebp - 36: caller's esi
+ # ebp - 32: caller's edi
+ # ebp - 28:
+ # ebp - 24:
+ # ebp - 20:
+ # ebp - 16:
+ # ebp - 12:
+ # ebp - 8:
+ # ebp - 4:
+ # ebp + 0: caller's ebp
+ # ebp + 4: return address
+ # ebp + 8: a argument
+ # ebp + 12: a_len argument
+ # ebp + 16: b argument
+ # ebp + 20: c argument
+ # registers:
+ # eax:
+ # ebx: carry
+ # ecx: a_len
+ # edx:
+ # esi: a ptr
+ # edi: c ptr
+.globl _s_mpv_mul_d
+.type _s_mpv_mul_d,@function
+_s_mpv_mul_d:
+ GET is_sse,%eax
+ cmp $0,%eax
+ je _s_mpv_mul_d_x86
+ jg _s_mpv_mul_d_sse2
+ call _s_mpi_is_sse2
+ PUT %eax,is_sse
+ cmp $0,%eax
+ jg _s_mpv_mul_d_sse2
+_s_mpv_mul_d_x86:
+ push %ebp
+ mov %esp,%ebp
+ sub $28,%esp
+ push %edi
+ push %esi
+ push %ebx
+ movl $0,%ebx # carry = 0
+ mov 12(%ebp),%ecx # ecx = a_len
+ mov 20(%ebp),%edi
+ cmp $0,%ecx
+ je 2f # jmp if a_len == 0
+ mov 8(%ebp),%esi # esi = a
+ cld
+1:
+ lodsl # eax = [ds:esi]; esi += 4
+ mov 16(%ebp),%edx # edx = b
+ mull %edx # edx:eax = Phi:Plo = a_i * b
+
+ add %ebx,%eax # add carry (%ebx) to edx:eax
+ adc $0,%edx
+ mov %edx,%ebx # high half of product becomes next carry
+
+ stosl # [es:edi] = ax; edi += 4;
+ dec %ecx # --a_len
+ jnz 1b # jmp if a_len != 0
+2:
+ mov %ebx,0(%edi) # *c = carry
+ pop %ebx
+ pop %esi
+ pop %edi
+ leave
+ ret
+ nop
+_s_mpv_mul_d_sse2:
+ push %ebp
+ mov %esp,%ebp
+ push %edi
+ push %esi
+ psubq %mm2,%mm2 # carry = 0
+ mov 12(%ebp),%ecx # ecx = a_len
+ movd 16(%ebp),%mm1 # mm1 = b
+ mov 20(%ebp),%edi
+ cmp $0,%ecx
+ je 6f # jmp if a_len == 0
+ mov 8(%ebp),%esi # esi = a
+ cld
+5:
+ movd 0(%esi),%mm0 # mm0 = *a++
+ add $4,%esi
+ pmuludq %mm1,%mm0 # mm0 = b * *a++
+ paddq %mm0,%mm2 # add the carry
+ movd %mm2,0(%edi) # store the 32bit result
+ add $4,%edi
+ psrlq $32, %mm2 # save the carry
+ dec %ecx # --a_len
+ jnz 5b # jmp if a_len != 0
+6:
+ movd %mm2,0(%edi) # *c = carry
+ emms
+ pop %esi
+ pop %edi
+ leave
+ ret
+ nop
+
+ # ebp - 36: caller's esi
+ # ebp - 32: caller's edi
+ # ebp - 28:
+ # ebp - 24:
+ # ebp - 20:
+ # ebp - 16:
+ # ebp - 12:
+ # ebp - 8:
+ # ebp - 4:
+ # ebp + 0: caller's ebp
+ # ebp + 4: return address
+ # ebp + 8: a argument
+ # ebp + 12: a_len argument
+ # ebp + 16: b argument
+ # ebp + 20: c argument
+ # registers:
+ # eax:
+ # ebx: carry
+ # ecx: a_len
+ # edx:
+ # esi: a ptr
+ # edi: c ptr
+.globl _s_mpv_mul_d_add
+.type _s_mpv_mul_d_add,@function
+_s_mpv_mul_d_add:
+ GET is_sse,%eax
+ cmp $0,%eax
+ je _s_mpv_mul_d_add_x86
+ jg _s_mpv_mul_d_add_sse2
+ call _s_mpi_is_sse2
+ PUT %eax,is_sse
+ cmp $0,%eax
+ jg _s_mpv_mul_d_add_sse2
+_s_mpv_mul_d_add_x86:
+ push %ebp
+ mov %esp,%ebp
+ sub $28,%esp
+ push %edi
+ push %esi
+ push %ebx
+ movl $0,%ebx # carry = 0
+ mov 12(%ebp),%ecx # ecx = a_len
+ mov 20(%ebp),%edi
+ cmp $0,%ecx
+ je 11f # jmp if a_len == 0
+ mov 8(%ebp),%esi # esi = a
+ cld
+10:
+ lodsl # eax = [ds:esi]; esi += 4
+ mov 16(%ebp),%edx # edx = b
+ mull %edx # edx:eax = Phi:Plo = a_i * b
+
+ add %ebx,%eax # add carry (%ebx) to edx:eax
+ adc $0,%edx
+ mov 0(%edi),%ebx # add in current word from *c
+ add %ebx,%eax
+ adc $0,%edx
+ mov %edx,%ebx # high half of product becomes next carry
+
+ stosl # [es:edi] = ax; edi += 4;
+ dec %ecx # --a_len
+ jnz 10b # jmp if a_len != 0
+11:
+ mov %ebx,0(%edi) # *c = carry
+ pop %ebx
+ pop %esi
+ pop %edi
+ leave
+ ret
+ nop
+_s_mpv_mul_d_add_sse2:
+ push %ebp
+ mov %esp,%ebp
+ push %edi
+ push %esi
+ psubq %mm2,%mm2 # carry = 0
+ mov 12(%ebp),%ecx # ecx = a_len
+ movd 16(%ebp),%mm1 # mm1 = b
+ mov 20(%ebp),%edi
+ cmp $0,%ecx
+ je 16f # jmp if a_len == 0
+ mov 8(%ebp),%esi # esi = a
+ cld
+15:
+ movd 0(%esi),%mm0 # mm0 = *a++
+ add $4,%esi
+ pmuludq %mm1,%mm0 # mm0 = b * *a++
+ paddq %mm0,%mm2 # add the carry
+ movd 0(%edi),%mm0
+ paddq %mm0,%mm2 # add the carry
+ movd %mm2,0(%edi) # store the 32bit result
+ add $4,%edi
+ psrlq $32, %mm2 # save the carry
+ dec %ecx # --a_len
+ jnz 15b # jmp if a_len != 0
+16:
+ movd %mm2,0(%edi) # *c = carry
+ emms
+ pop %esi
+ pop %edi
+ leave
+ ret
+ nop
+
+ # ebp - 8: caller's esi
+ # ebp - 4: caller's edi
+ # ebp + 0: caller's ebp
+ # ebp + 4: return address
+ # ebp + 8: a argument
+ # ebp + 12: a_len argument
+ # ebp + 16: b argument
+ # ebp + 20: c argument
+ # registers:
+ # eax:
+ # ebx: carry
+ # ecx: a_len
+ # edx:
+ # esi: a ptr
+ # edi: c ptr
+.globl _s_mpv_mul_d_add_prop
+.type _s_mpv_mul_d_add_prop,@function
+_s_mpv_mul_d_add_prop:
+ GET is_sse,%eax
+ cmp $0,%eax
+ je _s_mpv_mul_d_add_prop_x86
+ jg _s_mpv_mul_d_add_prop_sse2
+ call _s_mpi_is_sse2
+ PUT %eax,is_sse
+ cmp $0,%eax
+ jg _s_mpv_mul_d_add_prop_sse2
+_s_mpv_mul_d_add_prop_x86:
+ push %ebp
+ mov %esp,%ebp
+ sub $28,%esp
+ push %edi
+ push %esi
+ push %ebx
+ movl $0,%ebx # carry = 0
+ mov 12(%ebp),%ecx # ecx = a_len
+ mov 20(%ebp),%edi
+ cmp $0,%ecx
+ je 21f # jmp if a_len == 0
+ cld
+ mov 8(%ebp),%esi # esi = a
+20:
+ lodsl # eax = [ds:esi]; esi += 4
+ mov 16(%ebp),%edx # edx = b
+ mull %edx # edx:eax = Phi:Plo = a_i * b
+
+ add %ebx,%eax # add carry (%ebx) to edx:eax
+ adc $0,%edx
+ mov 0(%edi),%ebx # add in current word from *c
+ add %ebx,%eax
+ adc $0,%edx
+ mov %edx,%ebx # high half of product becomes next carry
+
+ stosl # [es:edi] = ax; edi += 4;
+ dec %ecx # --a_len
+ jnz 20b # jmp if a_len != 0
+21:
+ cmp $0,%ebx # is carry zero?
+ jz 23f
+ mov 0(%edi),%eax # add in current word from *c
+ add %ebx,%eax
+ stosl # [es:edi] = ax; edi += 4;
+ jnc 23f
+22:
+ mov 0(%edi),%eax # add in current word from *c
+ adc $0,%eax
+ stosl # [es:edi] = ax; edi += 4;
+ jc 22b
+23:
+ pop %ebx
+ pop %esi
+ pop %edi
+ leave
+ ret
+ nop
+_s_mpv_mul_d_add_prop_sse2:
+ push %ebp
+ mov %esp,%ebp
+ push %edi
+ push %esi
+ push %ebx
+ psubq %mm2,%mm2 # carry = 0
+ mov 12(%ebp),%ecx # ecx = a_len
+ movd 16(%ebp),%mm1 # mm1 = b
+ mov 20(%ebp),%edi
+ cmp $0,%ecx
+ je 26f # jmp if a_len == 0
+ mov 8(%ebp),%esi # esi = a
+ cld
+25:
+ movd 0(%esi),%mm0 # mm0 = *a++
+ movd 0(%edi),%mm3 # fetch the sum
+ add $4,%esi
+ pmuludq %mm1,%mm0 # mm0 = b * *a++
+ paddq %mm0,%mm2 # add the carry
+ paddq %mm3,%mm2 # add *c++
+ movd %mm2,0(%edi) # store the 32bit result
+ add $4,%edi
+ psrlq $32, %mm2 # save the carry
+ dec %ecx # --a_len
+ jnz 25b # jmp if a_len != 0
+26:
+ movd %mm2,%ebx
+ cmp $0,%ebx # is carry zero?
+ jz 28f
+ mov 0(%edi),%eax
+ add %ebx, %eax
+ stosl
+ jnc 28f
+27:
+ mov 0(%edi),%eax # add in current word from *c
+ adc $0,%eax
+ stosl # [es:edi] = ax; edi += 4;
+ jc 27b
+28:
+ emms
+ pop %ebx
+ pop %esi
+ pop %edi
+ leave
+ ret
+ nop
+
+
+ # ebp - 20: caller's esi
+ # ebp - 16: caller's edi
+ # ebp - 12:
+ # ebp - 8: carry
+ # ebp - 4: a_len local
+ # ebp + 0: caller's ebp
+ # ebp + 4: return address
+ # ebp + 8: pa argument
+ # ebp + 12: a_len argument
+ # ebp + 16: ps argument
+ # ebp + 20:
+ # registers:
+ # eax:
+ # ebx: carry
+ # ecx: a_len
+ # edx:
+ # esi: a ptr
+ # edi: c ptr
+
+.globl _s_mpv_sqr_add_prop
+.type _s_mpv_sqr_add_prop,@function
+_s_mpv_sqr_add_prop:
+ GET is_sse,%eax
+ cmp $0,%eax
+ je _s_mpv_sqr_add_prop_x86
+ jg _s_mpv_sqr_add_prop_sse2
+ call _s_mpi_is_sse2
+ PUT %eax,is_sse
+ cmp $0,%eax
+ jg _s_mpv_sqr_add_prop_sse2
+_s_mpv_sqr_add_prop_x86:
+ push %ebp
+ mov %esp,%ebp
+ sub $12,%esp
+ push %edi
+ push %esi
+ push %ebx
+ movl $0,%ebx # carry = 0
+ mov 12(%ebp),%ecx # a_len
+ mov 16(%ebp),%edi # edi = ps
+ cmp $0,%ecx
+ je 31f # jump if a_len == 0
+ cld
+ mov 8(%ebp),%esi # esi = pa
+30:
+ lodsl # %eax = [ds:si]; si += 4;
+ mull %eax
+
+ add %ebx,%eax # add "carry"
+ adc $0,%edx
+ mov 0(%edi),%ebx
+ add %ebx,%eax # add low word from result
+ mov 4(%edi),%ebx
+ stosl # [es:di] = %eax; di += 4;
+ adc %ebx,%edx # add high word from result
+ movl $0,%ebx
+ mov %edx,%eax
+ adc $0,%ebx
+ stosl # [es:di] = %eax; di += 4;
+ dec %ecx # --a_len
+ jnz 30b # jmp if a_len != 0
+31:
+ cmp $0,%ebx # is carry zero?
+ jz 34f
+ mov 0(%edi),%eax # add in current word from *c
+ add %ebx,%eax
+ stosl # [es:edi] = ax; edi += 4;
+ jnc 34f
+32:
+ mov 0(%edi),%eax # add in current word from *c
+ adc $0,%eax
+ stosl # [es:edi] = ax; edi += 4;
+ jc 32b
+34:
+ pop %ebx
+ pop %esi
+ pop %edi
+ leave
+ ret
+ nop
+_s_mpv_sqr_add_prop_sse2:
+ push %ebp
+ mov %esp,%ebp
+ push %edi
+ push %esi
+ push %ebx
+ psubq %mm2,%mm2 # carry = 0
+ mov 12(%ebp),%ecx # ecx = a_len
+ mov 16(%ebp),%edi
+ cmp $0,%ecx
+ je 36f # jmp if a_len == 0
+ mov 8(%ebp),%esi # esi = a
+ cld
+35:
+ movd 0(%esi),%mm0 # mm0 = *a
+ movd 0(%edi),%mm3 # fetch the sum
+ add $4,%esi
+ pmuludq %mm0,%mm0 # mm0 = sqr(a)
+ paddq %mm0,%mm2 # add the carry
+ paddq %mm3,%mm2 # add the low word
+ movd 4(%edi),%mm3
+ movd %mm2,0(%edi) # store the 32bit result
+ psrlq $32, %mm2
+ paddq %mm3,%mm2 # add the high word
+ movd %mm2,4(%edi) # store the 32bit result
+ psrlq $32, %mm2 # save the carry.
+ add $8,%edi
+ dec %ecx # --a_len
+ jnz 35b # jmp if a_len != 0
+36:
+ movd %mm2,%ebx
+ cmp $0,%ebx # is carry zero?
+ jz 38f
+ mov 0(%edi),%eax
+ add %ebx, %eax
+ stosl
+ jnc 38f
+37:
+ mov 0(%edi),%eax # add in current word from *c
+ adc $0,%eax
+ stosl # [es:edi] = ax; edi += 4;
+ jc 37b
+38:
+ emms
+ pop %ebx
+ pop %esi
+ pop %edi
+ leave
+ ret
+ nop
+
+ #
+ # Divide 64-bit (Nhi,Nlo) by 32-bit divisor, which must be normalized
+ # so its high bit is 1. This code is from NSPR.
+ #
+ # mp_err _s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, mp_digit divisor,
+ # mp_digit *qp, mp_digit *rp)
+
+ # esp + 0: Caller's ebx
+ # esp + 4: return address
+ # esp + 8: Nhi argument
+ # esp + 12: Nlo argument
+ # esp + 16: divisor argument
+ # esp + 20: qp argument
+ # esp + 24: rp argument
+ # registers:
+ # eax:
+ # ebx: carry
+ # ecx: a_len
+ # edx:
+ # esi: a ptr
+ # edi: c ptr
+ #
+
+.globl _s_mpv_div_2dx1d
+.type _s_mpv_div_2dx1d,@function
+_s_mpv_div_2dx1d:
+ push %ebx
+ mov 8(%esp),%edx
+ mov 12(%esp),%eax
+ mov 16(%esp),%ebx
+ div %ebx
+ mov 20(%esp),%ebx
+ mov %eax,0(%ebx)
+ mov 24(%esp),%ebx
+ mov %edx,0(%ebx)
+ xor %eax,%eax # return zero
+ pop %ebx
+ ret
+ nop
+
diff --git a/security/nss/lib/freebl/nsslowhash.c b/security/nss/lib/freebl/nsslowhash.c
index 507237db1fa1..e0a2a21c1177 100644
--- a/security/nss/lib/freebl/nsslowhash.c
+++ b/security/nss/lib/freebl/nsslowhash.c
@@ -33,7 +33,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-/* $Id: nsslowhash.c,v 1.3 2009/04/15 21:31:55 rrelyea%redhat.com Exp $ */
+/* $Id: nsslowhash.c,v 1.4 2009/06/09 23:34:06 rrelyea%redhat.com Exp $ */
#include "stubs.h"
#include "prtypes.h"
@@ -289,6 +289,7 @@ static int nsslow_GetFIPSEnabled(void) {
static int post = 0;
+static int post_failed = 0;
static NSSLOWInitContext dummyContext = { 0 };
@@ -302,11 +303,16 @@ NSSLOW_Init(void)
rv = FREEBL_InitStubs();
nsprAvailable = (rv == SECSuccess ) ? PR_TRUE : PR_FALSE;
+
+ if (post_failed) {
+ return NULL;
+ }
if (!post && nsslow_GetFIPSEnabled()) {
crv = freebl_fipsPowerUpSelfTest();
if (crv != CKR_OK) {
+ post_failed = 1;
return NULL;
}
}
@@ -323,12 +329,26 @@ NSSLOW_Shutdown(NSSLOWInitContext *context)
return;
}
+void
+NSSLOW_Reset(NSSLOWInitContext *context)
+{
+ PORT_Assert(context == &dummyContext);
+ post_failed = 0;
+ post = 0;
+ return;
+}
+
NSSLOWHASHContext *
NSSLOWHASH_NewContext(NSSLOWInitContext *initContext,
HASH_HashType hashType)
{
NSSLOWHASHContext *context;
+ if (post_failed) {
+ PORT_SetError(SEC_ERROR_PKCS11_DEVICE_ERROR);
+ return NULL;
+ }
+
if (initContext != &dummyContext) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return (NULL);
diff --git a/security/nss/lib/freebl/nsslowhash.h b/security/nss/lib/freebl/nsslowhash.h
index 9d5400a77de4..b8dbf2b7a69b 100644
--- a/security/nss/lib/freebl/nsslowhash.h
+++ b/security/nss/lib/freebl/nsslowhash.h
@@ -45,6 +45,7 @@ typedef struct NSSLOWHASHContextStr NSSLOWHASHContext;
NSSLOWInitContext *NSSLOW_Init(void);
void NSSLOW_Shutdown(NSSLOWInitContext *context);
+void NSSLOW_Reset(NSSLOWInitContext *context);
NSSLOWHASHContext *NSSLOWHASH_NewContext(
NSSLOWInitContext *initContext,
HASH_HashType hashType);
diff --git a/security/nss/lib/freebl/stubs.c b/security/nss/lib/freebl/stubs.c
index bdacbee71726..e3f855baf6a9 100644
--- a/security/nss/lib/freebl/stubs.c
+++ b/security/nss/lib/freebl/stubs.c
@@ -535,6 +535,14 @@ freebl_InitNSSUtil(void *lib)
#define freebl_releaseLibrary(lib) \
if (lib) dlclose(lib)
+static void * FREEBLnsprGlobalLib = NULL;
+static void * FREEBLnssutilGlobalLib = NULL;
+
+void __attribute ((destructor)) FREEBL_unload()
+{
+ freebl_releaseLibrary(FREEBLnsprGlobalLib);
+ freebl_releaseLibrary(FREEBLnssutilGlobalLib);
+}
#endif
/*
@@ -552,28 +560,30 @@ FREEBL_InitStubs()
void *nssutil = NULL;
/* NSPR should be first */
- if (!ptr_PR_DestroyLock) {
+ if (!FREEBLnsprGlobalLib) {
nspr = freebl_getLibrary(nsprLibName);
if (!nspr) {
return SECFailure;
}
rv = freebl_InitNSPR(nspr);
- freebl_releaseLibrary(nspr);
if (rv != SECSuccess) {
+ freebl_releaseLibrary(nspr);
return rv;
}
+ FREEBLnsprGlobalLib = nspr; /* adopt */
}
/* now load NSSUTIL */
- if (!ptr_SECITEM_ZfreeItem_Util) {
+ if (!FREEBLnssutilGlobalLib) {
nssutil= freebl_getLibrary(nssutilLibName);
if (!nssutil) {
return SECFailure;
}
rv = freebl_InitNSSUtil(nssutil);
- freebl_releaseLibrary(nssutil);
if (rv != SECSuccess) {
+ freebl_releaseLibrary(nssutil);
return rv;
}
+ FREEBLnssutilGlobalLib = nssutil; /* adopt */
}
#endif
diff --git a/security/nss/lib/freebl/unix_rand.c b/security/nss/lib/freebl/unix_rand.c
index 28b523759e2c..c8344b9b31bf 100644
--- a/security/nss/lib/freebl/unix_rand.c
+++ b/security/nss/lib/freebl/unix_rand.c
@@ -629,44 +629,6 @@ GiveSystemInfo(void)
}
#endif /* sinix */
-#if defined(VMS)
-#include
-
-static void
-GiveSystemInfo(void)
-{
- long si;
-
- /*
- * This is copied from the SCO/UNIXWARE etc section. And like the comment
- * there says, what's the point? This isn't random, it generates the same
- * stuff every time its run!
- */
- si = sysconf(_SC_CHILD_MAX);
- RNG_RandomUpdate(&si, sizeof(si));
-
- si = sysconf(_SC_STREAM_MAX);
- RNG_RandomUpdate(&si, sizeof(si));
-
- si = sysconf(_SC_OPEN_MAX);
- RNG_RandomUpdate(&si, sizeof(si));
-}
-
-/*
- * Use the "get the cycle counter" instruction on the alpha.
- * The low 32 bits completely turn over in less than a minute.
- * The high 32 bits are some non-counter gunk that changes sometimes.
- */
-static size_t
-GetHighResClock(void *buf, size_t maxbytes)
-{
- unsigned long t;
-
- t = asm("rpcc %v0");
- return CopyLowBits(buf, maxbytes, &t, sizeof(t));
-}
-
-#endif /* VMS */
#ifdef BEOS
#include
@@ -880,9 +842,6 @@ safe_pclose(FILE *fp)
return status;
}
-
-#if !defined(VMS)
-
#ifdef DARWIN
#include
#endif
@@ -1023,65 +982,6 @@ void RNG_SystemInfoForRNG(void)
#endif
}
-#else
-void RNG_SystemInfoForRNG(void)
-{
- FILE *fp;
- char buf[BUFSIZ];
- size_t bytes;
- int extra;
- char **cp;
- extern char **environ;
- char *randfile;
-
- GiveSystemInfo();
-
- bytes = RNG_GetNoise(buf, sizeof(buf));
- RNG_RandomUpdate(buf, bytes);
-
- /*
- * Pass the C environment and the addresses of the pointers to the
- * hash function. This makes the random number function depend on the
- * execution environment of the user and on the platform the program
- * is running on.
- */
- cp = environ;
- while (*cp) {
- RNG_RandomUpdate(*cp, strlen(*cp));
- cp++;
- }
- RNG_RandomUpdate(environ, (char*)cp - (char*)environ);
-
- /* Give in system information */
- if (gethostname(buf, sizeof(buf)) > 0) {
- RNG_RandomUpdate(buf, strlen(buf));
- }
- GiveSystemInfo();
-
- /* If the user points us to a random file, pass it through the rng */
- randfile = getenv("NSRANDFILE");
- if ( ( randfile != NULL ) && ( randfile[0] != '\0') ) {
- RNG_FileForRNG(randfile);
- }
-
- /*
- ** We need to generate at least 1024 bytes of seed data. Since we don't
- ** do the file stuff for VMS, and because the environ list is so short
- ** on VMS, we need to make sure we generate enough. So do another 1000
- ** bytes to be sure.
- */
- extra = 1000;
- while (extra > 0) {
- cp = environ;
- while (*cp) {
- int n = strlen(*cp);
- RNG_RandomUpdate(*cp, n);
- extra -= n;
- cp++;
- }
- }
-}
-#endif
#define TOTAL_FILE_LIMIT 1000000 /* one million */
diff --git a/security/nss/lib/freebl/win_rand.c b/security/nss/lib/freebl/win_rand.c
index 37eb11737359..184798817ec0 100644
--- a/security/nss/lib/freebl/win_rand.c
+++ b/security/nss/lib/freebl/win_rand.c
@@ -58,6 +58,7 @@ static PRInt32 filesToRead;
static DWORD totalFileBytes;
static DWORD maxFileBytes = 250000; /* 250 thousand */
static DWORD dwNumFiles, dwReadEvery, dwFileToRead;
+static PRBool usedWindowsPRNG;
static BOOL
CurrentClockTickTime(LPDWORD lpdwHigh, LPDWORD lpdwLow)
@@ -131,24 +132,25 @@ size_t RNG_GetNoise(void *buf, size_t maxbuf)
return n;
}
-typedef PRInt32 (* Handler)(const char *);
+typedef PRInt32 (* Handler)(const PRUnichar *);
#define MAX_DEPTH 2
+#define MAX_FOLDERS 4
+#define MAX_FILES 1024
static void
EnumSystemFilesInFolder(Handler func, PRUnichar* szSysDir, int maxDepth)
{
int iContinue;
+ unsigned int uFolders = 0;
+ unsigned int uFiles = 0;
HANDLE lFindHandle;
WIN32_FIND_DATAW fdData;
PRUnichar szFileName[_MAX_PATH];
- char narrowFileName[_MAX_PATH];
if (maxDepth < 0)
return;
- // tack *.* on the end so we actually look for files. this will
- // not overflow
- wcscpy(szFileName, szSysDir);
- wcscat(szFileName, L"\\*.*");
+ // append *.* so we actually look for files.
+ _snwprintf(szFileName, _MAX_PATH, L"%s\\*.*", szSysDir);
lFindHandle = FindFirstFileW(szFileName, &fdData);
if (lFindHandle == INVALID_HANDLE_VALUE)
@@ -163,13 +165,10 @@ EnumSystemFilesInFolder(Handler func, PRUnichar* szSysDir, int maxDepth)
_snwprintf(szFileName, _MAX_PATH, L"%s\\%s", szSysDir,
fdData.cFileName);
if (fdData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- EnumSystemFilesInFolder(func, szFileName, maxDepth - 1);
+ if (++uFolders <= MAX_FOLDERS)
+ EnumSystemFilesInFolder(func, szFileName, maxDepth - 1);
} else {
- iContinue = WideCharToMultiByte(CP_ACP, 0, szFileName, -1,
- narrowFileName, _MAX_PATH,
- NULL, NULL);
- if (iContinue)
- iContinue = !(*func)(narrowFileName);
+ iContinue = (++uFiles <= MAX_FILES) && !(*func)(szFileName);
}
}
if (iContinue)
@@ -187,7 +186,6 @@ EnumSystemFiles(Handler func)
CSIDL_RECENT,
#ifndef WINCE
CSIDL_INTERNET_CACHE,
- CSIDL_COMPUTERSNEARME,
CSIDL_HISTORY,
#endif
0
@@ -208,17 +206,16 @@ EnumSystemFiles(Handler func)
}
static PRInt32
-CountFiles(const char *file)
+CountFiles(const PRUnichar *file)
{
dwNumFiles++;
return 0;
}
-static void
+static int
ReadSingleFile(const char *filename)
{
PRFileDesc * file;
- int nBytes;
unsigned char buffer[1024];
file = PR_Open(filename, PR_RDONLY, 0);
@@ -227,27 +224,43 @@ ReadSingleFile(const char *filename)
;
PR_Close(file);
}
+ return (file != NULL);
}
static PRInt32
-ReadOneFile(const char *file)
+ReadOneFile(const PRUnichar *szFileName)
{
+ char narrowFileName[_MAX_PATH];
+
if (dwNumFiles == dwFileToRead) {
- ReadSingleFile(file);
+ int success = WideCharToMultiByte(CP_ACP, 0, szFileName, -1,
+ narrowFileName, _MAX_PATH,
+ NULL, NULL);
+ if (success)
+ success = ReadSingleFile(narrowFileName);
+ if (!success)
+ dwFileToRead++; /* couldn't read this one, read the next one. */
}
dwNumFiles++;
return dwNumFiles > dwFileToRead;
}
static PRInt32
-ReadFiles(const char *file)
+ReadFiles(const PRUnichar *szFileName)
{
+ char narrowFileName[_MAX_PATH];
+
if ((dwNumFiles % dwReadEvery) == 0) {
++filesToRead;
}
if (filesToRead) {
- DWORD prevFileBytes = totalFileBytes;
- RNG_FileForRNG(file);
+ DWORD prevFileBytes = totalFileBytes;
+ int iContinue = WideCharToMultiByte(CP_ACP, 0, szFileName, -1,
+ narrowFileName, _MAX_PATH,
+ NULL, NULL);
+ if (iContinue) {
+ RNG_FileForRNG(narrowFileName);
+ }
if (prevFileBytes < totalFileBytes) {
--filesToRead;
}
@@ -257,7 +270,7 @@ ReadFiles(const char *file)
}
static void
-ReadSystemFiles()
+ReadSystemFiles(void)
{
// first count the number of files
dwNumFiles = 0;
@@ -277,6 +290,7 @@ ReadSystemFiles()
dwReadEvery = 1; // less than 10 files
dwNumFiles = 0;
+ totalFileBytes = 0;
EnumSystemFiles(ReadFiles);
}
@@ -349,8 +363,9 @@ void RNG_SystemInfoForRNG(void)
}
#endif
- // now let's do some files
- ReadSystemFiles();
+ // Skip the potentially slow file scanning if the OS's PRNG worked.
+ if (!usedWindowsPRNG)
+ ReadSystemFiles();
nBytes = RNG_GetNoise(buffer, 20); // get up to 20 bytes
RNG_RandomUpdate(buffer, nBytes);
@@ -410,8 +425,10 @@ void RNG_FileForRNG(const char *filename)
size_t RNG_SystemRNG(void *dest, size_t maxLen)
{
size_t bytes = 0;
+ usedWindowsPRNG = PR_FALSE;
if (CeGenRandom(maxLen, dest)) {
- bytes = maxLen;
+ bytes = maxLen;
+ usedWindowsPRNG = PR_TRUE;
}
if (bytes == 0) {
bytes = rng_systemFromNoise(dest,maxLen);
@@ -429,8 +446,6 @@ void RNG_FileForRNG(const char *filename)
struct stat stat_buf;
unsigned char buffer[1024];
- /* static DWORD totalFileBytes = 0; */
-
/* windows doesn't initialize all the bytes in the stat buf,
* so initialize them all here to avoid UMRs.
*/
@@ -516,6 +531,7 @@ size_t RNG_SystemRNG(void *dest, size_t maxLen)
HCRYPTPROV hCryptProv;
size_t bytes = 0;
+ usedWindowsPRNG = PR_FALSE;
hModule = LoadLibrary("advapi32.dll");
if (hModule == NULL) {
return rng_systemFromNoise(dest,maxLen);
@@ -525,6 +541,7 @@ size_t RNG_SystemRNG(void *dest, size_t maxLen)
if (pRtlGenRandom) {
if (pRtlGenRandom(dest, maxLen)) {
bytes = maxLen;
+ usedWindowsPRNG = PR_TRUE;
} else {
bytes = rng_systemFromNoise(dest,maxLen);
}
@@ -544,6 +561,7 @@ size_t RNG_SystemRNG(void *dest, size_t maxLen)
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
if (pCryptGenRandom(hCryptProv, maxLen, dest)) {
bytes = maxLen;
+ usedWindowsPRNG = PR_TRUE;
}
pCryptReleaseContext(hCryptProv, 0);
}
diff --git a/security/nss/lib/jar/jarver.c b/security/nss/lib/jar/jarver.c
index 28e281789100..da83bcf40afd 100644
--- a/security/nss/lib/jar/jarver.c
+++ b/security/nss/lib/jar/jarver.c
@@ -343,11 +343,11 @@ jar_parse_any(JAR *jar, int type, JAR_Signer *signer,
/* skip over the preliminary section */
/* This is one section at the top of the file with global metainfo */
- while (raw_len) {
+ while (raw_len > 0) {
JAR_Metainfo *met;
raw_manifest = jar_eat_line(1, PR_TRUE, raw_manifest, &raw_len);
- if (!*raw_manifest)
+ if (raw_len <= 0 || !*raw_manifest)
break;
met = PORT_ZNew(JAR_Metainfo);
@@ -443,7 +443,7 @@ jar_parse_any(JAR *jar, int type, JAR_Signer *signer,
}
/* done with top section of global data */
- while (raw_len) {
+ while (raw_len > 0) {
*x_md5 = 0;
*x_sha = 0;
*x_name = 0;
@@ -461,7 +461,7 @@ jar_parse_any(JAR *jar, int type, JAR_Signer *signer,
} else
sec = raw_manifest;
- if (!PORT_Strncasecmp(sec, "Name:", 5)) {
+ if (sec_len > 0 && !PORT_Strncasecmp(sec, "Name:", 5)) {
if (type == jarTypeMF)
mfdig = jar_digest_section(sec, sec_len);
else
@@ -470,9 +470,9 @@ jar_parse_any(JAR *jar, int type, JAR_Signer *signer,
}
- while (raw_len) {
+ while (raw_len > 0) {
raw_manifest = jar_eat_line(1, PR_TRUE, raw_manifest, &raw_len);
- if (!*raw_manifest)
+ if (raw_len <= 0 || !*raw_manifest)
break; /* blank line, done with this entry */
if (PORT_Strlen(raw_manifest) >= SZ) {
@@ -747,53 +747,72 @@ loser:
/*
* e a t _ l i n e
*
- * Consume an ASCII line from the top of a file kept in memory.
- * This destroys the file in place.
+ * Reads and/or modifies input buffer "data" of length "*len".
+ * This function does zero, one or two of the following tasks:
+ * 1) if "lines" is non-zero, it reads and discards that many lines from
+ * the input. NUL characters are treated as end-of-line characters,
+ * not as end-of-input characters. The input is NOT NUL terminated.
+ * Note: presently, all callers pass either 0 or 1 for lines.
+ * 2) After skipping the specified number of input lines, if "eating" is
+ * non-zero, it finds the end of the next line of input and replaces
+ * the end of line character(s) with a NUL character.
+ * This function modifies the input buffer, containing the file, in place.
* This function handles PC, Mac, and Unix style text files.
+ * On entry, *len contains the maximum number of characters that this
+ * function should ever examine, starting with the character in *data.
+ * On return, *len is reduced by the number of characters skipped by the
+ * first task, if any;
+ * If lines is zero and eating is false, this function returns
+ * the value in the data argument, but otherwise does nothing.
*/
static char *
jar_eat_line(int lines, int eating, char *data, long *len)
{
- char *ret;
+ char *start = data;
+ long maxLen = *len;
- ret = data;
- if (!*len)
- return ret;
+ if (maxLen <= 0)
+ return start;
+
+#define GO_ON ((data - start) < maxLen)
/* Eat the requisite number of lines, if any;
- prior to terminating the current line with a 0. */
+ prior to terminating the current line with a 0. */
+ for (/* yip */ ; lines > 0; lines--) {
+ while (GO_ON && *data && *data != '\r' && *data != '\n')
+ data++;
- for (/* yip */ ; lines; lines--) {
- while (*data && *data != '\n')
+ /* Eat any leading CR */
+ if (GO_ON && *data == '\r')
data++;
/* After the CR, ok to eat one LF */
- if (*data == '\n')
+ if (GO_ON && *data == '\n')
data++;
- /* If there are zeros, we put them there */
- while (*data == 0 && data - ret < *len)
+ /* If there are NULs, this function probably put them there */
+ while (GO_ON && !*data)
data++;
}
-
- *len -= data - ret;
- ret = data;
-
- if (eating) {
+ maxLen -= data - start; /* we have this many characters left. */
+ *len = maxLen;
+ start = data; /* now start again here. */
+ if (maxLen > 0 && eating) {
/* Terminate this line with a 0 */
- while (*data && *data != '\n' && *data != '\r')
+ while (GO_ON && *data && *data != '\n' && *data != '\r')
data++;
- /* In any case we are allowed to eat CR */
- if (*data == '\r')
+ /* If not past the end, we are allowed to eat one CR */
+ if (GO_ON && *data == '\r')
*data++ = 0;
- /* After the CR, ok to eat one LF */
- if (*data == '\n')
+ /* After the CR (if any), if not past the end, ok to eat one LF */
+ if (GO_ON && *data == '\n')
*data++ = 0;
}
- return ret;
+ return start;
}
+#undef GO_ON
/*
* j a r _ d i g e s t _ s e c t i o n
@@ -811,9 +830,9 @@ jar_digest_section(char *manifest, long length)
global_end = manifest;
global_len = length;
- while (global_len) {
+ while (global_len > 0) {
global_end = jar_eat_line(1, PR_FALSE, global_end, &global_len);
- if (*global_end == 0 || *global_end == '\n')
+ if (global_len > 0 && (*global_end == 0 || *global_end == '\n'))
break;
}
return JAR_calculate_digest (manifest, global_end - manifest);
diff --git a/security/nss/lib/libpkix/include/pkix_errorstrings.h b/security/nss/lib/libpkix/include/pkix_errorstrings.h
index 182f8493a7c3..324e22761b07 100755
--- a/security/nss/lib/libpkix/include/pkix_errorstrings.h
+++ b/security/nss/lib/libpkix/include/pkix_errorstrings.h
@@ -142,7 +142,7 @@ PKIX_ERRORENTRY(CERTCHECKCRLFAILED,Fail to get crl cache issued by cert,0),
PKIX_ERRORENTRY(CERTCHECKEXTENDEDKEYUSAGEFAILED,pkix_pl_Cert_CheckExtendedKeyUsage failed,0),
PKIX_ERRORENTRY(CERTCHECKKEYUSAGEFAILED,CERT_CheckKeyUsage failed,SEC_ERROR_INADEQUATE_KEY_USAGE),
PKIX_ERRORENTRY(CERTCHECKNAMECONSTRAINTSFAILED,PKIX_PL_Cert_CheckNameConstraints failed,0),
-PKIX_ERRORENTRY(CERTCHECKVALIDITYFAILED,PKIX_PL_Cert_CheckValidity failed,SEC_ERROR_CERT_NOT_VALID),
+PKIX_ERRORENTRY(CERTCHECKVALIDITYFAILED,PKIX_PL_Cert_CheckValidity failed,0),
PKIX_ERRORENTRY(CERTCOMPLETECRLDECODEDENTRIESFAILED,CERT_CompleteCRLDecodedEntries failed,0),
PKIX_ERRORENTRY(CERTCOPYNAMECONSTRAINTFAILED,CERT_CopyNameConstraint failed,0),
PKIX_ERRORENTRY(CERTCOPYNAMEFAILED,CERT_CopyName failed,0),
diff --git a/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_aiamgr.c b/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_aiamgr.c
index 4b2fa91893a0..3d1dc64cc9b1 100644
--- a/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_aiamgr.c
+++ b/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_aiamgr.c
@@ -274,6 +274,8 @@ pkix_pl_AIAMgr_GetHTTPCerts(
/* find or create httpClient = default client */
httpClient = SEC_GetRegisteredHttpClient();
aiaMgr->client.hdata.httpClient = httpClient;
+ if (!httpClient)
+ PKIX_ERROR(PKIX_OUTOFMEMORY);
if (httpClient->version == 1) {
diff --git a/security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_crldp.c b/security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_crldp.c
index 3e88768a9434..60cdd79d2131 100644
--- a/security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_crldp.c
+++ b/security/nss/lib/libpkix/pkix_pl_nss/pki/pkix_pl_crldp.c
@@ -152,7 +152,7 @@ pkix_pl_CrlDp_Create(
issuerName = certIssuerName;
}
rdnArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
- if (rdnArena) {
+ if (!rdnArena) {
PKIX_ERROR(PKIX_PORTARENAALLOCFAILED);
}
issuerNameCopy = (CERTName *)PORT_ArenaZNew(rdnArena, CERTName*);
@@ -164,7 +164,7 @@ pkix_pl_CrlDp_Create(
PKIX_ERROR(PKIX_ALLOCERROR);
}
rv = CERT_AddRDN(issuerNameCopy, (CERTRDN*)relName);
- if (rv = SECFailure) {
+ if (rv == SECFailure) {
PKIX_ERROR(PKIX_ALLOCERROR);
}
dpl->distPointType = relativeDistinguishedName;
diff --git a/security/nss/lib/nss/config.mk b/security/nss/lib/nss/config.mk
index 98e6802a4968..e97ee7b9dbe8 100644
--- a/security/nss/lib/nss/config.mk
+++ b/security/nss/lib/nss/config.mk
@@ -129,29 +129,6 @@ SHARED_LIBRARY_DIRS = \
../libpkix/pkix_pl_nss/module \
$(NULL)
-ifeq ($(OS_TARGET),SunOS)
-ifeq ($(BUILD_SUN_PKG), 1)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-ifeq ($(USE_64), 1)
-MKSHLIB += -R '$$ORIGIN:/usr/lib/mps/secv1/64:/usr/lib/mps/64'
-else
-MKSHLIB += -R '$$ORIGIN:/usr/lib/mps/secv1:/usr/lib/mps'
-endif
-else
-MKSHLIB += -R '$$ORIGIN'
-endif
-endif
-
-ifeq ($(OS_ARCH), HP-UX)
-ifneq ($(OS_TEST), ia64)
-# pa-risc
-ifeq ($(USE_64), 1)
-MKSHLIB += +b '$$ORIGIN'
-endif
-endif
-endif
-
ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET)))
ifndef NS_USE_GCC
# Export 'mktemp' to be backward compatible with NSS 3.2.x and 3.3.x
diff --git a/security/nss/lib/nss/nss.h b/security/nss/lib/nss/nss.h
index ecb12c30d06b..d2347078b6d9 100644
--- a/security/nss/lib/nss/nss.h
+++ b/security/nss/lib/nss/nss.h
@@ -36,7 +36,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-/* $Id: nss.h,v 1.66 2009/04/30 18:16:09 kaie%kuix.de Exp $ */
+/* $Id: nss.h,v 1.67 2009/07/20 20:06:57 nelson%bolyard.com Exp $ */
#ifndef __nss_h_
#define __nss_h_
@@ -66,7 +66,7 @@
* The format of the version string should be
* ".[.][ ][ ]"
*/
-#define NSS_VERSION "3.12.4.1" _NSS_ECC_STRING _NSS_CUSTOMIZED " Beta"
+#define NSS_VERSION "3.12.4.4" _NSS_ECC_STRING _NSS_CUSTOMIZED " Beta"
#define NSS_VMAJOR 3
#define NSS_VMINOR 12
#define NSS_VPATCH 4
diff --git a/security/nss/lib/nss/nssinit.c b/security/nss/lib/nss/nssinit.c
index ed41fce73fcc..4522e882d44c 100644
--- a/security/nss/lib/nss/nssinit.c
+++ b/security/nss/lib/nss/nssinit.c
@@ -36,9 +36,10 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-/* $Id: nssinit.c,v 1.97 2008/08/22 01:33:03 wtc%google.com Exp $ */
+/* $Id: nssinit.c,v 1.98 2009/05/29 19:23:30 wtc%google.com Exp $ */
#include
+#include
#include "seccomon.h"
#include "prinit.h"
#include "prprf.h"
@@ -555,7 +556,11 @@ loser:
STAN_GetDefaultTrustDomain());
if ((!noModDB) && (!noCertDB) && (!noRootInit)) {
if (!SECMOD_HasRootCerts()) {
- nss_FindExternalRoot(configdir, secmodName);
+ const char *dbpath = configdir;
+ if (strncmp(dbpath, "sql:", 4) == 0) {
+ dbpath += 4;
+ }
+ nss_FindExternalRoot(dbpath, secmodName);
}
}
pk11sdr_Init();
diff --git a/security/nss/lib/pk11wrap/pk11auth.c b/security/nss/lib/pk11wrap/pk11auth.c
index c957d1b46636..23e55e374a5a 100644
--- a/security/nss/lib/pk11wrap/pk11auth.c
+++ b/security/nss/lib/pk11wrap/pk11auth.c
@@ -630,7 +630,7 @@ PK11_DoPassword(PK11SlotInfo *slot, PRBool loadCerts, void *wincx)
void PK11_LogoutAll(void)
{
SECMODListLock *lock = SECMOD_GetDefaultModuleListLock();
- SECMODModuleList *modList = SECMOD_GetDefaultModuleList();
+ SECMODModuleList *modList;
SECMODModuleList *mlp = NULL;
int i;
@@ -640,6 +640,7 @@ void PK11_LogoutAll(void)
}
SECMOD_GetReadLock(lock);
+ modList = SECMOD_GetDefaultModuleList();
/* find the number of entries */
for (mlp = modList; mlp != NULL; mlp = mlp->next) {
for (i=0; i < mlp->module->slotCount; i++) {
diff --git a/security/nss/lib/pk11wrap/pk11sdr.h b/security/nss/lib/pk11wrap/pk11sdr.h
index 488bd7d995e1..02e769a705a9 100644
--- a/security/nss/lib/pk11wrap/pk11sdr.h
+++ b/security/nss/lib/pk11wrap/pk11sdr.h
@@ -43,13 +43,14 @@ SEC_BEGIN_PROTOS
/*
* PK11SDR_Encrypt - encrypt data using the specified key id or SDR default
- *
+ * result should be freed with SECItem_ZfreeItem
*/
SECStatus
PK11SDR_Encrypt(SECItem *keyid, SECItem *data, SECItem *result, void *cx);
/*
* PK11SDR_Decrypt - decrypt data previously encrypted with PK11SDR_Encrypt
+ * result should be freed with SECItem_ZfreeItem
*/
SECStatus
PK11SDR_Decrypt(SECItem *data, SECItem *result, void *cx);
diff --git a/security/nss/lib/pk11wrap/pk11skey.c b/security/nss/lib/pk11wrap/pk11skey.c
index 7f80a0680935..acf65aceb90d 100644
--- a/security/nss/lib/pk11wrap/pk11skey.c
+++ b/security/nss/lib/pk11wrap/pk11skey.c
@@ -50,6 +50,7 @@
#include "secitem.h"
#include "secoid.h"
#include "secerr.h"
+#include "hasht.h"
/* forward static declarations. */
static PK11SymKey *pk11_DeriveWithTemplate(PK11SymKey *baseKey,
@@ -678,6 +679,26 @@ __PK11_GetKeyData(PK11SymKey *symKey)
return PK11_GetKeyData(symKey);
}
+
+/*
+ * PKCS #11 key Types with predefined length
+ */
+unsigned int
+pk11_GetPredefinedKeyLength(CK_KEY_TYPE keyType)
+{
+ int length = 0;
+ switch (keyType) {
+ case CKK_DES: length = 8; break;
+ case CKK_DES2: length = 16; break;
+ case CKK_DES3: length = 24; break;
+ case CKK_SKIPJACK: length = 10; break;
+ case CKK_BATON: length = 20; break;
+ case CKK_JUNIPER: length = 20; break;
+ default: break;
+ }
+ return length;
+}
+
/* return the keylength if possible. '0' if not */
unsigned int
PK11_GetKeyLength(PK11SymKey *key)
@@ -688,20 +709,12 @@ PK11_GetKeyLength(PK11SymKey *key)
/* First try to figure out the key length from its type */
keyType = PK11_ReadULongAttribute(key->slot,key->objectID,CKA_KEY_TYPE);
- switch (keyType) {
- case CKK_DES: key->size = 8; break;
- case CKK_DES2: key->size = 16; break;
- case CKK_DES3: key->size = 24; break;
- case CKK_SKIPJACK: key->size = 10; break;
- case CKK_BATON: key->size = 20; break;
- case CKK_JUNIPER: key->size = 20; break;
- case CKK_GENERIC_SECRET:
- if (key->type == CKM_SSL3_PRE_MASTER_KEY_GEN) {
- key->size=48;
- }
- break;
- default: break;
+ key->size = pk11_GetPredefinedKeyLength(keyType);
+ if ((keyType == CKK_GENERIC_SECRET) &&
+ (key->type == CKM_SSL3_PRE_MASTER_KEY_GEN)) {
+ key->size=48;
}
+
if( key->size != 0 ) return key->size;
if (key->data.data == NULL) {
@@ -1636,7 +1649,6 @@ PK11_PubDerive(SECKEYPrivateKey *privKey, SECKEYPublicKey *pubKey,
int templateCount;
CK_ATTRIBUTE *attrs = keyTemplate;
CK_ECDH1_DERIVE_PARAMS *mechParams = NULL;
- SECItem *pubValue = NULL;
if (pubKey->keyType != ecKey) {
PORT_SetError(SEC_ERROR_BAD_KEY);
@@ -1655,28 +1667,23 @@ PK11_PubDerive(SECKEYPrivateKey *privKey, SECKEYPublicKey *pubKey,
keyType = PK11_GetKeyType(target,keySize);
key_size = keySize;
- symKey->size = keySize;
- if (key_size == 0) templateCount--;
+ if (key_size == 0) {
+ if (pk11_GetPredefinedKeyLength(keyType)) {
+ templateCount --;
+ } else {
+ /* sigh, some tokens can't figure this out and require
+ * CKA_VALUE_LEN to be set */
+ key_size = SHA1_LENGTH;
+ }
+ }
+ symKey->size = key_size;
mechParams = PORT_ZNew(CK_ECDH1_DERIVE_PARAMS);
mechParams->kdf = CKD_SHA1_KDF;
mechParams->ulSharedDataLen = 0;
mechParams->pSharedData = NULL;
-
- if (PR_GetEnv("NSS_USE_DECODED_CKA_EC_POINT")) {
- mechParams->ulPublicDataLen = pubKey->u.ec.publicValue.len;
- mechParams->pPublicData = pubKey->u.ec.publicValue.data;
- } else {
- pubValue = SEC_ASN1EncodeItem(NULL, NULL,
- &pubKey->u.ec.publicValue,
- SEC_ASN1_GET(SEC_OctetStringTemplate));
- if (pubValue == NULL) {
- PORT_ZFree(mechParams, sizeof(CK_ECDH1_DERIVE_PARAMS));
- break;
- }
- mechParams->ulPublicDataLen = pubValue->len;
- mechParams->pPublicData = pubValue->data;
- }
+ mechParams->ulPublicDataLen = pubKey->u.ec.publicValue.len;
+ mechParams->pPublicData = pubKey->u.ec.publicValue.data;
mechanism.mechanism = derive;
mechanism.pParameter = mechParams;
@@ -1688,9 +1695,28 @@ PK11_PubDerive(SECKEYPrivateKey *privKey, SECKEYPublicKey *pubKey,
templateCount, &symKey->objectID);
pk11_ExitKeyMonitor(symKey);
- if (pubValue) {
+ /* old PKCS #11 spec was ambiguous on what needed to be passed,
+ * try this again with and encoded public key */
+ if (crv != CKR_OK) {
+ SECItem *pubValue = SEC_ASN1EncodeItem(NULL, NULL,
+ &pubKey->u.ec.publicValue,
+ SEC_ASN1_GET(SEC_OctetStringTemplate));
+ if (pubValue == NULL) {
+ PORT_ZFree(mechParams, sizeof(CK_ECDH1_DERIVE_PARAMS));
+ break;
+ }
+ mechParams->ulPublicDataLen = pubValue->len;
+ mechParams->pPublicData = pubValue->data;
+
+ pk11_EnterKeyMonitor(symKey);
+ crv = PK11_GETTAB(slot)->C_DeriveKey(symKey->session,
+ &mechanism, privKey->pkcs11ID, keyTemplate,
+ templateCount, &symKey->objectID);
+ pk11_ExitKeyMonitor(symKey);
+
SECITEM_FreeItem(pubValue,PR_TRUE);
}
+
PORT_ZFree(mechParams, sizeof(CK_ECDH1_DERIVE_PARAMS));
if (crv == CKR_OK) return symKey;
@@ -1722,7 +1748,6 @@ pk11_PubDeriveECKeyWithKDF(
int templateCount;
CK_ATTRIBUTE *attrs = keyTemplate;
CK_ECDH1_DERIVE_PARAMS *mechParams = NULL;
- SECItem *pubValue = NULL;
if (pubKey->keyType != ecKey) {
PORT_SetError(SEC_ERROR_BAD_KEY);
@@ -1750,9 +1775,27 @@ pk11_PubDeriveECKeyWithKDF(
keyType = PK11_GetKeyType(target,keySize);
key_size = keySize;
- symKey->size = keySize;
- if (key_size == 0)
- templateCount--;
+ if (key_size == 0) {
+ if (pk11_GetPredefinedKeyLength(keyType)) {
+ templateCount --;
+ } else {
+ /* sigh, some tokens can't figure this out and require
+ * CKA_VALUE_LEN to be set */
+ switch (kdf) {
+ case CKD_NULL:
+ key_size = (pubKey->u.ec.publicValue.len-1)/2;
+ break;
+ case CKD_SHA1_KDF:
+ key_size = SHA1_LENGTH;
+ break;
+ default:
+ PORT_Assert(!"Invalid CKD");
+ PORT_SetError(SEC_ERROR_INVALID_ALGORITHM);
+ return NULL;
+ }
+ }
+ }
+ symKey->size = key_size;
mechParams = PORT_ZNew(CK_ECDH1_DERIVE_PARAMS);
if (!mechParams) {
@@ -1767,21 +1810,8 @@ pk11_PubDeriveECKeyWithKDF(
mechParams->ulSharedDataLen = sharedData->len;
mechParams->pSharedData = sharedData->data;
}
- if (PR_GetEnv("NSS_USE_DECODED_CKA_EC_POINT")) {
- mechParams->ulPublicDataLen = pubKey->u.ec.publicValue.len;
- mechParams->pPublicData = pubKey->u.ec.publicValue.data;
- } else {
- pubValue = SEC_ASN1EncodeItem(NULL, NULL,
- &pubKey->u.ec.publicValue,
- SEC_ASN1_GET(SEC_OctetStringTemplate));
- if (pubValue == NULL) {
- PORT_ZFree(mechParams, sizeof(CK_ECDH1_DERIVE_PARAMS));
- PK11_FreeSymKey(symKey);
- return NULL;
- }
- mechParams->ulPublicDataLen = pubValue->len;
- mechParams->pPublicData = pubValue->data;
- }
+ mechParams->ulPublicDataLen = pubKey->u.ec.publicValue.len;
+ mechParams->pPublicData = pubKey->u.ec.publicValue.data;
mechanism.mechanism = derive;
mechanism.pParameter = mechParams;
@@ -1792,11 +1822,30 @@ pk11_PubDeriveECKeyWithKDF(
privKey->pkcs11ID, keyTemplate, templateCount, &symKey->objectID);
pk11_ExitKeyMonitor(symKey);
- PORT_ZFree(mechParams, sizeof(CK_ECDH1_DERIVE_PARAMS));
- if (pubValue) {
+ /* old PKCS #11 spec was ambiguous on what needed to be passed,
+ * try this again with and encoded public key */
+ if (crv != CKR_OK) {
+ SECItem *pubValue = SEC_ASN1EncodeItem(NULL, NULL,
+ &pubKey->u.ec.publicValue,
+ SEC_ASN1_GET(SEC_OctetStringTemplate));
+ if (pubValue == NULL) {
+ goto loser;
+ }
+ mechParams->ulPublicDataLen = pubValue->len;
+ mechParams->pPublicData = pubValue->data;
+
+ pk11_EnterKeyMonitor(symKey);
+ crv = PK11_GETTAB(slot)->C_DeriveKey(symKey->session,
+ &mechanism, privKey->pkcs11ID, keyTemplate,
+ templateCount, &symKey->objectID);
+ pk11_ExitKeyMonitor(symKey);
+
SECITEM_FreeItem(pubValue,PR_TRUE);
}
+loser:
+ PORT_ZFree(mechParams, sizeof(CK_ECDH1_DERIVE_PARAMS));
+
if (crv != CKR_OK) {
PK11_FreeSymKey(symKey);
symKey = NULL;
diff --git a/security/nss/lib/pk11wrap/pk11slot.c b/security/nss/lib/pk11wrap/pk11slot.c
index a954c9d87f57..6e8f69eb09d8 100644
--- a/security/nss/lib/pk11wrap/pk11slot.c
+++ b/security/nss/lib/pk11wrap/pk11slot.c
@@ -482,13 +482,19 @@ PRBool
SECMOD_HasRootCerts(void)
{
SECMODModuleList *mlp;
- SECMODModuleList *modules = SECMOD_GetDefaultModuleList();
+ SECMODModuleList *modules;
SECMODListLock *moduleLock = SECMOD_GetDefaultModuleListLock();
int i;
PRBool found = PR_FALSE;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return found;
+ }
+
/* work through all the slots */
SECMOD_GetReadLock(moduleLock);
+ modules = SECMOD_GetDefaultModuleList();
for(mlp = modules; mlp != NULL; mlp = mlp->next) {
for (i=0; i < mlp->module->slotCount; i++) {
PK11SlotInfo *tmpSlot = mlp->module->slots[i];
@@ -514,17 +520,22 @@ PK11_FindSlotsByNames(const char *dllName, const char* slotName,
const char* tokenName, PRBool presentOnly)
{
SECMODModuleList *mlp;
- SECMODModuleList *modules = SECMOD_GetDefaultModuleList();
+ SECMODModuleList *modules;
SECMODListLock *moduleLock = SECMOD_GetDefaultModuleListLock();
int i;
PK11SlotList* slotList = NULL;
PRUint32 slotcount = 0;
SECStatus rv = SECSuccess;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return slotList;
+ }
+
slotList = PK11_NewSlotList();
if (!slotList) {
PORT_SetError(SEC_ERROR_NO_MEMORY);
- return NULL;
+ return slotList;
}
if ( ((NULL == dllName) || (0 == *dllName)) &&
@@ -537,6 +548,7 @@ PK11_FindSlotsByNames(const char *dllName, const char* slotName,
/* work through all the slots */
SECMOD_GetReadLock(moduleLock);
+ modules = SECMOD_GetDefaultModuleList();
for (mlp = modules; mlp != NULL; mlp = mlp->next) {
PORT_Assert(mlp->module);
if (!mlp->module) {
@@ -584,17 +596,22 @@ PK11SlotInfo *
PK11_FindSlotByName(const char *name)
{
SECMODModuleList *mlp;
- SECMODModuleList *modules = SECMOD_GetDefaultModuleList();
+ SECMODModuleList *modules;
SECMODListLock *moduleLock = SECMOD_GetDefaultModuleListLock();
int i;
PK11SlotInfo *slot = NULL;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return slot;
+ }
if ((name == NULL) || (*name == 0)) {
return PK11_GetInternalKeySlot();
}
/* work through all the slots */
SECMOD_GetReadLock(moduleLock);
+ modules = SECMOD_GetDefaultModuleList();
for(mlp = modules; mlp != NULL; mlp = mlp->next) {
for (i=0; i < mlp->module->slotCount; i++) {
PK11SlotInfo *tmpSlot = mlp->module->slots[i];
@@ -621,13 +638,18 @@ PK11SlotInfo *
PK11_FindSlotBySerial(char *serial)
{
SECMODModuleList *mlp;
- SECMODModuleList *modules = SECMOD_GetDefaultModuleList();
+ SECMODModuleList *modules;
SECMODListLock *moduleLock = SECMOD_GetDefaultModuleListLock();
int i;
PK11SlotInfo *slot = NULL;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return slot;
+ }
/* work through all the slots */
SECMOD_GetReadLock(moduleLock);
+ modules = SECMOD_GetDefaultModuleList();
for(mlp = modules; mlp != NULL; mlp = mlp->next) {
for (i=0; i < mlp->module->slotCount; i++) {
PK11SlotInfo *tmpSlot = mlp->module->slots[i];
@@ -1722,12 +1744,16 @@ PRBool
PK11_TokenExists(CK_MECHANISM_TYPE type)
{
SECMODModuleList *mlp;
- SECMODModuleList *modules = SECMOD_GetDefaultModuleList();
+ SECMODModuleList *modules;
SECMODListLock *moduleLock = SECMOD_GetDefaultModuleListLock();
PK11SlotInfo *slot;
PRBool found = PR_FALSE;
int i;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return found;
+ }
/* we only need to know if there is a token that does this mechanism.
* check the internal module first because it's fast, and supports
* almost everything. */
@@ -1739,6 +1765,7 @@ PK11_TokenExists(CK_MECHANISM_TYPE type)
if (found) return PR_TRUE; /* bypass getting module locks */
SECMOD_GetReadLock(moduleLock);
+ modules = SECMOD_GetDefaultModuleList();
for(mlp = modules; mlp != NULL && (!found); mlp = mlp->next) {
for (i=0; i < mlp->module->slotCount; i++) {
slot = mlp->module->slots[i];
@@ -1764,18 +1791,27 @@ PK11SlotList *
PK11_GetAllTokens(CK_MECHANISM_TYPE type, PRBool needRW, PRBool loadCerts,
void *wincx)
{
- PK11SlotList * list = PK11_NewSlotList();
- PK11SlotList * loginList = PK11_NewSlotList();
- PK11SlotList * friendlyList = PK11_NewSlotList();
+ PK11SlotList * list;
+ PK11SlotList * loginList;
+ PK11SlotList * friendlyList;
SECMODModuleList * mlp;
- SECMODModuleList * modules = SECMOD_GetDefaultModuleList();
- SECMODListLock * moduleLock = SECMOD_GetDefaultModuleListLock();
+ SECMODModuleList * modules;
+ SECMODListLock * moduleLock;
int i;
#if defined( XP_WIN32 )
int j = 0;
PRInt32 waste[16];
#endif
+ moduleLock = SECMOD_GetDefaultModuleListLock();
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return NULL;
+ }
+
+ list = PK11_NewSlotList();
+ loginList = PK11_NewSlotList();
+ friendlyList = PK11_NewSlotList();
if ((list == NULL) || (loginList == NULL) || (friendlyList == NULL)) {
if (list) PK11_FreeSlotList(list);
if (loginList) PK11_FreeSlotList(loginList);
@@ -1784,6 +1820,8 @@ PK11_GetAllTokens(CK_MECHANISM_TYPE type, PRBool needRW, PRBool loadCerts,
}
SECMOD_GetReadLock(moduleLock);
+
+ modules = SECMOD_GetDefaultModuleList();
for(mlp = modules; mlp != NULL; mlp = mlp->next) {
#if defined( XP_WIN32 )
diff --git a/security/nss/lib/pk11wrap/pk11util.c b/security/nss/lib/pk11wrap/pk11util.c
index e4edaf2e6770..7cc5cc91224d 100644
--- a/security/nss/lib/pk11wrap/pk11util.c
+++ b/security/nss/lib/pk11wrap/pk11util.c
@@ -223,6 +223,10 @@ SECMOD_FindModule(const char *name)
SECMODModuleList *mlp;
SECMODModule *module = NULL;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return module;
+ }
SECMOD_GetReadLock(moduleLock);
for(mlp = modules; mlp != NULL; mlp = mlp->next) {
if (PORT_Strcmp(name,mlp->module->commonName) == 0) {
@@ -258,6 +262,10 @@ SECMOD_FindModuleByID(SECMODModuleID id)
SECMODModuleList *mlp;
SECMODModule *module = NULL;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return module;
+ }
SECMOD_GetReadLock(moduleLock);
for(mlp = modules; mlp != NULL; mlp = mlp->next) {
if (id == mlp->module->moduleID) {
@@ -282,6 +290,10 @@ SECMOD_FindSlotByID(SECMODModule *module, CK_SLOT_ID slotID)
int i;
PK11SlotInfo *slot = NULL;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return slot;
+ }
SECMOD_GetReadLock(moduleLock);
for (i=0; i < module->slotCount; i++) {
PK11SlotInfo *cSlot = module->slots[i];
@@ -329,6 +341,11 @@ SECMOD_DeleteModuleEx(const char *name, SECMODModule *mod,
SECMODModuleList **mlpp;
SECStatus rv = SECFailure;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return rv;
+ }
+
*type = SECMOD_EXTERNAL;
SECMOD_GetWriteLock(moduleLock);
@@ -405,6 +422,10 @@ SECMOD_DeleteInternalModule(const char *name)
PORT_SetError(SEC_ERROR_MODULE_STUCK);
return rv;
}
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return rv;
+ }
SECMOD_GetWriteLock(moduleLock);
for(mlpp = &modules,mlp = modules;
@@ -508,6 +529,10 @@ SECMOD_FindSlot(SECMODModule *module,const char *name)
char *string;
PK11SlotInfo *retSlot = NULL;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return retSlot;
+ }
SECMOD_GetReadLock(moduleLock);
for (i=0; i < module->slotCount; i++) {
PK11SlotInfo *slot = module->slots[i];
@@ -574,6 +599,10 @@ SECMOD_AddNewModuleEx(const char* moduleName, const char* dllPath,
PK11SlotInfo* slot;
PR_SetErrorText(0, NULL);
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return result;
+ }
module = SECMOD_CreateModule(dllPath, moduleName, modparms, nssparms);
@@ -693,10 +722,14 @@ PRBool
SECMOD_IsModulePresent( unsigned long int pubCipherEnableFlags )
{
PRBool result = PR_FALSE;
- SECMODModuleList *mods = SECMOD_GetDefaultModuleList();
+ SECMODModuleList *mods;
+
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return result;
+ }
SECMOD_GetReadLock(moduleLock);
-
-
+ mods = SECMOD_GetDefaultModuleList();
for ( ; mods != NULL; mods = mods->next) {
if (mods->module->ssl[0] &
SECMOD_PubCipherFlagstoInternal(pubCipherEnableFlags)) {
@@ -867,6 +900,11 @@ SECMOD_UpdateSlotList(SECMODModule *mod)
PK11SlotInfo **newSlots = NULL;
PK11SlotInfo **oldSlots = NULL;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return SECFailure;
+ }
+
/* C_GetSlotList is not a session function, make sure
* calls are serialized */
PZ_Lock(mod->refLock);
@@ -988,6 +1026,10 @@ secmod_HandleWaitForSlotEvent(SECMODModule *mod, unsigned long flags,
int i;
int error = SEC_ERROR_NO_EVENT;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return NULL;
+ }
PZ_Lock(mod->refLock);
if (mod->evControlMask & SECMOD_END_WAIT) {
mod->evControlMask &= ~SECMOD_END_WAIT;
@@ -1184,6 +1226,10 @@ SECMOD_HasRemovableSlots(SECMODModule *mod)
int i;
PRBool ret = PR_FALSE;
+ if (!moduleLock) {
+ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
+ return ret;
+ }
SECMOD_GetReadLock(moduleLock);
for (i=0; i < mod->slotCount; i++) {
PK11SlotInfo *slot = mod->slots[i];
diff --git a/security/nss/lib/pkcs12/p12d.c b/security/nss/lib/pkcs12/p12d.c
index 75afb5000970..408bd8f704f0 100644
--- a/security/nss/lib/pkcs12/p12d.c
+++ b/security/nss/lib/pkcs12/p12d.c
@@ -2407,7 +2407,10 @@ sec_pkcs12_add_cert(sec_PKCS12SafeBag *cert, PRBool keyExists, void *wincx)
rv = PK11_ImportDERCert(cert->slot, derCert, CK_INVALID_HANDLE,
nickData, PR_FALSE);
}
-
+ if (rv) {
+ cert->problem = 1;
+ cert->error = PORT_GetError();
+ }
cert->installed = PR_TRUE;
if(nickName) SECITEM_ZfreeItem(nickName, PR_TRUE);
return rv;
diff --git a/security/nss/lib/smime/config.mk b/security/nss/lib/smime/config.mk
index 7d0629a47208..f3af755d22f4 100644
--- a/security/nss/lib/smime/config.mk
+++ b/security/nss/lib/smime/config.mk
@@ -93,18 +93,3 @@ SHARED_LIBRARY_DIRS = \
../pkcs7 \
$(NULL)
-ifeq ($(OS_TARGET),SunOS)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-MKSHLIB += -R '$$ORIGIN'
-endif
-
-ifeq ($(OS_ARCH), HP-UX)
-ifneq ($(OS_TEST), ia64)
-# pa-risc
-ifeq ($(USE_64), 1)
-MKSHLIB += +b '$$ORIGIN'
-endif
-endif
-endif
-
diff --git a/security/nss/lib/softoken/config.mk b/security/nss/lib/softoken/config.mk
index 9c1e4bcf9028..c434af286bab 100644
--- a/security/nss/lib/softoken/config.mk
+++ b/security/nss/lib/softoken/config.mk
@@ -96,21 +96,9 @@ OS_LIBS += -lpthread
endif
ifeq ($(OS_TARGET),SunOS)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-MKSHLIB += -R '$$ORIGIN'
OS_LIBS += -lbsm
endif
-ifeq ($(OS_ARCH), HP-UX)
-ifneq ($(OS_TEST), ia64)
-# pa-risc
-ifeq ($(USE_64), 1)
-MKSHLIB += +b '$$ORIGIN'
-endif
-endif
-endif
-
ifeq ($(OS_TARGET),WINCE)
DEFINES += -DDBM_USING_NSPR
endif
diff --git a/security/nss/lib/softoken/fipstest.c b/security/nss/lib/softoken/fipstest.c
index f5f726139a9f..a9ca120a21c2 100644
--- a/security/nss/lib/softoken/fipstest.c
+++ b/security/nss/lib/softoken/fipstest.c
@@ -36,7 +36,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-/* $Id: fipstest.c,v 1.25 2009/03/29 03:45:34 wtc%google.com Exp $ */
+/* $Id: fipstest.c,v 1.27 2009/06/19 23:05:48 rrelyea%redhat.com Exp $ */
#include "softoken.h" /* Required for RC2-ECB, RC2-CBC, RC4, DES-ECB, */
/* DES-CBC, DES3-ECB, DES3-CBC, RSA */
@@ -90,17 +90,17 @@
#define FIPS_RSA_TYPE siBuffer
#define FIPS_RSA_PUBLIC_EXPONENT_LENGTH 3 /* 24-bits */
#define FIPS_RSA_PRIVATE_VERSION_LENGTH 1 /* 8-bits */
-#define FIPS_RSA_MESSAGE_LENGTH 128 /* 1024-bits */
-#define FIPS_RSA_COEFFICIENT_LENGTH 64 /* 512-bits */
-#define FIPS_RSA_PRIME0_LENGTH 64 /* 512-bits */
-#define FIPS_RSA_PRIME1_LENGTH 64 /* 512-bits */
-#define FIPS_RSA_EXPONENT0_LENGTH 64 /* 512-bits */
-#define FIPS_RSA_EXPONENT1_LENGTH 64 /* 512-bits */
-#define FIPS_RSA_PRIVATE_EXPONENT_LENGTH 128 /* 1024-bits */
-#define FIPS_RSA_ENCRYPT_LENGTH 128 /* 1024-bits */
-#define FIPS_RSA_DECRYPT_LENGTH 128 /* 1024-bits */
-#define FIPS_RSA_SIGNATURE_LENGTH 128 /* 1024-bits */
-#define FIPS_RSA_MODULUS_LENGTH 128 /* 1024-bits */
+#define FIPS_RSA_MESSAGE_LENGTH 256 /* 2048-bits */
+#define FIPS_RSA_COEFFICIENT_LENGTH 128 /* 1024-bits */
+#define FIPS_RSA_PRIME0_LENGTH 128 /* 1024-bits */
+#define FIPS_RSA_PRIME1_LENGTH 128 /* 1024-bits */
+#define FIPS_RSA_EXPONENT0_LENGTH 128 /* 1024-bits */
+#define FIPS_RSA_EXPONENT1_LENGTH 128 /* 1024-bits */
+#define FIPS_RSA_PRIVATE_EXPONENT_LENGTH 256 /* 2048-bits */
+#define FIPS_RSA_ENCRYPT_LENGTH 256 /* 2048-bits */
+#define FIPS_RSA_DECRYPT_LENGTH 256 /* 2048-bits */
+#define FIPS_RSA_SIGNATURE_LENGTH 256 /* 2048-bits */
+#define FIPS_RSA_MODULUS_LENGTH 256 /* 2048-bits */
/* FIPS preprocessor directives for DSA. */
@@ -1149,202 +1149,323 @@ loser:
static CK_RV
sftk_fips_RSA_PowerUpSelfTest( void )
{
- /* RSA Known Modulus used in both Public/Private Key Values (1024-bits). */
+ /* RSA Known Modulus used in both Public/Private Key Values (2048-bits). */
static const PRUint8 rsa_modulus[FIPS_RSA_MODULUS_LENGTH] = {
- 0xd5, 0x84, 0x95, 0x07, 0xf4, 0xd0, 0x1f, 0x82,
- 0xf3, 0x79, 0xf4, 0x99, 0x48, 0x10, 0xe1, 0x71,
- 0xa5, 0x62, 0x22, 0xa3, 0x4b, 0x00, 0xe3, 0x5b,
- 0x3a, 0xcc, 0x10, 0x83, 0xe0, 0xaf, 0x61, 0x13,
- 0x54, 0x6a, 0xa2, 0x6a, 0x2c, 0x5e, 0xb3, 0xcc,
- 0xa3, 0x71, 0x9a, 0xb2, 0x3e, 0x78, 0xec, 0xb5,
- 0x0e, 0x6e, 0x31, 0x3b, 0x77, 0x1f, 0x6e, 0x94,
- 0x41, 0x60, 0xd5, 0x6e, 0xd9, 0xc6, 0xf9, 0x29,
- 0xc3, 0x40, 0x36, 0x25, 0xdb, 0xea, 0x0b, 0x07,
- 0xae, 0x76, 0xfd, 0x99, 0x29, 0xf4, 0x22, 0xc1,
- 0x1a, 0x8f, 0x05, 0xfe, 0x98, 0x09, 0x07, 0x05,
- 0xc2, 0x0f, 0x0b, 0x11, 0x83, 0x39, 0xca, 0xc7,
- 0x43, 0x63, 0xff, 0x33, 0x80, 0xe7, 0xc3, 0x78,
- 0xae, 0xf1, 0x73, 0x52, 0x98, 0x1d, 0xde, 0x5c,
- 0x53, 0x6e, 0x01, 0x73, 0x0d, 0x12, 0x7e, 0x77,
- 0x03, 0xf1, 0xef, 0x1b, 0xc8, 0xa8, 0x0f, 0x97};
+ 0xb8, 0x15, 0x00, 0x33, 0xda, 0x0c, 0x9d, 0xa5,
+ 0x14, 0x8c, 0xde, 0x1f, 0x23, 0x07, 0x54, 0xe2,
+ 0xc6, 0xb9, 0x51, 0x04, 0xc9, 0x65, 0x24, 0x6e,
+ 0x0a, 0x46, 0x34, 0x5c, 0x37, 0x86, 0x6b, 0x88,
+ 0x24, 0x27, 0xac, 0xa5, 0x02, 0x79, 0xfb, 0xed,
+ 0x75, 0xc5, 0x3f, 0x6e, 0xdf, 0x05, 0x5f, 0x0f,
+ 0x20, 0x70, 0xa0, 0x5b, 0x85, 0xdb, 0xac, 0xb9,
+ 0x5f, 0x02, 0xc2, 0x64, 0x1e, 0x84, 0x5b, 0x3e,
+ 0xad, 0xbf, 0xf6, 0x2e, 0x51, 0xd6, 0xad, 0xf7,
+ 0xa7, 0x86, 0x75, 0x86, 0xec, 0xa7, 0xe1, 0xf7,
+ 0x08, 0xbf, 0xdc, 0x56, 0xb1, 0x3b, 0xca, 0xd8,
+ 0xfc, 0x51, 0xdf, 0x9a, 0x2a, 0x37, 0x06, 0xf2,
+ 0xd1, 0x6b, 0x9a, 0x5e, 0x2a, 0xe5, 0x20, 0x57,
+ 0x35, 0x9f, 0x1f, 0x98, 0xcf, 0x40, 0xc7, 0xd6,
+ 0x98, 0xdb, 0xde, 0xf5, 0x64, 0x53, 0xf7, 0x9d,
+ 0x45, 0xf3, 0xd6, 0x78, 0xb9, 0xe3, 0xa3, 0x20,
+ 0xcd, 0x79, 0x43, 0x35, 0xef, 0xd7, 0xfb, 0xb9,
+ 0x80, 0x88, 0x27, 0x2f, 0x63, 0xa8, 0x67, 0x3d,
+ 0x4a, 0xfa, 0x06, 0xc6, 0xd2, 0x86, 0x0b, 0xa7,
+ 0x28, 0xfd, 0xe0, 0x1e, 0x93, 0x4b, 0x17, 0x2e,
+ 0xb0, 0x11, 0x6f, 0xc6, 0x2b, 0x98, 0x0f, 0x15,
+ 0xe3, 0x87, 0x16, 0x7a, 0x7c, 0x67, 0x3e, 0x12,
+ 0x2b, 0xf8, 0xbe, 0x48, 0xc1, 0x97, 0x47, 0xf4,
+ 0x1f, 0x81, 0x80, 0x12, 0x28, 0xe4, 0x7b, 0x1e,
+ 0xb7, 0x00, 0xa4, 0xde, 0xaa, 0xfb, 0x0f, 0x77,
+ 0x84, 0xa3, 0xd6, 0xb2, 0x03, 0x48, 0xdd, 0x53,
+ 0x8b, 0x46, 0x41, 0x28, 0x52, 0xc4, 0x53, 0xf0,
+ 0x1c, 0x95, 0xd9, 0x36, 0xe0, 0x0f, 0x26, 0x46,
+ 0x9c, 0x61, 0x0e, 0x80, 0xca, 0x86, 0xaf, 0x39,
+ 0x95, 0xe5, 0x60, 0x43, 0x61, 0x3e, 0x2b, 0xb4,
+ 0xe8, 0xbd, 0x8d, 0x77, 0x62, 0xf5, 0x32, 0x43,
+ 0x2f, 0x4b, 0x65, 0x82, 0x14, 0xdd, 0x29, 0x5b};
/* RSA Known Public Key Values (24-bits). */
static const PRUint8 rsa_public_exponent[FIPS_RSA_PUBLIC_EXPONENT_LENGTH]
= { 0x01, 0x00, 0x01 };
/* RSA Known Private Key Values (version is 8-bits), */
- /* (private exponent is 1024-bits), */
- /* (private prime0 is 512-bits), */
- /* (private prime1 is 512-bits), */
- /* (private prime exponent0 is 512-bits), */
- /* (private prime exponent1 is 512-bits), */
- /* and (private coefficient is 512-bits). */
+ /* (private exponent is 2048-bits), */
+ /* (private prime0 is 1024-bits), */
+ /* (private prime1 is 1024-bits), */
+ /* (private prime exponent0 is 1024-bits), */
+ /* (private prime exponent1 is 1024-bits), */
+ /* and (private coefficient is 1024-bits). */
static const PRUint8 rsa_version[] = { 0x00 };
static const PRUint8 rsa_private_exponent[FIPS_RSA_PRIVATE_EXPONENT_LENGTH]
- = { 0x85, 0x27, 0x47, 0x61, 0x4c, 0xd4, 0xb5, 0xb2,
- 0x0e, 0x70, 0x91, 0x8f, 0x3d, 0x97, 0xf9, 0x5f,
- 0xcc, 0x09, 0x65, 0x1c, 0x7c, 0x5b, 0xb3, 0x6d,
- 0x63, 0x3f, 0x7b, 0x55, 0x22, 0xbb, 0x7c, 0x48,
- 0x77, 0xae, 0x80, 0x56, 0xc2, 0x10, 0xd5, 0x03,
- 0xdb, 0x31, 0xaf, 0x8d, 0x54, 0xd4, 0x48, 0x99,
- 0xa8, 0xc4, 0x23, 0x43, 0xb8, 0x48, 0x0b, 0xc7,
- 0xbc, 0xf5, 0xcc, 0x64, 0x72, 0xbf, 0x59, 0x06,
- 0x04, 0x1c, 0x32, 0xf5, 0x14, 0x2e, 0x6e, 0xe2,
- 0x0f, 0x5c, 0xde, 0x36, 0x3c, 0x6e, 0x7c, 0x4d,
- 0xcc, 0xd3, 0x00, 0x6e, 0xe5, 0x45, 0x46, 0xef,
- 0x4d, 0x25, 0x46, 0x6d, 0x7f, 0xed, 0xbb, 0x4f,
- 0x4d, 0x9f, 0xda, 0x87, 0x47, 0x8f, 0x74, 0x44,
- 0xb7, 0xbe, 0x9d, 0xf5, 0xdd, 0xd2, 0x4c, 0xa5,
- 0xab, 0x74, 0xe5, 0x29, 0xa1, 0xd2, 0x45, 0x3b,
- 0x33, 0xde, 0xd5, 0xae, 0xf7, 0x03, 0x10, 0x21};
+ = {0x29, 0x08, 0x05, 0x53, 0x89, 0x76, 0xe6, 0x6c,
+ 0xb5, 0x77, 0xf0, 0xca, 0xdf, 0xf3, 0xf2, 0x67,
+ 0xda, 0x03, 0xd4, 0x9b, 0x4c, 0x88, 0xce, 0xe5,
+ 0xf8, 0x44, 0x4d, 0xc7, 0x80, 0x58, 0xe5, 0xff,
+ 0x22, 0x8f, 0xf5, 0x5b, 0x92, 0x81, 0xbe, 0x35,
+ 0xdf, 0xda, 0x67, 0x99, 0x3e, 0xfc, 0xe3, 0x83,
+ 0x6b, 0xa7, 0xaf, 0x16, 0xb7, 0x6f, 0x8f, 0xc0,
+ 0x81, 0xfd, 0x0b, 0x77, 0x65, 0x95, 0xfb, 0x00,
+ 0xad, 0x99, 0xec, 0x35, 0xc6, 0xe8, 0x23, 0x3e,
+ 0xe0, 0x88, 0x88, 0x09, 0xdb, 0x16, 0x50, 0xb7,
+ 0xcf, 0xab, 0x74, 0x61, 0x9e, 0x7f, 0xc5, 0x67,
+ 0x38, 0x56, 0xc7, 0x90, 0x85, 0x78, 0x5e, 0x84,
+ 0x21, 0x49, 0xea, 0xce, 0xb2, 0xa0, 0xff, 0xe4,
+ 0x70, 0x7f, 0x57, 0x7b, 0xa8, 0x36, 0xb8, 0x54,
+ 0x8d, 0x1d, 0xf5, 0x44, 0x9d, 0x68, 0x59, 0xf9,
+ 0x24, 0x6e, 0x85, 0x8f, 0xc3, 0x5f, 0x8a, 0x2c,
+ 0x94, 0xb7, 0xbc, 0x0e, 0xa5, 0xef, 0x93, 0x06,
+ 0x38, 0xcd, 0x07, 0x0c, 0xae, 0xb8, 0x44, 0x1a,
+ 0xd8, 0xe7, 0xf5, 0x9a, 0x1e, 0x9c, 0x18, 0xc7,
+ 0x6a, 0xc2, 0x7f, 0x28, 0x01, 0x4f, 0xb4, 0xb8,
+ 0x90, 0x97, 0x5a, 0x43, 0x38, 0xad, 0xe8, 0x95,
+ 0x68, 0x83, 0x1a, 0x1b, 0x10, 0x07, 0xe6, 0x02,
+ 0x52, 0x1f, 0xbf, 0x76, 0x6b, 0x46, 0xd6, 0xfb,
+ 0xc3, 0xbe, 0xb5, 0xac, 0x52, 0x53, 0x01, 0x1c,
+ 0xf3, 0xc5, 0xeb, 0x64, 0xf2, 0x1e, 0xc4, 0x38,
+ 0xe9, 0xaa, 0xd9, 0xc3, 0x72, 0x51, 0xa5, 0x44,
+ 0x58, 0x69, 0x0b, 0x1b, 0x98, 0x7f, 0xf2, 0x23,
+ 0xff, 0xeb, 0xf0, 0x75, 0x24, 0xcf, 0xc5, 0x1e,
+ 0xb8, 0x6a, 0xc5, 0x2f, 0x4f, 0x23, 0x50, 0x7d,
+ 0x15, 0x9d, 0x19, 0x7a, 0x0b, 0x82, 0xe0, 0x21,
+ 0x5b, 0x5f, 0x9d, 0x50, 0x2b, 0x83, 0xe4, 0x48,
+ 0xcc, 0x39, 0xe5, 0xfb, 0x13, 0x7b, 0x6f, 0x81 };
static const PRUint8 rsa_prime0[FIPS_RSA_PRIME0_LENGTH] = {
- 0xf9, 0x74, 0x8f, 0x16, 0x02, 0x6b, 0xa0, 0xee,
- 0x7f, 0x28, 0x97, 0x91, 0xdc, 0xec, 0xc0, 0x7c,
- 0x49, 0xc2, 0x85, 0x76, 0xee, 0x66, 0x74, 0x2d,
- 0x1a, 0xb8, 0xf7, 0x2f, 0x11, 0x5b, 0x36, 0xd8,
- 0x46, 0x33, 0x3b, 0xd8, 0xf3, 0x2d, 0xa1, 0x03,
- 0x83, 0x2b, 0xec, 0x35, 0x43, 0x32, 0xff, 0xdd,
- 0x81, 0x7c, 0xfd, 0x65, 0x13, 0x04, 0x7c, 0xfc,
- 0x03, 0x97, 0xf0, 0xd5, 0x62, 0xdc, 0x0d, 0xbf};
+ 0xe4, 0xbf, 0x21, 0x62, 0x9b, 0xa9, 0x77, 0x40,
+ 0x8d, 0x2a, 0xce, 0xa1, 0x67, 0x5a, 0x4c, 0x96,
+ 0x45, 0x98, 0x67, 0xbd, 0x75, 0x22, 0x33, 0x6f,
+ 0xe6, 0xcb, 0x77, 0xde, 0x9e, 0x97, 0x7d, 0x96,
+ 0x8c, 0x5e, 0x5d, 0x34, 0xfb, 0x27, 0xfc, 0x6d,
+ 0x74, 0xdb, 0x9d, 0x2e, 0x6d, 0xf6, 0xea, 0xfc,
+ 0xce, 0x9e, 0xda, 0xa7, 0x25, 0xa2, 0xf4, 0x58,
+ 0x6d, 0x0a, 0x3f, 0x01, 0xc2, 0xb4, 0xab, 0x38,
+ 0xc1, 0x14, 0x85, 0xb6, 0xfa, 0x94, 0xc3, 0x85,
+ 0xf9, 0x3c, 0x2e, 0x96, 0x56, 0x01, 0xe7, 0xd6,
+ 0x14, 0x71, 0x4f, 0xfb, 0x4c, 0x85, 0x52, 0xc4,
+ 0x61, 0x1e, 0xa5, 0x1e, 0x96, 0x13, 0x0d, 0x8f,
+ 0x66, 0xae, 0xa0, 0xcd, 0x7d, 0x25, 0x66, 0x19,
+ 0x15, 0xc2, 0xcf, 0xc3, 0x12, 0x3c, 0xe8, 0xa4,
+ 0x52, 0x4c, 0xcb, 0x28, 0x3c, 0xc4, 0xbf, 0x95,
+ 0x33, 0xe3, 0x81, 0xea, 0x0c, 0x6c, 0xa2, 0x05};
static const PRUint8 rsa_prime1[FIPS_RSA_PRIME1_LENGTH] = {
- 0xdb, 0x1e, 0xa7, 0x3d, 0xe7, 0xfa, 0x8b, 0x04,
- 0x83, 0x48, 0xf3, 0xa5, 0x31, 0x9d, 0x35, 0x5e,
- 0x4d, 0x54, 0x77, 0xcc, 0x84, 0x09, 0xf3, 0x11,
- 0x0d, 0x54, 0xed, 0x85, 0x39, 0xa9, 0xca, 0xa8,
- 0xea, 0xae, 0x19, 0x9c, 0x75, 0xdb, 0x88, 0xb8,
- 0x04, 0x8d, 0x54, 0xc6, 0xa4, 0x80, 0xf8, 0x93,
- 0xf0, 0xdb, 0x19, 0xef, 0xd7, 0x87, 0x8a, 0x8f,
- 0x5a, 0x09, 0x2e, 0x54, 0xf3, 0x45, 0x24, 0x29};
+ 0xce, 0x03, 0x94, 0xf4, 0xa9, 0x2c, 0x1e, 0x06,
+ 0xe7, 0x40, 0x30, 0x01, 0xf7, 0xbb, 0x68, 0x8c,
+ 0x27, 0xd2, 0x15, 0xe3, 0x28, 0x49, 0x5b, 0xa8,
+ 0xc1, 0x9a, 0x42, 0x7e, 0x31, 0xf9, 0x08, 0x34,
+ 0x81, 0xa2, 0x0f, 0x04, 0x61, 0x34, 0xe3, 0x36,
+ 0x92, 0xb1, 0x09, 0x2b, 0xe9, 0xef, 0x84, 0x88,
+ 0xbe, 0x9c, 0x98, 0x60, 0xa6, 0x60, 0x84, 0xe9,
+ 0x75, 0x6f, 0xcc, 0x81, 0xd1, 0x96, 0xef, 0xdd,
+ 0x2e, 0xca, 0xc4, 0xf5, 0x42, 0xfb, 0x13, 0x2b,
+ 0x57, 0xbf, 0x14, 0x5e, 0xc2, 0x7f, 0x77, 0x35,
+ 0x29, 0xc4, 0xe5, 0xe0, 0xf9, 0x6d, 0x15, 0x4a,
+ 0x42, 0x56, 0x1c, 0x3e, 0x0c, 0xc5, 0xce, 0x70,
+ 0x08, 0x63, 0x1e, 0x73, 0xdb, 0x7e, 0x74, 0x05,
+ 0x32, 0x01, 0xc6, 0x36, 0x32, 0x75, 0x6b, 0xed,
+ 0x9d, 0xfe, 0x7c, 0x7e, 0xa9, 0x57, 0xb4, 0xe9,
+ 0x22, 0xe4, 0xe7, 0xfe, 0x36, 0x07, 0x9b, 0xdf};
static const PRUint8 rsa_exponent0[FIPS_RSA_EXPONENT0_LENGTH] = {
- 0x6a, 0xd1, 0x25, 0x80, 0x18, 0x33, 0x3c, 0x2b,
- 0x44, 0x19, 0xfe, 0xa5, 0x40, 0x03, 0xc4, 0xfc,
- 0xb3, 0x9c, 0xef, 0x07, 0x99, 0x58, 0x17, 0xc1,
- 0x44, 0xa3, 0x15, 0x7d, 0x7b, 0x22, 0x22, 0xdf,
- 0x03, 0x58, 0x66, 0xf5, 0x24, 0x54, 0x52, 0x91,
- 0x2d, 0x76, 0xfe, 0x63, 0x64, 0x4e, 0x0f, 0x50,
- 0x2b, 0x65, 0x79, 0x1f, 0xf1, 0xbf, 0xc7, 0x41,
- 0x26, 0xcc, 0xc6, 0x1c, 0xa9, 0x83, 0x6f, 0x03};
+ 0x04, 0x5a, 0x3a, 0xa9, 0x64, 0xaa, 0xd9, 0xd1,
+ 0x09, 0x9e, 0x99, 0xe5, 0xea, 0x50, 0x86, 0x8a,
+ 0x89, 0x72, 0x77, 0xee, 0xdb, 0xee, 0xb5, 0xa9,
+ 0xd8, 0x6b, 0x60, 0xb1, 0x84, 0xb4, 0xff, 0x37,
+ 0xc1, 0x1d, 0xfe, 0x8a, 0x06, 0x89, 0x61, 0x3d,
+ 0x37, 0xef, 0x01, 0xd3, 0xa3, 0x56, 0x02, 0x6c,
+ 0xa3, 0x05, 0xd4, 0xc5, 0x3f, 0x6b, 0x15, 0x59,
+ 0x25, 0x61, 0xff, 0x86, 0xea, 0x0c, 0x84, 0x01,
+ 0x85, 0x72, 0xfd, 0x84, 0x58, 0xca, 0x41, 0xda,
+ 0x27, 0xbe, 0xe4, 0x68, 0x09, 0xe4, 0xe9, 0x63,
+ 0x62, 0x6a, 0x31, 0x8a, 0x67, 0x8f, 0x55, 0xde,
+ 0xd4, 0xb6, 0x3f, 0x90, 0x10, 0x6c, 0xf6, 0x62,
+ 0x17, 0x23, 0x15, 0x7e, 0x33, 0x76, 0x65, 0xb5,
+ 0xee, 0x7b, 0x11, 0x76, 0xf5, 0xbe, 0xe0, 0xf2,
+ 0x57, 0x7a, 0x8c, 0x97, 0x0c, 0x68, 0xf5, 0xf8,
+ 0x41, 0xcf, 0x7f, 0x66, 0x53, 0xac, 0x31, 0x7d};
static const PRUint8 rsa_exponent1[FIPS_RSA_EXPONENT1_LENGTH] = {
- 0x12, 0x84, 0x1a, 0x99, 0xce, 0x9a, 0x8b, 0x58,
- 0xcc, 0x47, 0x43, 0xdf, 0x77, 0xbb, 0xd3, 0x20,
- 0xae, 0xe4, 0x2e, 0x63, 0x67, 0xdc, 0xf7, 0x5f,
- 0x3f, 0x83, 0x27, 0xb7, 0x14, 0x52, 0x56, 0xbf,
- 0xc3, 0x65, 0x06, 0xe1, 0x03, 0xcc, 0x93, 0x57,
- 0x09, 0x7b, 0x6f, 0xe8, 0x81, 0x4a, 0x2c, 0xb7,
- 0x43, 0xa9, 0x20, 0x1d, 0xf6, 0x56, 0x8b, 0xcc,
- 0xe5, 0x4c, 0xd5, 0x4f, 0x74, 0x67, 0x29, 0x51};
+ 0x93, 0x54, 0x14, 0x6e, 0x73, 0x9d, 0x4d, 0x4b,
+ 0xfa, 0x8c, 0xf8, 0xc8, 0x2f, 0x76, 0x22, 0xea,
+ 0x38, 0x80, 0x11, 0x8f, 0x05, 0xfc, 0x90, 0x44,
+ 0x3b, 0x50, 0x2a, 0x45, 0x3d, 0x4f, 0xaf, 0x02,
+ 0x7d, 0xc2, 0x7b, 0xa2, 0xd2, 0x31, 0x94, 0x5c,
+ 0x2e, 0xc3, 0xd4, 0x9f, 0x47, 0x09, 0x37, 0x6a,
+ 0xe3, 0x85, 0xf1, 0xa3, 0x0c, 0xd8, 0xf1, 0xb4,
+ 0x53, 0x7b, 0xc4, 0x71, 0x02, 0x86, 0x42, 0xbb,
+ 0x96, 0xff, 0x03, 0xa3, 0xb2, 0x67, 0x03, 0xea,
+ 0x77, 0x31, 0xfb, 0x4b, 0x59, 0x24, 0xf7, 0x07,
+ 0x59, 0xfb, 0xa9, 0xba, 0x1e, 0x26, 0x58, 0x97,
+ 0x66, 0xa1, 0x56, 0x49, 0x39, 0xb1, 0x2c, 0x55,
+ 0x0a, 0x6a, 0x78, 0x18, 0xba, 0xdb, 0xcf, 0xf4,
+ 0xf7, 0x32, 0x35, 0xa2, 0x04, 0xab, 0xdc, 0xa7,
+ 0x6d, 0xd9, 0xd5, 0x06, 0x6f, 0xec, 0x7d, 0x40,
+ 0x4c, 0xe8, 0x0e, 0xd0, 0xc9, 0xaa, 0xdf, 0x59};
static const PRUint8 rsa_coefficient[FIPS_RSA_COEFFICIENT_LENGTH] = {
- 0x23, 0xab, 0xf4, 0x03, 0x2f, 0x29, 0x95, 0x74,
- 0xac, 0x1a, 0x33, 0x96, 0x62, 0xed, 0xf7, 0xf6,
- 0xae, 0x07, 0x2a, 0x2e, 0xe8, 0xab, 0xfb, 0x1e,
- 0xb9, 0xb2, 0x88, 0x1e, 0x85, 0x05, 0x42, 0x64,
- 0x03, 0xb2, 0x8b, 0xc1, 0x81, 0x75, 0xd7, 0xba,
- 0xaa, 0xd4, 0x31, 0x3c, 0x8a, 0x96, 0x23, 0x9d,
- 0x3f, 0x06, 0x3e, 0x44, 0xa9, 0x62, 0x2f, 0x61,
- 0x5a, 0x51, 0x82, 0x2c, 0x04, 0x85, 0x73, 0xd1};
+ 0x17, 0xd7, 0xf5, 0x0a, 0xf0, 0x68, 0x97, 0x96,
+ 0xc4, 0x29, 0x18, 0x77, 0x9a, 0x1f, 0xe3, 0xf3,
+ 0x12, 0x13, 0x0f, 0x7e, 0x7b, 0xb9, 0xc1, 0x91,
+ 0xf9, 0xc7, 0x08, 0x56, 0x5c, 0xa4, 0xbc, 0x83,
+ 0x71, 0xf9, 0x78, 0xd9, 0x2b, 0xec, 0xfe, 0x6b,
+ 0xdc, 0x2f, 0x63, 0xc9, 0xcd, 0x50, 0x14, 0x5b,
+ 0xd3, 0x6e, 0x85, 0x4d, 0x0c, 0xa2, 0x0b, 0xa0,
+ 0x09, 0xb6, 0xca, 0x34, 0x9c, 0xc2, 0xc1, 0x4a,
+ 0xb0, 0xbc, 0x45, 0x93, 0xa5, 0x7e, 0x99, 0xb5,
+ 0xbd, 0xe4, 0x69, 0x29, 0x08, 0x28, 0xd2, 0xcd,
+ 0xab, 0x24, 0x78, 0x48, 0x41, 0x26, 0x0b, 0x37,
+ 0xa3, 0x43, 0xd1, 0x95, 0x1a, 0xd6, 0xee, 0x22,
+ 0x1c, 0x00, 0x0b, 0xc2, 0xb7, 0xa4, 0xa3, 0x21,
+ 0xa9, 0xcd, 0xe4, 0x69, 0xd3, 0x45, 0x02, 0xb1,
+ 0xb7, 0x3a, 0xbf, 0x51, 0x35, 0x1b, 0x78, 0xc2,
+ 0xcf, 0x0c, 0x0d, 0x60, 0x09, 0xa9, 0x44, 0x02};
/* RSA Known Plaintext Message (1024-bits). */
static const PRUint8 rsa_known_plaintext_msg[FIPS_RSA_MESSAGE_LENGTH] = {
- "Known plaintext message utilized"
+ "Known plaintext message utilized"
"for RSA Encryption & Decryption"
- "block, SHA1, SHA256, SHA384 and"
- "SHA512 RSA Signature KAT tests."};
+ "blocks SHA256, SHA384 and "
+ "SHA512 RSA Signature KAT tests. "
+ "Known plaintext message utilized"
+ "for RSA Encryption & Decryption"
+ "blocks SHA256, SHA384 and "
+ "SHA512 RSA Signature KAT tests."};
- /* RSA Known Ciphertext (1024-bits). */
+ /* RSA Known Ciphertext (2048-bits). */
static const PRUint8 rsa_known_ciphertext[] = {
- 0x1e, 0x7e, 0x12, 0xbb, 0x15, 0x62, 0xd0, 0x23,
- 0x53, 0x4c, 0x51, 0x97, 0x77, 0x06, 0xa0, 0xbb,
- 0x26, 0x99, 0x9a, 0x8f, 0x39, 0xad, 0x88, 0x5c,
- 0xc4, 0xce, 0x33, 0x40, 0x94, 0x92, 0xb4, 0x0e,
- 0xab, 0x71, 0xa9, 0x5d, 0x9a, 0x37, 0xe3, 0x9a,
- 0x24, 0x95, 0x13, 0xea, 0x0f, 0xbb, 0xf7, 0xff,
- 0xdf, 0x31, 0x33, 0x23, 0x1d, 0xce, 0x26, 0x9e,
- 0xd1, 0xde, 0x98, 0x40, 0xde, 0x57, 0x86, 0x12,
- 0xf1, 0xe6, 0x5a, 0x3f, 0x08, 0x02, 0x81, 0x85,
- 0xe0, 0xd9, 0xad, 0x3c, 0x8c, 0x71, 0xf8, 0xcf,
- 0x0a, 0x98, 0xc5, 0x08, 0xdc, 0xc4, 0xca, 0x8c,
- 0x23, 0x1b, 0x4d, 0x9b, 0xb5, 0x13, 0x44, 0xe1,
- 0x5f, 0xf9, 0x30, 0x80, 0x25, 0xe0, 0x1e, 0x94,
- 0xa3, 0x0c, 0xdc, 0x82, 0x2e, 0xfb, 0x30, 0xbe,
- 0x89, 0xba, 0x76, 0xb6, 0x23, 0xf7, 0xda, 0x7c,
- 0xca, 0xe6, 0x02, 0xbd, 0x92, 0xce, 0x64, 0xfc};
+ 0x04, 0x12, 0x46, 0xe3, 0x6a, 0xee, 0xde, 0xdd,
+ 0x49, 0xa1, 0xd9, 0x83, 0xf7, 0x35, 0xf9, 0x70,
+ 0x88, 0x03, 0x2d, 0x01, 0x8b, 0xd1, 0xbf, 0xdb,
+ 0xe5, 0x1c, 0x85, 0xbe, 0xb5, 0x0b, 0x48, 0x45,
+ 0x7a, 0xf0, 0xa0, 0xe3, 0xa2, 0xbb, 0x4b, 0xf6,
+ 0x27, 0xd0, 0x1b, 0x12, 0xe3, 0x77, 0x52, 0x34,
+ 0x9e, 0x8e, 0x03, 0xd2, 0xf8, 0x79, 0x6e, 0x39,
+ 0x79, 0x53, 0x3c, 0x44, 0x14, 0x94, 0xbb, 0x8d,
+ 0xaa, 0x14, 0x44, 0xa0, 0x7b, 0xa5, 0x8c, 0x93,
+ 0x5f, 0x99, 0xa4, 0xa3, 0x6e, 0x7a, 0x38, 0x40,
+ 0x78, 0xfa, 0x36, 0x91, 0x5e, 0x9a, 0x9c, 0xba,
+ 0x1e, 0xd4, 0xf9, 0xda, 0x4b, 0x0f, 0xa8, 0xa3,
+ 0x1c, 0xf3, 0x3a, 0xd1, 0xa5, 0xb4, 0x51, 0x16,
+ 0xed, 0x4b, 0xcf, 0xec, 0x93, 0x7b, 0x90, 0x21,
+ 0xbc, 0x3a, 0xf4, 0x0b, 0xd1, 0x3a, 0x2b, 0xba,
+ 0xa6, 0x7d, 0x5b, 0x53, 0xd8, 0x64, 0xf9, 0x29,
+ 0x7b, 0x7f, 0x77, 0x3e, 0x51, 0x4c, 0x9a, 0x94,
+ 0xd2, 0x4b, 0x4a, 0x8d, 0x61, 0x74, 0x97, 0xae,
+ 0x53, 0x6a, 0xf4, 0x90, 0xc2, 0x2c, 0x49, 0xe2,
+ 0xfa, 0xeb, 0x91, 0xc5, 0xe5, 0x83, 0x13, 0xc9,
+ 0x44, 0x4b, 0x95, 0x2c, 0x57, 0x70, 0x15, 0x5c,
+ 0x64, 0x8d, 0x1a, 0xfd, 0x2a, 0xc7, 0xb2, 0x9c,
+ 0x5c, 0x99, 0xd3, 0x4a, 0xfd, 0xdd, 0xf6, 0x82,
+ 0x87, 0x8c, 0x5a, 0xc4, 0xa8, 0x0d, 0x2a, 0xef,
+ 0xc3, 0xa2, 0x7e, 0x8e, 0x67, 0x9f, 0x6f, 0x63,
+ 0xdb, 0xbb, 0x1d, 0x31, 0xc4, 0xbb, 0xbc, 0x13,
+ 0x3f, 0x54, 0xc6, 0xf6, 0xc5, 0x28, 0x32, 0xab,
+ 0x96, 0x42, 0x10, 0x36, 0x40, 0x92, 0xbb, 0x57,
+ 0x55, 0x38, 0xf5, 0x43, 0x7e, 0x43, 0xc4, 0x65,
+ 0x47, 0x64, 0xaa, 0x0f, 0x4c, 0xe9, 0x49, 0x16,
+ 0xec, 0x6a, 0x50, 0xfd, 0x14, 0x49, 0xca, 0xdb,
+ 0x44, 0x54, 0xca, 0xbe, 0xa3, 0x0e, 0x5f, 0xef};
- /* RSA Known Signed Hash (1024-bits). */
- static const PRUint8 rsa_known_sha1_signature[] = {
- 0xd2, 0xa4, 0xe0, 0x2b, 0xc7, 0x03, 0x7f, 0xc6,
- 0x06, 0x9e, 0xa2, 0x82, 0x19, 0xe9, 0x2b, 0xaf,
- 0xe3, 0x48, 0x88, 0xc1, 0xf3, 0xb5, 0x0d, 0xe4,
- 0x52, 0x9e, 0xad, 0xd5, 0x58, 0xb5, 0x9f, 0xe8,
- 0x40, 0xe9, 0xb7, 0x2e, 0xc6, 0x71, 0x58, 0x56,
- 0x04, 0xac, 0xb0, 0xf3, 0x3a, 0x42, 0x38, 0x08,
- 0xc4, 0x43, 0x39, 0xba, 0x19, 0xce, 0xb1, 0x99,
- 0xf1, 0x8d, 0x89, 0xd8, 0x50, 0x07, 0x14, 0x3d,
- 0xcf, 0xd0, 0xb6, 0x79, 0xde, 0x9c, 0x89, 0x32,
- 0xb0, 0x73, 0x3f, 0xed, 0x03, 0x0b, 0xdf, 0x6d,
- 0x7e, 0xc9, 0x1c, 0x39, 0xe8, 0x2b, 0x16, 0x09,
- 0xbb, 0x5f, 0x99, 0x2f, 0xeb, 0xf3, 0x37, 0x73,
- 0x0d, 0x0e, 0xcc, 0x95, 0xad, 0x90, 0x80, 0x03,
- 0x1d, 0x80, 0x55, 0x37, 0xa1, 0x2a, 0x71, 0x76,
- 0x23, 0x87, 0x8c, 0x9b, 0x41, 0x07, 0xc6, 0x3d,
- 0xc6, 0xa3, 0x7d, 0x1b, 0xff, 0x4e, 0x11, 0x19};
-
- /* RSA Known Signed Hash (1024-bits). */
+ /* RSA Known Signed Hash (2048-bits). */
static const PRUint8 rsa_known_sha256_signature[] = {
- 0x27, 0x35, 0xdd, 0xc4, 0xf8, 0xe2, 0x0b, 0xa3,
- 0xef, 0x63, 0x57, 0x3b, 0xe1, 0x58, 0x9a, 0xbc,
- 0x20, 0x9c, 0x25, 0x12, 0x01, 0xbf, 0xbb, 0x29,
- 0x80, 0x1a, 0xb1, 0x37, 0x9c, 0xcd, 0x67, 0xc7,
- 0x0d, 0xf8, 0x64, 0x10, 0x9f, 0xe2, 0xa1, 0x9b,
- 0x21, 0x90, 0xcc, 0xda, 0x8b, 0x76, 0x5e, 0x79,
- 0x00, 0x9d, 0x58, 0x8b, 0x8a, 0xb3, 0xc3, 0xb5,
- 0xf1, 0x54, 0xc5, 0x8c, 0x72, 0xba, 0xde, 0x51,
- 0x3c, 0x6b, 0x94, 0xd6, 0xf3, 0x1b, 0xa2, 0x53,
- 0xe6, 0x1a, 0x46, 0x1d, 0x7f, 0x14, 0x86, 0xcc,
- 0xa6, 0x30, 0x92, 0x96, 0xc0, 0x96, 0x24, 0xf0,
- 0x42, 0x53, 0x4c, 0xdd, 0x27, 0xdf, 0x1d, 0x2e,
- 0x8b, 0x83, 0xbe, 0xed, 0x85, 0x1d, 0x50, 0x46,
- 0xa3, 0x7d, 0x20, 0xea, 0x3e, 0x91, 0xfb, 0xf6,
- 0x86, 0x51, 0xfd, 0x8c, 0xe5, 0x31, 0xe6, 0x7e,
- 0x60, 0x08, 0x0e, 0xec, 0xa6, 0xea, 0x24, 0x8d};
+ 0x8c, 0x2d, 0x2e, 0xfb, 0x37, 0xb5, 0x6f, 0x38,
+ 0x9f, 0x06, 0x5a, 0xf3, 0x8c, 0xa0, 0xd0, 0x7a,
+ 0xde, 0xcf, 0xf9, 0x14, 0x95, 0x59, 0xd3, 0x5f,
+ 0x51, 0x5d, 0x5d, 0xad, 0xd8, 0x71, 0x33, 0x50,
+ 0x1d, 0x03, 0x3b, 0x3a, 0x32, 0x00, 0xb4, 0xde,
+ 0x7f, 0xe4, 0xb1, 0xe5, 0x6b, 0x83, 0xf4, 0x80,
+ 0x10, 0x3b, 0xb8, 0x8a, 0xdb, 0xe8, 0x0a, 0x42,
+ 0x9e, 0x8d, 0xd7, 0xbe, 0xed, 0xde, 0x5a, 0x3d,
+ 0xc6, 0xdb, 0xfe, 0x49, 0x6a, 0xe9, 0x1e, 0x75,
+ 0x66, 0xf1, 0x3f, 0x9e, 0x3f, 0xff, 0x05, 0x65,
+ 0xde, 0xca, 0x62, 0x62, 0xf3, 0xec, 0x53, 0x09,
+ 0xa0, 0x37, 0xd5, 0x66, 0x62, 0x72, 0x14, 0xb6,
+ 0x51, 0x32, 0x67, 0x50, 0xc1, 0xe1, 0x2f, 0x9e,
+ 0x98, 0x4e, 0x53, 0x96, 0x55, 0x4b, 0xc4, 0x92,
+ 0xc3, 0xb4, 0x80, 0xf0, 0x35, 0xc9, 0x00, 0x4b,
+ 0x5c, 0x85, 0x92, 0xb1, 0xe8, 0x6e, 0xa5, 0x51,
+ 0x38, 0x9f, 0xc9, 0x11, 0xb6, 0x14, 0xdf, 0x34,
+ 0x64, 0x40, 0x82, 0x82, 0xde, 0x16, 0x69, 0x93,
+ 0x89, 0x4e, 0x5c, 0x32, 0xf2, 0x0a, 0x4e, 0x9e,
+ 0xbd, 0x63, 0x99, 0x4f, 0xf3, 0x15, 0x90, 0xc2,
+ 0xfe, 0x6f, 0xb7, 0xf4, 0xad, 0xd4, 0x8e, 0x0b,
+ 0xd2, 0xf5, 0x22, 0xd2, 0x71, 0x65, 0x13, 0xf7,
+ 0x82, 0x7b, 0x75, 0xb6, 0xc1, 0xb4, 0x45, 0xbd,
+ 0x8f, 0x95, 0xcf, 0x5b, 0x95, 0x32, 0xef, 0x18,
+ 0x5f, 0xd3, 0xdf, 0x7e, 0x22, 0xdd, 0x25, 0xeb,
+ 0xe1, 0xbf, 0x3b, 0x9a, 0x55, 0x75, 0x4f, 0x3c,
+ 0x38, 0x67, 0x57, 0x04, 0x04, 0x57, 0x27, 0xf6,
+ 0x34, 0x0e, 0x57, 0x8a, 0x7c, 0xff, 0x7d, 0xca,
+ 0x8c, 0x06, 0xf8, 0x9d, 0xdb, 0xe4, 0xd8, 0x19,
+ 0xdd, 0x4d, 0xfd, 0x8f, 0xa0, 0x06, 0x53, 0xe8,
+ 0x33, 0x00, 0x70, 0x3f, 0x6b, 0xc3, 0xbd, 0x9a,
+ 0x78, 0xb5, 0xa9, 0xef, 0x6d, 0xda, 0x67, 0x92};
- /* RSA Known Signed Hash (1024-bits). */
- static const PRUint8 rsa_known_sha384_signature[] = {
- 0x0b, 0x03, 0x94, 0x4f, 0x94, 0x78, 0x9b, 0x96,
- 0x76, 0xeb, 0x72, 0x58, 0xe1, 0xc5, 0xc7, 0x5f,
- 0x85, 0x01, 0xa8, 0xc4, 0xf6, 0x1a, 0xb5, 0x2c,
- 0xd1, 0xd8, 0x87, 0xde, 0x3a, 0x9c, 0x9f, 0x57,
- 0x81, 0x2a, 0x1e, 0x23, 0x07, 0x70, 0xb0, 0xf9,
- 0x28, 0x3d, 0xfa, 0xe5, 0x2e, 0x1b, 0x9a, 0x72,
- 0xc3, 0x74, 0xb3, 0x42, 0x1c, 0x9a, 0x13, 0xdc,
- 0xc9, 0xd6, 0xd5, 0x88, 0xc9, 0x9c, 0x46, 0xf1,
- 0x0c, 0xa6, 0xf7, 0xd8, 0x06, 0xa3, 0x1b, 0xdf,
- 0x55, 0xb3, 0x1b, 0x7b, 0x58, 0x1d, 0xff, 0x19,
- 0xc7, 0xe0, 0xdd, 0x59, 0xac, 0x2f, 0x78, 0x71,
- 0xe7, 0xe0, 0x17, 0xa3, 0x1c, 0x5c, 0x92, 0xef,
- 0xb6, 0x75, 0xed, 0xbe, 0x18, 0x39, 0x6b, 0xd7,
- 0xc9, 0x08, 0x62, 0x55, 0x62, 0xac, 0x5d, 0xa1,
- 0x9b, 0xd5, 0xb8, 0x98, 0x15, 0xc0, 0xf5, 0x41,
- 0x85, 0x44, 0x96, 0xca, 0x10, 0xdc, 0x57, 0x21};
+ /* RSA Known Signed Hash (2048-bits). */
+ static const PRUint8 rsa_known_sha384_signature[] = {
+ 0x20, 0x2d, 0x21, 0x3a, 0xaa, 0x1e, 0x05, 0x15,
+ 0x5c, 0xca, 0x84, 0x86, 0xc0, 0x15, 0x81, 0xdf,
+ 0xd4, 0x06, 0x9f, 0xe0, 0xc1, 0xed, 0xef, 0x0f,
+ 0xfe, 0xb3, 0xc3, 0xbb, 0x28, 0xa5, 0x56, 0xbf,
+ 0xe3, 0x11, 0x5c, 0xc2, 0xc0, 0x0b, 0xfa, 0xfa,
+ 0x3d, 0xd3, 0x06, 0x20, 0xe2, 0xc9, 0xe4, 0x66,
+ 0x28, 0xb7, 0xc0, 0x3b, 0x3c, 0x96, 0xc6, 0x49,
+ 0x3b, 0xcf, 0x86, 0x49, 0x31, 0xaf, 0x5b, 0xa3,
+ 0xec, 0x63, 0x10, 0xdf, 0xda, 0x2f, 0x68, 0xac,
+ 0x7b, 0x3a, 0x49, 0xfa, 0xe6, 0x0d, 0xfe, 0x37,
+ 0x17, 0x56, 0x8e, 0x5c, 0x48, 0x97, 0x43, 0xf7,
+ 0xa0, 0xbc, 0xe3, 0x4b, 0x42, 0xde, 0x58, 0x1d,
+ 0xd9, 0x5d, 0xb3, 0x08, 0x35, 0xbd, 0xa4, 0xe1,
+ 0x80, 0xc3, 0x64, 0xab, 0x21, 0x97, 0xad, 0xfb,
+ 0x71, 0xee, 0xa3, 0x3d, 0x9c, 0xaa, 0xfa, 0x16,
+ 0x60, 0x46, 0x32, 0xda, 0x44, 0x2e, 0x10, 0x92,
+ 0x20, 0xd8, 0x98, 0x80, 0x84, 0x75, 0x5b, 0x70,
+ 0x91, 0x00, 0x33, 0x19, 0x69, 0xc9, 0x2a, 0xec,
+ 0x3d, 0xe5, 0x5f, 0x0f, 0x9a, 0xa7, 0x97, 0x1f,
+ 0x79, 0xc3, 0x1d, 0x65, 0x74, 0x62, 0xc5, 0xa1,
+ 0x23, 0x65, 0x4b, 0x84, 0xa1, 0x03, 0x98, 0xf3,
+ 0xf1, 0x02, 0x24, 0xca, 0xe5, 0xd4, 0xc8, 0xa2,
+ 0x30, 0xad, 0x72, 0x7d, 0x29, 0x60, 0x1a, 0x8e,
+ 0x6f, 0x23, 0xa4, 0xda, 0x68, 0xa4, 0x45, 0x9c,
+ 0x39, 0x70, 0x44, 0x18, 0x4b, 0x73, 0xfe, 0xf8,
+ 0x33, 0x53, 0x1d, 0x7e, 0x93, 0x93, 0xac, 0xc7,
+ 0x1e, 0x6e, 0x6b, 0xfd, 0x9e, 0xba, 0xa6, 0x71,
+ 0x70, 0x47, 0x6a, 0xd6, 0x82, 0x32, 0xa2, 0x6e,
+ 0x20, 0x72, 0xb0, 0xba, 0xec, 0x91, 0xbb, 0x6b,
+ 0xcc, 0x84, 0x0a, 0x33, 0x2b, 0x8a, 0x8d, 0xeb,
+ 0x71, 0xcd, 0xca, 0x67, 0x1b, 0xad, 0x10, 0xd4,
+ 0xce, 0x4f, 0xc0, 0x29, 0xec, 0xfa, 0xed, 0xfa};
- /* RSA Known Signed Hash (1024-bits). */
- static const PRUint8 rsa_known_sha512_signature[] = {
- 0xa5, 0xd0, 0x80, 0x04, 0x22, 0xfc, 0x80, 0x73,
- 0x7d, 0x46, 0xc8, 0x7b, 0xac, 0x44, 0x7b, 0xe6,
- 0x07, 0xe5, 0x61, 0x4c, 0x33, 0x7f, 0x6f, 0x46,
- 0x7c, 0x30, 0xe3, 0x75, 0x59, 0x4b, 0x42, 0xf3,
- 0x9f, 0x35, 0x3c, 0x10, 0x56, 0xdb, 0xd2, 0x69,
- 0x43, 0xcb, 0x77, 0xe9, 0x7d, 0xcd, 0x07, 0x43,
- 0xc5, 0xd4, 0x0c, 0x9d, 0xf5, 0x92, 0xbd, 0x0e,
- 0x3b, 0xb7, 0x68, 0x88, 0x84, 0xca, 0xae, 0x0d,
- 0xab, 0x71, 0x10, 0xad, 0xab, 0x27, 0xe4, 0xa3,
- 0x24, 0x41, 0xeb, 0x1c, 0xa6, 0x5f, 0xf1, 0x85,
- 0xd0, 0xf6, 0x22, 0x74, 0x3d, 0x81, 0xbe, 0xdd,
- 0x1b, 0x2a, 0x4c, 0xd1, 0x6c, 0xb5, 0x6d, 0x7a,
- 0xbb, 0x99, 0x69, 0x01, 0xa6, 0xc0, 0x98, 0xfa,
- 0x97, 0xa3, 0xd1, 0xb0, 0xdf, 0x09, 0xe3, 0x3d,
- 0x88, 0xee, 0x90, 0xf3, 0x10, 0x41, 0x0f, 0x06,
- 0x31, 0xe9, 0x60, 0x2d, 0xbf, 0x63, 0x7b, 0xf8};
+ /* RSA Known Signed Hash (2048-bits). */
+ static const PRUint8 rsa_known_sha512_signature[] = {
+ 0x35, 0x0e, 0x74, 0x9d, 0xeb, 0xc7, 0x67, 0x31,
+ 0x9f, 0xff, 0x0b, 0xbb, 0x5e, 0x66, 0xb4, 0x2f,
+ 0xbf, 0x72, 0x60, 0x4f, 0xe9, 0xbd, 0xec, 0xc8,
+ 0x17, 0x79, 0x5f, 0x39, 0x83, 0xb4, 0x54, 0x2e,
+ 0x01, 0xb9, 0xd3, 0x20, 0x47, 0xcb, 0xd4, 0x42,
+ 0xf2, 0x6e, 0x36, 0xc1, 0x97, 0xad, 0xef, 0x8e,
+ 0xe6, 0x51, 0xee, 0x5e, 0x9e, 0x88, 0xb4, 0x9d,
+ 0xda, 0x3e, 0x77, 0x4b, 0xe8, 0xae, 0x48, 0x53,
+ 0x2c, 0xc4, 0xd3, 0x25, 0x6b, 0x23, 0xb7, 0x54,
+ 0x3c, 0x95, 0x8f, 0xfb, 0x6f, 0x6d, 0xc5, 0x56,
+ 0x39, 0x69, 0x28, 0x0e, 0x74, 0x9b, 0x31, 0xe8,
+ 0x76, 0x77, 0x2b, 0xc1, 0x44, 0x89, 0x81, 0x93,
+ 0xfc, 0xf6, 0xec, 0x5f, 0x8f, 0x89, 0xfc, 0x1d,
+ 0xa4, 0x53, 0x58, 0x8c, 0xe9, 0xc0, 0xc0, 0x26,
+ 0xe6, 0xdf, 0x6d, 0x27, 0xb1, 0x8e, 0x3e, 0xb6,
+ 0x47, 0xe1, 0x02, 0x96, 0xc2, 0x5f, 0x7f, 0x3d,
+ 0xc5, 0x6c, 0x2f, 0xea, 0xaa, 0x5e, 0x39, 0xfc,
+ 0x77, 0xca, 0x00, 0x02, 0x5c, 0x64, 0x7c, 0xce,
+ 0x7d, 0x63, 0x82, 0x05, 0xed, 0xf7, 0x5b, 0x55,
+ 0x58, 0xc0, 0xeb, 0x76, 0xd7, 0x95, 0x55, 0x37,
+ 0x85, 0x7d, 0x17, 0xad, 0xd2, 0x11, 0xfd, 0x97,
+ 0x48, 0xb5, 0xc2, 0x5e, 0xc7, 0x62, 0xc0, 0xe0,
+ 0x68, 0xa8, 0x61, 0x14, 0x41, 0xca, 0x25, 0x3a,
+ 0xec, 0x48, 0x54, 0x22, 0x83, 0x2b, 0x69, 0x54,
+ 0xfd, 0xc8, 0x99, 0x9a, 0xee, 0x37, 0x03, 0xa3,
+ 0x8f, 0x0f, 0x32, 0xb0, 0xaa, 0x74, 0x39, 0x04,
+ 0x7c, 0xd9, 0xc2, 0x8f, 0xbe, 0xf2, 0xc4, 0xbe,
+ 0xdd, 0x7a, 0x7a, 0x7f, 0x72, 0xd3, 0x80, 0x59,
+ 0x18, 0xa0, 0xa1, 0x2d, 0x6f, 0xa3, 0xa9, 0x48,
+ 0xed, 0x20, 0xa6, 0xea, 0xaa, 0x10, 0x83, 0x98,
+ 0x0c, 0x13, 0x69, 0x6e, 0xcd, 0x31, 0x6b, 0xd0,
+ 0x66, 0xa6, 0x5e, 0x30, 0x0c, 0x82, 0xd5, 0x81};
static const RSAPublicKey bl_public_key = { NULL,
{ FIPS_RSA_TYPE, (unsigned char *)rsa_modulus,
@@ -1447,13 +1568,6 @@ sftk_fips_RSA_PowerUpSelfTest( void )
FIPS_RSA_DECRYPT_LENGTH ) != 0 ) )
goto rsa_loser;
- rsa_status = sftk_fips_RSA_PowerUpSigSelfTest (HASH_AlgSHA1,
- rsa_public_key, rsa_private_key,
- rsa_known_plaintext_msg, FIPS_RSA_MESSAGE_LENGTH,
- rsa_known_sha1_signature);
- if( rsa_status != SECSuccess )
- goto rsa_loser;
-
rsa_status = sftk_fips_RSA_PowerUpSigSelfTest (HASH_AlgSHA256,
rsa_public_key, rsa_private_key,
rsa_known_plaintext_msg, FIPS_RSA_MESSAGE_LENGTH,
@@ -1822,7 +1936,7 @@ sftk_fips_RNG_PowerUpSelfTest( void )
0x7f,0x7e,0xc8,0xae,0x9c,0x09,0x99,0x7d,
0xbb,0x9e,0x48,0x7f,0xbb,0x96,0x46,0xb3,
0x03,0x75,0xf8,0xc8,0x69,0x45,0x3f,0x97,
- 0x5e,0x2e,0x48,0xe1,0x5d,0x58,0x97,0x4c};
+ 0x5e,0x2e,0x48,0xe1,0x5d,0x58,0x97,0x4c };
static const PRUint8 rng_known_result[] = {
0x16,0xe1,0x8c,0x57,0x21,0xd8,0xf1,0x7e,
0x5a,0xa0,0x16,0x0b,0x7e,0xa6,0x25,0xb4,
@@ -1830,67 +1944,36 @@ sftk_fips_RNG_PowerUpSelfTest( void )
0xbb,0xaa,0x2a,0x1b,0x22,0x33,0x2e,0x4a,
0x14,0x07,0x9d,0x52,0xfc,0x73,0x61,0x48,
0xac,0xc1,0x22,0xfc,0xa4,0xfc,0xac,0xa4,
- 0xdb,0xda,0x5b,0x27,0x33,0xc4,0xb3,0xec,
- 0xb0,0xf2,0xee,0x63,0x11,0x61,0xdb,0x30,
- 0xd3,0x04,0x6b,0x96,0x22,0x1e,0x17,0x24,
- 0x1a,0x54,0x70,0xf3,0x4d,0x1c,0x6a,0xb0,
- 0xf9,0xe3,0xc8,0x07,0x97,0x5f,0xbb,0xe5,
- 0xde,0xce,0xa9,0x3f,0x91,0xd3,0x82,0x33,
- 0x11,0x3f,0x5b,0xb2,0xa9,0x1e,0x71,0x59,
- 0x68,0x8f,0x7d,0x77,0xfd,0xf5,0xcb,0xc8,
- 0x8f,0x51,0xb9,0x62,0x30,0x1b,0x12,0xa5,
- 0x7a,0xe1,0xf3,0x15,0x49,0x15,0xe9,0xc4,
- 0x3d,0x2d,0x1f,0x8c,0xe8,0x4e,0xd1,0xe6,
- 0x4e,0xf1,0x7a,0x64,0x2e,0x05,0xd6,0xee,
- 0xb8,0x7b,0x71,0x82,0x38,0x2b,0xc5,0xdd,
- 0x3a,0x32,0xae,0x64,0x0e,0xed,0x30,0xb2,
- 0x00,0x72,0x61,0x65,0xfb,0x09,0x26,0x68,
- 0x3e,0x36,0xb3,0x15,0xe2,0x30,0xde,0x49,
- 0xed,0x60,0xc5,0x40,0xe1,0x1a,0xe9,0x33,
- 0x7f,0x77,0xb5,0xa9,0xf7,0xa1,0xb9,0xdb,
- 0x77,0x61,0x00,0xc2,0x18,0xa1,0xa1,0x3a,
- 0x0e,0x2a,0x6c,0xa1,0x3f,0x33,0xdd,0xb9,
- 0x23,0x48,0x75,0x50,0xd3,0xbb,0xd9,0x0e,
- 0xdb,0xb4,0x62,0x33,0x52,0x41,0x5c,0xfc,
- 0xdd,0x89,0xd6,0x60,0xe8,0x2b,0x6f,0xb2,
- 0x7f,0x4d,0x97,0x8c,0x69,0xa4,0x15,0x16,
- 0x4c,0x7f,0x4d,0x8d,0x2e,0xec,0xfa,0x0e,
- 0xfa,0x37,0xe9,0x9d,0x21,0x9b,0x69,0x2a,
- 0xc5,0x4f,0x5b,0x59,0xe9,0x98,0x73,0x54,
- 0x28,0x33,0x4d,0x7c,0x53,0x8c,0x43,0x2b,
- 0xc7,0x0e,0xfb,0x35,0x9d,0xf7,0x2e,0x1a,
- 0xaa,0x80,0xa3,0x70,0x2c,0x72,0x43,0xb0,
- 0x35,0x3b,0xe2,0x58,0x63,0xf8,0x1d,0xcd,
- 0x55,0x66,0xb8,0x1e,0x06,0xa5,0xb6,0x4d,
- 0xc2,0x9f,0x9b,0xde,0xa3,0xda,0x67,0x0e,
- 0xd9,0x4b,0xfd,0x29,0xba,0x16,0x4e,0x03,
- 0xe9,0x04,0x9a,0x67,0xf8,0xc4,0xb7,0x01,
- 0xba,0x3c,0x5f,0xdd,0x8e,0x56,0xf3,0xea,
- 0xf4,0xfb,0x75,0x76,0x30,0x20,0xe6,0xec,
- 0x44,0xc9,0x76,0xb2,0x21,0x0c,0x1c,0xb9,
- 0x5f,0x27,0xff,0x09,0x45,0x2c,0x26,0xfd,
- 0x27,0xb0,0xca,0x67,0xd3,0xb0,0x77,0x3e,
- 0x10,0x46,0xdd,0x81,0x70,0x47,0x5c,0x12,
- 0xe7,0x37,0x49,0x17,0xf5,0x04,0xbc,0x62,
- 0xef,0xba,0x6e,0x1d,0xb9,0x42,0xb5,0xf9,
- 0xda,0x2f,0x5b,0x05,0xa7,0x34,0x19,0xf6,
- 0xa4,0xdb,0x45,0xb0,0x18,0x6b,0x32,0x75,
- 0x0f,0x34,0xc8,0x1c,0x14,0xca,0x4f,0xf9,
- 0x43,0x76,0xa5,0x41,0xeb,0xd4,0x37,0xc9,
- 0xc8,0x94,0xe7,0x0f,0x4a,0xa1,0x72,0xc7,
- 0x48,0xbd,0x1c,0x84,0x74,0x73,0xd1,0x73,
- 0xcd,0x1e,0xf0,0xb9,0x66,0x00,0x63,0xab};
+ 0xdb,0xda,0x5b,0x27,0x33,0xc4,0xb3 };
+ static const PRUint8 reseed_entropy[] = {
+ 0xc6,0x0b,0x0a,0x30,0x67,0x07,0xf4,0xe2,
+ 0x24,0xa7,0x51,0x6f,0x5f,0x85,0x3e,0x5d,
+ 0x67,0x97,0xb8,0x3b,0x30,0x9c,0x7a,0xb1,
+ 0x52,0xc6,0x1b,0xc9,0x46,0xa8,0x62,0x79 };
+ static const PRUint8 additional_input[] = {
+ 0x86,0x82,0x28,0x98,0xe7,0xcb,0x01,0x14,
+ 0xae,0x87,0x4b,0x1d,0x99,0x1b,0xc7,0x41,
+ 0x33,0xff,0x33,0x66,0x40,0x95,0x54,0xc6,
+ 0x67,0x4d,0x40,0x2a,0x1f,0xf9,0xeb,0x65 };
+ static const PRUint8 rng_reseed_result[] = {
+ 0x02,0x0c,0xc6,0x17,0x86,0x49,0xba,0xc4,
+ 0x7b,0x71,0x35,0x05,0xf0,0xdb,0x4a,0xc2,
+ 0x2c,0x38,0xc1,0xa4,0x42,0xe5,0x46,0x4a,
+ 0x7d,0xf0,0xbe,0x47,0x88,0xb8,0x0e,0xc6,
+ 0x25,0x2b,0x1d,0x13,0xef,0xa6,0x87,0x96,
+ 0xa3,0x7d,0x5b,0x80,0xc2,0x38,0x76,0x61,
+ 0xc7,0x80,0x5d,0x0f,0x05,0x76,0x85 };
static const PRUint8 Q[] = {
0x85,0x89,0x9c,0x77,0xa3,0x79,0xff,0x1a,
0x86,0x6f,0x2f,0x3e,0x2e,0xf9,0x8c,0x9c,
0x9d,0xef,0xeb,0xed};
- static const PRUint8 GENX[] = {
+ static const PRUint8 GENX[] = {
0x65,0x48,0xe3,0xca,0xac,0x64,0x2d,0xf7,
0x7b,0xd3,0x4e,0x79,0xc9,0x7d,0xa6,0xa8,
0xa2,0xc2,0x1f,0x8f,0xe9,0xb9,0xd3,0xa1,
0x3f,0xf7,0x0c,0xcd,0xa6,0xca,0xbf,0xce,
0x84,0x0e,0xb6,0xf1,0x0d,0xbe,0xa9,0xa3};
- static const PRUint8 rng_known_DSAX[] = {
+ static const PRUint8 rng_known_DSAX[] = {
0x7a,0x86,0xf1,0x7f,0xbd,0x4e,0x6e,0xd9,
0x0a,0x26,0x21,0xd0,0x19,0xcb,0x86,0x73,
0x10,0x1f,0x60,0xd7};
@@ -1898,6 +1981,7 @@ sftk_fips_RNG_PowerUpSelfTest( void )
SECStatus rng_status = SECSuccess;
+ PR_STATIC_ASSERT(sizeof(rng_known_result) >= sizeof(rng_reseed_result));
PRUint8 result[sizeof(rng_known_result)];
PRUint8 DSAX[FIPS_DSA_SUBPRIME_LENGTH];
@@ -1909,10 +1993,24 @@ sftk_fips_RNG_PowerUpSelfTest( void )
if (rng_status != SECSuccess) {
return ( CKR_DEVICE_ERROR );
}
- rng_status = PRNGTEST_Generate(result, sizeof result, NULL, 0);
+ rng_status = PRNGTEST_Generate(result, sizeof rng_known_result, NULL, 0);
if ( ( rng_status != SECSuccess) ||
( PORT_Memcmp( result, rng_known_result,
- sizeof result ) != 0 ) ) {
+ sizeof rng_known_result ) != 0 ) ) {
+ PRNGTEST_Uninstantiate();
+ return ( CKR_DEVICE_ERROR );
+ }
+ rng_status = PRNGTEST_Reseed(reseed_entropy, sizeof reseed_entropy,
+ additional_input, sizeof additional_input);
+ if (rng_status != SECSuccess) {
+ PRNGTEST_Uninstantiate();
+ return ( CKR_DEVICE_ERROR );
+ }
+ rng_status = PRNGTEST_Generate(result, sizeof rng_reseed_result, NULL, 0);
+ if ( ( rng_status != SECSuccess) ||
+ ( PORT_Memcmp( result, rng_reseed_result,
+ sizeof rng_reseed_result ) != 0 ) ) {
+ PRNGTEST_Uninstantiate();
return ( CKR_DEVICE_ERROR );
}
rng_status = PRNGTEST_Uninstantiate();
diff --git a/security/nss/lib/softoken/legacydb/config.mk b/security/nss/lib/softoken/legacydb/config.mk
index f155a2aedd57..eb184790f76a 100644
--- a/security/nss/lib/softoken/legacydb/config.mk
+++ b/security/nss/lib/softoken/legacydb/config.mk
@@ -90,21 +90,9 @@ EXTRA_SHARED_LIBS += \
endif
ifeq ($(OS_TARGET),SunOS)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-MKSHLIB += -R '$$ORIGIN'
OS_LIBS += -lbsm
endif
-ifeq ($(OS_ARCH), HP-UX)
-ifneq ($(OS_TEST), ia64)
-# pa-risc
-ifeq ($(USE_64), 1)
-MKSHLIB += +b '$$ORIGIN'
-endif
-endif
-endif
-
ifeq ($(OS_TARGET),WINCE)
DEFINES += -DDBM_USING_NSPR
endif
diff --git a/security/nss/lib/softoken/pk11pars.h b/security/nss/lib/softoken/pk11pars.h
index 20e2c3cb680e..dea16e753177 100644
--- a/security/nss/lib/softoken/pk11pars.h
+++ b/security/nss/lib/softoken/pk11pars.h
@@ -122,7 +122,7 @@ static PRBool secmod_argGetPair(char c) {
}
static PRBool secmod_argIsBlank(char c) {
- return isspace(c);
+ return isspace((unsigned char )c);
}
static PRBool secmod_argIsEscape(char c) {
diff --git a/security/nss/lib/softoken/pkcs11.c b/security/nss/lib/softoken/pkcs11.c
index f9572476f367..e536f8c104da 100644
--- a/security/nss/lib/softoken/pkcs11.c
+++ b/security/nss/lib/softoken/pkcs11.c
@@ -2589,8 +2589,6 @@ CK_RV nsc_CommonInitialize(CK_VOID_PTR pReserved, PRBool isFIPS)
crv = CKR_DEVICE_ERROR;
return crv;
}
- RNG_SystemInfoForRNG();
-
/* NOTE:
* we should be getting out mutexes from this list, not statically binding
diff --git a/security/nss/lib/softoken/pkcs11u.c b/security/nss/lib/softoken/pkcs11u.c
index a416c63f6a8d..7f44873e759b 100644
--- a/security/nss/lib/softoken/pkcs11u.c
+++ b/security/nss/lib/softoken/pkcs11u.c
@@ -143,7 +143,7 @@ sftk_FindTokenAttribute(SFTKTokenObject *object,CK_ATTRIBUTE_TYPE type)
{
SFTKAttribute *myattribute = NULL;
SFTKDBHandle *dbHandle = NULL;
- CK_RV crv;
+ CK_RV crv = CKR_HOST_MEMORY;
myattribute = (SFTKAttribute*)PORT_Alloc(sizeof(SFTKAttribute));
if (myattribute == NULL) {
diff --git a/security/nss/lib/softoken/sdb.c b/security/nss/lib/softoken/sdb.c
index 3a602771c550..f9d85130be0c 100644
--- a/security/nss/lib/softoken/sdb.c
+++ b/security/nss/lib/softoken/sdb.c
@@ -324,7 +324,7 @@ sdb_getTempDir(sqlite3 *sqlDB)
/*
* Map SQL_LITE errors to PKCS #11 errors as best we can.
*/
-static int
+static CK_RV
sdb_mapSQLError(sdbDataType type, int sqlerr)
{
switch (sqlerr) {
@@ -731,6 +731,7 @@ sdb_FindObjectsInit(SDB *sdb, const CK_ATTRIBUTE *template, CK_ULONG count,
loser:
if (findstmt) {
+ sqlite3_reset(findstmt);
sqlite3_finalize(findstmt);
}
if (sqlDB) {
@@ -1977,8 +1978,10 @@ s_open(const char *directory, const char *certPrefix, const char *keyPrefix,
int inUpdate;
PRUint32 accessOps;
- *certdb = NULL;
- *keydb = NULL;
+ if (certdb)
+ *certdb = NULL;
+ if (keydb)
+ *keydb = NULL;
*newInit = 0;
#ifdef SQLITE_UNSAFE_THREADS
diff --git a/security/nss/lib/softoken/sftkdb.c b/security/nss/lib/softoken/sftkdb.c
index 655e196870af..0a4d4d3ef92e 100644
--- a/security/nss/lib/softoken/sftkdb.c
+++ b/security/nss/lib/softoken/sftkdb.c
@@ -1328,12 +1328,13 @@ CK_RV
sftkdb_SetAttributeValue(SFTKDBHandle *handle, SFTKObject *object,
const CK_ATTRIBUTE *template, CK_ULONG count)
{
- CK_RV crv = CKR_OK;
CK_ATTRIBUTE *ntemplate;
unsigned char *data = NULL;
PLArenaPool *arena = NULL;
- CK_OBJECT_HANDLE objectID = (object->handle & SFTK_OBJ_ID_MASK);
SDB *db;
+ CK_RV crv = CKR_OK;
+ CK_OBJECT_HANDLE objectID = (object->handle & SFTK_OBJ_ID_MASK);
+ PRBool inTransaction = PR_FALSE;
if (handle == NULL) {
return CKR_TOKEN_WRITE_PROTECTED;
@@ -1363,18 +1364,20 @@ sftkdb_SetAttributeValue(SFTKDBHandle *handle, SFTKObject *object,
/* make sure we don't have attributes that conflict with the existing DB */
crv = sftkdb_checkConflicts(db, object->objclass, template, count, objectID);
if (crv != CKR_OK) {
- return crv;
+ goto loser;
}
arena = PORT_NewArena(256);
if (arena == NULL) {
- return CKR_HOST_MEMORY;
+ crv = CKR_HOST_MEMORY;
+ goto loser;
}
crv = (*db->sdb_Begin)(db);
if (crv != CKR_OK) {
goto loser;
}
+ inTransaction = PR_TRUE;
crv = sftkdb_setAttributeValue(arena, handle, db,
objectID, template, count);
if (crv != CKR_OK) {
@@ -1382,14 +1385,16 @@ sftkdb_SetAttributeValue(SFTKDBHandle *handle, SFTKObject *object,
}
crv = (*db->sdb_Commit)(db);
loser:
- if (crv != CKR_OK) {
+ if (crv != CKR_OK && inTransaction) {
(*db->sdb_Abort)(db);
}
if (data) {
PORT_Free(ntemplate);
PORT_Free(data);
}
- PORT_FreeArena(arena, PR_FALSE);
+ if (arena) {
+ PORT_FreeArena(arena, PR_FALSE);
+ }
return crv;
}
@@ -2113,7 +2118,8 @@ sftkdb_updateObjectTemplate(PRArenaPool *arena, SDB *db,
* give them a new CKA_ID */
/* NOTE: this changes ptemplate */
attr = sftkdb_getAttributeFromTemplate(CKA_ID,ptemplate,*plen);
- crv = sftkdb_incrementCKAID(arena, attr);
+ crv = attr ? sftkdb_incrementCKAID(arena, attr)
+ : CKR_HOST_MEMORY;
/* in the extremely rare event that we needed memory and
* couldn't get it, just drop the key */
if (crv != CKR_OK) {
diff --git a/security/nss/lib/softoken/sftkmod.c b/security/nss/lib/softoken/sftkmod.c
index 73c7dbb642ba..c89b7daaed79 100644
--- a/security/nss/lib/softoken/sftkmod.c
+++ b/security/nss/lib/softoken/sftkmod.c
@@ -628,12 +628,16 @@ sftkdb_DeleteSecmodDB(SDBType dbType, const char *appName,
}
fclose(fd);
fclose(fd2);
- /* rename dbname2 to dbname */
if (found) {
+ /* rename dbname2 to dbname */
PR_Delete(dbname);
PR_Rename(dbname2,dbname);
+ } else {
+ PR_Delete(dbname2);
}
PORT_Free(dbname2);
+ PORT_Free(lib);
+ PORT_Free(name);
return SECSuccess;
loser:
@@ -647,6 +651,8 @@ loser:
PR_Delete(dbname2);
PORT_Free(dbname2);
}
+ PORT_Free(lib);
+ PORT_Free(name);
return SECFailure;
}
@@ -695,9 +701,9 @@ sftkdb_AddSecmodDB(SDBType dbType, const char *appName,
block = sftkdb_DupCat(block, module);
break;
}
- value = sftk_argFetchValue(&keyEnd[1], &count);
block = sftkdb_DupnCat(block, module, keyEnd-module+1);
if (block == NULL) { goto loser; }
+ value = sftk_argFetchValue(&keyEnd[1], &count);
if (value) {
block = sftkdb_DupCat(block, sftk_argStrip(value));
PORT_Free(value);
diff --git a/security/nss/lib/softoken/sftkpars.c b/security/nss/lib/softoken/sftkpars.c
index 014514be2163..aefd69639ce3 100644
--- a/security/nss/lib/softoken/sftkpars.c
+++ b/security/nss/lib/softoken/sftkpars.c
@@ -74,7 +74,7 @@ static PRBool sftk_argGetPair(char c) {
}
static PRBool sftk_argIsBlank(char c) {
- return isspace(c);
+ return isspace((unsigned char )c);
}
static PRBool sftk_argIsEscape(char c) {
diff --git a/security/nss/lib/softoken/sftkpwd.c b/security/nss/lib/softoken/sftkpwd.c
index 3559898cfe75..9d56f1b11927 100644
--- a/security/nss/lib/softoken/sftkpwd.c
+++ b/security/nss/lib/softoken/sftkpwd.c
@@ -610,13 +610,13 @@ sftkdb_FreeUpdatePasswordKey(SFTKDBHandle *handle)
{
SECItem *key = NULL;
- /* if we're a cert db, we don't have one */
- if (handle->type == SFTK_CERTDB_TYPE) {
+ /* don't have one */
+ if (!handle) {
return;
}
- /* don't have one */
- if (!handle) {
+ /* if we're a cert db, we don't have one */
+ if (handle->type == SFTK_CERTDB_TYPE) {
return;
}
diff --git a/security/nss/lib/softoken/softkver.h b/security/nss/lib/softoken/softkver.h
index 67ee0b72be04..f292b856de17 100644
--- a/security/nss/lib/softoken/softkver.h
+++ b/security/nss/lib/softoken/softkver.h
@@ -57,7 +57,7 @@
* The format of the version string should be
* ".[.][ ][ ]"
*/
-#define SOFTOKEN_VERSION "3.12.4" SOFTOKEN_ECC_STRING
+#define SOFTOKEN_VERSION "3.12.4.4" SOFTOKEN_ECC_STRING
#define SOFTOKEN_VMAJOR 3
#define SOFTOKEN_VMINOR 12
#define SOFTOKEN_VPATCH 4
diff --git a/security/nss/lib/sqlite/config.mk b/security/nss/lib/sqlite/config.mk
index fa476ff9fe2d..219bb5bfb282 100644
--- a/security/nss/lib/sqlite/config.mk
+++ b/security/nss/lib/sqlite/config.mk
@@ -55,17 +55,6 @@ endif
endif
ifeq ($(OS_TARGET),SunOS)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-MKSHLIB += -R '$$ORIGIN'
OS_LIBS += -lbsm
endif
-ifeq ($(OS_ARCH), HP-UX)
-ifneq ($(OS_TEST), ia64)
-# pa-risc
-ifeq ($(USE_64), 1)
-MKSHLIB += +b '$$ORIGIN'
-endif
-endif
-endif
diff --git a/security/nss/lib/ssl/config.mk b/security/nss/lib/ssl/config.mk
index 8901280f6a93..5bbcd33c817a 100644
--- a/security/nss/lib/ssl/config.mk
+++ b/security/nss/lib/ssl/config.mk
@@ -107,19 +107,4 @@ ifeq ($(OS_ARCH), BeOS)
EXTRA_SHARED_LIBS += -lbe
endif
-ifeq ($(OS_TARGET),SunOS)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-MKSHLIB += -R '$$ORIGIN'
-endif
-
-ifeq ($(OS_ARCH), HP-UX)
-ifneq ($(OS_TEST), ia64)
-# pa-risc
-ifeq ($(USE_64), 1)
-MKSHLIB += +b '$$ORIGIN'
-endif
-endif
-endif
-
endif
diff --git a/security/nss/lib/ssl/sslmutex.c b/security/nss/lib/ssl/sslmutex.c
index a91dde3efc79..6b5dbd166392 100644
--- a/security/nss/lib/ssl/sslmutex.c
+++ b/security/nss/lib/ssl/sslmutex.c
@@ -33,7 +33,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-/* $Id: sslmutex.c,v 1.23 2008/12/02 06:36:59 nelson%bolyard.com Exp $ */
+/* $Id: sslmutex.c,v 1.24 2009/06/05 02:34:14 nelson%bolyard.com Exp $ */
#include "seccomon.h"
/* This ifdef should match the one in sslsnce.c */
@@ -89,7 +89,7 @@ static SECStatus single_process_sslMutex_Lock(sslMutex* pMutex)
return SECSuccess;
}
-#if defined(LINUX) || defined(AIX) || defined(VMS) || defined(BEOS) || defined(BSDI) || (defined(NETBSD) && __NetBSD_Version__ < 500000000) || defined(OPENBSD)
+#if defined(LINUX) || defined(AIX) || defined(BEOS) || defined(BSDI) || (defined(NETBSD) && __NetBSD_Version__ < 500000000) || defined(OPENBSD)
#include
#include
diff --git a/security/nss/lib/ssl/sslmutex.h b/security/nss/lib/ssl/sslmutex.h
index aeeef64e10d0..0fdb6852a3c1 100644
--- a/security/nss/lib/ssl/sslmutex.h
+++ b/security/nss/lib/ssl/sslmutex.h
@@ -33,7 +33,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-/* $Id: sslmutex.h,v 1.11 2008/12/02 06:36:59 nelson%bolyard.com Exp $ */
+/* $Id: sslmutex.h,v 1.12 2009/06/05 02:34:15 nelson%bolyard.com Exp $ */
#ifndef __SSLMUTEX_H_
#define __SSLMUTEX_H_ 1
@@ -83,7 +83,7 @@ typedef struct
typedef int sslPID;
-#elif defined(LINUX) || defined(AIX) || defined(VMS) || defined(BEOS) || defined(BSDI) || (defined(NETBSD) && __NetBSD_Version__ < 500000000) || defined(OPENBSD)
+#elif defined(LINUX) || defined(AIX) || defined(BEOS) || defined(BSDI) || (defined(NETBSD) && __NetBSD_Version__ < 500000000) || defined(OPENBSD)
#include
#include "prtypes.h"
diff --git a/security/nss/lib/ssl/sslsnce.c b/security/nss/lib/ssl/sslsnce.c
index 29864543b969..5387f2c20123 100644
--- a/security/nss/lib/ssl/sslsnce.c
+++ b/security/nss/lib/ssl/sslsnce.c
@@ -36,7 +36,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-/* $Id: sslsnce.c,v 1.49 2008/12/02 06:36:59 nelson%bolyard.com Exp $ */
+/* $Id: sslsnce.c,v 1.50 2009/06/05 02:34:15 nelson%bolyard.com Exp $ */
/* Note: ssl_FreeSID() in sslnonce.c gets used for both client and server
* cache sids!
@@ -260,7 +260,7 @@ static PRBool isMultiProcess = PR_FALSE;
#define MAX_SSL3_TIMEOUT 86400L /* 24 hours */
#define MIN_SSL3_TIMEOUT 5 /* seconds */
-#if defined(AIX) || defined(LINUX) || defined(VMS) || defined(NETBSD) || defined(OPENBSD)
+#if defined(AIX) || defined(LINUX) || defined(NETBSD) || defined(OPENBSD)
#define MAX_SID_CACHE_LOCKS 8 /* two FDs per lock */
#elif defined(OSF1)
#define MAX_SID_CACHE_LOCKS 16 /* one FD per lock */
diff --git a/security/nss/lib/util/config.mk b/security/nss/lib/util/config.mk
index b51f3db58919..bc025571c3e0 100644
--- a/security/nss/lib/util/config.mk
+++ b/security/nss/lib/util/config.mk
@@ -80,25 +80,3 @@ EXTRA_SHARED_LIBS += \
endif
-ifeq ($(OS_TARGET),SunOS)
-ifeq ($(BUILD_SUN_PKG), 1)
-# The -R '$ORIGIN' linker option instructs this library to search for its
-# dependencies in the same directory where it resides.
-ifeq ($(USE_64), 1)
-MKSHLIB += -R '$$ORIGIN:/usr/lib/mps/secv1/64:/usr/lib/mps/64'
-else
-MKSHLIB += -R '$$ORIGIN:/usr/lib/mps/secv1:/usr/lib/mps'
-endif
-else
-MKSHLIB += -R '$$ORIGIN'
-endif
-endif
-
-ifeq ($(OS_ARCH), HP-UX)
-ifneq ($(OS_TEST), ia64)
-# pa-risc
-ifeq ($(USE_64), 1)
-MKSHLIB += +b '$$ORIGIN'
-endif
-endif
-endif
diff --git a/security/nss/lib/util/nssutil.h b/security/nss/lib/util/nssutil.h
index 83b057117ede..bb100479bdbe 100644
--- a/security/nss/lib/util/nssutil.h
+++ b/security/nss/lib/util/nssutil.h
@@ -51,7 +51,7 @@
* The format of the version string should be
* ".[.][ ]"
*/
-#define NSSUTIL_VERSION "3.12.4 Beta"
+#define NSSUTIL_VERSION "3.12.4.4 Beta"
#define NSSUTIL_VMAJOR 3
#define NSSUTIL_VMINOR 12
#define NSSUTIL_VPATCH 4
diff --git a/security/nss/pkg/solaris/SUNWtlsd/prototype b/security/nss/pkg/solaris/SUNWtlsd/prototype
index fab227f29910..6e9ccf519999 100755
--- a/security/nss/pkg/solaris/SUNWtlsd/prototype
+++ b/security/nss/pkg/solaris/SUNWtlsd/prototype
@@ -38,7 +38,7 @@
#
# ***** END LICENSE BLOCK *****
#
-#ident "$Id: prototype,v 1.9 2009/03/02 23:21:03 christophe.ravel.bugs%sun.com Exp $"
+#ident "$Id: prototype,v 1.10 2009/06/25 01:29:18 julien.pierre.boogz%sun.com Exp $"
#
# This required package information file contains a list of package contents.
# The 'pkgmk' command uses this file to identify the contents of a package
@@ -159,3 +159,4 @@ f none usr/include/mps/ssl.h 0644 root bin
f none usr/include/mps/sslerr.h 0644 root bin
f none usr/include/mps/sslproto.h 0644 root bin
f none usr/include/mps/sslt.h 0644 root bin
+f none usr/include/mps/utilrename.h 0644 root bin
diff --git a/security/nss/tests/chains/chains.sh b/security/nss/tests/chains/chains.sh
index ffa6aed5c80c..d6e1b76ca564 100644
--- a/security/nss/tests/chains/chains.sh
+++ b/security/nss/tests/chains/chains.sh
@@ -167,7 +167,8 @@ n
6
7
9
-n" > ${CU_DATA}
+n
+" > ${CU_DATA}
TESTNAME="Creating Root CA ${ENTITY}"
echo "${SCRIPTNAME}: ${TESTNAME}"
@@ -204,20 +205,25 @@ create_cert_req()
CA_FLAG=
EXT_DATA=
+ OPTIONS=
+
if [ "${TYPE}" != "EE" ]; then
CA_FLAG="-2"
EXT_DATA="y
-1
-y"
+y
+"
fi
+ process_crldp
+
echo "${EXT_DATA}" > ${CU_DATA}
TESTNAME="Creating ${TYPE} certifiate request ${REQ}"
echo "${SCRIPTNAME}: ${TESTNAME}"
- echo "certutil -s \"CN=${ENTITY} ${TYPE}, O=${ENTITY}, C=US\" ${CTYPE_OPT} -R ${CA_FLAG} -d ${ENTITY_DB} -f ${ENTITY_DB}/dbpasswd -z ${NOISE_FILE} -o ${REQ} < ${CU_DATA}"
+ echo "certutil -s \"CN=${ENTITY} ${TYPE}, O=${ENTITY}, C=US\" ${CTYPE_OPT} -R ${CA_FLAG} -d ${ENTITY_DB} -f ${ENTITY_DB}/dbpasswd -z ${NOISE_FILE} -o ${REQ} ${OPTIONS} < ${CU_DATA}"
print_cu_data
- ${BINDIR}/certutil -s "CN=${ENTITY} ${TYPE}, O=${ENTITY}, C=US" ${CTYPE_OPT} -R ${CA_FLAG} -d ${ENTITY_DB} -f ${ENTITY_DB}/dbpasswd -z ${NOISE_FILE} -o ${REQ} < ${CU_DATA}
+ ${BINDIR}/certutil -s "CN=${ENTITY} ${TYPE}, O=${ENTITY}, C=US" ${CTYPE_OPT} -R ${CA_FLAG} -d ${ENTITY_DB} -f ${ENTITY_DB}/dbpasswd -z ${NOISE_FILE} -o ${REQ} ${OPTIONS} < ${CU_DATA}
html_msg $? 0 "${SCENARIO}${TESTNAME}"
}
@@ -395,10 +401,71 @@ process_ocsp()
${NSS_AIA_OCSP}:${OCSP}
0
n
-n"
+n
+"
fi
}
+process_crldp()
+{
+ if [ -n "${CRLDP}" ]; then
+ OPTIONS="${OPTIONS} -4"
+
+ EXT_DATA="${EXT_DATA}1
+"
+
+ for ITEM in ${CRLDP}; do
+ CRL_PUBLIC="${HOST}-$$-${ITEM}.crl"
+
+ EXT_DATA="${EXT_DATA}7
+${NSS_AIA_HTTP}/${CRL_PUBLIC}
+"
+ done
+
+ EXT_DATA="${EXT_DATA}0
+0
+0
+n
+n
+"
+ fi
+}
+
+process_ku_ns_eku()
+{
+ if [ -n "${EXT_KU}" ]; then
+ OPTIONS="${OPTIONS} --keyUsage ${EXT_KU}"
+ fi
+ if [ -n "${EXT_NS}" ]; then
+ EXT_NS_KEY=$(echo ${EXT_NS} | cut -d: -f1)
+ EXT_NS_CODE=$(echo ${EXT_NS} | cut -d: -f2)
+
+ OPTIONS="${OPTIONS} --nsCertType ${EXT_NS_KEY}"
+ DATA="${DATA}${EXT_NS_CODE}
+-1
+n
+"
+ fi
+ if [ -n "${EXT_EKU}" ]; then
+ OPTIONS="${OPTIONS} --extKeyUsage ${EXT_EKU}"
+ fi
+}
+
+copy_crl()
+
+{
+ if [ -z "${NSS_AIA_PATH}" ]; then
+ return;
+ fi
+
+ CRL_LOCAL="${COPYCRL}.crl"
+ CRL_PUBLIC="${HOST}-$$-${COPYCRL}.crl"
+
+ cp ${CRL_LOCAL} ${NSS_AIA_PATH}/${CRL_PUBLIC} 2> /dev/null
+ chmod a+r ${NSS_AIA_PATH}/${CRL_PUBLIC}
+ echo ${NSS_AIA_PATH}/${CRL_PUBLIC} >> ${AIA_FILES}
+}
+
########################## process_extension ###########################
# local shell function to process entity extension parameters and
# generate input for certutil
@@ -413,6 +480,7 @@ process_extensions()
process_inhibit
process_aia
process_ocsp
+ process_ku_ns_eku
}
############################## sign_cert ###############################
@@ -663,16 +731,19 @@ verify_cert()
fi
done
- TESTNAME="Verifying certificate(s) ${VFY_LIST} with flags ${REV_OPTS} ${DB_OPT} ${FETCH_OPT} ${POLICY_OPT} ${TRUST_OPT}"
+ VFY_OPTS_TNAME="${REV_OPTS} ${DB_OPT} ${FETCH_OPT} ${USAGE_OPT} ${POLICY_OPT} ${TRUST_OPT}"
+ VFY_OPTS_ALL="${DB_OPT} -pp -vv ${REV_OPTS} ${FETCH_OPT} ${USAGE_OPT} ${POLICY_OPT} ${VFY_CERTS} ${TRUST_OPT}"
+
+ TESTNAME="Verifying certificate(s) ${VFY_LIST} with flags ${VFY_OPTS_TNAME}"
echo "${SCRIPTNAME}: ${TESTNAME}"
- echo "vfychain ${DB_OPT} -pp -vv ${REV_OPTS} ${FETCH_OPT} ${POLICY_OPT} ${VFY_CERTS} ${TRUST_OPT}"
+ echo "vfychain ${VFY_OPTS_ALL}"
if [ -z "${MEMLEAK_DBG}" ]; then
- VFY_OUT=$(${BINDIR}/vfychain ${DB_OPT} -pp -vv ${REV_OPTS} ${FETCH_OPT} ${POLICY_OPT} ${VFY_CERTS} ${TRUST_OPT} 2>&1)
+ VFY_OUT=$(${BINDIR}/vfychain ${VFY_OPTS_ALL} 2>&1)
RESULT=$?
echo "${VFY_OUT}"
else
- VFY_OUT=$(${RUN_COMMAND_DBG} ${BINDIR}/vfychain ${REV_OPTS} ${DB_OPT} -pp -vv ${FETCH_OPT} ${POLICY_OPT} ${VFY_CERTS} ${TRUST_OPT} 2>> ${LOGFILE})
+ VFY_OUT=$(${RUN_COMMAND_DBG} ${BINDIR}/vfychain ${VFY_OPTS_ALL} 2>> ${LOGFILE})
RESULT=$?
echo "${VFY_OUT}"
fi
@@ -699,7 +770,6 @@ verify_cert()
fi
}
-
check_ocsp()
{
OCSP_CERT=$1
@@ -722,7 +792,7 @@ check_ocsp()
ping -n 1 ${OCSP_HOST}
return $?
elif [ "${OS_ARCH}" = "HP-UX" ]; then
- ping ${OCSP_HOST} -c 1
+ ping ${OCSP_HOST} -n 1
return $?
else
ping -c 1 ${OCSP_HOST}
@@ -780,9 +850,13 @@ parse_config()
MAPPING=
INHIBIT=
AIA=
+ CRLDP=
OCSP=
DB=
EMAILS=
+ EXT_KU=
+ EXT_NS=
+ EXT_EKU=
;;
"type")
TYPE="${VALUE}"
@@ -800,6 +874,9 @@ parse_config()
MAPPING=
INHIBIT=
AIA=
+ EXT_KU=
+ EXT_NS=
+ EXT_EKU=
;;
"ctype")
CTYPE="${VALUE}"
@@ -816,6 +893,9 @@ parse_config()
"aia")
AIA="${AIA} ${VALUE}"
;;
+ "crldp")
+ CRLDP="${CRLDP} ${VALUE}"
+ ;;
"ocsp")
OCSP="${VALUE}"
;;
@@ -842,6 +922,10 @@ parse_config()
"serial")
SERIAL="${VALUE}"
;;
+ "copycrl")
+ COPYCRL="${VALUE}"
+ copy_crl "${COPYCRL}"
+ ;;
"verify")
VERIFY="${VALUE}"
TRUST=
@@ -849,6 +933,7 @@ parse_config()
FETCH=
EXP_RESULT=
REV_OPTS=
+ USAGE_OPT=
;;
"cert")
VERIFY="${VERIFY} ${VALUE}"
@@ -907,6 +992,18 @@ parse_config()
break;
fi
;;
+ "ku")
+ EXT_KU="${VALUE}"
+ ;;
+ "ns")
+ EXT_NS="${VALUE}"
+ ;;
+ "eku")
+ EXT_EKU="${VALUE}"
+ ;;
+ "usage")
+ USAGE_OPT="-u ${VALUE}"
+ ;;
"")
if [ -n "${ENTITY}" ]; then
if [ -z "${DB}" ]; then
diff --git a/security/nss/tests/dbtests/dbtests.sh b/security/nss/tests/dbtests/dbtests.sh
index e48d4dae9d1c..5614e51202bb 100755
--- a/security/nss/tests/dbtests/dbtests.sh
+++ b/security/nss/tests/dbtests/dbtests.sh
@@ -80,8 +80,6 @@ dbtest_init()
fi
SCRIPTNAME="dbtests.sh"
- DBTEST_LOG=${HOSTDIR}/dbtest.log #we don't want all the errormessages
- # in the output.log, otherwise we can't tell what's a real error
RONLY_DIR=${HOSTDIR}/ronlydir
EMPTY_DIR=${HOSTDIR}/emptydir
CONFLICT_DIR=${HOSTDIR}/conflictdir
@@ -283,5 +281,5 @@ dbtest_main()
################## main #################################################
dbtest_init
-dbtest_main >$DBTEST_LOG 2>&1
+dbtest_main 2>&1
dbtest_cleanup
diff --git a/security/nss/tests/libpkix/certs/PayPalEE.cert b/security/nss/tests/libpkix/certs/PayPalEE.cert
index 1a8a08593305..6e7f755542f4 100644
Binary files a/security/nss/tests/libpkix/certs/PayPalEE.cert and b/security/nss/tests/libpkix/certs/PayPalEE.cert differ
diff --git a/security/nss/tests/libpkix/certs/PayPalICA.cert b/security/nss/tests/libpkix/certs/PayPalICA.cert
index 28e971d68441..459373be9487 100644
Binary files a/security/nss/tests/libpkix/certs/PayPalICA.cert and b/security/nss/tests/libpkix/certs/PayPalICA.cert differ
diff --git a/toolkit/components/feeds/src/FeedProcessor.js b/toolkit/components/feeds/src/FeedProcessor.js
index 64298ee083f7..9c30ab94ed96 100644
--- a/toolkit/components/feeds/src/FeedProcessor.js
+++ b/toolkit/components/feeds/src/FeedProcessor.js
@@ -803,25 +803,25 @@ function LC(element) {
// create a generator element
function atomGenerator(s, generator) {
generator.QueryInterface(Ci.nsIFeedGenerator);
- generator.agent = trimString(s);
+ generator.agent = s.trim();
return generator;
}
// post-process atom:logo to create an RSS2-like structure
function atomLogo(s, logo) {
- logo.setPropertyAsAString("url", trimString(s));
+ logo.setPropertyAsAString("url", s.trim());
}
// post-process an RSS category, map it to the Atom fields.
function rssCatTerm(s, cat) {
// add slash handling?
- cat.setPropertyAsAString("term", trimString(s));
+ cat.setPropertyAsAString("term", s.trim());
return cat;
}
// post-process a GUID
function rssGuid(s, guid) {
- guid.setPropertyAsAString("guid", trimString(s));
+ guid.setPropertyAsAString("guid", s.trim());
return guid;
}
@@ -841,13 +841,13 @@ function rssGuid(s, guid) {
function rssAuthor(s,author) {
author.QueryInterface(Ci.nsIFeedPerson);
// check for RSS2 string format
- var chars = trimString(s);
+ var chars = s.trim();
var matches = chars.match(/(.*)\((.*)\)/);
var emailCheck =
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (matches) {
- var match1 = trimString(matches[1]);
- var match2 = trimString(matches[2]);
+ var match1 = matches[1].trim();
+ var match2 = matches[2].trim();
if (match2.indexOf("mailto:") == 0)
match2 = match2.substring(7);
if (emailCheck.test(match1)) {
@@ -896,16 +896,6 @@ function isValidRFC822Date(aDateStr) {
return regex.test(aDateStr);
}
-/**
- * Removes leading and trailing whitespace from a string.
- * @param s The string to trim.
- *
- * @returns A new string with whitespace stripped.
- */
-function trimString(s) {
- return(s.replace(/^\s+/, "").replace(/\s+$/, ""));
-}
-
// Regular expression matching RFC822 dates
const RFC822_RE = "^((Mon|Tue|Wed|Thu|Fri|Sat|Sun)([a-z]+)?,? *)?\\d\\d?"
+ " +(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)([a-z]+)?"
@@ -922,7 +912,7 @@ const RFC822_RE = "^((Mon|Tue|Wed|Thu|Fri|Sat|Sun)([a-z]+)?,? *)?\\d\\d?"
* @returns A Date.toString XXX--fixme
*/
function dateParse(dateString) {
- var date = trimString(dateString);
+ var date = dateString.trim();
if (date.search(/^\d\d\d\d/) != -1) //Could be a ISO8601/W3C date
return W3CToIETFDate(dateString);
@@ -1067,7 +1057,7 @@ XHTMLHandler.prototype = {
// When we peek too far, go back to the main processor
if (this._depth < 0) {
- this._processor.returnFromXHTMLHandler(trimString(this._buf),
+ this._processor.returnFromXHTMLHandler(this._buf.trim(),
uri, localName, qName);
return;
}
@@ -1134,7 +1124,7 @@ ExtensionHandler.prototype = {
endElement: function EH_endElement(uri, localName, qName) {
--this._depth;
if (this._depth == 0) {
- var text = this._hasChildElements ? null : trimString(this._buf);
+ var text = this._hasChildElements ? null : this._buf.trim();
this._processor.returnFromExtHandler(this._uri, this._localName,
text, this._attrs);
}
@@ -1779,7 +1769,7 @@ FeedProcessor.prototype = {
// Only for RSS2esque formats
_findRSSVersion: function FP__findRSSVersion(attributes) {
- var versionAttr = trimString(attributes.getValueFromName("", "version"));
+ var versionAttr = attributes.getValueFromName("", "version").trim();
var versions = { "0.91":"rss091",
"0.92":"rss092",
"0.93":"rss093",
diff --git a/toolkit/content/contentAreaUtils.js b/toolkit/content/contentAreaUtils.js
index c3ac0f345c37..83cbad598419 100644
--- a/toolkit/content/contentAreaUtils.js
+++ b/toolkit/content/contentAreaUtils.js
@@ -41,6 +41,15 @@
#
# ***** END LICENSE BLOCK *****
+var ContentAreaUtils = {
+ get ioService() {
+ delete this.ioService;
+ return this.ioService =
+ Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+ }
+}
+
/**
* urlSecurityCheck: JavaScript wrapper for checkLoadURIWithPrincipal
* and checkLoadURIStrWithPrincipal.
@@ -772,16 +781,12 @@ function makeWebBrowserPersist()
*/
function makeURI(aURL, aOriginCharset, aBaseURI)
{
- var ioService = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- return ioService.newURI(aURL, aOriginCharset, aBaseURI);
+ return ContentAreaUtils.ioService.newURI(aURL, aOriginCharset, aBaseURI);
}
function makeFileURI(aFile)
{
- var ioService = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- return ioService.newFileURI(aFile);
+ return ContentAreaUtils.ioService.newFileURI(aFile);
}
function makeFilePicker()
@@ -1025,9 +1030,7 @@ function getCharsetforSave(aDocument)
*/
function openURL(aURL)
{
- var ios = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- var uri = ios.newURI(aURL, null, null);
+ var uri = makeURI(aURL);
var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
.getService(Components.interfaces.nsIExternalProtocolService);
@@ -1075,7 +1078,7 @@ function openURL(aURL)
}
}
- var channel = ios.newChannelFromURI(uri);
+ var channel = ContentAreaUtils.ioService.newChannelFromURI(uri);
var uriLoader = Components.classes["@mozilla.org/uriloader;1"]
.getService(Components.interfaces.nsIURILoader);
uriLoader.openURI(channel, true, uriListener);
diff --git a/toolkit/locales/en-US/chrome/global/filepicker.properties b/toolkit/locales/en-US/chrome/global/filepicker.properties
index 3fc9d36ffde2..e250be0e9b6e 100644
--- a/toolkit/locales/en-US/chrome/global/filepicker.properties
+++ b/toolkit/locales/en-US/chrome/global/filepicker.properties
@@ -7,7 +7,6 @@ htmlFilter=*.html; *.htm; *.shtml; *.xhtml
textTitle=Text Files
textFilter=*.txt; *.text
imageTitle=Image Files
-imageFilter=*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.xbm; *.ico
xmlTitle=XML Files
xmlFilter=*.xml
xulTitle=XUL Files
diff --git a/toolkit/toolkit-makefiles.sh b/toolkit/toolkit-makefiles.sh
index c4163e3ec6d0..77094a4f0d59 100644
--- a/toolkit/toolkit-makefiles.sh
+++ b/toolkit/toolkit-makefiles.sh
@@ -809,7 +809,6 @@ MAKEFILES_libpr0n="
modules/libpr0n/decoders/icon/win/Makefile
modules/libpr0n/decoders/icon/gtk/Makefile
modules/libpr0n/decoders/icon/beos/Makefile
- modules/libpr0n/decoders/xbm/Makefile
modules/libpr0n/encoders/Makefile
modules/libpr0n/encoders/png/Makefile
modules/libpr0n/encoders/jpeg/Makefile
diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp
index 80736937fa9d..00baa955f006 100644
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -98,13 +98,22 @@ struct nsRequestInfo : public PLDHashEntryHdr
{
nsRequestInfo(const void *key)
: mKey(key), mCurrentProgress(0), mMaxProgress(0), mUploading(PR_FALSE)
+ , mIsDone(PR_FALSE)
{
}
+ nsIRequest* Request() {
+ return static_cast(const_cast(mKey));
+ }
+
const void* mKey; // Must be first for the pldhash stubs to work
nsInt64 mCurrentProgress;
nsInt64 mMaxProgress;
PRBool mUploading;
+
+ PRBool mIsDone;
+ nsString mLastStatus;
+ nsresult mLastStatusCode;
};
@@ -117,6 +126,12 @@ RequestInfoHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
return PR_TRUE;
}
+static void
+RequestInfoHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
+{
+ nsRequestInfo* info = static_cast(entry);
+ info->~nsRequestInfo();
+}
struct nsListenerInfo {
nsListenerInfo(nsIWeakReference *aListener, unsigned long aNotifyMask)
@@ -153,7 +168,7 @@ nsDocLoader::nsDocLoader()
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,
- PL_DHashClearEntryStub,
+ RequestInfoHashClearEntry,
PL_DHashFinalizeStub,
RequestInfoHashInitEntry
};
@@ -576,6 +591,8 @@ nsDocLoader::OnStopRequest(nsIRequest *aRequest,
//
nsRequestInfo *info = GetRequestInfo(aRequest);
if (info) {
+ info->mIsDone = PR_TRUE;
+
nsInt64 oldMax = info->mMaxProgress;
info->mMaxProgress = info->mCurrentProgress;
@@ -837,6 +854,24 @@ void nsDocLoader::doStartURLLoad(nsIRequest *request)
NS_OK);
}
+// PLDHashTable enumeration callback that finds a RequestInfo that's not done
+// yet.
+static PLDHashOperator
+FindUnfinishedRequestCallback(PLDHashTable *table, PLDHashEntryHdr *hdr,
+ PRUint32 number, void *arg)
+{
+ nsRequestInfo* info = static_cast(hdr);
+ nsRequestInfo** retval = static_cast(arg);
+
+ if (!info->mIsDone && !info->mLastStatus.IsEmpty()) {
+ *retval = info;
+ return PL_DHASH_STOP;
+ }
+
+ return PL_DHASH_NEXT;
+}
+
+
void nsDocLoader::doStopURLLoad(nsIRequest *request, nsresult aStatus)
{
#if defined(DEBUG)
@@ -854,6 +889,17 @@ void nsDocLoader::doStopURLLoad(nsIRequest *request, nsresult aStatus)
nsIWebProgressListener::STATE_STOP |
nsIWebProgressListener::STATE_IS_REQUEST,
aStatus);
+
+ // Fire a status change message for a random unfinished request to make sure
+ // that the displayed status is not outdated.
+ nsRequestInfo* unfinishedRequest = nsnull;
+ PL_DHashTableEnumerate(&mRequestInfoHash, FindUnfinishedRequestCallback,
+ &unfinishedRequest);
+ if (unfinishedRequest) {
+ FireOnStatusChange(this, unfinishedRequest->Request(),
+ unfinishedRequest->mLastStatusCode,
+ unfinishedRequest->mLastStatus.get());
+ }
}
void nsDocLoader::doStopDocumentLoad(nsIRequest *request,
@@ -1113,6 +1159,15 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsISupports* ctxt,
nsXPIDLString msg;
rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg));
if (NS_FAILED(rv)) return rv;
+
+ // Keep around the message. In case a request finishes, we need to make sure
+ // to send the status message of another request to our user to that we
+ // don't display, for example, "Transferring" messages for requests that are
+ // already done.
+ if (info) {
+ info->mLastStatus = msg;
+ info->mLastStatusCode = aStatus;
+ }
FireOnStatusChange(this, aRequest, aStatus, msg);
}
return NS_OK;
@@ -1696,4 +1751,3 @@ void nsDocLoader::DumpChannelInfo()
printf("\nCurrent=%d Total=%d\n====\n", current, max);
}
#endif /* 0 */
-
diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp
index 9864ad0f2d1e..1bad616d74a7 100644
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -1869,142 +1869,6 @@ NS_METHOD nsWindow::SetCursor(nsCursor aCursor)
return NS_OK;
}
-// Adjust cursor image data
-PRUint8* nsWindow::Data32BitTo1Bit(PRUint8* aImageData,
- PRUint32 aWidth, PRUint32 aHeight)
-{
- // We need (aWidth + 7) / 8 bytes plus zero-padding up to a multiple of
- // 4 bytes for each row (HBITMAP requirement). Bug 353553.
- PRUint32 outBpr = ((aWidth + 31) / 8) & ~3;
-
- // Allocate and clear mask buffer
- PRUint8* outData = (PRUint8*)PR_Calloc(outBpr, aHeight);
- if (!outData)
- return NULL;
-
- PRInt32 *imageRow = (PRInt32*)aImageData;
- for (PRUint32 curRow = 0; curRow < aHeight; curRow++) {
- PRUint8 *outRow = outData + curRow * outBpr;
- PRUint8 mask = 0x80;
- for (PRUint32 curCol = 0; curCol < aWidth; curCol++) {
- // Use sign bit to test for transparency, as alpha byte is highest byte
- if (*imageRow++ < 0)
- *outRow |= mask;
-
- mask >>= 1;
- if (!mask) {
- outRow ++;
- mask = 0x80;
- }
- }
- }
-
- return outData;
-}
-
-PRBool nsWindow::IsCursorTranslucencySupported()
-{
-#ifdef WINCE
- return PR_FALSE;
-#else
- static PRBool didCheck = PR_FALSE;
- static PRBool isSupported = PR_FALSE;
- if (!didCheck) {
- didCheck = PR_TRUE;
- // Cursor translucency is supported on Windows XP and newer
- isSupported = nsWindow::GetWindowsVersion() >= 0x501;
- }
-
- return isSupported;
-#endif
-}
-
-/**
- * Convert the given image data to a HBITMAP. If the requested depth is
- * 32 bit and the OS supports translucency, a bitmap with an alpha channel
- * will be returned.
- *
- * @param aImageData The image data to convert. Must use the format accepted
- * by CreateDIBitmap.
- * @param aWidth With of the bitmap, in pixels.
- * @param aHeight Height of the image, in pixels.
- * @param aDepth Image depth, in bits. Should be one of 1, 24 and 32.
- *
- * @return The HBITMAP representing the image. Caller should call
- * DeleteObject when done with the bitmap.
- * On failure, NULL will be returned.
- */
-HBITMAP nsWindow::DataToBitmap(PRUint8* aImageData,
- PRUint32 aWidth,
- PRUint32 aHeight,
- PRUint32 aDepth)
-{
-#ifndef WINCE
- HDC dc = ::GetDC(NULL);
-
- if (aDepth == 32 && IsCursorTranslucencySupported()) {
- // Alpha channel. We need the new header.
- BITMAPV4HEADER head = { 0 };
- head.bV4Size = sizeof(head);
- head.bV4Width = aWidth;
- head.bV4Height = aHeight;
- head.bV4Planes = 1;
- head.bV4BitCount = aDepth;
- head.bV4V4Compression = BI_BITFIELDS;
- head.bV4SizeImage = 0; // Uncompressed
- head.bV4XPelsPerMeter = 0;
- head.bV4YPelsPerMeter = 0;
- head.bV4ClrUsed = 0;
- head.bV4ClrImportant = 0;
-
- head.bV4RedMask = 0x00FF0000;
- head.bV4GreenMask = 0x0000FF00;
- head.bV4BlueMask = 0x000000FF;
- head.bV4AlphaMask = 0xFF000000;
-
- HBITMAP bmp = ::CreateDIBitmap(dc,
- reinterpret_cast(&head),
- CBM_INIT,
- aImageData,
- reinterpret_cast(&head),
- DIB_RGB_COLORS);
- ::ReleaseDC(NULL, dc);
- return bmp;
- }
-
- char reserved_space[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2];
- BITMAPINFOHEADER& head = *(BITMAPINFOHEADER*)reserved_space;
-
- head.biSize = sizeof(BITMAPINFOHEADER);
- head.biWidth = aWidth;
- head.biHeight = aHeight;
- head.biPlanes = 1;
- head.biBitCount = (WORD)aDepth;
- head.biCompression = BI_RGB;
- head.biSizeImage = 0; // Uncompressed
- head.biXPelsPerMeter = 0;
- head.biYPelsPerMeter = 0;
- head.biClrUsed = 0;
- head.biClrImportant = 0;
-
- BITMAPINFO& bi = *(BITMAPINFO*)reserved_space;
-
- if (aDepth == 1) {
- RGBQUAD black = { 0, 0, 0, 0 };
- RGBQUAD white = { 255, 255, 255, 0 };
-
- bi.bmiColors[0] = white;
- bi.bmiColors[1] = black;
- }
-
- HBITMAP bmp = ::CreateDIBitmap(dc, &head, CBM_INIT, aImageData, &bi, DIB_RGB_COLORS);
- ::ReleaseDC(NULL, dc);
- return bmp;
-#else
- return nsnull;
-#endif
-}
-
// Setting the actual cursor
NS_IMETHODIMP nsWindow::SetCursor(imgIContainer* aCursor,
PRUint32 aHotspotX, PRUint32 aHotspotY)
@@ -2014,14 +1878,14 @@ NS_IMETHODIMP nsWindow::SetCursor(imgIContainer* aCursor,
return NS_OK;
}
- // Get the image data
- nsRefPtr frame;
- aCursor->CopyCurrentFrame(getter_AddRefs(frame));
- if (!frame)
- return NS_ERROR_NOT_AVAILABLE;
+ PRInt32 width;
+ PRInt32 height;
- PRInt32 width = frame->Width();
- PRInt32 height = frame->Height();
+ nsresult rv;
+ rv = aCursor->GetWidth(&width);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = aCursor->GetHeight(&height);
+ NS_ENSURE_SUCCESS(rv, rv);
// Reject cursors greater than 128 pixels in either direction, to prevent
// spoofing.
@@ -2030,30 +1894,9 @@ NS_IMETHODIMP nsWindow::SetCursor(imgIContainer* aCursor,
if (width > 128 || height > 128)
return NS_ERROR_NOT_AVAILABLE;
- PRUint8 *data = frame->Data();
-
- HBITMAP bmp = DataToBitmap(data, width, -height, 32);
- PRUint8* a1data = Data32BitTo1Bit(data, width, height);
- if (!a1data) {
- return NS_ERROR_FAILURE;
- }
-
- HBITMAP mbmp = DataToBitmap(a1data, width, -height, 1);
- PR_Free(a1data);
-
- ICONINFO info = {0};
- info.fIcon = FALSE;
- info.xHotspot = aHotspotX;
- info.yHotspot = aHotspotY;
- info.hbmMask = mbmp;
- info.hbmColor = bmp;
-
- HCURSOR cursor = ::CreateIconIndirect(&info);
- ::DeleteObject(mbmp);
- ::DeleteObject(bmp);
- if (cursor == NULL) {
- return NS_ERROR_FAILURE;
- }
+ HCURSOR cursor;
+ rv = nsWindowGfx::CreateIcon(aCursor, PR_TRUE, aHotspotX, aHotspotY, &cursor);
+ NS_ENSURE_SUCCESS(rv, rv);
mCursor = nsCursor(-1);
::SetCursor(cursor);
diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h
index 62819e614499..2c3a9cc69c61 100644
--- a/widget/src/windows/nsWindow.h
+++ b/widget/src/windows/nsWindow.h
@@ -374,13 +374,6 @@ private:
protected:
#endif // MOZ_XUL
- /**
- * Cursor helpers
- */
- static PRUint8* Data32BitTo1Bit(PRUint8* aImageData, PRUint32 aWidth, PRUint32 aHeight);
- static PRBool IsCursorTranslucencySupported();
- static HBITMAP DataToBitmap(PRUint8* aImageData, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aDepth);
-
/**
* Misc.
*/
diff --git a/widget/src/windows/nsWindowGfx.cpp b/widget/src/windows/nsWindowGfx.cpp
index df47df8f9a8e..866a5ffa78d0 100644
--- a/widget/src/windows/nsWindowGfx.cpp
+++ b/widget/src/windows/nsWindowGfx.cpp
@@ -63,6 +63,7 @@
#include "gfxContext.h"
#include "nsIRenderingContext.h"
#include "nsIDeviceContext.h"
+#include "prmem.h"
#ifndef WINCE
#include "nsUXThemeData.h"
@@ -643,6 +644,202 @@ DDRAW_FAILED:
return result;
}
+nsresult nsWindowGfx::CreateIcon(imgIContainer *aContainer,
+ PRBool aIsCursor,
+ PRUint32 aHotspotX,
+ PRUint32 aHotspotY,
+ HICON *aIcon) {
+
+ nsresult rv;
+ PRInt32 maxWidth = GetSystemMetrics(SM_CXICON);
+ PRInt32 maxHeight = GetSystemMetrics(SM_CYICON);
+
+ if (!maxWidth || !maxHeight)
+ return NS_ERROR_UNEXPECTED;
+
+ PRUint32 nFrames;
+ rv = aContainer->GetNumFrames(&nFrames);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ if (!nFrames)
+ return NS_ERROR_INVALID_ARG;
+
+ // Get the image data
+ nsRefPtr frame;
+ aContainer->CopyCurrentFrame(getter_AddRefs(frame));
+ if (!frame)
+ return NS_ERROR_NOT_AVAILABLE;
+
+ PRUint8 *data = frame->Data();
+
+ PRInt32 width = frame->Width();
+ PRInt32 height = frame->Height();
+
+ if (width > maxWidth || height > maxHeight)
+ return NS_ERROR_INVALID_ARG;
+
+ HBITMAP bmp = DataToBitmap(data, width, -height, 32);
+ PRUint8* a1data = Data32BitTo1Bit(data, width, height);
+ if (!a1data) {
+ return NS_ERROR_FAILURE;
+ }
+
+ HBITMAP mbmp = DataToBitmap(a1data, width, -height, 1);
+ PR_Free(a1data);
+
+ ICONINFO info = {0};
+ info.fIcon = !aIsCursor;
+ info.xHotspot = aHotspotX;
+ info.yHotspot = aHotspotY;
+ info.hbmMask = mbmp;
+ info.hbmColor = bmp;
+
+ HCURSOR icon = ::CreateIconIndirect(&info);
+ ::DeleteObject(mbmp);
+ ::DeleteObject(bmp);
+ if (!icon)
+ return NS_ERROR_FAILURE;
+ *aIcon = icon;
+ return NS_OK;
+}
+
+// Adjust cursor image data
+PRUint8* nsWindowGfx::Data32BitTo1Bit(PRUint8* aImageData,
+ PRUint32 aWidth, PRUint32 aHeight)
+{
+ // We need (aWidth + 7) / 8 bytes plus zero-padding up to a multiple of
+ // 4 bytes for each row (HBITMAP requirement). Bug 353553.
+ PRUint32 outBpr = ((aWidth + 31) / 8) & ~3;
+
+ // Allocate and clear mask buffer
+ PRUint8* outData = (PRUint8*)PR_Calloc(outBpr, aHeight);
+ if (!outData)
+ return NULL;
+
+ PRInt32 *imageRow = (PRInt32*)aImageData;
+ for (PRUint32 curRow = 0; curRow < aHeight; curRow++) {
+ PRUint8 *outRow = outData + curRow * outBpr;
+ PRUint8 mask = 0x80;
+ for (PRUint32 curCol = 0; curCol < aWidth; curCol++) {
+ // Use sign bit to test for transparency, as alpha byte is highest byte
+ if (*imageRow++ < 0)
+ *outRow |= mask;
+
+ mask >>= 1;
+ if (!mask) {
+ outRow ++;
+ mask = 0x80;
+ }
+ }
+ }
+
+ return outData;
+}
+
+PRBool nsWindowGfx::IsCursorTranslucencySupported()
+{
+#ifdef WINCE
+ return PR_FALSE;
+#else
+ static PRBool didCheck = PR_FALSE;
+ static PRBool isSupported = PR_FALSE;
+ if (!didCheck) {
+ didCheck = PR_TRUE;
+ // Cursor translucency is supported on Windows XP and newer
+ isSupported = nsWindow::GetWindowsVersion() >= 0x501;
+ }
+
+ return isSupported;
+#endif
+}
+
+/**
+ * Convert the given image data to a HBITMAP. If the requested depth is
+ * 32 bit and the OS supports translucency, a bitmap with an alpha channel
+ * will be returned.
+ *
+ * @param aImageData The image data to convert. Must use the format accepted
+ * by CreateDIBitmap.
+ * @param aWidth With of the bitmap, in pixels.
+ * @param aHeight Height of the image, in pixels.
+ * @param aDepth Image depth, in bits. Should be one of 1, 24 and 32.
+ *
+ * @return The HBITMAP representing the image. Caller should call
+ * DeleteObject when done with the bitmap.
+ * On failure, NULL will be returned.
+ */
+HBITMAP nsWindowGfx::DataToBitmap(PRUint8* aImageData,
+ PRUint32 aWidth,
+ PRUint32 aHeight,
+ PRUint32 aDepth)
+{
+#ifndef WINCE
+ HDC dc = ::GetDC(NULL);
+
+ if (aDepth == 32 && IsCursorTranslucencySupported()) {
+ // Alpha channel. We need the new header.
+ BITMAPV4HEADER head = { 0 };
+ head.bV4Size = sizeof(head);
+ head.bV4Width = aWidth;
+ head.bV4Height = aHeight;
+ head.bV4Planes = 1;
+ head.bV4BitCount = aDepth;
+ head.bV4V4Compression = BI_BITFIELDS;
+ head.bV4SizeImage = 0; // Uncompressed
+ head.bV4XPelsPerMeter = 0;
+ head.bV4YPelsPerMeter = 0;
+ head.bV4ClrUsed = 0;
+ head.bV4ClrImportant = 0;
+
+ head.bV4RedMask = 0x00FF0000;
+ head.bV4GreenMask = 0x0000FF00;
+ head.bV4BlueMask = 0x000000FF;
+ head.bV4AlphaMask = 0xFF000000;
+
+ HBITMAP bmp = ::CreateDIBitmap(dc,
+ reinterpret_cast(&head),
+ CBM_INIT,
+ aImageData,
+ reinterpret_cast(&head),
+ DIB_RGB_COLORS);
+ ::ReleaseDC(NULL, dc);
+ return bmp;
+ }
+
+ char reserved_space[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2];
+ BITMAPINFOHEADER& head = *(BITMAPINFOHEADER*)reserved_space;
+
+ head.biSize = sizeof(BITMAPINFOHEADER);
+ head.biWidth = aWidth;
+ head.biHeight = aHeight;
+ head.biPlanes = 1;
+ head.biBitCount = (WORD)aDepth;
+ head.biCompression = BI_RGB;
+ head.biSizeImage = 0; // Uncompressed
+ head.biXPelsPerMeter = 0;
+ head.biYPelsPerMeter = 0;
+ head.biClrUsed = 0;
+ head.biClrImportant = 0;
+
+ BITMAPINFO& bi = *(BITMAPINFO*)reserved_space;
+
+ if (aDepth == 1) {
+ RGBQUAD black = { 0, 0, 0, 0 };
+ RGBQUAD white = { 255, 255, 255, 0 };
+
+ bi.bmiColors[0] = white;
+ bi.bmiColors[1] = black;
+ }
+
+ HBITMAP bmp = ::CreateDIBitmap(dc, &head, CBM_INIT, aImageData, &bi, DIB_RGB_COLORS);
+ ::ReleaseDC(NULL, dc);
+ return bmp;
+#else
+ return nsnull;
+#endif
+}
+
+
// Windows Mobile Special image/direct draw painting fun
#if defined(CAIRO_HAS_DDRAW_SURFACE)
PRBool nsWindow::OnPaintImageDDraw16()
diff --git a/widget/src/windows/nsWindowGfx.h b/widget/src/windows/nsWindowGfx.h
index e9ffe0cb7d43..18e28f817fb5 100644
--- a/widget/src/windows/nsWindowGfx.h
+++ b/widget/src/windows/nsWindowGfx.h
@@ -43,6 +43,7 @@
*/
#include "nsWindow.h"
+#include
// This isn't ideal, we should figure out how to export
// the #defines here; need this to figure out if we have
@@ -62,6 +63,16 @@ public:
#if defined(CAIRO_HAS_DDRAW_SURFACE)
static PRBool InitDDraw();
#endif // defined(CAIRO_HAS_DDRAW_SURFACE)
+
+ static nsresult CreateIcon(imgIContainer *aContainer, PRBool aIsCursor, PRUint32 aHotspotX, PRUint32 aHotspotY, HICON *aIcon);
+
+private:
+ /**
+ * Cursor helpers
+ */
+ static PRUint8* Data32BitTo1Bit(PRUint8* aImageData, PRUint32 aWidth, PRUint32 aHeight);
+ static PRBool IsCursorTranslucencySupported();
+ static HBITMAP DataToBitmap(PRUint8* aImageData, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aDepth);
};
-#endif // WindowGfx_h__
\ No newline at end of file
+#endif // WindowGfx_h__
diff --git a/widget/src/xpwidgets/nsBaseFilePicker.cpp b/widget/src/xpwidgets/nsBaseFilePicker.cpp
index 70152a4409d1..0ca2682b5b28 100644
--- a/widget/src/xpwidgets/nsBaseFilePicker.cpp
+++ b/widget/src/xpwidgets/nsBaseFilePicker.cpp
@@ -153,8 +153,7 @@ nsBaseFilePicker::AppendFilters(PRInt32 aFilterMask)
}
if (aFilterMask & filterImages) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("imageTitle").get(), getter_Copies(title));
- stringBundle->GetStringFromName(NS_LITERAL_STRING("imageFilter").get(), getter_Copies(filter));
- AppendFilter(title,filter);
+ AppendFilter(title,NS_LITERAL_STRING("*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.ico"));
}
if (aFilterMask & filterXML) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("xmlTitle").get(), getter_Copies(title));
diff --git a/xpfe/browser/src/nsBrowserStatusFilter.cpp b/xpfe/browser/src/nsBrowserStatusFilter.cpp
index 31ef21a9b41b..0da5e318c972 100644
--- a/xpfe/browser/src/nsBrowserStatusFilter.cpp
+++ b/xpfe/browser/src/nsBrowserStatusFilter.cpp
@@ -243,7 +243,7 @@ nsBrowserStatusFilter::OnStatusChange(nsIWebProgress *aWebProgress,
//
// limit frequency of calls to OnStatusChange
//
- if (!mCurrentStatusMsg.Equals(aMessage)) {
+ if (mStatusIsDirty || !mCurrentStatusMsg.Equals(aMessage)) {
mStatusIsDirty = PR_TRUE;
mStatusMsg = aMessage;
}