Checkin for bug 120866. Add getenv() support to autoconfig module. Checking in for Jerry Tan. r=dveditz, sr=alecf, a=asa.

This commit is contained in:
bnesse%netscape.com 2002-03-22 21:37:50 +00:00
Родитель 5a09686f98
Коммит 6b43b951d8
4 изменённых файлов: 47 добавлений и 0 удалений

Просмотреть файл

@ -197,3 +197,15 @@ function displayError(message) {
promptService.alert(null, title, err);
}
}
function getenv(name) {
try {
var currentProcess=Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
return currentProcess.getEnvironment(name);
}
catch(e) {
displayError("getEnvironment failed with error: " + e);
}
}

Просмотреть файл

@ -16,6 +16,16 @@ interface nsIProcess : nsISupports
readonly attribute string processName;
readonly attribute unsigned long processSignature;
readonly attribute long exitValue;
/**
* Called to get the value of environment variable
*
* @param aName The string enviroment variable name
* @exception NS_ERROR_OUT_OF_MEMORY
*
* @return The value of the requested string environment variable name
*/
string getEnvironment(in string aName);
};
%{C++

Просмотреть файл

@ -35,6 +35,8 @@
#include "nsProcess.h"
#include "prtypes.h"
#include "prio.h"
#include "prenv.h"
#include "nsCRT.h"
#include <stdlib.h>
@ -345,3 +347,13 @@ nsProcess::GetExitValue(PRInt32 *aExitValue)
return NS_OK;
}
NS_IMETHODIMP
nsProcess::GetEnvironment(const char *aName, char **aValue)
{
NS_ENSURE_ARG_POINTER(aName);
*aValue = nsCRT::strdup(PR_GetEnv(aName));
if (!*aValue)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}

Просмотреть файл

@ -38,6 +38,8 @@
#include "prtypes.h"
#include "prio.h"
#include "prenv.h"
#include "nsCRT.h"
#include "prthread.h"
#include <stdlib.h>
@ -138,6 +140,17 @@ NS_IMETHODIMP nsProcess::InitWithPid(PRUint32 pid)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsProcess::GetEnvironment(const char *aName, char **aValue)
{
NS_ENSURE_ARG_POINTER(aName);
*aValue = nsCRT::strdup(PR_GetEnv(aName));
if (!*aValue)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsProcess::GetLocation(nsIFile** aLocation)
{