warning fixes + removal of nsString constructor usage w/ internal string byte size specifier

This commit is contained in:
valeski%netscape.com 1999-09-01 14:13:51 +00:00
parent dc75493b3e
commit b314594876
8 changed files with 90 additions and 99 deletions

View File

@ -54,19 +54,21 @@ static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
// initiated by the server (PORT command) or by the client (PASV command).
// Client initiation is the most command case and is attempted first.
nsFTPChannel::nsFTPChannel()
: mUrl(nsnull), mConnected(PR_FALSE), mListener(nsnull),
mLoadAttributes(LOAD_NORMAL), mLoadGroup(nsnull), mContext(nsnull), mEventQueue(nsnull)
{
nsresult rv;
nsFTPChannel::nsFTPChannel() {
NS_INIT_REFCNT();
NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueService, &rv);
if (NS_SUCCEEDED(rv)) {
rv = eventQService->GetThreadEventQueue(PR_CurrentThread(), &mEventQueue);
}
mUrl = nsnull;
mEventQueue = nsnull;
mEventSink = nsnull;
mConnected = PR_FALSE;
mListener = nsnull;
mContext = nsnull;
mLoadAttributes = LOAD_NORMAL;
mBufferInputStream = nsnull;
mBufferOutputStream = nsnull;
mSourceOffset = 0;
mAmount = 0;
mLoadGroup = nsnull;
}
nsFTPChannel::~nsFTPChannel() {
@ -129,6 +131,11 @@ nsFTPChannel::Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
}
}
NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueService, &rv);
if (NS_SUCCEEDED(rv)) {
rv = eventQService->GetThreadEventQueue(PR_CurrentThread(), &mEventQueue);
}
return NS_OK;
}

View File

@ -44,8 +44,7 @@ void PR_CALLBACK nsFtpStreamListenerEvent::HandlePLEvent(PLEvent* aEvent)
// to compensate for the vtable...
nsFtpStreamListenerEvent *ev = (nsFtpStreamListenerEvent*)aEvent;
nsresult rv = ev->HandleEvent();
//ev->mListener->SetStatus(rv);
ev->HandleEvent();
}
void PR_CALLBACK nsFtpStreamListenerEvent::DestroyPLEvent(PLEvent* aEvent)

View File

@ -193,7 +193,8 @@ nsHTTPRequest::Build()
// Write the request into the stream...
//
nsXPIDLCString autoBuffer;
nsString2 lineBuffer(eOneByte);
nsString2 lineBuffer;
nsStr::Initialize(lineBuffer, eOneByte);
PRUint32 bytesWritten = 0;
PR_LOG(gHTTPLog, PR_LOG_ALWAYS,

View File

@ -57,12 +57,11 @@ static const int kMAX_HEADER_SIZE = 60000;
nsHTTPResponseListener::nsHTTPResponseListener(nsHTTPChannel* aConnection):
mConsumer(nsnull),
mFirstLineParsed(PR_FALSE),
mHeaderBuffer(eOneByte),
mHeadersDone(PR_FALSE),
mReadLength(0),
mResponse(nsnull),
mResponseContext(nsnull)
mHeadersDone(PR_FALSE),
mResponseContext(nsnull),
mFirstLineParsed(PR_FALSE),
mResponse(nsnull)
{
NS_INIT_REFCNT();
@ -422,7 +421,7 @@ nsresult nsHTTPResponseListener::ParseStatusLine(nsIBufferInputStream* in,
//
const char *token;
nsAutoString str(eOneByte);
nsCAutoString str;
PRInt32 offset, error;
//
@ -622,7 +621,7 @@ nsresult nsHTTPResponseListener::ParseHTTPHeader(nsIBufferInputStream* in,
// The header name is case-insensitive...
//
PRInt32 colonOffset;
nsAutoString headerKey(eOneByte);
nsCAutoString headerKey;
nsCOMPtr<nsIAtom> headerAtom;
colonOffset = mHeaderBuffer.FindChar(':');
@ -691,7 +690,7 @@ nsresult nsHTTPResponseListener::FinishedResponseHeaders(void)
nsresult nsHTTPResponseListener::ProcessHeader(nsIAtom* aHeader,
nsString& aValue)
nsCString& aValue)
{
nsresult rv;
@ -700,7 +699,7 @@ nsresult nsHTTPResponseListener::ProcessHeader(nsIAtom* aHeader,
// and Charset information must be set into the nsHTTPChannel...
//
if (nsHTTPAtoms::Content_Type == aHeader) {
nsAutoString buffer(eOneByte);
nsCAutoString buffer;
PRInt32 semicolon;
// Set the content-type in the HTTPChannel...

View File

@ -94,21 +94,20 @@ protected:
nsresult FinishedResponseHeaders();
nsresult ProcessHeader(nsIAtom* aHeader, nsString& aValue);
nsresult ProcessHeader(nsIAtom* aHeader, nsCString& aValue);
nsresult ProcessStatusCode();
nsresult ProcessRedirection(PRInt32 aStatusCode);
nsresult ProcessAuthentication(PRInt32 aStatusCode);
protected:
nsCString mHeaderBuffer;
nsHTTPChannel* mConnection;
nsIStreamListener* mConsumer;
PRBool mFirstLineParsed;
nsString mHeaderBuffer;
PRBool mHeadersDone;
PRUint32 mReadLength; // Already read
nsHTTPResponse* mResponse;
nsCOMPtr<nsISupports> mResponseContext;
};

View File

@ -76,7 +76,6 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt,
if (!mBoundaryCStr) {
// ask the channel for the content-type and extract the boundary from it.
nsString2 boundaryStr(eOneByte);
nsIHTTPChannel *httpChannel = nsnull;
rv = channel->QueryInterface(NS_GET_IID(nsIHTTPChannel), (void**)&httpChannel);
if (NS_SUCCEEDED(rv)) {
@ -96,7 +95,7 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt,
bndry++; // move past the equals sign
nsString2 boundaryString(bndry, eOneByte);
nsCString boundaryString(bndry);
boundaryString.StripWhitespace();
mBoundaryCStr = boundaryString.ToNewCString();
if (!mBoundaryCStr) return NS_ERROR_OUT_OF_MEMORY;
@ -144,7 +143,7 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt,
// This is the start of a part. We want to build up a new stub
// channel and call through to our listener.
mBoundaryStart = PR_TRUE;
nsString2 contentTypeStr(eOneByte);
nsCString contentTypeStr;
NS_IF_RELEASE(mPartChannel);
@ -157,19 +156,19 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt,
char *headersEnd = PL_strstr(boundaryLoc + mBoundaryStrLen, "\n\n");
if (headersEnd) {
char *headerStart = boundaryLoc + mBoundaryStrLen + 1;
char *header = nsnull;
while ( header = PL_strchr(headerStart, '\n')) {
*header = '\0';
char *headerCStr = nsnull;
while ( (headerCStr = PL_strchr(headerStart, '\n')) ) {
*headerCStr = '\0';
char *colon = PL_strchr(headerStart, ':');
if (colon) {
*colon = '\0';
nsString2 headerStr(headerStart, eOneByte);
nsCString headerStr(headerStart);
headerStr.ToLowerCase();
nsIAtom *header = NS_NewAtom(headerStr.GetBuffer());
*colon = ':';
nsString2 headerVal(colon + 1, eOneByte);
nsCString headerVal(colon + 1);
headerVal.StripWhitespace();
if (headerStr == "content-type") {
@ -180,10 +179,10 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt,
}
}
*header = '\n';
if (header[1] == '\n') break;
*headerCStr = '\n';
if (headerCStr[1] == '\n') break;
// increment and move on.
headerStart = header + 1;
headerStart = headerCStr + 1;
}
}
@ -351,7 +350,7 @@ nsMultiMixedConv::BuildURI(nsIChannel *aChannel, nsIURI **_retval) {
if (NS_FAILED(rv)) return rv;
nsCString dummyURIStr(uriSpec);
dummyURIStr.Append('##');
dummyURIStr.Append("##");
dummyURIStr.Append(mPartCount);
char *dummyCStr = dummyURIStr.ToNewCString();

View File

@ -161,7 +161,7 @@ nsStreamConverterService::AddAdjacency(const char *aProgID) {
nsresult rv;
// first parse out the FROM and TO MIME-types.
nsString2 fromStr(eOneByte), toStr(eOneByte);
nsCString fromStr, toStr;
rv = ParseFromTo(aProgID, fromStr, toStr);
if (NS_FAILED(rv)) return rv;
@ -188,7 +188,7 @@ nsStreamConverterService::AddAdjacency(const char *aProgID) {
}
data->key = fromKey;
delFrom = PR_FALSE;
data->keyString = new nsString2(fromStr.GetBuffer(), eOneByte);
data->keyString = new nsCString(fromStr.GetBuffer());
if (!data->keyString) {
delete fromKey;
delete toKey;
@ -217,7 +217,7 @@ nsStreamConverterService::AddAdjacency(const char *aProgID) {
}
data->key = toKey;
delTo = PR_FALSE;
data->keyString = new nsString2(toStr.GetBuffer(), eOneByte);
data->keyString = new nsCString(toStr.GetBuffer());
if (!data->keyString) {
delete fromKey;
delete toKey;
@ -254,15 +254,15 @@ nsStreamConverterService::AddAdjacency(const char *aProgID) {
}
nsresult
nsStreamConverterService::ParseFromTo(const char *aProgID, nsString2 &aFromRes, nsString2 &aToRes) {
nsStreamConverterService::ParseFromTo(const char *aProgID, nsCString &aFromRes, nsCString &aToRes) {
nsString2 ProgIDStr(aProgID, eOneByte);
nsCString ProgIDStr(aProgID);
PRInt32 fromLoc = ProgIDStr.Find("from=") + 5;
PRInt32 toLoc = ProgIDStr.Find("to=") + 3;
if (-1 == fromLoc || -1 == toLoc ) return NS_ERROR_FAILURE;
nsString2 fromStr(eOneByte), toStr(eOneByte);
nsCString fromStr, toStr;
ProgIDStr.Mid(fromStr, fromLoc, toLoc - 4 - fromLoc);
ProgIDStr.Mid(toStr, toLoc, ProgIDStr.Length() - toLoc);
@ -293,7 +293,7 @@ PRBool InitBFSTable(nsHashKey *aKey, void *aData, void* closure) {
SCTableData *origData = (SCTableData*)aData;
NS_ASSERTION(origData, "no data in the table enumeration");
data->keyString = new nsString2(*origData->keyString, eOneByte);
data->keyString = new nsCString(*origData->keyString);
data->data = state;
BFSTable->Put(aKey, data);
@ -336,18 +336,17 @@ nsStreamConverterService::FindConverter(const char *aProgID, nsVoidArray **aEdge
NS_ASSERTION(lBFSTable.Count() == vertexCount, "strmconv BFS table init problem");
// This is our source vertex; our starting point.
nsString2 from(eOneByte), to(eOneByte);
rv = ParseFromTo(aProgID, from, to);
nsCString fromC, toC;
rv = ParseFromTo(aProgID, fromC, toC);
if (NS_FAILED(rv)) return rv;
nsStringKey *source = new nsStringKey(from.GetBuffer());
nsStringKey *source = new nsStringKey(fromC.GetBuffer());
if (!source) return NS_ERROR_OUT_OF_MEMORY;
SCTableData *data = (SCTableData*)lBFSTable.Get(source);
BFSState *state = (BFSState*)data->data;
// XXX probably don't need this check.
if (!state)
return NS_ERROR_FAILURE;
if (!state) return NS_ERROR_FAILURE;
state->color = gray;
state->distance = 0;
@ -371,7 +370,8 @@ nsStreamConverterService::FindConverter(const char *aProgID, nsVoidArray **aEdge
for (int i = 0; i < edgeCount; i++) {
nsIAtom *curVertexAtom = (nsIAtom*)edges->ElementAt(i);
nsString2 curVertexStr(eOneByte);
nsString2 curVertexStr;
nsStr::Initialize(curVertexStr, eOneByte);
curVertexAtom->ToString(curVertexStr);
char * curVertexCString = curVertexStr.ToNewCString();
nsStringKey *curVertex = new nsStringKey(curVertexCString);
@ -402,12 +402,12 @@ nsStreamConverterService::FindConverter(const char *aProgID, nsVoidArray **aEdge
// first parse out the FROM and TO MIME-types being registered.
nsString2 fromStr(eOneByte), toStr(eOneByte);
nsCString fromStr, toStr;
rv = ParseFromTo(aProgID, fromStr, toStr);
if (NS_FAILED(rv)) return rv;
// get the root PROGID
nsString2 ProgIDPrefix(NS_ISTREAMCONVERTER_KEY, eOneByte);
nsCString ProgIDPrefix(NS_ISTREAMCONVERTER_KEY);
nsVoidArray *shortestPath = new nsVoidArray();
nsStringKey *toMIMEType = new nsStringKey(toStr);
data = (SCTableData*)lBFSTable.Get(toMIMEType);
@ -437,17 +437,13 @@ nsStreamConverterService::FindConverter(const char *aProgID, nsVoidArray **aEdge
if (!predecessorData) break; // no predecessor, chain doesn't exist.
// build out the PROGID.
nsString2 *newProgID = new nsString2(ProgIDPrefix, eOneByte);
nsCString *newProgID = new nsCString(ProgIDPrefix);
newProgID->Append("?from=");
char *from = predecessorData->keyString->ToNewCString();
newProgID->Append(from);
nsAllocator::Free(from);
newProgID->Append(predecessorData->keyString->GetBuffer());
newProgID->Append("?to=");
char *to = data->keyString->ToNewCString();
newProgID->Append(to);
nsAllocator::Free(to);
newProgID->Append(data->keyString->GetBuffer());
// Add this PROGID to the chain.
shortestPath->AppendElement(newProgID);
@ -476,29 +472,23 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
// first determine whether we can even handle this covnversion
// build a PROGID
nsString2 progID(NS_ISTREAMCONVERTER_KEY);
nsCString progID(NS_ISTREAMCONVERTER_KEY);
progID.Append("?from=");
progID.Append(aFromType);
progID.Append("?to=");
progID.Append(aToType);
char * cProgID = progID.ToNewCString();
if (!cProgID) return NS_ERROR_OUT_OF_MEMORY;
const char *cProgID = progID.GetBuffer();
nsISupports *converter = nsnull;
rv = nsServiceManager::GetService(cProgID, nsCOMTypeInfo<nsIStreamConverter>::GetIID(), &converter);
if (NS_FAILED(rv)) {
// couldn't go direct, let's try walking the graph of converters.
rv = BuildGraph();
if (NS_FAILED(rv)) {
nsAllocator::Free(cProgID);
return rv;
}
if (NS_FAILED(rv)) return rv;
nsVoidArray *converterChain = nsnull;
rv = FindConverter(cProgID, &converterChain);
nsAllocator::Free(cProgID);
cProgID = nsnull;
if (NS_FAILED(rv)) {
// can't make this conversion.
// XXX should have a more descriptive error code.
@ -516,9 +506,8 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
NS_ADDREF(dataToConvert);
for (PRInt32 i = edgeCount-1; i >= 0; i--) {
nsString2 *progIDStr = (nsString2*)converterChain->ElementAt(i);
char * lProgID = progIDStr->ToNewCString();
const char *x = lProgID;
nsCString *progIDStr = (nsCString*)converterChain->ElementAt(i);
const char *lProgID = progIDStr->GetBuffer();
nsIComponentManager *comMgr;
rv = NS_GetGlobalComponentManager(&comMgr);
@ -526,8 +515,8 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
nsCID cid;
rv = comMgr->ProgIDToCLSID(x, &cid);
if (!lProgID) return NS_ERROR_OUT_OF_MEMORY;
rv = comMgr->ProgIDToCLSID(lProgID, &cid);
// XXX should we be using a service or componentn mgr?
// rv = nsComponentManager::GetService(lProgID, nsCOMTypeInfo<nsIStreamConverter>::GetIID(), &converter);
rv = comMgr->CreateInstance(cid,
nsnull,
@ -537,8 +526,8 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
//NS_ASSERTION(NS_SUCCEEDED(rv), "registration problem. someone registered a progid w/ the registry, but didn/'t register it with the component manager");
if (NS_FAILED(rv)) {
// clean up the array.
nsString2 *progID;
while ( (progID = (nsString2*)converterChain->ElementAt(0)) ) {
nsCString *progID;
while ( (progID = (nsCString*)converterChain->ElementAt(0)) ) {
delete progID;
converterChain->RemoveElementAt(0);
}
@ -546,9 +535,8 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
return rv;
}
nsString2 fromStr(eOneByte), toStr(eOneByte);
nsCString fromStr, toStr;
rv = ParseFromTo(lProgID, fromStr, toStr);
nsAllocator::Free(lProgID);
if (NS_FAILED(rv)) return rv;
nsIStreamConverter *conv = nsnull;
@ -568,8 +556,8 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
}
// clean up the array.
nsString2 *progID;
while ( (progID = (nsString2*)converterChain->ElementAt(0)) ) {
nsCString *progID;
while ( (progID = (nsCString*)converterChain->ElementAt(0)) ) {
delete progID;
converterChain->RemoveElementAt(0);
}
@ -578,7 +566,6 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream,
} else {
// we're going direct.
nsAllocator::Free(cProgID);
nsIStreamConverter *conv = nsnull;
rv = converter->QueryInterface(nsCOMTypeInfo<nsIStreamConverter>::GetIID(), (void**)&conv);
NS_RELEASE(converter);
@ -602,29 +589,23 @@ nsStreamConverterService::AsyncConvertData(const PRUnichar *aFromType,
// first determine whether we can even handle this covnversion
// build a PROGID
nsString2 progID(NS_ISTREAMCONVERTER_KEY);
nsCString progID(NS_ISTREAMCONVERTER_KEY);
progID.Append("?from=");
progID.Append(aFromType);
progID.Append("?to=");
progID.Append(aToType);
char * cProgID = progID.ToNewCString();
if (!cProgID) return NS_ERROR_OUT_OF_MEMORY;
const char *cProgID = progID.GetBuffer();
nsISupports *converter = nsnull;
rv = nsServiceManager::GetService(cProgID, nsCOMTypeInfo<nsIStreamConverter>::GetIID(), &converter);
if (NS_FAILED(rv)) {
// couldn't go direct, let's try walking the graph of converters.
rv = BuildGraph();
if (NS_FAILED(rv)) {
nsAllocator::Free(cProgID);
return rv;
}
if (NS_FAILED(rv)) return rv;
nsVoidArray *converterChain = nsnull;
rv = FindConverter(cProgID, &converterChain);
nsAllocator::Free(cProgID);
cProgID = nsnull;
if (NS_FAILED(rv)) {
// can't make this conversion.
// XXX should have a more descriptive error code.
@ -642,22 +623,29 @@ nsStreamConverterService::AsyncConvertData(const PRUnichar *aFromType,
NS_ADDREF(forwardListener);
for (int i = 0; i < edgeCount; i++) {
nsString2 *progIDStr = (nsString2*)converterChain->ElementAt(i);
char * lProgID = progIDStr->ToNewCString();
if (!lProgID) return NS_ERROR_OUT_OF_MEMORY;
nsCString *progIDStr = (nsCString*)converterChain->ElementAt(i);
const char *lProgID = progIDStr->GetBuffer();
// XXX should we be using a service or componentn mgr?
rv = nsServiceManager::GetService(lProgID, nsCOMTypeInfo<nsIStreamConverter>::GetIID(), &converter);
NS_ASSERTION(NS_SUCCEEDED(rv), "graph construction problem, built a progid that wasn't registered");
nsString2 fromStr(eOneByte), toStr(eOneByte);
nsCString fromStr, toStr;
rv = ParseFromTo(lProgID, fromStr, toStr);
nsAllocator::Free(lProgID);
if (NS_FAILED(rv)) return rv;
nsIStreamConverter *conv = nsnull;
rv = converter->QueryInterface(nsCOMTypeInfo<nsIStreamConverter>::GetIID(), (void**)&conv);
NS_RELEASE(converter);
if (NS_FAILED(rv)) return rv;
rv = conv->AsyncConvertData(fromStr.GetUnicode(), toStr.GetUnicode(), forwardListener, nsnull);
PRUnichar *fromStrUni = fromStr.ToNewUnicode();
PRUnichar *toStrUni = toStr.ToNewUnicode();
rv = conv->AsyncConvertData(fromStrUni, toStrUni, forwardListener, nsnull);
nsAllocator::Free(fromStrUni);
nsAllocator::Free(toStrUni);
if (NS_FAILED(rv)) return rv;
nsIStreamListener *listener = nsnull;
rv = conv->QueryInterface(NS_GET_IID(nsIStreamListener), (void**)&listener);
@ -678,7 +666,6 @@ nsStreamConverterService::AsyncConvertData(const PRUnichar *aFromType,
} else {
// we're going direct.
nsAllocator::Free(cProgID);
nsIStreamListener *listener= nsnull;
rv = converter->QueryInterface(nsCOMTypeInfo<nsIStreamListener>::GetIID(), (void**)&listener);
if (NS_FAILED(rv)) return rv;

View File

@ -68,7 +68,7 @@ private:
nsresult FindConverter(const char *aProgID, nsVoidArray **aEdgeList);
nsresult BuildGraph(void);
nsresult AddAdjacency(const char *aProgID);
nsresult ParseFromTo(const char *aProgID, nsString2 &aFromRes, nsString2 &aToRes);
nsresult ParseFromTo(const char *aProgID, nsCString &aFromRes, nsCString &aToRes);
// member variables
nsHashtable *mAdjacencyList;
@ -80,7 +80,7 @@ private:
// adjacency list and BFS hashtable data class.
typedef struct _tableData {
nsHashKey *key;
nsString2 *keyString;
nsCString *keyString;
void *data;
} SCTableData;