Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsPrintJobPS.cpp File Reference
#include "nscore.h"
#include "nsIDeviceContext.h"
#include "nsIDeviceContextPS.h"
#include "nsIDeviceContextSpecPS.h"
#include "nsPrintJobPS.h"
#include "nsPSPrinters.h"
#include "nsReadableUtils.h"
#include "prenv.h"
#include "prinit.h"
#include "prlock.h"
#include "prprf.h"
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>

Go to the source code of this file.

Functions

static PRStatus EnvLock ()
 Get the lock for setting printing-related environment variables and running print commands.
static PRStatus EnvSetPrinter (nsCString &aPrinter)
 Set MOZ_PRINTER_NAME to the specified string.
static void EnvClear ()
 Clear the printer environment variable and release the environment lock.
static PRStatus EnvLockInit ()

Variables

static PRLockEnvLockObj
static PRCallOnceType EnvLockOnce
static char * EnvPrinterString
static const char EnvPrinterName [] = { "MOZ_PRINTER_NAME" }

Function Documentation

static void EnvClear ( ) [static]

Clear the printer environment variable and release the environment lock.

Definition at line 535 of file nsPrintJobPS.cpp.

{
    if (EnvPrinterString) {
        /* On some systems, setenv("FOO") will remove FOO
         * from the environment.
         */
        PR_SetEnv(EnvPrinterName);
        if (!PR_GetEnv(EnvPrinterName)) {
            /* It must have worked */
            PR_smprintf_free(EnvPrinterString);
            EnvPrinterString = nsnull;
        }
    }
    PR_Unlock(EnvLockObj);
}

Here is the caller graph for this function:

static PRStatus EnvLock ( ) [static]

Get the lock for setting printing-related environment variables and running print commands.

Returns:
PR_SUCCESS on success PR_FAILURE if the lock object could not be initialized.

Definition at line 494 of file nsPrintJobPS.cpp.

{
    if (PR_FAILURE == PR_CallOnce(&EnvLockOnce, EnvLockInit))
        return PR_FAILURE;
    PR_Lock(EnvLockObj);
    return PR_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRStatus EnvLockInit ( ) [static]

Definition at line 479 of file nsPrintJobPS.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static PRStatus EnvSetPrinter ( nsCString aPrinter) [static]

Set MOZ_PRINTER_NAME to the specified string.

Parameters:
aPrinterThe value for MOZ_PRINTER_NAME. May be an empty string.
Returns:
PR_SUCCESS on success. PR_FAILURE if memory could not be allocated.

Definition at line 514 of file nsPrintJobPS.cpp.

{
    /* Construct the new environment string */
    char *newVar = PR_smprintf("%s=%s", EnvPrinterName, aPrinter.get());
    if (!newVar)
        return PR_FAILURE;

    /* Add it to the environment and dispose of any old string */
    PR_SetEnv(newVar);
    if (EnvPrinterString)
        PR_smprintf_free(EnvPrinterString);
    EnvPrinterString = newVar;

    return PR_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

PRLock* EnvLockObj [static]

Definition at line 474 of file nsPrintJobPS.cpp.

Definition at line 475 of file nsPrintJobPS.cpp.

const char EnvPrinterName[] = { "MOZ_PRINTER_NAME" } [static]

Definition at line 504 of file nsPrintJobPS.cpp.

char* EnvPrinterString [static]

Definition at line 503 of file nsPrintJobPS.cpp.