2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Process environment utility
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2011-02-17
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 20:44:47 +00:00
|
|
|
* Copyright (C) 2011-2013 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <util/string.h>
|
|
|
|
#include <os/attached_ram_dataspace.h>
|
|
|
|
#include <base/printf.h>
|
|
|
|
|
|
|
|
/* Noux includes */
|
|
|
|
#include <path.h>
|
|
|
|
|
|
|
|
namespace Noux {
|
|
|
|
|
2012-10-08 12:44:31 +00:00
|
|
|
class Environment : private Attached_ram_dataspace
|
2011-12-22 15:19:25 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2012-08-28 15:24:59 +00:00
|
|
|
Sysio::Env *_env;
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \param env comma-separated list of environment variables
|
|
|
|
*/
|
2012-08-28 15:24:59 +00:00
|
|
|
Environment(Sysio::Env const &env) :
|
|
|
|
Attached_ram_dataspace(Genode::env()->ram_session(), sizeof(Sysio::Env)),
|
|
|
|
_env(local_addr<Sysio::Env>())
|
2011-12-22 15:19:25 +00:00
|
|
|
{
|
2012-08-28 15:24:59 +00:00
|
|
|
memcpy(_env, env, sizeof(Sysio::Env));
|
2011-12-22 15:19:25 +00:00
|
|
|
}
|
|
|
|
|
2012-04-23 18:42:55 +00:00
|
|
|
using Attached_ram_dataspace::cap;
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2012-03-19 15:49:54 +00:00
|
|
|
/**
|
2012-08-28 15:24:59 +00:00
|
|
|
* Return list of environment variables as zero-separated list
|
2012-03-19 15:49:54 +00:00
|
|
|
*/
|
2012-08-28 15:24:59 +00:00
|
|
|
Sysio::Env const &env() { return *_env; }
|
2011-12-22 15:19:25 +00:00
|
|
|
};
|
|
|
|
}
|