Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
JSConsole.cpp File Reference
#include "JSConsole.h"
#include "jsconsres.h"
#include "nsIScriptContext.h"
#include <stdio.h>
#include "jsapi.h"
#include "nsReadableUtils.h"

Go to the source code of this file.

Defines

#define MESSAGE_LENGTH   256
#define VERIFY(value, errorCondition, message)   (value)

Functions

void DisplayError (LPSTR lpMessage)
LPSTR NormalizeBuffer (LPSTR aBuffer)
LPSTR PrepareForTextArea (LPSTR aBuffer, PRInt32 aSize)

Define Documentation

Definition at line 58 of file JSConsole.cpp.

#define VERIFY (   value,
  errorCondition,
  message 
)    (value)

Definition at line 84 of file JSConsole.cpp.


Function Documentation

void DisplayError ( LPSTR  lpMessage)

Definition at line 59 of file JSConsole.cpp.

{
    CHAR lpMsgBuf[MESSAGE_LENGTH * 2];
    CHAR lpLastError[MESSAGE_LENGTH];

    ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
                    NULL,
                    GetLastError(),
                    0,
                    (LPTSTR)&lpLastError,
                    MESSAGE_LENGTH,
                    NULL);
    
    strcpy(lpMsgBuf, lpMessage);
    strcat(lpMsgBuf, "\nThe WWS (Worthless Windows System) reports:\n");
    strcat(lpMsgBuf, lpLastError);

    // Display the string.
    ::MessageBox(NULL, lpMsgBuf, "JSConsole Error", MB_OK | MB_ICONSTOP);
}

Here is the caller graph for this function:

LPSTR NormalizeBuffer ( LPSTR  aBuffer)

Definition at line 823 of file JSConsole.cpp.

{
    // trim all the 0x0D at the beginning (should be 1 at most, but hey...)
    while (*aBuffer == 0x0D) {
        aBuffer++;
    }

    LPSTR readPointer = aBuffer;
    LPSTR writePointer = aBuffer;
    
    do {
        // compact the buffer if needed
        *writePointer = *readPointer;

        // skip the 0x0D
        if (*readPointer != 0x0D) {
            writePointer++;
        }

    } while (*readPointer++ != '\0');

    return aBuffer;
}

Here is the caller graph for this function:

LPSTR PrepareForTextArea ( LPSTR  aBuffer,
PRInt32  aSize 
)

Definition at line 847 of file JSConsole.cpp.

{
  PRInt32 count = 0;
  LPSTR newBuffer = aBuffer;
  LPSTR readPointer = aBuffer;

  // count the '\n'
  while (*readPointer != '\0' && (*readPointer++ != '\n' || ++count));

  if (0 != count) {
    readPointer = aBuffer;
    newBuffer = new CHAR[aSize + count + 1];
    LPSTR writePointer = newBuffer;
    while (*readPointer != '\0') {
      if (*readPointer == '\n') {
        *writePointer++ = 0x0D;
      }
      *writePointer++ = *readPointer++;
    }
    *writePointer = '\0';
  }

  return newBuffer;
}

Here is the caller graph for this function: