Bayonne2 / Common C++ 2 Framework
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
script3.h
Go to the documentation of this file.
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // ccScript. If you copy code from other releases into a copy of GNU
28 // ccScript, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU ccScript, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
44 #ifndef CCXX_SCRIPT3_H_
45 #define CCXX_SCRIPT3_H_
46 
47 #ifndef CCXX_MISC_H_
48 #include <cc++/misc.h>
49 #endif
50 
51 #ifndef CXXX_FILE_H_
52 #include <cc++/file.h>
53 #endif
54 
55 #ifndef CCXX_BUFFER_H_
56 #include <cc++/buffer.h>
57 #endif
58 
59 #define TRAP_BITS (sizeof(unsigned long) * 8)
60 #define SCRIPT_INDEX_SIZE KEYDATA_INDEX_SIZE
61 #define SCRIPT_MAX_ARGS 250
62 #define SCRIPT_TEMP_SPACE 16
63 #define SCRIPT_STACK_SIZE 32
64 #define SCRIPT_ROUTE_SLOTS 16
65 #define SCRIPT_EXEC_WRAPPER
66 #define SCRIPT_APPS_WRAPPER
67 #define SCRIPT_RIPPLE_LEVEL 2
68 #define SCRIPT_RIPPLE_KEYDATA
69 #define SCRIPT_BINDER_SELECT
70 #define SCRIPT_SERVER_PREFIX
71 #define SCRIPT_DEFINE_TOKENS
72 
73 #ifndef CCXX_PACKING
74 #if defined(__GNUC__)
75 #define CCXX_PACKED
76 #elif !defined(__hpux) && !defined(_AIX)
77 #define CCXX_PACKED
78 #endif
79 #endif
80 
81 namespace ost {
82 
91 
100 {
101 public:
102  class __EXPORT Line;
103  class __EXPORT Name;
104 
105  typedef bool (ScriptInterp::*Method)(void);
106  typedef const char *(ScriptCommand::*Check)(Line *line, ScriptImage *img);
107  typedef bool (*Cond)(ScriptInterp *interp, const char *v);
108  typedef long (*Function)(long *args, unsigned prec);
109  typedef const char *(*Meta)(ScriptInterp *interp, const char *token);
110  typedef const char *(*Parse)(ScriptCompiler *img, const char *token);
111  typedef void (*Init)(void);
112 
113  enum scrAccess {
118  scrLOCAL
119  };
120 
121  typedef enum scrAccess scrAccess;
122 
123  enum symType {
124  symNORMAL = 0,
142  symBOOL
143  };
144 
145  typedef enum symType symType;
146 
147  typedef struct _symbol {
148  struct _symbol *next;
149  const char *id;
150  unsigned short size;
151  symType type: 8;
152  char data[1];
153  } Symbol;
154 
155 #ifdef CCXX_PACKED
156 #pragma pack(1)
157 #endif
158 
159  typedef struct _array {
160  unsigned short head, tail, rec, count;
161  } Array;
162 
163 #ifdef CCXX_PACKED
164 #pragma pack()
165 #endif
166 
167 public:
169  {
170  public:
172  union {
174  Method method;
176  } scr;
177  const char *cmd, **args;
178  unsigned long cmask, mask;
179  unsigned short loop, line, lnum;
180  unsigned short argc;
181  };
182 
184  {
185  public:
188  char type;
189  const char *name;
190  };
191 
193  {
194  public:
197  Line *first, *select;
198  Line *trap[TRAP_BITS];
199  unsigned long mask;
200  const char *name, *filename;
202  };
203 
205  {
206  public:
207  const char *name;
208  unsigned size;
209  const char *value;
210  };
211 
213  {
214  public:
215  const char *keyword;
216  bool init;
217  Method method;
218  Check check;
219  };
220 
222  {
223  public:
224  const char *id;
225  Cond handler;
227  };
228 
229  class __EXPORT Fun
230  {
231  public:
232  const char *id;
233  unsigned args;
234  Function fn;
236  };
237 
239  {
240  public:
241  Init handler;
243  };
244 
245  class __EXPORT Package : public DSO
246  {
247  public:
248  static Package *first;
250  const char *filename;
251 
252  Package(const char *name);
253  };
254 
255  static bool fastStart;
256  static bool useBigmem;
257  static unsigned fastStepping;
258  static unsigned autoStepping;
259  static size_t pagesize;
260  static unsigned symsize;
261  static unsigned symlimit;
262 
263  static bool isScript(Name *scr);
264  static bool isSymbol(const char *id);
265  static bool use(const char *name);
266  static unsigned getIndex(const char *id);
267  static Symbol *deref(Symbol *sym);
268  static bool commit(Symbol *sym, const char *value);
269  static bool append(Symbol *sym, const char *value);
270  static bool symindex(Symbol *sym, short offset);
271  static const char *extract(Symbol *sym);
272  static unsigned count(Symbol *sym);
273  static unsigned storage(Symbol *sym);
274  static void clear(Symbol *sym);
275  static char decimal;
276  static bool use_definitions;
277  static bool use_macros;
278  static bool use_prefix;
279  static bool use_merge;
280  static bool use_funcs;
281  static const char *plugins;
282  static const char *altplugins;
283  static const char *access_user;
284  static const char *access_pass;
285  static const char *access_host;
286  static bool exec_funcs;
287  static const char *exec_extensions;
288  static const char *exec_token;
289  static const char *exec_prefix;
290  static const char *exit_token;
291  static const char *apps_extensions;
292  static const char *apps_prefix;
293 
294  static const char *etc_prefix;
295  static const char *var_prefix;
296  static const char *log_prefix;
297 
298  static void addFunction(const char *name, unsigned count, Function i);
299  static void addConditional(const char *name, Cond test);
300 
301  static bool isPrivate(Name *scr);
302  static bool isFunction(Name *scr);
303 
304 protected:
305  static Test *test;
306  static Fun *ifun;
307 
308 };
309 
310 class __EXPORT ScriptSymbols : public MemPager, public Script
311 {
312 protected:
314 
315  void purge(void);
316 
317 public:
318  ScriptSymbols();
319  ~ScriptSymbols();
320 
321  inline const char *cstring(const char *str)
322  {return MemPager::alloc(str);};
323 
324  unsigned gathertype(Symbol **idx, unsigned max, const char *prefix, symType group);
325  unsigned gather(Symbol **idx, unsigned max, const char *prefix, const char *suffix);
326  Symbol *find(const char *id, unsigned short size = 0);
327  Symbol *make(const char *id, unsigned short size);
328 
329  Symbol *setReference(const char *id, Symbol *target);
330 };
331 
343 class __EXPORT ScriptCommand : public Keydata, public Mutex, public Script
344 {
345 private:
346  friend class __EXPORT ScriptImage;
347  friend class __EXPORT ScriptInterp;
348  friend class __EXPORT ScriptCompiler;
349  friend class __EXPORT ScriptBinder;
350 
351 #ifdef CCXX_PACKED
352 #pragma pack(1)
353 #endif
354 
355  typedef struct _keyword {
356  struct _keyword *next;
357  Method method;
358  Check check;
359  bool init : 1;
360  char keyword[1];
361  } Keyword;
362 
363 #ifdef CCXX_PACKED
364 #pragma pack()
365 #endif
366 
369  char *traps[TRAP_BITS];
371  unsigned keyword_count;
372  unsigned trap_count;
373  unsigned long imask;
374  unsigned dbcount;
375  void *dbc;
376 
377 protected:
378  bool ripple;
379  unsigned activity; // activity counter
381 
382  virtual const char *getExternal(const char *opt);
383 
384 public:
392  virtual bool isInput(Line *line);
393 
401  Method getHandler(const char *keyword);
402 
410  bool control(char **args);
411 
417  inline ScriptImage *getActive(void)
418  {return active;};
419 
426  const char *getTrapName(unsigned id);
427 
434  void aliasModule(const char *id, const char *use);
435 
436 protected:
443  bool isInitial(const char *keyword);
444 
453  const char *check(char *command, Line *line, ScriptImage *img);
454 
461  virtual unsigned getTrapId(const char *name);
462 
468  virtual unsigned long getTrapDefault(void);
469 
475  virtual unsigned long getTrapHandler(Name *script);
476 
484  virtual unsigned long getTrapMask(unsigned id);
485 
494  virtual unsigned long getTrapModifier(const char *name);
495 
504  virtual unsigned long getTrapMask(const char *name);
505 
512  static bool hasKeywords(Line *line);
513 
514 public:
522  static const char *findKeyword(Line *line, const char *keyword);
523 
532  static const char *findKeyword(ScriptImage *img, Line *line, const char *keyword);
533 
540  virtual void errlog(const char *level, const char *text);
541 
542 public:
550  static bool useKeywords(Line *line, const char *list);
551 
558  static unsigned getCount(Line *line);
559 
566  static const char *getMember(Line *line);
567 
568 
569 protected:
577  static bool useMember(Line *line, const char *list);
578 
586  static const char *getOption(Line *line, unsigned *index);
587 
595  void load(Script::Define *keywords);
596 
606  int trap(const char *name, bool inherited = true);
607 
613  inline unsigned getCount(void)
614  {return trap_count;};
615 
619  bool isInherited(unsigned id);
620 
629  virtual const char *check(Check chk, Line *line, ScriptImage *img);
630 
631 public:
635  ScriptCommand();
636 
641 
647  inline unsigned getActivity(void)
648  {return activity;};
649 
650 };
651 
653 {
654 private:
655  friend class __EXPORT ScriptInterp;
656  friend class __EXPORT ScriptCompiler;
657  friend class __EXPORT ScriptCommand;
658 
661  const char *id;
662 
663 protected:
664  void bind(Script::Define *extensions);
665 
666  virtual void attach(ScriptInterp *interp);
667  virtual void detach(ScriptInterp *interp);
668  virtual bool select(ScriptInterp *interp);
669  virtual bool reload(ScriptCompiler *img);
670  virtual bool control(ScriptImage *img, char **args);
671  virtual void down(void);
672  virtual const char *use(Line *line, ScriptImage *img);
673 
674 public:
675  ScriptBinder(const char *id = NULL);
676  ScriptBinder(Script::Define *extensions);
677  virtual ~ScriptBinder();
678 
679  static const char *check(Line *line, ScriptImage *img);
680  static void shutdown(void);
681  static bool rebuild(ScriptCompiler *img);
682 };
683 
685 {
686 public:
687  ScriptRuntime();
688 };
689 
691 {
692 public:
693  ScriptRipple();
694 };
695 
697 {
698 public:
702  const char *chkIgnore(Line *line, ScriptImage *img);
703 
707  const char *chkUse(Line *line, ScriptImage *img);
708 
716  const char *chkHasModify(Line *line, ScriptImage *img);
717 
725  const char *chkProperty(Line *line, ScriptImage *img);
726 
734  const char *chkFirstVar(Line *line, ScriptImage *img);
735 
743  const char *chkType(Line *line, ScriptImage *img);
744 
754  const char *chkHasVars(Line *line, ScriptImage *img);
755 
764  const char *chkHasList(Line *line, ScriptImage *img);
765 
774  const char *chkNoArgs(Line *line, ScriptImage *img);
775 
784  const char *chkAllVars(Line *line, ScriptImage *img);
785 
794  const char *chkHasArgs(Line *line, ScriptImage *img);
795 
804  const char *chkOnlyArgs(Line *line, ScriptImage *img);
805 
806  const char *chkOnlyOneArg(Line *line, ScriptImage *img);
807 
808  const char *chkRefArgs(Line *line, ScriptImage *img);
809 
810  const char *chkSlog(Line *line, ScriptImage *img);
811 
812  const char *chkExpression(Line *line, ScriptImage *img);
813 
814  const char *chkConditional(Line *line, ScriptImage *img);
815 
816  const char *chkGoto(Line *line, ScriptImage *img);
817 
818  const char *chkLabel(Line *line, ScriptImage *img);
819 
820  const char *chkCall(Line *line, ScriptImage *img);
821 
822  const char *chkReturn(Line *line, ScriptImage *img);
823 
824  const char *chkRestart(Line *line, ScriptImage *img);
825 
826  const char *chkVar(Line *line, ScriptImage *img);
827 
828  const char *chkVarType(Line *line, ScriptImage *img);
829 
830  const char *chkDecimal(Line *line, ScriptImage *img);
831 
832  const char *chkNumber(Line *line, ScriptImage *img);
833 
834  const char *chkString(Line *line, ScriptImage *img);
835 
836  const char *chkChar(Line *line, ScriptImage *img);
837 
838  const char *chkExpr(Line *line, ScriptImage *img);
839 
840  const char *chkIndex(Line *line, ScriptImage *img);
841 
842  const char *chkError(Line *line, ScriptImage *img);
843 
844  const char *chkConst(Line *line, ScriptImage *img);
845 
846  const char *chkSequence(Line *line, ScriptImage *img);
847 
848  const char *chkSignal(Line *line, ScriptImage *img);
849 
850  const char *chkThrow(Line *line, ScriptImage *img);
851 
852  const char *chkSet(Line *line, ScriptImage *img);
853 
854  const char *chkRepeat(Line *line, ScriptImage *img);
855 
856  const char *chkArray(Line *line, ScriptImage *img);
857 
858  const char *chkFor(Line *line, ScriptImage *img);
859 
860  const char *chkForeach(Line *line, ScriptImage *img);
861 
862  const char *chkCat(Line *line, ScriptImage *img);
863 
864  const char *chkRemove(Line *line, ScriptImage *img);
865 
866  const char *chkOnlyCommand(Line *line, ScriptImage *img);
867 
868  const char *chkCounter(Line *line, ScriptImage *img);
869 
870  const char *chkTimer(Line *line, ScriptImage *img);
871 
872  const char *chkClear(Line *line, ScriptImage *img);
873 
874  const char *chkPack(Line *line, ScriptImage *img);
875 
876  const char *chkConstruct(Line *line, ScriptImage *img);
877 
878  const char *chkLock(Line *line, ScriptImage *img);
879 
880  const char *chkSession(Line *line, ScriptImage *img);
881 
882  const char *chkKeywords(Line *line, ScriptImage *img);
883 
884  const char *chkDefine(Line *line, ScriptImage *img);
885 };
886 
895 {
896 private:
897  friend class __EXPORT ScriptImage;
899 
900 protected:
901  ScriptObject(ScriptImage *image);
902  virtual ~ScriptObject();
903 };
904 
914 class __EXPORT ScriptImage : public Keydata, public Script, public Assoc
915 {
916 protected:
917  friend class __EXPORT ScriptObject;
918 
920  unsigned refcount;
921  Name *index[SCRIPT_INDEX_SIZE + 1], *current;
922  Line *select, *selecting, *registration;
923  Line *advertising[SCRIPT_ROUTE_SLOTS];
926  static unsigned long serial;
927  unsigned long instance;
928 
930  {
931  public:
933  } *ilist;
934 
935  friend class __EXPORT ScriptInterp;
936 
943  Method getHandler(const char *keyword)
944  {return cmds->getHandler(keyword);};
945 
946 public:
953  void *getMemory(size_t size);
954 
961  const char *dupString(const char *str);
962 
966  virtual void fastBranch(ScriptInterp *interp);
967 
973  inline Name *getCurrent(void)
974  {return current;};
975 
981  void addSelect(Line *line);
982 
988  void addRegistration(Line *line);
989 
995  ScriptRegistry *getRegistry(void);
996 
1003  void addRoute(Line *line, unsigned pri);
1004 
1010  inline Line *getSelect(void)
1011  {return select;};
1012 
1018  inline Line *getRegistration(void)
1019  {return registration;};
1020 
1026  inline Line *getRoute(unsigned pri)
1027  {return advertising[pri];};
1028 
1032  inline unsigned long getInstance(void)
1033  {return instance;};
1034 
1043  ScriptImage(ScriptCommand *cmdset, const char *symset);
1044 
1048  ~ScriptImage();
1049 
1053  void purge(void);
1054 
1060  void commit(void);
1061 
1067  void load(Initial *ilist);
1068 
1076  void initial(const char *keyword, const char *value, unsigned size = 0);
1077 
1084  virtual Name *getScript(const char *name);
1085 
1092  {return cmds;};
1093 
1099  bool isRipple(void)
1100  {return cmds->ripple;};
1101 
1110  unsigned gather(const char *suffix, Name **array, unsigned size);
1111 
1115  inline void incRef(void)
1116  {++refcount;};
1117 
1121  inline void decRef(void)
1122  {--refcount;};
1123 
1129  inline bool isRef(void)
1130  {return (bool)(refcount > 0);};
1131 
1137  inline ScriptImage *getActive(void)
1138  {return cmds->getActive();};
1139 };
1140 
1151 {
1152 protected:
1153  std::ifstream scrSource;
1154  std::istream *scrStream;
1155  char *buffer;
1156  unsigned bufsize;
1157  char *bp;
1158  bool quote;
1159  unsigned paren;
1160  unsigned inccount;
1161  const char *incfiles[256];
1162 
1163  typedef struct _merge {
1164  struct _merge *next;
1165  Name *target;
1166  const char *source;
1167  const char *prefix;
1168  } merge_t;
1169 
1171 
1172  friend class __EXPORT ScriptInterp;
1173 
1174  virtual bool checkSegment(Name *scr);
1175 
1176 public:
1177  char *getToken(char **pre = NULL);
1178 
1182  virtual void fastBranch(ScriptInterp *interp);
1183 
1192  ScriptCompiler(ScriptCommand *cmdset, const char *symset);
1193 
1201  Name *include(const char *name);
1202 
1211  int compile(const char *file);
1212 
1221  int compile(const char *file, char *name);
1222 
1230  int compileDefinitions(const char *file);
1231 
1240  int compile(std::istream *stream, char *name, const char *file = NULL);
1241 
1247  void commit(void);
1248 
1255  virtual const char *getDefined(const char *token);
1256 
1263  const char *preproc(const char *token);
1264 
1271  inline std::istream *getSource(void)
1272  {return (std::istream *)&scrSource;};
1273 };
1274 
1276 {
1277 protected:
1278  friend class __EXPORT ScriptThread;
1279  friend class __EXPORT ScriptCommand;
1280  friend class __EXPORT ScriptBinder;
1281 
1282 public:
1284  {
1285  public:
1286  Name *script;
1287  Line *line, *first;
1288  unsigned short index;
1290  unsigned long mask;
1291  bool caseflag : 1;
1292  bool tranflag : 1;
1293  bool unused1 : 1;
1294  bool unused2 : 1;
1295  unsigned decimal : 4;
1296  unsigned base : 8;
1297  };
1298 
1299  static long getRealValue(double val, unsigned prec);
1300  static double getDouble(long value, unsigned prec);
1301  static long getInteger(long value, unsigned prec);
1302  static long getTens(unsigned prec);
1303  long getIntValue(const char *text, unsigned prec, ScriptProperty *property = NULL);
1304  int numericExpression(long *list, int max, unsigned prec, ScriptProperty *property = NULL);
1305  bool conditionalExpression(void);
1306  bool conditional(void);
1307 
1308 protected:
1309  Mutex *lock; // any additional lock that is siezed
1315  char *temps[SCRIPT_TEMP_SPACE];
1316  unsigned tempidx;
1317  unsigned stack;
1318  bool initialized, trace, exiting, updated;
1319  unsigned long sequence;
1320  char logname[32];
1321 
1322 public:
1323  virtual unsigned getId(void);
1324 
1325  inline unsigned long getSequence(void)
1326  {return sequence;};
1327 
1328  virtual const char *getLogname(void)
1329  {return logname;};
1330 
1331  virtual ScriptInterp *getInterp(const char *id);
1332 
1333  virtual const char *getExternal(const char *opt);
1334 
1335  inline ScriptImage *getImage(void)
1336  {return image;};
1337 
1338 protected:
1339  virtual ScriptSymbols *getSymbols(const char *id);
1340 
1341  ScriptSymbols *getLocal(void);
1342 
1343 public:
1344  const char *getMember(void);
1345  const char *getKeyword(const char *kw);
1346  const char *getKeyoption(const char *kw);
1347  const char *getValue(const char *def = NULL);
1348  const char *getOption(const char *def = NULL);
1349  const char *hasOption(void);
1350  const char *getContent(const char *opt);
1351  const char *getSymContent(const char *opt);
1352  Symbol *getKeysymbol(const char *kw, unsigned size = 0);
1353  Symbol *getSymbol(unsigned short size = 0);
1354  char getPackToken(void);
1355 
1356 protected:
1360  void initRuntime(Name *name);
1361 
1366  virtual void initialize(void);
1367 
1368 public:
1369  inline Frame *getFrame(void)
1370  {return &frame[stack];};
1371 
1372  inline Line *getLine(void)
1373  {return frame[stack].line;};
1374 
1375  void setFrame(void);
1376 
1377  inline Name *getName(void)
1378  {return frame[stack].script;};
1379 
1380  inline bool getTrace(void)
1381  {return trace;};
1382 
1390  bool execute(Method method);
1391 
1392 protected:
1398  bool push(void);
1399 
1405  bool pull(void);
1406 
1410  void clearStack(void);
1411 
1415  void advance(void);
1416 
1420  void skip(void);
1421 
1428  void error(const char *error);
1429 
1440  bool scriptEvent(const char *name, bool inhereted = true);
1441 
1447  void gotoEvent(NamedEvent *event);
1448 
1456  void trap(unsigned id);
1457 
1464  bool tryCatch(const char *id);
1465 
1472  void trap(const char *name);
1473 
1474 public:
1475  virtual void logmissing(const char *id, const char *level = "undefined", const char *group = "symbol");
1476  virtual void logerror(const char *msg, const char *name = NULL);
1477 
1478  Symbol *mapSymbol(const char *id, unsigned short = 0);
1479  Symbol *mapDirect(const char *id, unsigned short = 0);
1480 
1481 protected:
1482  virtual bool isLocked(const char *id);
1483  virtual const char *remapLocal(void);
1484  virtual bool exit(void);
1485  virtual void enterThread(ScriptThread *thread);
1486  virtual void exitThread(const char *msg);
1487  virtual void waitThread(void);
1488  virtual void startThread(void);
1489 
1490  bool eventThread(const char *evt, bool flag = true);
1491 
1492  bool redirect(const char *scr);
1493 
1494  void ripple(void);
1495 
1496  bool redirect(bool evflag);
1497 
1498  unsigned long getMask(void);
1499 
1500 public:
1501  bool setNumber(const char *id, const char *value = NULL, unsigned dec = 0);
1502  bool setSymbol(const char *id, const char *value = NULL, unsigned short size = 0);
1503  bool setConst(const char *id, const char *value);
1504  bool putSymbol(const char *id, const char *value, unsigned short size = 0);
1505  bool getSymbol(const char *id, char *buffer, unsigned short max);
1506  bool catSymbol(const char *id, const char *value, unsigned short size = 0);
1507 
1508  const char *getSymbol(const char *id);
1509 
1510  Name *getScript(const char *name);
1511 
1512  ScriptInterp();
1513 
1514  bool step(void);
1515  bool attach(ScriptCommand *cmd, const char *scrname);
1516  void detach(void);
1517  void attach(ScriptCommand *cmd, ScriptImage *img, Name *scr);
1518 
1522  void release(void);
1523 
1533  bool signal(const char *name);
1534 
1542  bool signal(unsigned id);
1543 
1544  bool done(void);
1545 
1546  timeout_t getTimeout(void);
1547 
1553  virtual void branching(void);
1554 
1555  inline bool isRunning(void)
1556  {return (image != NULL) && initialized;};
1557 
1558  inline bool isExiting(void)
1559  {return exiting;};
1560 
1561  char *getTemp(void);
1562 
1563  unsigned getTempSize(void);
1564 };
1565 
1567 {
1568 public:
1569  bool scrNop(void);
1570  bool scrError(void);
1571  bool scrExit(void);
1572  bool scrDecimal(void);
1573  bool scrDefine(void);
1574  bool scrVar(void);
1575  bool scrType(void);
1576  bool scrNumber(void);
1577  bool scrSlog(void);
1578  bool scrExpr(void);
1579  bool scrIndex(void);
1580  bool scrOffset(void);
1581  bool scrRef(void);
1582  bool scrRestart(void);
1583  bool scrInit(void);
1584  bool intGoto(void);
1585  bool scrGoto(void);
1586  bool scrCall(void);
1587  bool scrReturn(void);
1588  bool scrBegin(void);
1589  bool scrEnd(void);
1590  bool scrConst(void);
1591  bool scrSequence(void);
1592  bool scrSet(void);
1593  bool scrArray(void);
1594  bool scrClear(void);
1595  bool scrConstruct(void);
1596  bool scrDeconstruct(void);
1597  bool scrPack(void);
1598  bool scrUnpack(void);
1599  bool scrLock(void);
1600  bool scrSession(void);
1601  bool scrSignal(void);
1602  bool scrThrow(void);
1603  bool scrInvoke(void);
1604  bool scrCounter(void);
1605  bool scrTimer(void);
1606  bool scrCase(void);
1607  bool scrEndcase(void);
1608  bool scrRemove(void);
1609  bool scrDo(void);
1610  bool scrRepeat(void);
1611  bool scrFor(void);
1612  bool scrForeach(void);
1613  bool scrLoop(void);
1614  bool scrContinue(void);
1615  bool scrBreak(void);
1616  bool scrIf(void);
1617  bool scrIfThen(void);
1618  bool scrThen(void);
1619  bool scrElse(void);
1620  bool scrEndif(void);
1621 };
1622 
1623 class __EXPORT ScriptThread : public Thread, public Script
1624 {
1625 private:
1626  volatile bool exiting;
1627  size_t stacksize;
1628 
1629 protected:
1630  friend class __EXPORT ScriptInterp;
1631 
1633 
1634  void exit(const char *errmsg = NULL);
1635 
1636  void exitEvent(const char *evt, bool inherited = true);
1637 
1638  inline bool isExiting(void)
1639  {return exiting;};
1640 
1641  inline bool putSymbol(const char *id, const char *value, unsigned short size = 0)
1642  {return interp->putSymbol(id, value, size);};
1643 
1644  inline bool getSymbol(const char *id, char *buffer, unsigned short max)
1645  {return interp->getSymbol(id, buffer, max);};
1646 
1647  inline bool addSymbol(const char *id, char *buffer, unsigned short max)
1648  {return interp->getSymbol(id, buffer, max);};
1649 
1650  void block(void);
1651 
1652  void unblock(void);
1653 
1654  void lock(void);
1655 
1656  void release(void);
1657 
1658 public:
1659  virtual timeout_t getTimeout(void);
1660 
1661  inline size_t getStack(void)
1662  {return stacksize;};
1663 
1664  ScriptThread(ScriptInterp *interp, int pri = 0, size_t stack = 0);
1665  ~ScriptThread();
1666 };
1667 
1676 class __EXPORT ScriptRegistry : public Script, public TimerPort
1677 {
1678 public:
1679  const char *protocol;
1681  Name *scr; // script being registered
1682  Line *line; // line of registry statement
1683 };
1684 
1693 {
1694 private:
1695  friend class ScriptInterp;
1696 
1699  const char *id;
1700 
1701 public:
1709  virtual void set(const char *data, char *temp, unsigned size) = 0;
1710 
1716  virtual unsigned prec(void);
1717 
1725  virtual void setValue(char *data, unsigned short size, long value);
1726 
1733  virtual bool isProperty(const char *data);
1734 
1742  virtual void clear(char *data, unsigned size = 0);
1743 
1749  virtual char token(void);
1750 
1758  virtual void adjust(char *data, size_t size, long adjustment);
1759 
1766  virtual long adjustValue(long value);
1767 
1774  virtual long getValue(const char *data);
1775 
1776  ScriptProperty(const char *name);
1777  virtual ~ScriptProperty();
1778 
1779  static ScriptProperty *find(const char *name);
1780 };
1781 
1782 }
1783 
1784 #endif
1785 
The memory pager is used to allocate cumulative memory pages for storing object specific "persistant"...
Definition: misc.h:91
static bool use_prefix
Definition: script3.h:278
ScriptObject * next
Definition: script3.h:898
const char * cstring(const char *str)
Definition: script3.h:321
Function fn
Definition: script3.h:234
const char * name
Definition: script3.h:189
unsigned getCount(void)
Get count of active traps.
Definition: script3.h:613
static unsigned symlimit
Definition: script3.h:261
std::istream * getSource(void)
Used by embedded interpreters to fetch script from the current source file.
Definition: script3.h:1271
static bool use_definitions
Definition: script3.h:276
ScriptSymbols * local
Definition: script3.h:1289
static const char * apps_prefix
Definition: script3.h:292
const char * id
Definition: script3.h:232
class __EXPORT ScriptSymbols
Definition: script3.h:87
bool putSymbol(const char *id, const char *value, unsigned short size=0)
Definition: script3.h:1641
NamedEvent * events
Definition: script3.h:196
#define SCRIPT_INDEX_SIZE
Definition: script3.h:60
ScriptInterp * interp
Definition: script3.h:1632
struct _symbol * next
Definition: script3.h:148
unsigned args
Definition: script3.h:233
Memory management, configuration keydata objects and string tokenizer.
static bool use_merge
Definition: script3.h:279
ScriptImage * getImage(void)
Definition: script3.h:1335
virtual const char * getLogname(void)
Definition: script3.h:1328
unsigned refcount
Definition: script3.h:920
unsigned long getSequence(void)
Definition: script3.h:1325
const char * value
Definition: script3.h:209
ScriptInterp * session
Definition: script3.h:1312
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541
const char * filename
Definition: script3.h:250
Method getHandler(const char *keyword)
Get the interpreter method pointer for a given keyword.
Definition: script3.h:943
static unsigned fastStepping
Definition: script3.h:257
This class is used for DSO modules that impliment property extensions for scripting objects...
Definition: script3.h:1692
ScriptCommand * cmd
Definition: script3.h:1310
NamedEvent * next
Definition: script3.h:186
#define SCRIPT_STACK_SIZE
Definition: script3.h:63
unsigned tempidx
Definition: script3.h:1316
This class is used for registering scripts with an external registry.
Definition: script3.h:1676
unsigned short argc
Definition: script3.h:180
std::istream * scrStream
Definition: script3.h:1154
ScriptRegistry * registry
Definition: script3.h:173
#define TRAP_BITS
Definition: script3.h:59
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
Definition: thread.h:186
Files and dynamic loader services.
unsigned long sequence
Definition: script3.h:1319
This class is used to associate (object) pointers with named strings.
Definition: misc.h:674
Line * getSelect(void)
Get the selection list from the image.
Definition: script3.h:1010
__EXPORT char * find(const char *cs, char *str, size_t len=0)
static ScriptProperty * first
Definition: script3.h:1697
volatile bool exiting
Definition: script3.h:1626
const char * cmd
Definition: script3.h:177
bool isRunning(void)
Definition: script3.h:1555
Name * getCurrent(void)
Get current entity being compiled...
Definition: script3.h:973
unsigned long getInstance(void)
Get the session instance of the image.
Definition: script3.h:1032
bool addSymbol(const char *id, char *buffer, unsigned short max)
Definition: script3.h:1647
ScriptObject * objects
Definition: script3.h:925
A derivable class to hold compiled script images for active processes.
Definition: script3.h:1150
class __EXPORT ScriptThread
Definition: script3.h:89
unsigned long instance
Definition: script3.h:927
unsigned inccount
Definition: script3.h:1160
bool isExiting(void)
Definition: script3.h:1558
scrAccess access
Definition: script3.h:201
ScriptBinder * next
Definition: script3.h:660
bool getSymbol(const char *id, char *buffer, unsigned short max)
Definition: script3.h:1644
Keydata objects are used to load and hold "configuration" data for a given application.
Definition: misc.h:352
unsigned long timeout_t
Definition: thread.h:74
ScriptProperty * next
Definition: script3.h:1698
static unsigned symsize
Definition: script3.h:260
unsigned short tail
Definition: script3.h:160
static char decimal
Definition: script3.h:275
Package * next
Definition: script3.h:249
virtual void * alloc(size_t size)
Allocate memory from either the currently active page, or allocate a new page for the object...
unsigned activity
Definition: script3.h:379
ThreadQueue * tq
Definition: script3.h:367
static unsigned autoStepping
Definition: script3.h:258
const char * name
Definition: script3.h:200
A linkable list of objects that can be destroyed when a script image is removed from memory...
Definition: script3.h:894
#define SCRIPT_ROUTE_SLOTS
Definition: script3.h:64
A derivable class to hold compiled script images for active processes.
Definition: script3.h:914
unsigned stack
Definition: script3.h:1317
static const char * exec_token
Definition: script3.h:288
Line * getLine(void)
Definition: script3.h:1372
static const char * apps_extensions
Definition: script3.h:291
struct _merge * next
Definition: script3.h:1164
unsigned long imask
Definition: script3.h:373
#define SCRIPT_TEMP_SPACE
Definition: script3.h:62
bool getTrace(void)
Definition: script3.h:1380
Somewhat generic queue processing class to establish a producer consumer queue.
Definition: buffer.h:261
static unsigned long serial
Definition: script3.h:926
size_t stacksize
Definition: script3.h:1627
static const char * plugins
Definition: script3.h:281
static const char * exec_extensions
Definition: script3.h:287
const char * id
Definition: script3.h:661
static const char * exit_token
Definition: script3.h:290
bool isExiting(void)
Definition: script3.h:1638
timeout_t duration
Definition: script3.h:1680
unsigned short size
Definition: script3.h:150
ScriptImage * image
Definition: script3.h:1311
static bool exec_funcs
Definition: script3.h:286
Generic script class to hold master data types and various useful class encpasulated friend functions...
Definition: script3.h:99
static const char * access_host
Definition: script3.h:285
merge_t * mlist
Definition: script3.h:1170
unsigned long mask
Definition: script3.h:199
ScriptCommand * cmds
Definition: script3.h:919
unsigned short loop
Definition: script3.h:179
unsigned trap_count
Definition: script3.h:372
class __EXPORT ScriptCommand
Definition: script3.h:84
static const char * access_user
Definition: script3.h:283
unsigned getActivity(void)
Get activity counter.
Definition: script3.h:647
Frame * getFrame(void)
Definition: script3.h:1369
bool isRipple(void)
Get the ripple flag for the current image.
Definition: script3.h:1099
size_t getStack(void)
Definition: script3.h:1661
static const char * etc_prefix
Definition: script3.h:294
struct _keyword * next
Definition: script3.h:356
const char * protocol
Definition: script3.h:1679
static const char * log_prefix
Definition: script3.h:296
unsigned dbcount
Definition: script3.h:374
ScriptCommand * getCommand(void)
Get the command object associated with the image.
Definition: script3.h:1091
unsigned long mask
Definition: script3.h:1290
static bool use_macros
Definition: script3.h:277
unsigned long mask
Definition: script3.h:178
const char * id
Definition: script3.h:149
std::ifstream scrSource
Definition: script3.h:1153
static bool use_funcs
Definition: script3.h:280
static Test * test
Definition: script3.h:305
#define __EXPORT
Definition: audio2.h:51
const char *(ScriptCommand::* Check)(Line *line, ScriptImage *img)
Definition: script3.h:106
static bool useBigmem
Definition: script3.h:256
static const char * altplugins
Definition: script3.h:282
Line * selecting
Definition: script3.h:922
object passing services between threads.
The DSO dynamic loader class is used to load object files.
Definition: file.h:889
ScriptImage * active
Definition: script3.h:370
const char * keyword
Definition: script3.h:215
static const char * var_prefix
Definition: script3.h:295
static Package * first
Definition: script3.h:248
const char * id
Definition: script3.h:1699
Every thread of execution in an application is created by instantiating an object of a class derived ...
Definition: thread.h:1093
bool isRef(void)
See if the image is referenced...
Definition: script3.h:1129
struct timespec * getTimeout(struct timespec *spec, timeout_t timeout)
const char * id
Definition: script3.h:224
InitScript * next
Definition: script3.h:242
ScriptThread * thread
Definition: script3.h:1313
ScriptImage * getActive(void)
Get the active image from command.
Definition: script3.h:1137
static bool fastStart
Definition: script3.h:255
Name * getName(void)
Definition: script3.h:1377
static size_t pagesize
Definition: script3.h:259
unsigned keyword_count
Definition: script3.h:371
char * dupString(const char *src, size_t size=0)
Definition: strchar.h:94
Timer ports are used to provide synchronized timing events when managed under a "service thread" such...
Definition: thread.h:1759
class __EXPORT ScriptCompiler
Definition: script3.h:90
class __EXPORT ScriptProperty
Definition: script3.h:88
Line * getRegistration(void)
Get the registration list from the image.
Definition: script3.h:1018
unsigned short line
Definition: script3.h:179
unsigned bufsize
Definition: script3.h:1156
const char * name
Definition: script3.h:207
void decRef(void)
dec the reference count.
Definition: script3.h:1121
class __EXPORT ScriptInterp
Definition: script3.h:86
void incRef(void)
inc the reference count.
Definition: script3.h:1115
unsigned short index
Definition: script3.h:1288
ScriptImage * getActive(void)
Get the active script.
Definition: script3.h:417
Line * getRoute(unsigned pri)
Get an advertised priority record from the image.
Definition: script3.h:1026
static ScriptBinder * first
Definition: script3.h:659
This class holds the bound keyword set for a given Bayonne style script interpreter.
Definition: script3.h:343
class __EXPORT ScriptImage
Definition: script3.h:85
static ScriptCommand * runtime
Definition: script3.h:380
static Fun * ifun
Definition: script3.h:306
static const char * access_pass
Definition: script3.h:284
static const char * exec_prefix
Definition: script3.h:289