aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.10&content-type=text/x-cvsweb-markup/index.html
blob: 70e1502b2e0cb1ee11bee6b6b1aec3cc860455bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
<!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.10</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.10" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/nelns/admin_service/admin_service.cpp?rev=1.10','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR>
Revision <B>1.10</B>, <i>Thu Jul  5 08:26:07 2001 UTC</i> (12 months, 2 weeks ago) by <i>lecroart</i>
<BR>Branch: <b>MAIN</b>
<BR>Changes since <b>1.9: +1 -6
 lines</b><PRE>
REMOVED: update()
</PRE>
</td></tr></table><HR noshade><PRE>/** \file admin_service.cpp
 * Admin Service (AS)
 *
 * $Id: admin_service.cpp,v 1.10 2001/07/05 08:26:07 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/misc/command.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; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AliasName; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InConfig; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// true if the service is in the configuration
 &nbsp; &nbsp; &nbsp; &nbsp;std::vector&lt;NLMISC::CSerialCommand&gt; &nbsp; &nbsp; &nbsp; &nbsp;Commands;

 &nbsp; &nbsp; &nbsp; &nbsp;void setValues (const CService &amp;t)
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// copy all except gtk stuffs
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Id = t.Id;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AliasName = t.AliasName;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShortName = t.ShortName;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LongName = t.LongName;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Ready = t.Ready;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Connected = t.Connected;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//InConfig = t.InConfig; never change the inconfig value
 &nbsp; &nbsp; &nbsp; &nbsp;}
};

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;}

 &nbsp; &nbsp; &nbsp; &nbsp;SIT findService (const string &amp;alias, 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).AliasName == alias)
 &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;nlinfo (&quot;&gt; Admin&quot;);
 &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; &nbsp;&gt; '%s' '%s' '%s' '%s' %d %d&quot;, (*aesit).SockId-&gt;asString().c_str(), (*sit).AliasName.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;}
}


// send a message to a client. if ok is 0 it s an error or it s a normal 
void messageToClient (uint8 ok, string msg, TSockId from = NULL)
{
 &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;MESSAGE&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (ok, msg);
 &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, from);
}


////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////// SCRIPT MANAGER /////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

bool StartAllServices = false;
uint32 StartAllServicesPos;

void doNextStartAllServicesStep ()
{
 &nbsp; &nbsp; &nbsp; &nbsp;nlassert (StartAllServices);

 &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(&quot;Services&quot;);

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// check the position

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (StartAllServicesPos*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;StartAllServices = 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;messageToClient (1, &quot;Start All Service finnished correctly&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;// 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 (StartAllServicesPos*2);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;serviceAlias = script.asString (StartAllServicesPos*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;messageToClient (1, &quot;'Services' variable does not contains a good number of entries (must be a multiple of 2)&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;'Services' variable does not contains a good number of entries (must be a multiple of 2)&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StartAllServices = 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;messageToClient (1, &quot;don't find the server&quot;);
 &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;StartAllServices = 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;// check if the service is not currently running

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StartAllServicesPos++;

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SIT sit = (*aesit).findService (serviceAlias);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((*sit).Connected)
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// the service is already running, go to the next process
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;doNextStartAllServicesStep ();
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
 &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA((*aesit).ServerAlias), &quot;STARTS&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (serviceAlias);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send ((*aesit).ServerAlias, msgout);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;catch(EUnknownVar&amp;)
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;messageToClient (1, &quot;'Services' variable is not found&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;'Services' variable is not found&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StartAllServices = false;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
 &nbsp; &nbsp; &nbsp; &nbsp;}
}

void initStartAllServices ()
{
 &nbsp; &nbsp; &nbsp; &nbsp;if (StartAllServices)
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;messageToClient (1, &quot;already running a script, reset it&quot;);
 &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;StartAllServices = 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(&quot;Services&quot;);

 &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;messageToClient (1, &quot;an aes is not running, can't run the script&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning(&quot;aes '%s' isn't running, can't run the script&quot;, serverAlias.c_str());
 &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;messageToClient (1, &quot;bad config file&quot;);
 &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;StartAllServicesPos = 0;
 &nbsp; &nbsp; &nbsp; &nbsp;StartAllServices = true;

 &nbsp; &nbsp; &nbsp; &nbsp;doNextStartAllServicesStep();
}


////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////// 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;);
}

// get the service list from the admin exec and send the list to all admin client
static void cbServiceList (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
{
 &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) (uint) from-&gt;appId();

 &nbsp; &nbsp; &nbsp; &nbsp;//
 &nbsp; &nbsp; &nbsp; &nbsp;// Get the list of service from aes
 &nbsp; &nbsp; &nbsp; &nbsp;//

 &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbs;
 &nbsp; &nbsp; &nbsp; &nbsp;msgin.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;// find the service
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CService s;

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (s.Id, s.AliasName, s.ShortName, s.LongName, s.Ready);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serialCont (s.Commands);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.Connected = true;

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!s.AliasName.empty())
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SIT sit = aes-&gt;findService (s.AliasName, false);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (sit == aes-&gt;Services.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;aes-&gt;Services.push_back (s);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
 &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;nlassert (&quot;the service already exists with alias, update it&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).setValues (s);
 &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;else
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SIT sit = aes-&gt;findService (s.Id, false);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (sit == aes-&gt;Services.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;aes-&gt;Services.push_back (s);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
 &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;nlassert (&quot;the service already exists with id, update it&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).setValues (s);
 &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;
 &nbsp; &nbsp; &nbsp; &nbsp;displayServices ();

 &nbsp; &nbsp; &nbsp; &nbsp;//
 &nbsp; &nbsp; &nbsp; &nbsp;// Send the new list to all admin
 &nbsp; &nbsp; &nbsp; &nbsp;//

 &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;SERVICE_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);
 &nbsp; &nbsp; &nbsp; &nbsp;uint32 ss = aes-&gt;Services.size();
 &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (ss);

 &nbsp; &nbsp; &nbsp; &nbsp;for (SIT sit = aes-&gt;Services.begin(); sit != aes-&gt;Services.end(); sit++)
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial ((*sit).Id, (*sit).AliasName, (*sit).ShortName, (*sit).LongName);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial ((*sit).Ready, (*sit).Connected, (*sit).InConfig);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serialCont ((*sit).Commands);
 &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send (&quot;AS&quot;, msgout, 0);
}

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*) (uint) from-&gt;appId();

 &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;ServiceAliasList.clear ();
 &nbsp; &nbsp; &nbsp; &nbsp;msgin.serialCont (aes-&gt;ServiceAliasList);

 &nbsp; &nbsp; &nbsp; &nbsp;nlinfo(&quot;send SAL to admin callback from aes&quot;);

 &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*) (uint) from-&gt;appId();

 &nbsp; &nbsp; &nbsp; &nbsp;uint32 sid;
 &nbsp; &nbsp; &nbsp; &nbsp;string alias;

 &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (sid, alias);

 &nbsp; &nbsp; &nbsp; &nbsp;SIT sit;
 &nbsp; &nbsp; &nbsp; &nbsp;if (!alias.empty())
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sit = aes-&gt;findService (alias, false);

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (sit == aes-&gt;Services.end ())
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// the alias is not found
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;new service with alias (%s) but not in my list&quot;, alias.c_str());

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Services.push_back (CService ());
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sit = aes-&gt;Services.end();
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sit--;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// normal case
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;else
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sit = aes-&gt;findService (sid, false);

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (sit == aes-&gt;Services.end ())
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// normal case for unknown services
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;new service without alias and not in my list, add it&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;new service without alias is already in my list with id %d, add it&quot;, sid);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Services.push_back (CService ());
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sit = aes-&gt;Services.end();
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sit--;
 &nbsp; &nbsp; &nbsp; &nbsp;}

 &nbsp; &nbsp; &nbsp; &nbsp;(*sit).Id = sid;
 &nbsp; &nbsp; &nbsp; &nbsp;(*sit).AliasName = alias;
 &nbsp; &nbsp; &nbsp; &nbsp;(*sit).Connected = true;
 &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial ((*sit).ShortName, (*sit).LongName);
 &nbsp; &nbsp; &nbsp; &nbsp;msgin.serialCont ((*sit).Commands);

 &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;*:%d:%d is identified to be '%s' '%s' '%s'&quot;, aes-&gt;Id, sid, (*sit).AliasName.c_str(), (*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).AliasName, (*sit).ShortName, (*sit).LongName);
 &nbsp; &nbsp; &nbsp; &nbsp;msgout.serialCont ((*sit).Commands);

 &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*) (uint) 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 (StartAllServices)
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;doNextStartAllServicesStep();
}

static void cbServiceConnection (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
{
 &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) (uint) 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;// don't do anything. we have to wait identification to add it in out lists

/*
 &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*) (uint) 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;if ((*sit).InConfig)
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).Ready = (*sit).Connected = false;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).Id = 0xFFFFFFFF;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).ShortName = (*sit).LongName = &quot;&quot;;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).Commands.clear ();
 &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;else
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// erase only if it's not a service in the config
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Services.erase (sit);
 &nbsp; &nbsp; &nbsp; &nbsp;}

 &nbsp; &nbsp; &nbsp; &nbsp;displayServices ();
}

// 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)(uint)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;// 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*) (uint) from-&gt;appId();

 &nbsp; &nbsp; &nbsp; &nbsp;aes-&gt;Connected = false;

 &nbsp; &nbsp; &nbsp; &nbsp;SIT sit;
 &nbsp; &nbsp; &nbsp; &nbsp;for (sit = aes-&gt;Services.begin(); sit != aes-&gt;Services.end();)
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// keep only inconfig services
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((*sit).InConfig)
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).Id = 0xFFFFFFFF;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).ShortName = (*sit).LongName = &quot;&quot;;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*sit).Ready = (*sit).Connected = false;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sit++;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// erase only if it's not a service in the config
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sit = aes-&gt;Services.erase (sit);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;}

 &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;displayServices ();

 &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;// get the aes with the appid
 &nbsp; &nbsp; &nbsp; &nbsp;CAdminExecutorService *aes = (CAdminExecutorService*) (uint) from-&gt;appId();

 &nbsp; &nbsp; &nbsp; &nbsp;// broadcast the message to the admin service
 &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (CNetManager::getSIDA (&quot;AS&quot;), &quot;XLOG&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp;string log;
 &nbsp; &nbsp; &nbsp; &nbsp;uint32 sid;
 &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (sid);
 &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (log);

 &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (aes-&gt;Id);
 &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (sid);
 &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;XLOG&quot;, cbLog },
};


////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////// CONNECTION TO THE CLIENT ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

//
// 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).AliasName, (*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;msgout.serialCont ((*sit).Commands);
 &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;displayServices ();

 &nbsp; &nbsp; &nbsp; &nbsp;//
 &nbsp; &nbsp; &nbsp; &nbsp;// send service alias list
 &nbsp; &nbsp; &nbsp; &nbsp;//

 &nbsp; &nbsp; &nbsp; &nbsp;nlinfo(&quot;send SAL to admin startup&quot;);

 &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 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;messageToClient (0, &quot;couldn't execute command, as didn't find the aes&quot;, from);
 &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 serviceAlias;
 &nbsp; &nbsp; &nbsp; &nbsp;uint32 aesid;
 &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (aesid);
 &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (serviceAlias);

 &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;messageToClient (0, &quot;couldn't start service, as didn't find the aes&quot;, from);
 &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 (serviceAlias);
 &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;messageToClient (0, &quot;couldn't stop service, as didn't find the aes&quot;, from);
 &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;messageToClient (0, &quot;couldn't stop service, as didn't find the service&quot;, from);
 &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;messageToClient (0, &quot;couldn't stop service, as didn't find the aes&quot;, from);
 &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;messageToClient (0, &quot;couldn't stop service, as didn't find the service&quot;, from);
 &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);
}

static void cbStartAllServices (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
{
 &nbsp; &nbsp; &nbsp; &nbsp;initStartAllServices ();
}

static void cbStopAllServices (CMessage&amp; msgin, TSockId from, CCallbackNetBase &amp;netbase)
{
 &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;if ((*sit).Connected)
 &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;CMessage msgout (CNetManager::getSIDA((*aesit).ServerAlias), &quot;STOPS&quot;);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial ((*sit).Id);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CNetManager::send ((*aesit).ServerAlias, msgout);
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;}
}

TCallbackItem ClientCallbackArray[] =
{
 &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;SYS&quot;, cbExecuteSystemCommand },
 &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 },
 &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;START_ALL_SERVICES&quot;, cbStartAllServices },
 &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;STOP_ALL_SERVICES&quot;, cbStopAllServices },
};

////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////// 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;DebugLog-&gt;addNegativeFilter (&quot;L0:&quot;);
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DebugLog-&gt;addNegativeFilter (&quot;L1:&quot;);
// &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;sint i;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (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.AliasName = 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;displayServices ();
 &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>