Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsGopherChannel.cpp File Reference
#include "nsGopherChannel.h"
#include "nsMimeTypes.h"
#include "nsEscape.h"
#include "nsNetUtil.h"
#include "netCore.h"
#include "nsCRT.h"
#include "prlog.h"
#include "nsIServiceManager.h"
#include "nsILoadGroup.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsISocketTransportService.h"
#include "nsIStringStream.h"
#include "nsIStreamConverterService.h"
#include "nsITXTToHTMLConv.h"
#include "nsIEventQueue.h"
#include "nsEventQueueUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"

Go to the source code of this file.

Defines

#define BUFFER_SEG_SIZE   (4*1024)
#define BUFFER_MAX_SIZE   (64*1024)

Functions

static NS_DEFINE_CID (kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID)
static NS_DEFINE_CID (kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID)
 NS_IMPL_THREADSAFE_ISUPPORTS5 (nsGopherChannel, nsIChannel, nsIRequest, nsIStreamListener, nsIRequestObserver, nsITransportEventSink) nsresult nsGopherChannel

Define Documentation

#define BUFFER_MAX_SIZE   (64*1024)

Definition at line 73 of file nsGopherChannel.cpp.

#define BUFFER_SEG_SIZE   (4*1024)

Definition at line 72 of file nsGopherChannel.cpp.


Function Documentation

static NS_DEFINE_CID ( kSocketTransportServiceCID  ,
NS_SOCKETTRANSPORTSERVICE_CID   
) [static]
static NS_DEFINE_CID ( kStreamConverterServiceCID  ,
NS_STREAMCONVERTERSERVICE_CID   
) [static]

Definition at line 93 of file nsGopherChannel.cpp.

{
    nsresult rv;

    nsCOMPtr<nsIURL> url = do_QueryInterface(uri, &rv);
    if (NS_FAILED(rv))
        return NS_ERROR_MALFORMED_URI;
    
    mUrl = uri;
    mProxyInfo = proxyInfo;
    
    nsCAutoString buffer;

    rv = url->GetPath(buffer); // unescaped down below
    if (NS_FAILED(rv))
        return rv;

    rv = url->GetAsciiHost(mHost);
    if (NS_FAILED(rv))
        return rv;
    rv = url->GetPort(&mPort);
    if (NS_FAILED(rv))
        return rv;

    // For security reasons, don't allow anything expect the default
    // gopher port (70). See bug 71916 - bbaetz@cs.mcgill.ca
/*
    if (mPort==-1)
        mPort=GOPHER_PORT;
*/
    mPort=GOPHER_PORT;

    // No path given
    if (buffer[0]=='\0' || (buffer[0]=='/' && buffer[1]=='\0')) {
        mType = '1';
        mSelector.Truncate();
    } else {
        mType = buffer[1]; // Ignore leading '/'

        // Do it this way in case selector contains embedded nulls after
        // unescaping
        char* selector = nsCRT::strdup(buffer.get()+2);
        PRInt32 count = nsUnescapeCount(selector);
        mSelector.Assign(selector,count);
        nsCRT::free(selector);

        if (mSelector.FindCharInSet(nsCString("\t\n\r\0",4)) != -1) {
            // gopher selectors cannot containt tab, cr, lf, or \0
            return NS_ERROR_MALFORMED_URI;
        }
    }

    PR_LOG(gGopherLog,
           PR_LOG_DEBUG,
           ("Host: mHost = %s, mPort = %d\n", mHost.get(), mPort));
    PR_LOG(gGopherLog,
           PR_LOG_DEBUG,
           ("Status: mType = %c, mSelector = %s\n", mType, mSelector.get()));
    
    return NS_OK;
}

Here is the call graph for this function: