aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.4&content-type=text/x-cvsweb-markup/index.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.4&content-type=text/x-cvsweb-markup/index.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.4&content-type=text/x-cvsweb-markup/index.html')
-rw-r--r--cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.4&content-type=text/x-cvsweb-markup/index.html756
1 files changed, 756 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.4&content-type=text/x-cvsweb-markup/index.html b/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.4&content-type=text/x-cvsweb-markup/index.html
new file mode 100644
index 00000000..0e23cd2d
--- /dev/null
+++ b/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.4&content-type=text/x-cvsweb-markup/index.html
@@ -0,0 +1,756 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
+<HEAD><style> A { color:black }</style>
+<!-- hennerik CVSweb $Revision: 1.93 $ -->
+<TITLE>code/nelns/admin_service/admin_service.cpp - view - 1.4</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="admin_service.cpp"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="admin_service.cpp">admin_service.cpp</A>
+ CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/">code</a> / <a href="/cvs/cvsweb.cgi/code/nelns/">nelns</a> / <a href="/cvs/cvsweb.cgi/code/nelns/admin_service/">admin_service</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/">code</a> / <a href="/cvs/cvsweb.cgi/code/nelns/">nelns</a> / <a href="/cvs/cvsweb.cgi/code/nelns/admin_service/">admin_service</a> / <a href="/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp">admin_service.cpp</a>&nbsp;(<A HREF="/cvs/cvsweb.cgi/~checkout~/code/nelns/admin_service/admin_service.cpp?rev=1.4" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/nelns/admin_service/admin_service.cpp?rev=1.4','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR>
+Revision <B>1.4</B>, <i>Fri May 18 16:51:33 2001 UTC</i> (14 months ago) by <i>lecroart</i>
+<BR>Branch: <b>MAIN</b>
+<BR>Changes since <b>1.3: +405 -101
+ lines</b><PRE>
+ADDED: work in progress. added gtk
+</PRE>
+</td></tr></table><HR noshade><PRE>/** \file admin_service.cpp
+ * Admin Service (AS)
+ *
+ * $Id: admin_service.cpp,v 1.4 2001/05/18 16:51:33 lecroart Exp $
+ *
+ */
+
+/* Copyright, 2000 Nevrax Ltd.
+ *
+ * This file is part of NEVRAX NeL Network Services.
+ * NEVRAX NeL Network Services is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * NEVRAX NeL Network Services is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with NEVRAX NeL Network Services; see the file COPYING. If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include &lt;string&gt;
+#include &lt;list&gt;
+
+#include &quot;nel/net/service.h&quot;
+#include &quot;nel/misc/debug.h&quot;
+#include &quot;nel/misc/config_file.h&quot;
+
+#include &quot;nel/net/net_manager.h&quot;
+
+using namespace std;
+using namespace NLMISC;
+using namespace NLNET;
+
+////////////////////////
+
+
+struct CService
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CService () : Id(0xFFFFFFFF), Ready(false), Connected(false), InConfig(false) { }
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 &nbsp; &nbsp; &nbsp; &nbsp;Id; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// uint32 to identify the service
+ &nbsp; &nbsp; &nbsp; &nbsp;string &nbsp; &nbsp; &nbsp; &nbsp;ServiceAlias; &nbsp; &nbsp; &nbsp; &nbsp;/// alias of the service used in the AES and AS to find him (unique per AES)
+ &nbsp; &nbsp; &nbsp; &nbsp;string &nbsp; &nbsp; &nbsp; &nbsp;ShortName; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// name of the service in short format (&quot;NS&quot; for example)
+ &nbsp; &nbsp; &nbsp; &nbsp;string &nbsp; &nbsp; &nbsp; &nbsp;LongName; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// name of the service in long format (&quot;naming_service&quot;)
+ &nbsp; &nbsp; &nbsp; &nbsp;bool &nbsp; &nbsp; &nbsp; &nbsp;Ready; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// true if the service is ready
+ &nbsp; &nbsp; &nbsp; &nbsp;bool &nbsp; &nbsp; &nbsp; &nbsp;Connected; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// true if the service is connected to the AES
+ &nbsp; &nbsp; &nbsp; &nbsp;bool &nbsp; &nbsp; &nbsp; &nbsp;InConfig; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// true if the service is in the configuration
+};
+
+typedef list&lt;CService&gt; TServices;
+typedef list&lt;CService&gt;::iterator SIT;
+
+struct CAdminExecutorService
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService () : Id(NextId++), SockId(NULL), Connected(false) { }
+
+ &nbsp; &nbsp; &nbsp; &nbsp;TSockId &nbsp; &nbsp; &nbsp; &nbsp;SockId; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// connection to the AES
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 &nbsp; &nbsp; &nbsp; &nbsp;Id; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// uint32 to identify the AES where the service is running
+
+ &nbsp; &nbsp; &nbsp; &nbsp;string &nbsp; &nbsp; &nbsp; &nbsp;ServerAlias; &nbsp; &nbsp; &nbsp; &nbsp;/// name of the layer4 connection, used to send message to this AES
+ &nbsp; &nbsp; &nbsp; &nbsp;string &nbsp; &nbsp; &nbsp; &nbsp;ServerAddr; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// address in a string format (only the ip)
+ &nbsp; &nbsp; &nbsp; &nbsp;bool &nbsp; &nbsp; &nbsp; &nbsp;Connected; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// true if the AES is connected
+
+ &nbsp; &nbsp; &nbsp; &nbsp;TServices Services;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;string&gt; &nbsp; &nbsp; &nbsp; &nbsp;ServiceAliasList;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;SIT findService (uint32 sid, bool asrt = true)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SIT sit;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (sit = Services.begin(); sit != Services.end(); sit++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((*sit).Id == sid)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (asrt)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlassert (sit != Services.end());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return sit;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+private:
+ &nbsp; &nbsp; &nbsp; &nbsp;static uint32 NextId;
+};
+
+uint32 CAdminExecutorService::NextId = 1;
+
+typedef list&lt;CAdminExecutorService&gt; TAdminExecutorServices;
+typedef list&lt;CAdminExecutorService&gt;::iterator AESIT;
+
+TAdminExecutorServices AdminExecutorServices;
+
+/////////////////
+
+AESIT findAdminExecutorService (uint32 aesid, bool asrt = true)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit;
+ &nbsp; &nbsp; &nbsp; &nbsp;for (aesit = AdminExecutorServices.begin(); aesit != AdminExecutorServices.end(); aesit++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((*aesit).Id == aesid)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (asrt)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlassert (aesit != AdminExecutorServices.end());
+ &nbsp; &nbsp; &nbsp; &nbsp;return aesit;
+}
+
+AESIT findAdminExecutorService (string ServerAlias, bool asrt = true)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit;
+ &nbsp; &nbsp; &nbsp; &nbsp;for (aesit = AdminExecutorServices.begin(); aesit != AdminExecutorServices.end(); aesit++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((*aesit).ServerAlias == ServerAlias)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (asrt)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlassert (aesit != AdminExecutorServices.end());
+ &nbsp; &nbsp; &nbsp; &nbsp;return aesit;
+}
+
+void displayServices ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;for (AESIT aesit = AdminExecutorServices.begin(); aesit != AdminExecutorServices.end(); aesit++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (SIT sit = (*aesit).Services.begin(); sit != (*aesit).Services.end(); sit++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;&gt; %s %s %s %d %d&quot;, (*aesit).SockId-&gt;asString().c_str(), (*sit).ShortName.c_str(), (*sit).LongName.c_str(), (*aesit).Id, (*sit).Id);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////// SCRIPT MANAGER /////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool ScriptRunning = false;
+string ScriptName;
+uint32 ScriptPos;
+
+void doNextScriptStep ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (ScriptRunning);
+
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// get the script
+
+ &nbsp; &nbsp; &nbsp; &nbsp;try
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CConfigFile::CVar &amp;script = IService::ConfigFile.getVar(ScriptName);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// check the position
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (ScriptPos*2 &gt;= (uint32)script.size())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRunning = false;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlinfo(&quot;end of the script&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// todo send that the script is finish to the admin
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// get the script line
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string serverAlias;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string serviceAlias;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serverAlias = script.asString (ScriptPos*2);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serviceAlias = script.asString (ScriptPos*2+1);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch(EBadSize &amp;)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;script '%s' not contains a good number of entries (must be a multiple of 2)&quot;, ScriptName.c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRunning = false;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit = findAdminExecutorService (serverAlias, false);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (aesit == AdminExecutorServices.end())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRunning = false;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning(&quot;don't find the server&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// send the resquest to the AES
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA((*aesit).ServerAlias), &quot;STARTS&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (serviceAlias);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send ((*aesit).ServerAlias, msgout);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptPos++;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;catch(EUnknownVar&amp;)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;script '%s' not found&quot;, ScriptName.c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRunning = false;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+void initScript(string scriptName)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;if (ScriptRunning)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning(&quot;already running a script, reset it&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRunning = false;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;try
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CConfigFile::CVar &amp;script = IService::ConfigFile.getVar(scriptName);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (sint i = 0 ; i &lt; script.size (); i+=2)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string serverAlias = script.asString(i);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit = findAdminExecutorService (serverAlias, false);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (aesit == AdminExecutorServices.end())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning(&quot;aes not running, can't run the script&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;catch(EConfigFile &amp;)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;bad config file&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;ScriptName = scriptName;
+ &nbsp; &nbsp; &nbsp; &nbsp;ScriptPos = 0;
+ &nbsp; &nbsp; &nbsp; &nbsp;ScriptRunning = true;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;doNextScriptStep();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////// CONNECTION TO THE AES ///////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+static void cbExecuteSystemCommandResult (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;vector&lt;string&gt; result;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serialCont (result);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo(&quot;command result&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;for (uint i = 0; i &lt; result.size(); i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf (&quot;%s&quot;, result[i].c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo(&quot;end of command result&quot;);
+}
+
+static void cbServiceList (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+/* &nbsp; &nbsp; &nbsp;// get the service list from the admin exec and send the list to all admin client
+ &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) from-&gt;appId();
+ &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Services.clear();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;SL&quot;);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbaes = 1;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (nbaes);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbs;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (nbs);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (nbs);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (uint32 i = 0; i &lt; nbs; i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint32 sid;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial(sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Services.push_back (CService(sid));
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CService *s = &amp;(aes-&gt;Services.back());
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial(s-&gt;ShortName, s-&gt;LongName, s-&gt;Ready);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (s-&gt;Id, s-&gt;ShortName, s-&gt;LongName, s-&gt;Ready);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+ &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;displayServices ();
+*/}
+
+static void cbServiceAliasList (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// get the service list from the admin exec and send the list to all admin client
+ &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) from-&gt;appId();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;ServiceAliasList.clear ();
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serialCont (aes-&gt;ServiceAliasList);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;SAL&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serialCont (aes-&gt;ServiceAliasList);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+ &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo(&quot;new service alias list&quot;);
+}
+
+
+static void cbServiceIdentification (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) from-&gt;appId();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 sid;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;SIT sit = aes-&gt;findService(sid);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial ((*sit).ShortName, (*sit).LongName);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;*:%d:%d is identified to be '%s' '%s'&quot;, aes-&gt;Id, sid, (*sit).ShortName.c_str(), (*sit).LongName.c_str());
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the message to all admin client
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;SID&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id, sid, (*sit).ShortName, (*sit).LongName);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+}
+
+static void cbServiceReady (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) from-&gt;appId();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 sid;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;SIT sit = aes-&gt;findService(sid);
+ &nbsp; &nbsp; &nbsp; &nbsp;(*sit).Ready = true;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;*:%d:%d is ready&quot;, aes-&gt;Id, sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the message to all admin client
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;SR&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id, sid);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// if we are in a script execution, continue
+ &nbsp; &nbsp; &nbsp; &nbsp;if (ScriptRunning)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;doNextScriptStep();
+}
+
+static void cbServiceConnection (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+/* &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) from-&gt;appId();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 sid;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;*:%d:%d connected&quot;, aes-&gt;Id, sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Services.push_back (CService(sid));
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the message to all admin client
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;SC&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id, sid);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+*/}
+
+static void cbServiceDisconnection (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) from-&gt;appId();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 sid;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;*:%d:%d disconnected&quot;, aes-&gt;Id, sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;SIT sit = aes-&gt;findService(sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the message to all admin client
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;SD&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id, (*sit).Id);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Services.erase (sit);
+}
+
+// i'm connected to a new admin executor service
+void cbAESConnection (const string &amp;serviceName, TSockId from, void *arg)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit = findAdminExecutorService (serviceName); &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = &amp;(*aesit);
+ &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;// set the appid to find the aes in O(1)
+ &nbsp; &nbsp; &nbsp; &nbsp;from-&gt;setAppId ((uint64)aes);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Connected = true;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;*:%d:* connected&quot;, aes-&gt;Id);
+/* &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the message that an admin exec is connected to all admin client
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;AESC&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+*/
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the new state of this AES
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;AES_LIST&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbaes = 1;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (nbaes);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id, aes-&gt;ServerAlias, aes-&gt;ServerAddr, aes-&gt;Connected);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+}
+
+// i'm disconnected to an admin executor service
+void cbAESDisconnection (const string &amp;serviceName, TSockId from, void *arg)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// get the aes with the appid
+ &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) from-&gt;appId();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Connected = false;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;*:%d:* disconnected&quot;, aes-&gt;Id);
+/* &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the message to all admin client that an admin exec is disconnected
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;AESD&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+*/
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the new state of this AES
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;AES_LIST&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbaes = 1;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (nbaes);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id, aes-&gt;ServerAlias, aes-&gt;ServerAddr, aes-&gt;Connected);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+}
+
+static void cbLog (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// received an answer for a command, give it to all admin client
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the message to the admin service
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;LOG&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;string log;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (log);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (log);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
+}
+
+
+TCallbackItem AESCallbackArray[] =
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;ESCR&quot;, cbExecuteSystemCommandResult },
+
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;SL&quot;, cbServiceList },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;SID&quot;, cbServiceIdentification },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;SR&quot;, cbServiceReady },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;SC&quot;, cbServiceConnection },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;SD&quot;, cbServiceDisconnection },
+
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;SAL&quot;, cbServiceAliasList },
+
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;LOG&quot;, cbLog },
+};
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////// CONNECTION TO THE CLIENT ////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void errorMessage(string message, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (netbase.getSIDA (), &quot;ERR&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (message);
+ &nbsp; &nbsp; &nbsp; &nbsp;netbase.send (msgout, from);
+}
+
+//
+// A new admin client is connected.
+//
+void clientConnection (const string &amp;serviceName, TSockId from, void *arg)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// new client, send him all out info about services
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;client %s is connected&quot;, from-&gt;asString().c_str());
+
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;// send the list of all the aes
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout2 (CNetManager::getSIDA (&quot;AS&quot;), &quot;AES_LIST&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit;
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbaes = (uint32)AdminExecutorServices.size();
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout2.serial (nbaes);
+ &nbsp; &nbsp; &nbsp; &nbsp;for (aesit = AdminExecutorServices.begin(); aesit != AdminExecutorServices.end(); aesit++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// send info about the AES
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout2.serial ((*aesit).Id, (*aesit).ServerAlias, (*aesit).ServerAddr, (*aesit).Connected);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout2, from);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;// send the list of all services
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;SERVICE_LIST&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;nbaes = (uint32)AdminExecutorServices.size();
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (nbaes);
+ &nbsp; &nbsp; &nbsp; &nbsp;for (aesit = AdminExecutorServices.begin(); aesit != AdminExecutorServices.end(); aesit++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial ((*aesit).Id);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbs = (uint32)(*aesit).Services.size();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (nbs);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (SIT sit = (*aesit).Services.begin(); sit != (*aesit).Services.end(); sit++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// send info about services of the AES
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial ((*sit).Id, (*sit).ServiceAlias, (*sit).ShortName, (*sit).LongName);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial ((*sit).Ready, (*sit).Connected, (*sit).InConfig);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, from);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;// send service alias list
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (aesit = AdminExecutorServices.begin(); aesit != AdminExecutorServices.end(); aesit++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout2 (CNetManager::getSIDA (&quot;AS&quot;), &quot;SAL&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout2.serial ((*aesit).Id);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout2.serialCont ((*aesit).ServiceAliasList);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout2, from);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+
+static void cbExecuteScript (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;string script;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (script);
+ &nbsp; &nbsp; &nbsp; &nbsp;initScript (script);
+}
+
+
+static void cbExecuteSystemCommand (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;string command;
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 aesid;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (aesid);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (command);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit = findAdminExecutorService (aesid, false);
+ &nbsp; &nbsp; &nbsp; &nbsp;if (aesit == AdminExecutorServices.end())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// don't find the aes, send an error message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorMessage (&quot;couldn't execute command, as didn't find the aes&quot;, from, netbase);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// send the resquest to the AES
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA((*aesit).ServerAlias), &quot;SYS&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (command);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send ((*aesit).ServerAlias, msgout);
+}
+
+
+static void cbStartService (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;string serviceName;
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 aesid;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (aesid);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (serviceName);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit = findAdminExecutorService (aesid, false);
+ &nbsp; &nbsp; &nbsp; &nbsp;if (aesit == AdminExecutorServices.end())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// don't find the aes, send an error message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorMessage (&quot;couldn't start service, as didn't find the aes&quot;, from, netbase);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// send the resquest to the AES
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA((*aesit).ServerAlias), &quot;STARTS&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (serviceName);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send ((*aesit).ServerAlias, msgout);
+}
+
+static void cbStopService (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 aesid, sid;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (aesid);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (sid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit = findAdminExecutorService (aesid, false);
+ &nbsp; &nbsp; &nbsp; &nbsp;if (aesit == AdminExecutorServices.end())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorMessage (&quot;couldn't stop service, as didn't find the aes&quot;, from, netbase);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// don't find the aes, send an error message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;SIT sit = (*aesit).findService (sid, false);
+ &nbsp; &nbsp; &nbsp; &nbsp;if (sit == (*aesit).Services.end())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// don't find the s, send an error message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorMessage (&quot;couldn't stop service, as didn't find the service&quot;, from, netbase);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// send the resquest to the AES
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA((*aesit).ServerAlias), &quot;STOPS&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (sid);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send ((*aesit).ServerAlias, msgout);
+}
+
+static void cbExecCommand (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 aesid, sid;
+ &nbsp; &nbsp; &nbsp; &nbsp;string command;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (aesid);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (sid);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (command);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit = findAdminExecutorService (aesid, false);
+ &nbsp; &nbsp; &nbsp; &nbsp;if (aesit == AdminExecutorServices.end())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorMessage (&quot;couldn't stop service, as didn't find the aes&quot;, from, netbase);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// don't find the aes, send an error message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;SIT sit = (*aesit).findService (sid, false);
+ &nbsp; &nbsp; &nbsp; &nbsp;if (sit == (*aesit).Services.end())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// don't find the s, send an error message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorMessage (&quot;couldn't stop service, as didn't find the service&quot;, from, netbase);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// send the resquest to the AES
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA((*aesit).ServerAlias), &quot;EXEC_COMMAND&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (sid);
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (command);
+ &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send ((*aesit).ServerAlias, msgout);
+}
+
+
+TCallbackItem ClientCallbackArray[] =
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;SYS&quot;, cbExecuteSystemCommand },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;EXEC&quot;, cbExecuteScript },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;STARTS&quot;, cbStartService },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;STOPS&quot;, cbStopService },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;EXEC_COMMAND&quot;, cbExecCommand },
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////// SERVICE IMPLEMENTATION //////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class CAdminService : public IService
+{
+public:
+
+ &nbsp; &nbsp; &nbsp; &nbsp;/// Init the service, load the universal time.
+ &nbsp; &nbsp; &nbsp; &nbsp;void &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;init ()
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DebugLog-&gt;addNegativeFilter (&quot;L0:&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DebugLog-&gt;addNegativeFilter (&quot;L1:&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DebugLog-&gt;addNegativeFilter (&quot;L2:&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::setConnectionCallback (&quot;AS&quot;, clientConnection, NULL);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Get the list of AESHosts, add in the structures and create connection to all AES
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CConfigFile::CVar &amp;host = ConfigFile.getVar (&quot;AESHosts&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (sint i = 0 ; i &lt; host.size (); i+=2)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string serverAlias = host.asString(i);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string serverAddr = host.asString(i+1);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// add to the list
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService aes;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;aes.ServerAlias = serverAlias;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;aes.ServerAddr = serverAddr;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AdminExecutorServices.push_back (aes);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// connect to the AES
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::setConnectionCallback (serverAlias, cbAESConnection, NULL);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::setDisconnectionCallback (serverAlias, cbAESDisconnection, NULL);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::addClient (serverAlias, serverAddr+&quot;:49996&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::addCallbackArray (serverAlias, AESCallbackArray, sizeof (AESCallbackArray)/sizeof(AESCallbackArray[0]));
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Get the list of services in the shard
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CConfigFile::CVar &amp;serv = ConfigFile.getVar (&quot;Services&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (i = 0 ; i &lt; serv.size (); i+=2)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string serverAlias = serv.asString(i);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string serviceAlias = serv.asString(i+1);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AESIT aesit = findAdminExecutorService (serverAlias);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// add new AES in the list
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CService s;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.ServiceAlias = serviceAlias;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.InConfig = true;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*aesit).Services.push_back (s);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;bool &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;update ()
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return true;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+};
+
+
+// AS is a server connection to the admin client
+// AESAS is a client connection to the admin executor
+
+/// Naming Service
+NLNET_SERVICE_MAIN (CAdminService, &quot;AS&quot;, &quot;admin_service&quot;, 49995, ClientCallbackArray);
+</PRE> \ No newline at end of file