genode/repos/ports/src/noux/environment.h

60 lines
1.1 KiB
C
Raw Normal View History

2011-12-22 16:19:25 +01:00
/*
* \brief Process environment utility
* \author Norman Feske
* \date 2011-02-17
*/
/*
* Copyright (C) 2011-2017 Genode Labs GmbH
2011-12-22 16:19:25 +01:00
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
2011-12-22 16:19:25 +01:00
*/
#ifndef _NOUX__ENVIRONMENT_H_
#define _NOUX__ENVIRONMENT_H_
2011-12-22 16:19:25 +01:00
/* Genode includes */
#include <util/string.h>
#include <base/attached_ram_dataspace.h>
2011-12-22 16:19:25 +01:00
/* Noux includes */
#include <path.h>
namespace Noux {
class Environment;
using namespace Genode;
}
2011-12-22 16:19:25 +01:00
2019-01-18 16:18:19 +01:00
class Noux::Environment : Noncopyable
{
private:
2011-12-22 16:19:25 +01:00
2019-01-18 16:18:19 +01:00
Attached_ram_dataspace _ds;
Sysio::Env &_env { *_ds.local_addr<Sysio::Env>() };
2011-12-22 16:19:25 +01:00
public:
2011-12-22 16:19:25 +01:00
/**
* Constructor
*
* \param env comma-separated list of environment variables
*/
Environment(Ram_allocator &ram, Region_map &local_rm, Sysio::Env const &env)
2019-01-18 16:18:19 +01:00
: _ds(ram, local_rm, sizeof(Sysio::Env))
{
2019-01-18 16:18:19 +01:00
memcpy(&_env, &env, sizeof(Sysio::Env));
}
2011-12-22 16:19:25 +01:00
2019-01-18 16:18:19 +01:00
Dataspace_capability cap() { return _ds.cap(); }
/**
* Return list of environment variables as zero-separated list
*/
2019-01-18 16:18:19 +01:00
Sysio::Env const &env() { return _env; }
};
#endif /* _NOUX__ENVIRONMENT_H_ */