Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsGopherDirListingConv.cpp File Reference
#include "plstr.h"
#include "nsMemory.h"
#include "nsCRT.h"
#include "nsIServiceManager.h"
#include "nsIGenericFactory.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
#include "nsEscape.h"
#include "nsIStreamListener.h"
#include "nsIStreamConverter.h"
#include "nsIStringStream.h"
#include "nsIRequestObserver.h"
#include "nsNetUtil.h"
#include "nsMimeTypes.h"
#include "nsGopherDirListingConv.h"

Go to the source code of this file.


#define CONV_BUF_SIZE   (4*1024)


 NS_IMPL_THREADSAFE_ISUPPORTS3 (nsGopherDirListingConv, nsIStreamConverter, nsIStreamListener, nsIRequestObserver) NS_IMETHODIMP nsGopherDirListingConv
nsresult NS_NewGopherDirListingConv (nsGopherDirListingConv **aGopherDirListingConv)

Define Documentation

#define CONV_BUF_SIZE   (4*1024)

Function Documentation

Definition at line 62 of file nsGopherDirListingConv.cpp.

    nsresult rv;

    char buffer[CONV_BUF_SIZE] = {0};
    nsFixedCString aBuffer(buffer, CONV_BUF_SIZE, 0);
    nsCAutoString convertedData;

    NS_ASSERTION(aCtxt, "Gopher dir conversion needs the context");
    // build up the 300: line
    nsCAutoString spec;
    mUri = do_QueryInterface(aCtxt, &rv);
    if (NS_FAILED(rv)) return rv;
    rv = mUri->GetAsciiSpec(spec);
    if (NS_FAILED(rv)) return rv;

    convertedData.AppendLiteral("300: ");
    // END 300:
    //Column headings
    // We should also send the content-type, probably. The stuff in
    // nsGopherChannel::GetContentType should then be moved out - 
    // maybe into an nsIGopherURI interface/class?

    // Should also possibly use different hosts as a symlink, but the directory
    // viewer stuff doesn't support SYM-FILE or SYM-DIRECTORY
    convertedData.AppendLiteral("200: description filename file-type\n");

    // build up the body
    while (1) {
        PRUint32 amtRead = 0;

        rv = aFromStream->Read(buffer+aBuffer.Length(),
                               CONV_BUF_SIZE-aBuffer.Length(), &amtRead);
        if (NS_FAILED(rv)) return rv;

        if (!amtRead) {
            // EOF

        aBuffer = DigestBufferLines(buffer, convertedData);
    // send the converted data out.
    return NS_NewCStringInputStream(_retval, convertedData);

Here is the call graph for this function:

Definition at line 433 of file nsGopherDirListingConv.cpp.

    NS_PRECONDITION(aGopherDirListingConv, "null ptr");
    if (! aGopherDirListingConv)
        return NS_ERROR_NULL_POINTER;

    *aGopherDirListingConv = new nsGopherDirListingConv();
    if (! *aGopherDirListingConv)
        return NS_ERROR_OUT_OF_MEMORY;

    return (*aGopherDirListingConv)->Init();

Here is the call graph for this function: