--nextPart1743484.ONNvhj8Qpe
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit

Are there any K (or Q) wrappers for getenv, setenv/putenv?
([GS]etEnvironmentVariable on Windows). I can't see any but I'm likely
looking in the wrong place ;-)

For info, I attach the implementation I've been using in QDVI
(http://sourceforge.net/projects/qdvi/).

Thoughts? Perhaps it should be turned into a class?

Regards,
Angus

--nextPart1743484.ONNvhj8Qpe
Content-Type: text/x-c++src; name="environment.cpp"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="environment.cpp"

// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
/**
* \file environment.cpp
* Distributed under the GNU GPL version 2 or (at your option)
* any later version. See accompanying file COPYING or copy at
* http://www.gnu.org/copyleft/gpl.html
*
* \author Angus Leeming
* \author João Luis M. Assirati
* \author Lars Gullik Bjønnes
*/

#include

#include "environment.h"
#include "os.h"

#include
#include
#include

#include


namespace kvs {

QString const getEnv(const QString& envname)
{
const char* const ch = ::getenv(envname.toLocal8Bit());
return !ch ? QString() : ch;
}


bool setEnv(const QString& name, QString const& value)
{
#if defined (HAVE_SETENV)
const int retval = ::setenv(name.toLocal8Bit(), value.local8Bit(), true);

#elif defined (HAVE_PUTENV)
static QMap varmap;

const QByteArray envstr = QString(name + '=' + value).toLocal8Bit();
const char* const envcstr = envstr;
const int retval = :utenv(const_cast(envcstr));
varmap[name] = envstr;

#else
#error No environment-setting function has been defined.
#endif
return retval == 0;
}


QStringList const getEnvPath(const QString& name)
{
#if defined _WIN32
const char path_separator = ';';
#else
const char path_separator = ':';
#endif

return getEnv(name).split(path_separator);
}

} // namespace kvs

--nextPart1743484.ONNvhj8Qpe
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


--nextPart1743484.ONNvhj8Qpe--