2018-07-13 11:13:30 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2019-06-06 05:28:23 +00:00
|
|
|
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
2018-07-13 11:13:30 +00:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <qse/xli/SkvEnv.hpp>
|
|
|
|
#include <qse/si/sio.h>
|
|
|
|
#include <qse/cmn/main.h>
|
|
|
|
#include <qse/cmn/mbwc.h>
|
|
|
|
#include <qse/cmn/str.h>
|
2018-07-14 17:05:08 +00:00
|
|
|
#include <qse/cmn/String.hpp>
|
2018-07-13 11:13:30 +00:00
|
|
|
|
|
|
|
#include <locale.h>
|
|
|
|
#if defined(_WIN32)
|
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class MyEnv: public QSE::SkvEnv
|
|
|
|
{
|
2018-07-14 17:05:08 +00:00
|
|
|
public:
|
|
|
|
int probe_agent_name (const qse_char_t* name)
|
|
|
|
{
|
|
|
|
qse_printf (QSE_T("probing agent_name %s\n"), name);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-07-13 11:13:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MyEnv myenv;
|
|
|
|
|
|
|
|
static int env_main (int argc, qse_char_t* argv[])
|
|
|
|
{
|
2018-07-14 17:05:08 +00:00
|
|
|
myenv.addItem (QSE_T("main*target"), QSE_T("file"));
|
|
|
|
myenv.addItem (QSE_T("main*targetq"), QSE_T("file"));
|
|
|
|
myenv.addItem (QSE_T("agent*name"), QSE_T("my-agent"), (MyEnv::ProbeProc)&MyEnv::probe_agent_name);
|
|
|
|
|
2018-07-13 11:13:30 +00:00
|
|
|
myenv.load (QSE_T("myenv.conf"));
|
|
|
|
|
2018-07-14 17:05:08 +00:00
|
|
|
QSE::String x (myenv.getValue(QSE_T("main*target")));
|
|
|
|
x.append (QSE_T("-jj"));
|
|
|
|
myenv.setValue(QSE_T("main*target"), x);
|
|
|
|
|
2018-07-13 11:13:30 +00:00
|
|
|
const qse_char_t* v = myenv.getValue(QSE_T("main*target"));
|
|
|
|
qse_printf (QSE_T("%s\n"), (v? v: QSE_T("<null>")));
|
|
|
|
|
2018-07-14 17:05:08 +00:00
|
|
|
myenv.store (QSE_T("myenv.conf"));
|
2018-07-13 11:13:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int qse_main (int argc, qse_achar_t* argv[])
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
qse_open_stdsios ();
|
|
|
|
|
|
|
|
{
|
|
|
|
#if defined(_WIN32)
|
|
|
|
char locale[100];
|
|
|
|
UINT codepage = GetConsoleOutputCP();
|
|
|
|
if (codepage == CP_UTF8)
|
|
|
|
{
|
|
|
|
/*SetConsoleOUtputCP (CP_UTF8);*/
|
|
|
|
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf (locale, ".%u", (unsigned int)codepage);
|
|
|
|
setlocale (LC_ALL, locale);
|
|
|
|
/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-09-13 03:16:23 +00:00
|
|
|
x = qse_run_main (argc,argv,env_main);
|
2018-07-13 11:13:30 +00:00
|
|
|
qse_close_stdsios ();
|
|
|
|
return x;
|
|
|
|
}
|