This file is indexed.

/usr/include/cc++/script3.h is in libccscript3-dev 1.1.7-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
// Copyright (C) 1999-2005 Open Source Telecom Corporation.
//
// This program 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 of the License, or
// (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free software
// library without restriction.  Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License.  This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
//
// This exception applies only to the code released under the name GNU
// ccScript.  If you copy code from other releases into a copy of GNU
// ccScript, as the General Public License permits, the exception does
// not apply to the code that you add in this way.  To avoid misleading
// anyone as to the status of such modified files, you must delete
// this exception notice from them.
//
// If you write modifications of your own for GNU ccScript, it is your choice
// whether to permit this exception to apply to your modifications.
// If you do not wish that, delete this exception notice.
//

/**
 * @file script3.h
 * @short Threaded step execute scripting engine framework.
 **/


#ifndef	CCXX_SCRIPT3_H_
#define	CCXX_SCRIPT3_H_

#ifndef	CCXX_MISC_H_
#include <cc++/misc.h>
#endif

#ifndef	CXXX_FILE_H_
#include <cc++/file.h>
#endif

#ifndef	CCXX_BUFFER_H_
#include <cc++/buffer.h>
#endif

#define TRAP_BITS (sizeof(unsigned long) * 8)
#define	SCRIPT_INDEX_SIZE KEYDATA_INDEX_SIZE
#define	SCRIPT_MAX_ARGS	250
#define	SCRIPT_TEMP_SPACE 16
#define	SCRIPT_STACK_SIZE 32
#define	SCRIPT_ROUTE_SLOTS 16
#define	SCRIPT_EXEC_WRAPPER
#define	SCRIPT_APPS_WRAPPER
#define	SCRIPT_RIPPLE_LEVEL 2
#define	SCRIPT_RIPPLE_KEYDATA
#define	SCRIPT_BINDER_SELECT
#define	SCRIPT_SERVER_PREFIX
#define	SCRIPT_DEFINE_TOKENS

#ifndef CCXX_PACKING
#if defined(__GNUC__)
#define CCXX_PACKED
#elif !defined(__hpux) && !defined(_AIX)
#define CCXX_PACKED
#endif
#endif

namespace ost {

class __EXPORT ScriptRegistry;
class __EXPORT ScriptCommand;
class __EXPORT ScriptImage;
class __EXPORT ScriptInterp;
class __EXPORT ScriptSymbols;
class __EXPORT ScriptProperty;
class __EXPORT ScriptThread;
class __EXPORT ScriptCompiler;

/**
 * Generic script class to hold master data types and various useful
 * class encpasulated friend functions.
 *
 * @author David Sugar <dyfet@ostel.com>
 * @short Master script class.
 */
class __EXPORT Script
{
public:
	class __EXPORT Line;
	class __EXPORT Name;

	typedef bool (ScriptInterp::*Method)(void);
	typedef const char *(ScriptCommand::*Check)(Line *line, ScriptImage *img);
	typedef bool (*Cond)(ScriptInterp *interp, const char *v);
	typedef long (*Function)(long *args, unsigned prec);
	typedef const char *(*Meta)(ScriptInterp *interp, const char *token);
	typedef const char *(*Parse)(ScriptCompiler *img, const char *token);
	typedef void (*Init)(void);

	enum scrAccess {
		scrPUBLIC,
		scrPROTECTED,
		scrPRIVATE,
		scrFUNCTION,
		scrLOCAL
	};

	typedef enum scrAccess scrAccess;

	enum symType {
		symNORMAL = 0,
		symCONST,
		symDYNAMIC,
		symFIFO,
		symSEQUENCE,
		symSTACK,
		symCOUNTER,
		symPOINTER,
		symREF,
		symARRAY,
		symASSOC,
		symINITIAL,
		symNUMBER,
		symLOCK,
		symPROPERTY,
		symORIGINAL,
		symMODIFIED,
		symTIMER,
		symBOOL
	};

	typedef enum symType symType;

	typedef struct _symbol {
		struct _symbol *next;
		const char *id;
		unsigned short size;
		symType type: 8;
		char data[1];
	}	Symbol;

#ifdef CCXX_PACKED
#pragma	pack(1)
#endif

	typedef struct _array {
		unsigned short head, tail, rec, count;
	}	Array;

#ifdef	CCXX_PACKED
#pragma pack()
#endif

public:
	class __EXPORT Line
	{
	public:
		Line *next;
		union {
			ScriptRegistry *registry;
			Method method;
			Name *name;
		}	scr;
		const char *cmd, **args;
		unsigned long cmask, mask;
		unsigned short loop, line, lnum;
		unsigned short argc;
	};

	class __EXPORT NamedEvent
	{
	public:
		NamedEvent *next;
		Line *line;
		char type;
		const char *name;
	};

	class __EXPORT Name
	{
	public:
		Name *next;
		NamedEvent *events;
		Line *first, *select;
		Line *trap[TRAP_BITS];
		unsigned long mask;
		const char *name, *filename;
		scrAccess access;
	};

	class __EXPORT Initial
	{
		public:
		const char *name;
		unsigned size;
		const char *value;
	};

	class __EXPORT Define
	{
		public:
		const char *keyword;
		bool init;
		Method method;
		Check check;
	};

	class __EXPORT Test
	{
		public:
		const char *id;
		Cond handler;
		Test *next;
	};

	class __EXPORT Fun
	{
	public:
		const char *id;
		unsigned args;
		Function fn;
		Fun *next;
	};

	class __EXPORT InitScript
	{
	public:
		Init handler;
		InitScript *next;
	};

	class __EXPORT Package : public DSO
	{
	public:
		static Package *first;
		Package *next;
		const char *filename;

		Package(const char *name);
	};

	static bool fastStart;
	static bool useBigmem;
	static unsigned fastStepping;
	static unsigned autoStepping;
	static size_t pagesize;
	static unsigned symsize;
	static unsigned symlimit;

	static bool isScript(Name *scr);
	static bool isSymbol(const char *id);
	static bool use(const char *name);
	static unsigned getIndex(const char *id);
	static Symbol *deref(Symbol *sym);
	static bool commit(Symbol *sym, const char *value);
	static bool append(Symbol *sym, const char *value);
	static bool symindex(Symbol *sym, short offset);
	static const char *extract(Symbol *sym);
	static unsigned count(Symbol *sym);
	static unsigned storage(Symbol *sym);
	static void clear(Symbol *sym);
	static char decimal;
	static bool use_definitions;
	static bool use_macros;
	static bool use_prefix;
	static bool use_merge;
	static bool use_funcs;
	static const char *plugins;
	static const char *altplugins;
	static const char *access_user;
	static const char *access_pass;
	static const char *access_host;
	static bool exec_funcs;
	static const char *exec_extensions;
	static const char *exec_token;
	static const char *exec_prefix;
	static const char *exit_token;
	static const char *apps_extensions;
	static const char *apps_prefix;

	static const char *etc_prefix;
	static const char *var_prefix;
	static const char *log_prefix;

	static void addFunction(const char *name, unsigned count, Function i);
	static void addConditional(const char *name, Cond test);

	static bool isPrivate(Name *scr);
	static bool isFunction(Name *scr);

protected:
	static Test *test;
	static Fun *ifun;

};

class __EXPORT ScriptSymbols : public MemPager, public Script
{
protected:
	Symbol *index[SCRIPT_INDEX_SIZE + 1];

	void purge(void);

public:
	ScriptSymbols();
	~ScriptSymbols();

	inline const char *cstring(const char *str)
		{return MemPager::alloc(str);};

	unsigned gathertype(Symbol **idx, unsigned max, const char *prefix, symType group);
	unsigned gather(Symbol **idx, unsigned max, const char *prefix, const char *suffix);
	Symbol *find(const char *id, unsigned short size = 0);
	Symbol *make(const char *id, unsigned short size);

	Symbol *setReference(const char *id, Symbol *target);
};

/**
 * This class holds the bound keyword set for a given Bayonne style
 * script interpreter.  Application specific dialects are created
 * by deriving a application specific version of ScriptCommand which
 * then binds application specific keywords and associated methods
 * in an application derived ScriptInterp which are typecast to
 * (scriptmethod_t).
 *
 * @author David Sugar <dyfet@ostel.com>
 * @short Bayonne script keyword binding tables and compiler constants.
 */
class __EXPORT ScriptCommand : public Keydata, public Mutex, public Script
{
private:
	friend class __EXPORT ScriptImage;
	friend class __EXPORT ScriptInterp;
	friend class __EXPORT ScriptCompiler;
	friend class __EXPORT ScriptBinder;

#ifdef	CCXX_PACKED
#pragma pack(1)
#endif

	typedef struct _keyword {
		struct _keyword *next;
		Method method;
		Check check;
		bool init : 1;
		char keyword[1];
	}	Keyword;

#ifdef	CCXX_PACKED
#pragma pack()
#endif

	ThreadQueue *tq;
	Keyword *keywords[SCRIPT_INDEX_SIZE];
	char *traps[TRAP_BITS];
	ScriptImage *active;
	unsigned keyword_count;
	unsigned trap_count;
	unsigned long imask;
	unsigned dbcount;
	void *dbc;

protected:
	bool ripple;
	unsigned activity;	// activity counter
	static ScriptCommand *runtime;

	virtual const char *getExternal(const char *opt);

public:
	/**
	 * Checks if the line statement is an input statement.  Used in
	 * some servers...
	 *
	 * @return true if line is input.
	 * @param line to examine.
	 */
	virtual bool isInput(Line *line);

	/**
	 * Get the method handler associated with a given keyword.  This
	 * is used by ScriptImage when compiling.
	 *
	 * @param keyword to search for.
	 * @return method handler to execute for this keyword.
	 */
	Method getHandler(const char *keyword);

	/**
	 * Issue a control event against current image for attached
	 * modules until claimed.
	 *
	 * @param args list of control command and arguments.
	 * @return true if processed.
	 */
	bool control(char **args);

	/**
	 * Get the active script.
	 *
	 * @return pointer to active script image.
	 */
	inline ScriptImage *getActive(void)
		{return active;};

	/**
	 * Get the name of a trap from it's id.
	 *
	 * @param id of trap.
	 * @return name of trap.
	 */
	const char *getTrapName(unsigned id);

	/**
	 * Alias use modules...
	 *
	 * @param id to alias.
	 * @param id to use.
	 */
	void aliasModule(const char *id, const char *use);

protected:
	/**
	 * Fetch whether the given keyword is valid for constructor.
	 *
	 * @param keyword to search for.
	 * @return init flag.
	 */
	bool isInitial(const char *keyword);

	/**
	 * Check keyword syntax.
	 *
	 * @return syntax error string or NULL.
	 * @param command name of keyword to check.
	 * @param line pointer to line being compiled.
	 * @param img pointer to image being compiled.
	 */
	const char *check(char *command, Line *line, ScriptImage *img);

	/**
	 * Get the trap id number associated with a trap name.
	 *
	 * @return trap id number, 0 (exit) if invalid.
	 * @param name of trap identifier.
	 */
	virtual unsigned getTrapId(const char *name);

	/**
	 * Get the mask bits for the default script.
	 *
	 * @return trap mask to use.
	 */
	virtual unsigned long getTrapDefault(void);

	/**
	 * Get the mask bits for a trap "handler".
	 *
	 * @return script object of trap mask to use.
	 */
	virtual unsigned long getTrapHandler(Name *script);

	/**
	 * Get a trap mask for a given identifer.  This is a virtual
	 * since some derived handlers may manipulate mask bits.
	 *
	 * @return signal bit mask based on id number.
	 * @param id number of trap mask.
	 */
	virtual unsigned long getTrapMask(unsigned id);

	/**
	 * A helper method for the compiler.  Converts a named
	 * trap into it's bit shifted mask.  By making it a virtual,
	 * derived dialects can add "aliases" to default trap names.
	 *
	 * @param name of trap identifier.
	 * @return bit shifted mask or 0 if invalid.
	 */
	virtual unsigned long getTrapModifier(const char *name);

	/**
	 * A helper method for the compiler used specifically for
	 * "^" trap subsection requests.  These will occasionally
	 * carry different attribute settings.
	 *
	 * @param name of trap identifier.
	 * @return bit shifted mask or 0 if invalid.
	 */
	virtual unsigned long getTrapMask(const char *name);

	/**
	 * Test current command to see if it uses keyword syntax.
	 *
	 * @return true if keyword syntax used.
	 * @param line record to examine in check routine.
	 */
	static bool hasKeywords(Line *line);

public:
	/**
	 * Test for a specific keyword.
	 *
	 * @return content of keyword that is found.
	 * @param line pointer to record to examine in check routine.
	 * @param keyword to search for.
	 */
	static const char *findKeyword(Line *line, const char *keyword);

	/**
	 * Test for a specific keyword or keydata filler.
	 *
	 * @return content of keyword that is found.
	 * @param script image for keydata.
	 * @param line pointer to record to examine in check routine.
	 * @param keyword to search for.
	 */
	static const char *findKeyword(ScriptImage *img, Line *line, const char *keyword);

	/**
	 * Server level logging interface override.
	 *
	 * @param level of log message.
	 * @param text of message.
	 */
	virtual void errlog(const char *level, const char *text);

public:
	/**
	 * Test current command against a list of valid keywords.
	 *
	 * @return first keyword found not in list.
	 * @param line record to examine in check routine.
	 * @param list of =xxx keyword entries.
	 */
	static bool useKeywords(Line *line, const char *list);

	/**
	 * Count non-keyword arguments.
	 *
	 * @return number of non-keyword arguments.
	 * @param line record to examine.
	 */
	static unsigned getCount(Line *line);

	/**
	 * Get the member id code of a line.
	 *
	 * @return member id code.
	 * @param line record to examine in check routine.
	 */
	static const char *getMember(Line *line);


protected:
	/**
	 * Check the member list.
	 *
	 * @return true if member found or none.
	 * @param line record to examine in check routine.
	 * @param list of .members...
	 */
	static bool useMember(Line *line, const char *list);

	/**
	 * Get an option to examine in check routine.
	 *
	 * @return option or NULL if past end of line record.
	 * @param line record pointer to line to examine.
	 * @param index pointer to index value.  Start at 0.
	 */
	static const char *getOption(Line *line, unsigned *index);

	/**
	 * Load a set of keywords into the system keyword table.  This
	 * provides a convenient method of initializing and adding to
	 * the keyword indexes.
	 *
	 * @param keywords defined pair entries to load.
	 */
	void load(Script::Define *keywords);

	/**
	 * Add a trap handler symbolic identity to the keyword table.
	 * These are used to handle signal mask coercion and event
	 * branch points in the compiler.
	 *
	 * @param name of requested trap to add to the trap table.
	 * @param inherited status of trap.
	 * @return assigned id number for the trap.
	 */
	int trap(const char *name, bool inherited = true);

	/**
	 * Get count of active traps.
	 *
	 * @return count of active trap identifiers.
	 */
	inline unsigned getCount(void)
		{return trap_count;};

	/**
	 * Return true if the trap id is inherited.
	 */
	bool isInherited(unsigned id);

	/**
	 * Perform compile time check of a specified symbol.
	 *
	 * @return syntax error message string.
	 * @param chk object pointer to check member function.
	 * @param line pointer to line being checked.
	 * @param img pointer to image being compiled.
	 */
	virtual const char *check(Check chk, Line *line, ScriptImage *img);

public:
	/**
	 * Create an initialized script command box.
	 */
	ScriptCommand();

	/**
	 * Create a ScriptCommand box initialized from another.
	 */
	ScriptCommand(ScriptCommand *ini);

	/**
	 * Get activity counter.
	 *
	 * @return activity counter.
	 */
	inline unsigned getActivity(void)
		{return activity;};

};

class __EXPORT ScriptBinder : public Script
{
private:
	friend class __EXPORT ScriptInterp;
	friend class __EXPORT ScriptCompiler;
	friend class __EXPORT ScriptCommand;

	static ScriptBinder *first;
	ScriptBinder *next;
	const char *id;

protected:
	void bind(Script::Define *extensions);

	virtual void attach(ScriptInterp *interp);
	virtual void detach(ScriptInterp *interp);
	virtual bool select(ScriptInterp *interp);
	virtual bool reload(ScriptCompiler *img);
	virtual bool control(ScriptImage *img, char **args);
	virtual void down(void);
	virtual const char *use(Line *line, ScriptImage *img);

public:
	ScriptBinder(const char *id = NULL);
	ScriptBinder(Script::Define *extensions);
	virtual ~ScriptBinder();

	static const char *check(Line *line, ScriptImage *img);
	static void shutdown(void);
	static bool rebuild(ScriptCompiler *img);
};

class __EXPORT ScriptRuntime : public ScriptCommand
{
public:
	ScriptRuntime();
};

class __EXPORT ScriptRipple : public ScriptCommand
{
public:
	ScriptRipple();
};

class __EXPORT ScriptChecks : public ScriptCommand
{
public:
	/**
	 * Default compiler syntax to accept any syntax.
	 */
	const char *chkIgnore(Line *line, ScriptImage *img);

	/**
	 * Performs DSO load phase for USE modules.
	 */
	const char *chkUse(Line *line, ScriptImage *img);

	/**
	 * A check used by "inc" and "dec".
	 *
	 * @return synxtax error message string or NULL.
	 * @param line statement being examined.
	 * @param img pointer to image being examined.
	 */
	const char *chkHasModify(Line *line, ScriptImage *img);

	/**
	 * Check if member is NULL or a property reference.
	 *
	 * @param line pointer to line checked for property reference.
	 * @param img pointer to image being compiled.
	 * @return syntax error message string or NULL.
	 */
	const char *chkProperty(Line *line, ScriptImage *img);

	/**
	 * A check for first var...
	 *
	 * @return syntax error message string or NULL.
	 * @param line statement being examined.
	 * @param img pointer to image being compiled.
	 */
	const char *chkFirstVar(Line *line, ScriptImage *img);

	/**
	 * A basic type check for simple type declarations...
	 *
	 * @return syntax error message string or NULL.
	 * @param line statement being examined.
	 * @param img pointer to image being compiled.
	 */
	const char *chkType(Line *line, ScriptImage *img);

	/**
	 * Script compiler syntax check for certain variable using
	 * statements such as "clear".  Assumes list of valid variable
	 * arguments.
	 *
	 * @return syntax error message string or NULL.
	 * @param line statement being examined.
	 * @param img pointer to image being compiled.
	 */
	const char *chkHasVars(Line *line, ScriptImage *img);

	/**
	 * Script compiler syntax check for assignment statements
	 * such as "set", "for", etc.
	 *
	 * @return syntax error message string or NULL.
	 * @param line statement being examined.
	 * @param img pointer to image being compiled.
	 */
	const char *chkHasList(Line *line, ScriptImage *img);

	/**
	 * Script compiler syntax check for commands that require
	 * no arguments to be present.
	 *
	 * @return syntax error message string or NULL.
	 * @param line statement being examined.
	 * @param img pointer to image being compiled.
	 */
	const char *chkNoArgs(Line *line, ScriptImage *img);

	/**
	 * Script compiler syntax check for commands that require
	 * all arguments to be symbols.
	 *
	 * @return syntax error message string or NULL.
	 * @param line pointer being examined.
	 * @param img pointer to image being compiled.
	 */
	const char *chkAllVars(Line *line, ScriptImage *img);

	/**
	 * Script compiler syntax check for commands that require
	 * one or more arguments to be present.
	 *
	 * @return syntax error message string or NULL.
	 * @param line statement being examined.
	 * @param img pointer to image being compiled.
	 */
	const char *chkHasArgs(Line *line, ScriptImage *img);

	/**
	 * Script compiler syntax check for commands that require
	 * one or more arguments but use no keywords.
	 *
	 * @return syntax error message string or NULL.
	 * @param line statement being examined.
	 * @param img pointer to image being compiled.
	 */
	const char *chkOnlyArgs(Line *line, ScriptImage *img);

	const char *chkOnlyOneArg(Line *line, ScriptImage *img);

	const char *chkRefArgs(Line *line, ScriptImage *img);

	const char *chkSlog(Line *line, ScriptImage *img);

	const char *chkExpression(Line *line, ScriptImage *img);

	const char *chkConditional(Line *line, ScriptImage *img);

	const char *chkGoto(Line *line, ScriptImage *img);

	const char *chkLabel(Line *line, ScriptImage *img);

	const char *chkCall(Line *line, ScriptImage *img);

	const char *chkReturn(Line *line, ScriptImage *img);

	const char *chkRestart(Line *line, ScriptImage *img);

	const char *chkVar(Line *line, ScriptImage *img);

	const char *chkVarType(Line *line, ScriptImage *img);

	const char *chkDecimal(Line *line, ScriptImage *img);

	const char *chkNumber(Line *line, ScriptImage *img);

	const char *chkString(Line *line, ScriptImage *img);

	const char *chkChar(Line *line, ScriptImage *img);

	const char *chkExpr(Line *line, ScriptImage *img);

	const char *chkIndex(Line *line, ScriptImage *img);

	const char *chkError(Line *line, ScriptImage *img);

	const char *chkConst(Line *line, ScriptImage *img);

	const char *chkSequence(Line *line, ScriptImage *img);

	const char *chkSignal(Line *line, ScriptImage *img);

	const char *chkThrow(Line *line, ScriptImage *img);

	const char *chkSet(Line *line, ScriptImage *img);

	const char *chkRepeat(Line *line, ScriptImage *img);

	const char *chkArray(Line *line, ScriptImage *img);

	const char *chkFor(Line *line, ScriptImage *img);

	const char *chkForeach(Line *line, ScriptImage *img);

	const char *chkCat(Line *line, ScriptImage *img);

	const char *chkRemove(Line *line, ScriptImage *img);

	const char *chkOnlyCommand(Line *line, ScriptImage *img);

	const char *chkCounter(Line *line, ScriptImage *img);

	const char *chkTimer(Line *line, ScriptImage *img);

	const char *chkClear(Line *line, ScriptImage *img);

	const char *chkPack(Line *line, ScriptImage *img);

	const char *chkConstruct(Line *line, ScriptImage *img);

	const char *chkLock(Line *line, ScriptImage *img);

	const char *chkSession(Line *line, ScriptImage *img);

	const char *chkKeywords(Line *line, ScriptImage *img);

	const char *chkDefine(Line *line, ScriptImage *img);
};

/**
 * A linkable list of objects that can be destroyed when a script image
 * is removed from memory.
 *
 * @author David Sugar <dyfet@ostel.com>
 * @short Object list in image.
 */
class __EXPORT ScriptObject : public Script
{
private:
	friend class __EXPORT ScriptImage;
	ScriptObject *next;

protected:
	ScriptObject(ScriptImage *image);
	virtual ~ScriptObject();
};

/**
 * A derivable class to hold compiled script images for active processes.
 * This includes the script image compiler itself.  Typically, a script is
 * compiled one file at a time from a directory, and the committed, during
 * the constructor in a derived class.
 *
 * @author David Sugar <dyfet@ostel.com>.
 * @short Script compiler image set.
 */
class __EXPORT ScriptImage : public Keydata, public Script, public Assoc
{
protected:
	friend class __EXPORT ScriptObject;

	ScriptCommand *cmds;
	unsigned refcount;
	Name *index[SCRIPT_INDEX_SIZE + 1], *current;
	Line *select, *selecting, *registration;
	Line *advertising[SCRIPT_ROUTE_SLOTS];
	Mutex duplock;
	ScriptObject *objects;
	static unsigned long serial;
	unsigned long instance;

	class	__EXPORT InitialList : public Script::Initial
	{
	public:
		InitialList *next;
	}	*ilist;

	friend class __EXPORT ScriptInterp;

	/**
	 * Get the interpreter method pointer for a given keyword.
	 *
	 * @return method handler.
	 * @param keyword to search.
	 */
	Method getHandler(const char *keyword)
		{return cmds->getHandler(keyword);};

public:
	/**
	 * Get memory for assoc data...
	 *
	 * @return memory pointer.
	 * @param size of memory request.
	 */
	void *getMemory(size_t size);

	/**
	 * Duplicate string...
	 *
	 * @return memory pointer.
	 * @param string requested.
	 */
	const char *dupString(const char *str);

	/**
	 * Fast branch linkback code.
	 */
	virtual void fastBranch(ScriptInterp *interp);

	/**
	 * Get current entity being compiled...
	 *
	 * @return pointer to script currently compiling.
	 */
	inline Name *getCurrent(void)
		{return current;};

	/**
	 * Add a select record to the currently compiled script.
	 *
	 * @param line statement to add to list.
	 */
	void addSelect(Line *line);

	/**
	 * Add a registration record to the compiled script.
	 *
	 * @param line statement to add to list.
	 */
	void addRegistration(Line *line);

	/**
	 * Get a registration record to use.
	 *
	 * @return registration object.
	 */
	ScriptRegistry *getRegistry(void);

	/**
	 * Add an advertised route in a priority slot.
	 *
	 * @param line statement to add to list.
	 * @param pri of route to add to.
	 */
	void addRoute(Line *line, unsigned pri);

	/**
	 * Get the selection list from the image.
	 *
	 * @return selection list.
	 */
	inline Line *getSelect(void)
		{return select;};

	/**
	 * Get the registration list from the image.
	 *
	 * @return registration list.
	 */
	inline Line *getRegistration(void)
		{return registration;};

	/**
	 * Get an advertised priority record from the image.
	 *
	 * @return priority list.
	 */
	inline Line *getRoute(unsigned pri)
		{return advertising[pri];};

	/**
	 * Get the session instance of the image.
	 */
	inline unsigned long getInstance(void)
		{return instance;};

	/**
	 * Construct a new working image.  This must be derived to an
	 * application specific compiler that can scan directories and
	 * invoke the compiler as needed.
	 *
	 * @param cmdset of keyword table object used.
	 * @param symset of predefined symbols being used.
	 */
	ScriptImage(ScriptCommand *cmdset, const char *symset);

	/**
	 * Destruct the ScriptImage itself by removing linked objects.
	 */
	~ScriptImage();

	/**
	 * Purge and reload the script image workspace.
	 */
	void purge(void);

	/**
	 * Used in the derived constructor to "commit" the current image
	 * for new processes.  This is usually the last statement in the
	 * derived constructor.
	 */
	void commit(void);

	/**
	 * Used by a derived constructor to load an initialization list.
	 *
	 * @param ilist initialization list of symbol pairs to load.
	 */
	void load(Initial *ilist);

	/**
	 * Used to load a single initialization list entry.
	 *
	 * @param keyword name to initialize.
	 * @param value of keyword.
	 * @param size of keyword data field.
	 */
	void initial(const char *keyword, const char *value, unsigned size = 0);

	/**
	 * Fetch named script.
	 *
	 * @param name of script to find.
	 * @return script or NULL.
	 */
	virtual Name *getScript(const char *name);

	/**
	 * Get the command object associated with the image.
	 *
	 * @return command object.
	 */
	inline ScriptCommand *getCommand(void)
		{return cmds;};

	/**
	 * Get the ripple flag for the current image.
	 *
	 * @return true if a ripple image.
	 */
	bool isRipple(void)
		{return cmds->ripple;};

	/**
	 * Fetch list of relational scripts.
	 *
	 * @param suffix extension of scripts being fetched.
	 * @param array of script objects gathered from image.
	 * @param size limit of array to gather.
	 * @return count of entries found.
	 */
	unsigned gather(const char *suffix, Name **array, unsigned size);

	/**
	 * inc the reference count.
	 */
	inline void incRef(void)
		{++refcount;};

	/**
	 * dec the reference count.
	 */
	inline void decRef(void)
		{--refcount;};

	/**
	 * See if the image is referenced...
	 *
	 * @return true if is referenced.
	 */
	inline bool isRef(void)
		{return (bool)(refcount > 0);};

	/**
	 * Get the active image from command.  Useful when compiling.
	 *
	 * @return ScriptImage of currently active image.
	 */
	inline ScriptImage *getActive(void)
		{return cmds->getActive();};
};

/**
 * A derivable class to hold compiled script images for active processes.
 * This includes the script image compiler itself.  Typically, a script is
 * compiled one file at a time from a directory, and the committed, during
 * the constructor in a derived class.
 *
 * @author David Sugar <dyfet@ostel.com>.
 * @short Script compiler image set.
 */
class __EXPORT ScriptCompiler : public ScriptImage
{
protected:
	std::ifstream scrSource;
	std::istream *scrStream;
	char *buffer;
	unsigned bufsize;
	char *bp;
	bool quote;
	unsigned paren;
	unsigned inccount;
	const char *incfiles[256];

	typedef struct _merge {
		struct _merge *next;
		Name *target;
		const char *source;
		const char *prefix;
	}	merge_t;

	merge_t *mlist;

	friend class __EXPORT ScriptInterp;

	virtual bool checkSegment(Name *scr);

public:
	char *getToken(char **pre = NULL);

	/**
	 * Fast branch linkback code.
	 */
	virtual void fastBranch(ScriptInterp *interp);

	/**
	 * Construct a new working image.  This must be derived to an
	 * application specific compiler that can scan directories and
	 * invoke the compiler as needed.
	 *
	 * @param cmdset of keyword table object used.
	 * @param symset of symbols to set.
	 */
	ScriptCompiler(ScriptCommand *cmdset, const char *symset);

	/**
	 * A method to invoke the script compiler to include a script
	 * only if it has not been included already.
	 *
	 * @return named script object.
	 * @param name of script file to compile.
	 */
	Name *include(const char *name);

	/**
	 * The script compiler itself.  This linearly compiles a Bayonne
	 * script file that is specified.  Normally used along with a dir
	 * scanner in the constructor.
	 *
	 * @return lines of script compiled.
	 * @param file name of script file to compile.
	 */
	int compile(const char *file);

	/**
	 * Compile a script from disk and give it a different internal
	 * "name" as passed.
	 *
	 * @return lines of script compiled.
	 * @param file name of script file to compile.
	 * @param name of script to compile under.
	 */
	int compile(const char *file, char *name);

	/**
	 * Compile a defintions library, commonly used for remapping
	 * tokens to macros.
	 *
	 * @return lines of script compiled.
	 * @param file name of defintions file to compile.
	 */
	int compileDefinitions(const char *file);

	/**
	 * Compile an open stream object into a script.
	 *
	 * @return lines of script compiled.
	 * @param stream object to use.
	 * @param name of script save under.
	 * @param file name to use in object.
	 */
	int compile(std::istream *stream, char *name, const char *file = NULL);

	/**
	 * Used in the derived constructor to "commit" the current image
	 * for new processes.  This is usually the last statement in the
	 * derived constructor.
	 */
	void commit(void);

	/**
	 * Used to process '$const' inserts.
	 *
	 * @return string if found.
	 * @param token string being substituted.
	 */
	virtual const char *getDefined(const char *token);

	/**
	 * Check for special preprocessor token.
	 *
	 * @return error message or NULL if no error.
	 * @param token name of keyword to check.
	 */
	const char *preproc(const char *token);

	/**
	 * Used by embedded interpreters to fetch script from the current
	 * source file.
	 *
	 * @return reference to source file stream.
	 */
	inline std::istream *getSource(void)
		{return (std::istream *)&scrSource;};
};

class __EXPORT ScriptInterp : public Mutex, public ScriptSymbols
{
protected:
	friend class __EXPORT ScriptThread;
	friend class __EXPORT ScriptCommand;
	friend class __EXPORT ScriptBinder;

public:
	class __EXPORT Frame
	{
	public:
		Name *script;
		Line *line, *first;
		unsigned short index;
		ScriptSymbols *local;
		unsigned long mask;
		bool caseflag : 1;
		bool tranflag : 1;
		bool unused1 : 1;
		bool unused2 : 1;
		unsigned decimal : 4;
		unsigned base : 8;
	};

	static long getRealValue(double val, unsigned prec);
	static double getDouble(long value, unsigned prec);
	static long getInteger(long value, unsigned prec);
	static long getTens(unsigned prec);
	long getIntValue(const char *text, unsigned prec, ScriptProperty *property = NULL);
	int numericExpression(long *list, int max, unsigned prec, ScriptProperty *property = NULL);
	bool conditionalExpression(void);
	bool conditional(void);

protected:
	Mutex *lock;	// any additional lock that is siezed
	ScriptCommand *cmd;
	ScriptImage *image;
	ScriptInterp *session;
	ScriptThread *thread;
	Frame frame[SCRIPT_STACK_SIZE];
	char *temps[SCRIPT_TEMP_SPACE];
	unsigned tempidx;
	unsigned stack;
	bool initialized, trace, exiting, updated;
	unsigned long sequence;
	char logname[32];

public:
	virtual unsigned getId(void);

	inline unsigned long getSequence(void)
		{return sequence;};

	virtual const char *getLogname(void)
		{return logname;};

	virtual ScriptInterp *getInterp(const char *id);

	virtual const char *getExternal(const char *opt);

	inline ScriptImage *getImage(void)
		{return image;};

protected:
	virtual ScriptSymbols *getSymbols(const char *id);

	ScriptSymbols *getLocal(void);

public:
	const char *getMember(void);
	const char *getKeyword(const char *kw);
	const char *getKeyoption(const char *kw);
	const char *getValue(const char *def = NULL);
	const char *getOption(const char *def = NULL);
	const char *hasOption(void);
	const char *getContent(const char *opt);
	const char *getSymContent(const char *opt);
	Symbol *getKeysymbol(const char *kw, unsigned size = 0);
	Symbol *getSymbol(unsigned short size = 0);
	char getPackToken(void);

protected:
	/**
	 * Initialize execution environment for a script.
	 */
	void initRuntime(Name *name);

	/**
	 * New virtual to initialize script environment syms
	 * before running init sections.
	 */
	virtual void initialize(void);

public:
	inline Frame *getFrame(void)
		{return &frame[stack];};

	inline Line *getLine(void)
		{return frame[stack].line;};

	void setFrame(void);

	inline Name *getName(void)
		{return frame[stack].script;};

	inline bool getTrace(void)
		{return trace;};

	/**
	 * Runtime execution of script handler.  This can be called in
	 * the current or derived class to invoke extensible methods.
	 *
	 * @return true if immediately ready for next step.
	 * @param method derived method member to call.
	 */
	bool execute(Method method);

protected:
	/**
	 * Attempt to push a value onto the stack.
	 *
	 * @return false if stack overflow.
	 */
	bool push(void);

	/**
	 * Attempt to recall a previous stack level.
	 *
	 * @return false if stack underflow.
	 */
	bool pull(void);

	/**
	 * Clear the stack of local loops or recursion for branching.
	 */
	void clearStack(void);

	/**
	 * Advance program to the next script statement.
	 */
	void advance(void);

	/**
	 * Skip line without checking or setting updates.
	 */
	void skip(void);

	/**
	 * Set error variable and advance to either the error handler
	 * or next script statement.
	 *
	 * @param error message.
	 */
	void error(const char *error);

	/**
	 * Events reference to named \@event handlers which have been
	 * attached to a script.  This allows low level applications
	 * to invoke an event handler much the way a signal handler
	 * occurs.
	 *
	 * @return true if event handler exists.
	 * @param name of event handler.
	 * @param inhereted search flag.
	 */
	bool scriptEvent(const char *name, bool inhereted = true);

	/**
	 * Branch to a selected event record immediately.
	 *
	 * @param event record pointer to access.
	 */
	void gotoEvent(NamedEvent *event);

	/**
	 * Set the execution interpreter to a trap identifier.  If no
	 * trap id exists, then advance to next script statement (unless
	 * exit trap).
	 *
	 * @param id of trap to select numerically.
	 */
	void trap(unsigned id);

	/**
	 * Tries a catch handler...
	 *
	 * @return true if caught.
	 * @param id of catch handler to try.
	 */
	bool tryCatch(const char *id);

	/**
	 * Select trap by symbolic name and execute if found, else advance
	 * to next script step (unless exit trap).
	 *
	 * @param name of trap to select.
	 */
	void trap(const char *name);

public:
	virtual void logmissing(const char *id, const char *level = "undefined", const char *group = "symbol");
	virtual void logerror(const char *msg, const char *name = NULL);

	Symbol *mapSymbol(const char *id, unsigned short = 0);
	Symbol *mapDirect(const char *id, unsigned short = 0);

protected:
	virtual bool isLocked(const char *id);
	virtual const char *remapLocal(void);
	virtual bool exit(void);
	virtual void enterThread(ScriptThread *thread);
	virtual void exitThread(const char *msg);
	virtual void waitThread(void);
	virtual void startThread(void);

	bool eventThread(const char *evt, bool flag = true);

	bool redirect(const char *scr);

	void ripple(void);

	bool redirect(bool evflag);

	unsigned long getMask(void);

public:
	bool setNumber(const char *id, const char *value = NULL, unsigned dec = 0);
	bool setSymbol(const char *id, const char *value = NULL, unsigned short size = 0);
	bool setConst(const char *id, const char *value);
	bool putSymbol(const char *id, const char *value, unsigned short size = 0);
	bool getSymbol(const char *id, char *buffer, unsigned short max);
	bool catSymbol(const char *id, const char *value, unsigned short size = 0);

	const char *getSymbol(const char *id);

	Name *getScript(const char *name);

	ScriptInterp();

	bool step(void);
	bool attach(ScriptCommand *cmd, const char *scrname);
	void detach(void);
	void attach(ScriptCommand *cmd, ScriptImage *img, Name *scr);

	/**
	 * Release any acquired lock...
	 */
	void release(void);

	   /**
	 * Signals are used during "delayed" execution steps when a
	 * signal event has occured aynchronously with the execution
	 * of a script controlled state event handler.  This mechanism
	 * can be used in place of calling implicit "Step" traps.
	 *
	 * @return true if signal handler is not blocked.
	 * @param name of signal identifier.
	 */
	bool signal(const char *name);

	/**
	 * Signals can be referenced by numeric id as well as by symbolic
	 * name.
	 *
	 * @return true if signal handler is not blocked.
	 * @param id number of handler.
	 */
	bool signal(unsigned id);

	bool done(void);

	timeout_t getTimeout(void);

	/**
	 * A virtual holding a branch conditional member.  This may be
	 * invoked typically from goto or restart.  Can be used to check
	 * contextual changes.
	 */
	virtual void branching(void);

	inline bool isRunning(void)
		{return (image != NULL) && initialized;};

	inline bool isExiting(void)
		{return exiting;};

	char *getTemp(void);

	unsigned getTempSize(void);
};

class __EXPORT ScriptMethods : public ScriptInterp
{
public:
	bool scrNop(void);
	bool scrError(void);
	bool scrExit(void);
	bool scrDecimal(void);
	bool scrDefine(void);
	bool scrVar(void);
	bool scrType(void);
	bool scrNumber(void);
	bool scrSlog(void);
	bool scrExpr(void);
	bool scrIndex(void);
	bool scrOffset(void);
	bool scrRef(void);
	bool scrRestart(void);
	bool scrInit(void);
	bool intGoto(void);
	bool scrGoto(void);
	bool scrCall(void);
	bool scrReturn(void);
	bool scrBegin(void);
	bool scrEnd(void);
	bool scrConst(void);
	bool scrSequence(void);
	bool scrSet(void);
	bool scrArray(void);
	bool scrClear(void);
	bool scrConstruct(void);
	bool scrDeconstruct(void);
	bool scrPack(void);
	bool scrUnpack(void);
	bool scrLock(void);
	bool scrSession(void);
	bool scrSignal(void);
	bool scrThrow(void);
	bool scrInvoke(void);
	bool scrCounter(void);
	bool scrTimer(void);
	bool scrCase(void);
	bool scrEndcase(void);
	bool scrRemove(void);
	bool scrDo(void);
	bool scrRepeat(void);
	bool scrFor(void);
	bool scrForeach(void);
	bool scrLoop(void);
	bool scrContinue(void);
	bool scrBreak(void);
	bool scrIf(void);
	bool scrIfThen(void);
	bool scrThen(void);
	bool scrElse(void);
	bool scrEndif(void);
};

class __EXPORT ScriptThread : public Thread, public Script
{
private:
	volatile bool exiting;
	size_t stacksize;

protected:
	friend class __EXPORT ScriptInterp;

	ScriptInterp *interp;

	void exit(const char *errmsg = NULL);

	void exitEvent(const char *evt, bool inherited = true);

	inline bool isExiting(void)
		{return exiting;};

	inline bool putSymbol(const char *id, const char *value, unsigned short size = 0)
		{return interp->putSymbol(id, value, size);};

	inline bool getSymbol(const char *id, char *buffer, unsigned short max)
		{return interp->getSymbol(id, buffer, max);};

	inline bool addSymbol(const char *id, char *buffer, unsigned short max)
		{return interp->getSymbol(id, buffer, max);};

	void block(void);

	void unblock(void);

	void lock(void);

	void release(void);

public:
	virtual timeout_t getTimeout(void);

	inline size_t getStack(void)
		{return stacksize;};

	ScriptThread(ScriptInterp *interp, int pri = 0, size_t stack = 0);
	~ScriptThread();
};

/**
 * This class is used for registering scripts with an external
 * registry.  Sometimes this is used as a base class for a more
 * complete one.
 *
 * @author David Sugar <dyfet@ostel.com>
 * @short Registry for script objects.
 */
class __EXPORT ScriptRegistry : public Script, public TimerPort
{
public:
	const char *protocol;
	timeout_t duration;
	Name *scr;		// script being registered
	Line *line;		// line of registry statement
};

/**
 * This class is used for DSO modules that impliment property
 * extensions for scripting objects.
 *
 * @author David Sugar <dyfet@ostel.com>
 * @short ccScript property module
 */
class __EXPORT ScriptProperty : public Script
{
private:
	friend class ScriptInterp;

	static ScriptProperty *first;
	ScriptProperty *next;
	const char *id;

public:
	/**
	 * Set property method.  Performs set.xxx and init.xxx methods.
	 *
	 * @param data buffer to work from.
	 * @param temp workspace buffer to use.
	 * @param size of temp area.
	 */
	virtual void set(const char *data, char *temp, unsigned size) = 0;

	/**
	 * Precision for property type expressions.
	 *
	 * @return precision.
	 */
	virtual unsigned prec(void);

	/**
	 * Set property from integer value.
	 *
	 * @param data to save.
	 * @param size of data.
	 * @param value being set.
	 */
	virtual void setValue(char *data, unsigned short size, long value);

	/**
	 * See if should be computed as property.
	 *
	 * @return true if property valid.
	 * @param data string to test.
	 */
	virtual bool isProperty(const char *data);

	/**
	 * Initialize a new property through var definition.
	 *
	 * @return property value.
	 * @param data location to clear.
	 * @param size of workspace to clear.
	 */
	virtual void clear(char *data, unsigned size = 0);

	/**
	 * Fetch a property specific seperator token.
	 *
	 * @return seperator token used in foreach loops...
	 */
	virtual char token(void);

	/**
	 * adjust value method.  Performs inc.xxx conversions.
	 *
	 * @param data buffer to work from.
	 * @param size of data buffer.
	 * @param adjustment offset to apply.
	 */
	virtual void adjust(char *data, size_t size, long adjustment);

	/**
	 * normalize values for scope and range.
	 *
	 * @return noramized value.
	 * @param value prior to normalization.
	 */
	virtual long adjustValue(long value);

	/**
	 * Get the "numeric" (or #var) value of this property symbol.
	 *
	 * @return numeric value of this property object.
	 * @param data being examined from property object.
	 */
	virtual long getValue(const char *data);

	ScriptProperty(const char *name);
	virtual ~ScriptProperty();

	static ScriptProperty *find(const char *name);
};

}

#endif