Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

bayonne.h

Go to the documentation of this file.
00001 // Copyright (C) 2000 Open Source Telecom Corporation.
00002 //  
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 // 
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 // 
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software 
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 
00017 #ifndef __CCXX_BAYONNE_H__
00018 #define __CCXX_BAYONNE_H__
00019 
00020 #ifndef __CCXX_SCRIPT_H__
00021 #include <cc++/script.h>
00022 #endif
00023 
00024 #ifndef __CCXX_XML_H__
00025 #include <cc++/xml.h>
00026 #endif
00027 
00028 #ifndef __CCXX_URL_H__
00029 #include <cc++/url.h>
00030 #endif
00031 
00032 #ifndef __CCXX_SLOG_H__
00033 #include <cc++/slog.h>
00034 #endif
00035 
00036 #ifndef __CCXX_DSO_H__
00037 #include <cc++/file.h>
00038 #endif
00039 
00040 #ifndef __CCXX_SOCKET_H__
00041 #include <cc++/socket.h>
00042 #endif
00043 
00044 #ifndef __CCXX_AUDIO_H__
00045 #include <cc++/audio.h>
00046 #endif
00047 
00048 #include <stdlib.h>
00049 
00050 #ifdef  __FreeBSD__
00051 #undef  read
00052 #undef  write
00053 #undef  readv
00054 #undef  writev
00055 #endif
00056 
00057 #ifndef COMMON_TPPORT_TYPE_DEFINED
00058 typedef short   tpport_t;
00059 #endif
00060 
00061 /* Bayonne uses a universal event record for all driver plugins and
00062    state handlers.  Not all drivers impliment the entire set of events
00063    and some drivers have specific events associated with their unique
00064    characteristcs.  However, most events are considered "universal".
00065 */
00066 
00067 class Trunk;
00068 class TrunkImage;
00069 class Service;
00070 class phTone;
00071 class TrunkGroup;
00072 class Module;
00073 class Request;
00074 
00075 typedef enum
00076 {
00077         SELECT_FIRST,
00078         SELECT_LAST
00079 } seltype_t;
00080 
00081 typedef enum
00082 {
00083         MAP_PREFIX,
00084         MAP_SUFFIX,
00085         MAP_ABSOLUTE
00086 } mapmode_t;
00087 
00088 typedef enum {
00089         MODULE_GENERIC,
00090         MODULE_DELIVERY,
00091         MODULE_SENDFILE,
00092         MODULE_SENDFAX,
00093         MODULE_NOTIFY,
00094         MODULE_FIFO,
00095         MODULE_TGI,
00096         MODULE_URL,
00097         MODULE_NET,
00098         MODULE_REPLY,
00099         MODULE_ASR,
00100         MODULE_TTS,
00101         MODULE_XML,
00102         MODULE_ANY
00103 }       modtype_t;
00104 
00105 typedef enum {
00106         // step change requests
00107         TRUNK_STEP_HANGUP = 0,
00108         TRUNK_STEP_SLEEP,
00109         TRUNK_STEP_ANSWER,
00110         TRUNK_STEP_COLLECT,
00111         TRUNK_STEP_PLAY,
00112         TRUNK_STEP_PLAYWAIT,
00113         TRUNK_STEP_RECORD,
00114         TRUNK_STEP_TONE,
00115         TRUNK_STEP_DIALXFER,
00116         TRUNK_STEP_FLASH,
00117         TRUNK_STEP_JOIN,
00118         TRUNK_STEP_RTP,
00119         TRUNK_STEP_DUPLEX,
00120         TRUNK_STEP_DETECT,
00121         TRUNK_STEP_REQUIRES,
00122         TRUNK_STEP_LOADER,
00123         TRUNK_STEP_EXIT = TRUNK_STEP_HANGUP,
00124         TRUNK_STEP_DRIVER
00125 } trunkstep_t;
00126 
00127 typedef enum {
00128         // notify script from state handler
00129         TRUNK_SIGNAL_STEP = 0,
00130         TRUNK_SIGNAL_EXIT,
00131         TRUNK_SIGNAL_HANGUP=TRUNK_SIGNAL_EXIT,
00132         TRUNK_SIGNAL_ERROR,
00133         TRUNK_SIGNAL_TIMEOUT,
00134         TRUNK_SIGNAL_DTMF,
00135         TRUNK_SIGNAL_0,
00136         TRUNK_SIGNAL_1,
00137         TRUNK_SIGNAL_2,
00138         TRUNK_SIGNAL_3,
00139         TRUNK_SIGNAL_4,
00140         TRUNK_SIGNAL_5,
00141         TRUNK_SIGNAL_6,
00142         TRUNK_SIGNAL_7,
00143         TRUNK_SIGNAL_8,
00144         TRUNK_SIGNAL_9,
00145         TRUNK_SIGNAL_STAR,
00146         TRUNK_SIGNAL_POUND,
00147         TRUNK_SIGNAL_A,
00148         TRUNK_SIGNAL_B,
00149         TRUNK_SIGNAL_C,
00150         TRUNK_SIGNAL_D,
00151         TRUNK_SIGNAL_DIALTONE,
00152         TRUNK_SIGNAL_BUSY,
00153         TRUNK_SIGNAL_CANCEL,
00154         TRUNK_SIGNAL_SIGNAL,
00155         TRUNK_SIGNAL_DRIVER
00156 }       trunksignal_t;
00157 
00158 typedef enum {
00159         // primary state handlers
00160 
00161         TRUNK_ENTER_STATE = 100,// newly entered handler state
00162         TRUNK_EXIT_STATE,       // exiting prior state (unused)
00163         TRUNK_STOP_STATE,       // request state termination
00164         TRUNK_NOTIFICATION,     // death notify event
00165         TRUNK_SERVICE_SUCCESS,  // service completion successful
00166         TRUNK_SERVICE_FAILURE,  // service completion failed
00167         TRUNK_SERVICE_LOOKUP,   // lookup transaction
00168         TRUNK_SERVICE_LOGIN,    // login transaction
00169         TRUNK_SIGNAL_NOTIFY,    // signal between trunks
00170         TRUNK_JOIN_TRUNKS,      // join two trunks together
00171         TRUNK_PART_TRUNKS,      // split two trunks that were joined
00172         TRUNK_NULL_EVENT,       // used to push pipe driven systems
00173 
00174         // tgi/integration control state handlers
00175 
00176         TRUNK_EXIT_SHELL = 200, // tgi completion event
00177         TRUNK_START_SCRIPT,     // start of script
00178         TRUNK_RING_START,       // smdi/integrated answer
00179         TRUNK_RING_REDIRECT,    // smdi/integrated answer options
00180         TRUNK_STOP_DISCONNECT,  // integrated hangup notification
00181 
00182         // in the future these will be used
00183 
00184         TRUNK_START_INCOMING = TRUNK_RING_START,
00185         TRUNK_START_OUTGOING = TRUNK_START_SCRIPT,
00186 
00187         // primary "mode" selection controls
00188 
00189         TRUNK_MAKE_TEST =  300, // request driver perform line test
00190         TRUNK_MAKE_BUSY,        // request driver lockout line
00191         TRUNK_MAKE_IDLE,        // request driver reset line
00192         TRUNK_MAKE_STEP,        // pass step event internally
00193 
00194         // basic trunk events
00195 
00196         TRUNK_LINE_WINK = 400,  // used for line disconnect notification
00197         TRUNK_TIMER_EXPIRED,    // driver specific port timer expired
00198         TRUNK_RINGING_ON,       // some drivers distinguish start/stop
00199         TRUNK_RINGING_OFF,      // default ring event
00200         TRUNK_TEST_IDLE,        // some drivers have line test completion
00201         TRUNK_TEST_FAILURE,     // some drivers notify errors
00202         TRUNK_ON_HOOK,          // some drivers notify on hook
00203         TRUNK_OFF_HOOK,         // some drivers notify off hook
00204         TRUNK_CALLER_ID,        // caller id parse request
00205         TRUNK_RINGING_DID,      // did digit ring signal
00206         TRUNK_CALL_DETECT,      // ISDN call detected notification
00207         TRUNK_CALL_CONNECT,     // ISDN call connection notification
00208         TRUNK_CALL_RELEASE,     // ISDN call release notification
00209         TRUNK_CALL_ACCEPT,      // ISDN incoming call accepted
00210         TRUNK_CALL_RINGING,     // digital T1 incoming call
00211         TRUNK_CALL_DISCONNECT,  // digital T1 circuit break
00212 
00213         // basic audio processing events
00214 
00215         TRUNK_AUDIO_IDLE = 500, // audio reset or completion event
00216         TRUNK_INPUT_PENDING,    // some drivers monitor audio i/o status
00217         TRUNK_OUTPUT_PENDING,   // some drivers monitor audio i/p status
00218         TRUNK_AUDIO_BUFFER,     // some drivers return audio buffers
00219         TRUNK_TONE_IDLE,        // tone generator completion event
00220         TRUNK_DTMF_KEYDOWN,     // some drivers distinguish tone down
00221         TRUNK_DTMF_KEYUP,       // default dtmf event
00222         TRUNK_TONE_START,       // tone detected
00223         TRUNK_TONE_STOP,        // some drivers have tone completion event
00224         TRUNK_FSK_DETECT,       // fsk tone detect
00225         TRUNK_FAX_DETECT,       // fax tone detect
00226         TRUNK_VOX_DETECT,       // speaker detected
00227         TRUNK_AUDIO_START,      // some drivers may "vox" compress
00228         TRUNK_AUDIO_STOP,       // some drivers may "vox" compress
00229         TRUNK_CPA_DIALTONE,     // dialtone heard on the line
00230         TRUNK_CPA_BUSYTONE,
00231         TRUNK_CPA_RINGING,
00232         TRUNK_CPA_RINGBACK = TRUNK_CPA_RINGING,
00233         TRUNK_CPA_INTERCEPT,
00234         TRUNK_CPA_NODIALTONE,
00235         TRUNK_CPA_NORINGBACK,
00236         TRUNK_CPA_NOANSWER,
00237         TRUNK_CPA_CONNECT,
00238         TRUNK_CPA_FAILURE,
00239         TRUNK_DSP_READY,        // dsp resource became available
00240 
00241         // driver specific events and anomolies
00242 
00243         TRUNK_DRIVER_SPECIFIC=8000      // very oddball events
00244 } trunkevent_t;
00245 
00246 typedef enum
00247 {
00248         DSP_MODE_INACTIVE = 0,  // dsp is idle
00249         DSP_MODE_VOICE,         // standard voice processing
00250         DSP_MODE_CALLERID,      // caller id support
00251         DSP_MODE_DATA,          // fsk modem mode
00252         DSP_MODE_FAX,           // fax support
00253         DSP_MODE_TDM,           // TDM bus with echo cancellation
00254         DSP_MODE_RTP,           // VoIP full duplex
00255         DSP_MODE_DUPLEX,        // mixed play/record
00256         DSP_MODE_JOIN,          // support of joined channels
00257         DSP_MODE_CONF,          // in conference
00258         DSP_MODE_TONE           // tone processing
00259 } dspmode_t;
00260 
00261 typedef enum
00262 {
00263         TRUNK_MODE_INCOMING = 0,
00264         TRUNK_MODE_OUTGOING,
00265         TRUNK_MODE_INACTIVE,
00266         TRUNK_MODE_UNAVAILABLE
00267 } trunkmode_t;
00268  
00269 typedef enum
00270 {
00271         STAT_MAX_INCOMING,
00272         STAT_MAX_OUTGOING,
00273         STAT_TOT_INCOMING,
00274         STAT_TOT_OUTGOING,
00275         STAT_ACTIVE_CALLS
00276 } statitem_t;
00277 
00278 typedef enum
00279 {
00280         PLAY_MODE_NORMAL,
00281         PLAY_MODE_ONE,
00282         PLAY_MODE_ANY,
00283         PLAY_MODE_TEMP
00284 } playmode_t;
00285 
00286 typedef enum
00287 {
00288         TTS_GATEWAY_TEXT,
00289         TTS_GATEWAY_FILE
00290 } ttsmode_t;
00291 
00292 #define TRUNK_CAP_VOICE         0x00000001
00293 #define TRUNK_CAP_DIAL          0x00000002
00294 #define TRUNK_CAP_SENDFAX       0x00000004
00295 #define TRUNK_CAP_RECVFAX       0x00000008
00296 #define TRUNK_CAP_DATA          0x00000010
00297 #define TRUNK_CAP_TTS           0x00000020
00298 #define TRUNK_CAP_ASR           0x00000040
00299 
00300 typedef union
00301 {
00302         scriptsymbol_t sym;
00303         char data[sizeof(scriptsymbol_t) + 12];
00304 }       numbersymbol_t;
00305 
00306 typedef union
00307 {
00308         scriptsymbol_t bin;
00309         char data[sizeof(scriptsymbol_t) + 32];
00310 }       digitsymbol_t;
00311 
00312 typedef struct
00313 {
00314         
00315         int pid;
00316         unsigned seq;
00317         void *data;
00318 }       execdata_t;
00319 
00320 typedef union
00321 {
00322         struct
00323         {
00324                 int rings;
00325                 int timeout;
00326         }       answer;
00327         struct
00328         {
00329                 char list[256];
00330                 char *name;
00331                 unsigned long offset;
00332                 unsigned long limit;
00333                 unsigned char volume;
00334                 unsigned short term;
00335                 playmode_t mode;
00336                 timeout_t timeout;
00337                 unsigned repeat;
00338         }       play;
00339         struct
00340         {
00341                 char *name;
00342                 timeout_t timeout;
00343                 unsigned long offset;
00344                 unsigned short term;
00345                 unsigned char volume;
00346                 unsigned long trim;
00347                 bool append;
00348         }       record;
00349         struct
00350         {
00351                 char digits[65];
00352                 char *digit;
00353                 timeout_t interdigit;
00354                 bool exit;
00355                 timeout_t timeout;
00356                 timeout_t offhook;
00357                 timeout_t onhook;
00358         }       dialxfer;
00359         struct
00360         {
00361                 timeout_t timeout;
00362                 unsigned count;
00363                 unsigned short term;
00364                 unsigned short ignore;
00365         }       collect;
00366         struct
00367         {
00368                 timeout_t wakeup;
00369                 unsigned rings;
00370                 unsigned loops;
00371         }       sleep;
00372         struct
00373         {
00374                 timeout_t wakeup;
00375                 unsigned loops;
00376                 phTone *tone;
00377         }       tone;
00378         struct
00379         {
00380                 timeout_t wakeup;
00381                 Trunk *trunk;
00382                 phTone *tone;
00383         }       join;
00384         struct
00385         {
00386                 struct in_addr addr;
00387                 unsigned short bind, port, term;
00388                 audioencoding_t codec;
00389         }       rtp;
00390         struct
00391         {
00392                 TrunkImage *image;
00393                 const char *url;
00394                 const char *section;
00395                 char **vars;
00396                 bool post;
00397                 timeout_t timeout;
00398         }       load;
00399 }       trunkdata_t;
00400 
00401 typedef struct
00402 {
00403         trunkevent_t id;        // event id
00404         union
00405         {
00406                 struct
00407                 {
00408                         unsigned digit: 4;
00409                         unsigned duration: 12;
00410                         unsigned e1: 8;
00411                         unsigned e2: 8;
00412                 } dtmf;
00413                 struct
00414                 {
00415                         unsigned tone: 8;
00416                         unsigned energy: 8;
00417                         unsigned duration: 16;
00418                 } tone;
00419                 struct
00420                 {
00421                         unsigned digit:  4;
00422                         unsigned duration: 24;
00423                 } ring;
00424                 struct
00425                 {
00426                         unsigned seq;
00427                         bool result;
00428                         char *data;
00429                 } lookup;
00430                 int status;
00431                 Trunk *trunk;
00432                 void *data;
00433                 char **argv;
00434                 char *error;
00435                 timeout_t duration;
00436                 trunkstep_t step;
00437                 char dn[8];
00438                 dspmode_t dsp;
00439         } parm;
00440 } TrunkEvent;
00441 
00442 #pragma pack(1)
00443 
00444 typedef struct {
00445         time_t  update;
00446         char name[16];
00447         struct in_addr addr;
00448         unsigned char version;
00449         unsigned char buddies;
00450         unsigned char ports;
00451         char stat[255];
00452 }       statnode_t;
00453 
00454 #pragma pack()
00455 
00456 /* This is used to bind user defined "functions" which may be loaded
00457    in a DSO module.
00458 */
00459 
00460 typedef char *(*functioncall_t)(scriptsymbol_t *sym, char **args);
00461 
00462 typedef struct
00463 {
00464         char *name;
00465         functioncall_t function;
00466 } FUNCTIONS;
00467 
00468 
00476 class CallStat : public Mutex
00477 {
00478 protected:
00479         int capacity;
00480         struct
00481         {
00482                 int incoming;
00483                 int outgoing;
00484         }       active, max, lastmax;
00485 
00486         struct
00487         {
00488                 long incoming;
00489                 long outgoing;
00490         }       total, lasttotal;
00491 
00492 public:
00493         CallStat();
00494 
00500         inline int getCapacity(void)
00501                 {return capacity;};
00502 
00509         long getStat(statitem_t item);
00510 
00514         void incIncoming(void);
00515 
00519         void decIncoming(void);
00520 
00524         void incOutgoing(void);
00525 
00529         void decOutgoing(void);
00530 
00534         void Update(void);
00535 };
00536 
00549 class Translator : protected Keydata
00550 {
00551 private:
00552         friend Translator *getTranslator(char *name);
00553         static Translator *first;
00554         Translator *next;
00555 
00556 protected:
00562         virtual char *getName(void) = 0;
00563 
00570         char *getPlayBuffer(Trunk *trunk);
00571 
00572         void scanDir(const char *etcdir, const char *language, const char *lib);
00573 
00574         Translator(const char *conf, const char *lib);
00575 
00576 public:
00584         virtual char *Speak(Trunk *trunk) = 0;
00585 };
00586 
00600 class Functions
00601 {
00602 protected:
00608         virtual char *getName(void) = 0;
00609 
00615         void Load(FUNCTIONS *map);
00616 };
00617 
00618 /* Bayonne config file istanciation classes.  In Bayonne these are
00619    created as keydata objects out of bayonne.conf during process
00620    startup automatically.  This is Bayonne runtime configuration magic.
00621 */
00622 
00629 class KeyTones : protected Keydata
00630 {
00631 public:
00635         KeyTones();
00636 };
00637 
00645 class KeyLocal : public Keydata
00646 {
00647 public:
00651         KeyLocal();
00652 };
00653 
00660 class KeyHandlers : public Keydata
00661 {
00662 public:
00666         KeyHandlers();
00667 };
00668 
00676 class KeyPaths : public Keydata
00677 {
00678 public:
00682         KeyPaths();
00683 
00687         inline const char *getLibexec(void)
00688                 {return getLast("libexec");};
00689 
00693         inline const char *getTgipath(void)
00694                 {return getLast("tgipath");};
00695 
00699         inline const char *getLibpath(void)
00700                 {return getLast("libpath");};
00701 
00705         inline const char *getDatafiles(void)
00706                 {return getLast("datafiles");};
00707 
00711         inline const char *getWrappers(void)
00712                 {return getLast("wrappers");};
00713 
00717         inline const char *getRunfiles(void)
00718                 {return getLast("runfiles");};
00719 
00723         inline const char *getSpool(void)
00724                 {return getLast("spool");};
00725 
00729         inline const char *getScriptFiles(void)
00730                 {return getLast("scripts");};
00731 
00735         inline const char *getPromptFiles(void)
00736                 {return getLast("prompts");};
00737 
00741         inline const char *getCache(void)
00742                 {return getLast("precache");};
00743 };
00744 
00752 class KeyNetwork : public Keydata
00753 {
00754 public:
00758         KeyNetwork();
00759 
00765         unsigned getRefresh(void)
00766                 {return atoi(getLast("refresh"));};
00767 
00773         unsigned getTimeToLive(void)
00774                 {return atoi(getLast("live"));};
00775 
00781         unsigned getTimeToElect(void)
00782                 {return atoi(getLast("elect"));};
00783 
00789         unsigned getTimeToExpire(void)
00790                 {return atoi(getLast("expire"));};
00791 
00797         InetHostAddress getBroadcast(void);
00798 
00804         InetAddress getAddress(void);
00805 
00811         tpport_t getPort(void);
00812 
00818         InetHostAddress getDBHost(void);
00819 
00825         tpport_t getDBPort(void);
00826 };
00827 
00834 class KeyProxy : public Keydata
00835 {
00836 public:
00840         KeyProxy();
00841 
00847         const char *getHTTPServer(void);
00848 
00854         tpport_t getHTTPPort(void);
00855 };      
00856 
00864 class KeyMailbox : public Keydata
00865 {
00866 public:
00870         KeyMailbox();
00871 
00877         inline unsigned getCount(void)
00878                 {return atoi(getLast("count"));};
00879 
00885         inline unsigned getLimit(void)
00886                 {return atoi(getLast("limit"));};
00887 
00894         inline unsigned getQuota(void)
00895                 {return atoi(getLast("quota"));};
00896 
00902         inline unsigned getMinimum(void)
00903                 {return atoi(getLast("minimum"));};
00904 
00910         inline unsigned getMaximum(void)
00911                 {return atoi(getLast("maximum"));};
00912 
00918         inline const char *getPassword(void)
00919                 {return getLast("password");};
00920 };
00921 
00930 class KeyMemory : public Keydata
00931 {
00932 public:
00936         KeyMemory();
00937 
00943         inline int getSymbolSize(void)
00944                 {return atoi(getLast("symbols"));};
00945 
00952         inline int getPageSize(void)
00953                 {return atoi(getLast("page"));};
00954 };
00955 
00963 class KeyFeed : public Keydata
00964 {
00965 public:
00969         KeyFeed();
00970 
00976         inline unsigned getBuffers(void)
00977                 {return atoi(getLast("buffers"));};
00978 };
00979 
00980 
00988 class KeyThreads : public Keydata
00989 {
00990 public:
00994         KeyThreads();
00995 
01001         inline int priService(void)
01002                 {return atoi(getLast("services"));};
01003 
01009         inline int priScheduler(void)
01010                 {return atoi(getLast("scheduler"));};
01011 
01017         inline int priGUI(void)
01018                 {return atoi(getLast("gui"));};
01019 
01025         inline int priRTP(void)
01026                 {return atoi(getLast("rtp"));};
01027 
01033         inline int getStepDelay(void)
01034                 {return atoi(getLast("stepdelay"));};
01035 
01041         inline int getStepInterval(void)
01042                 {return atoi(getLast("stepinterval"));};
01043 
01049         inline int getResetDelay(void)
01050                 {return atoi(getLast("resetdelay"));};
01051 
01057         size_t getStack(void);
01058 
01064         int getServices(void);
01065 
01071         int priResolver(void);
01072 
01079         int getResolver(void);
01080 
01086         inline int priAudio(void)
01087                 {return atoi(getLast("audio"));};
01088 
01094         inline int priFeed(void)
01095                 {return atoi(getLast("feed"));};
01096 
01102         inline int priGateway(void)
01103                 {return atoi(getLast("gateways"));};
01104 
01110         inline int priManager(void)
01111                 {return atoi(getLast("managers"));};
01112 
01118         inline int priNetwork(void)
01119                 {return atoi(getLast("network"));};
01120 
01126         inline int priXML(void)
01127                 {return atoi(getLast("xml"));};
01128 
01134         inline int getInterval(void)
01135                 {return atoi(getLast("interval"));};
01136 
01142         inline int getRefresh(void)
01143                 {return atoi(getLast("refresh"));};
01144 
01150         int getGateways(void);
01151         
01158         inline int getPriority(void)
01159                 {return atoi(getLast("priority"));};
01160 
01166         int getPolicy(void);
01167 
01173         inline int getPages(void)
01174                 {return atoi(getLast("pages"));};
01175 };
01176 
01184 class Auditdata : public Keydata
01185 {
01186 private:
01187         friend class Audit;
01188 
01189         Auditdata();
01190 };
01191 
01200 class Policy
01201 {
01202 private:
01203         friend class TrunkGroup;
01204 
01205         Policy *next;
01206         TrunkGroup *group;
01207 
01208 protected:
01209         Policy(TrunkGroup *grp);
01210         
01211         virtual Request *loPriority(void)
01212                 {return NULL;};
01213 
01214         virtual Request *hiPriority(void)
01215                 {return NULL;};
01216 };
01217 
01227 class Request
01228 {
01229 private:
01230         friend class TrunkGroup;
01231 
01232         static unsigned seq;
01233 
01234         unsigned id;
01235         Request *next;
01236         time_t expires;
01237         TrunkGroup *group;
01238 
01239         char *argv[33];
01240         char buffer[512];
01241         char tagid[65];
01242 
01243         void Detach(void);
01244 
01245 public:
01246         Request(TrunkGroup *grp, const char *text, unsigned expire, const char *tag = NULL);
01247         ~Request()
01248                 {Detach();};
01249 
01250         inline char **getList(void)
01251                 {return argv;};
01252 
01253         inline char *getTag(void)
01254                 {return tagid;};
01255 
01256         bool isExpired(void);
01257 
01258         friend void cancel(TrunkGroup *group, const char *tag);
01259         friend Request *request(TrunkGroup *group, char **argv, unsigned timeout, const char *tag = NULL);
01260         friend Request *locate(TrunkGroup *group, const char *tag, int *pos);
01261 };
01262 
01273 class TrunkGroup : public Keydata, public CallStat
01274 {
01275 private:
01276         friend class KeyServer;
01277         friend class Scheduler;
01278         friend class Audit;
01279         friend class TestDebug;
01280         friend class Request;
01281         friend class Policy;
01282         friend class Trunk;
01283         static TrunkGroup *first;
01284         TrunkGroup *next;
01285         char schedule[65];
01286         char planned[65];
01287         unsigned trump;
01288         Request *reqfirst, *reqlast;
01289         Policy *polFirst;
01290         unsigned members;
01291 
01292         void setSchedule(const char *str);
01293 
01294         friend inline const char *getGroups(void)
01295                 {return TrunkGroup::first->getLast("groups");};
01296 
01297         friend void cancel(TrunkGroup *group, const char *tag);
01298         friend Request *locate(TrunkGroup *group, const char *tag, int *pos = NULL);
01299 
01300 
01301 public:
01307         TrunkGroup(char *name = NULL);
01308 
01314         inline const char *getName(void)
01315                 {return getLast("name");};
01316 
01322         inline unsigned getAnswer(void)
01323                 {return atoi(getLast("answer"));};
01324 
01330         bool getDetect(void);
01331 
01337         inline unsigned getCallerid(void)
01338                 {return atoi(getLast("callerid"));};
01339 
01345         inline unsigned getPickup(void)
01346                 {return atoi(getLast("pickup"));};
01347 
01353         inline const char *chkRequest(void)
01354                 {return getLast("requests");};
01355 
01361         seltype_t getSelect(void);
01362 
01368         inline unsigned getThreashold(void)
01369                 {return atoi(getLast("threashold"));};
01370 
01376         inline unsigned getAnalysis(void)
01377                 {return atoi(getLast("analysis"));};
01378 
01385         inline timeout_t getReady(void)
01386                 {return atol(getLast("ready"));};
01387         
01393         inline unsigned getIdleTime(void)
01394                 {return atoi(getLast("idletime"));};
01395 
01401         inline unsigned getSiezeTime(void)
01402                 {return atoi(getLast("siezetime"));};
01403 
01409         inline unsigned getRingTime(void)
01410                 {return atoi(getLast("ringtime"));};
01411 
01417         inline int getHangup(void)
01418                 {return atoi(getLast("hangup"));};
01419 
01425         inline timeout_t getFlash(void)
01426                 {return atol(getLast("flash"));};
01427 
01433         inline timeout_t getDialtone(void)
01434                 {return atol(getLast("dialtone"));};
01435 
01441         inline timeout_t getDialspeed(void)
01442                 {return atol(getLast("dialspeed"));};
01443 
01450         const char *getNumber(void);
01451 
01458         const char *getSchedule(char *buf);
01459 
01469         const char *getRedirect(const char *redirect, char *buf);
01470 
01474         inline void incCapacity(void)
01475                 {++capacity;};
01476 
01482         Request *getRequest(void);
01483 
01489         friend TrunkGroup *getGroup(const char *name);
01490 };
01491 
01499 class KeyServer : public Keydata
01500 {
01501 private:
01502         unsigned uid, gid;
01503         const char *altdir;
01504         const char *phrdir;
01505 
01506 public:
01510         KeyServer();
01511 
01517         inline const char *getNode(void)
01518                 {return getLast("node");};
01519 
01525         inline const char *getPassword(void)
01526                 {return getLast("password");};
01527 
01533         inline const char *getToken(void)
01534                 {return getLast("token");};
01535 
01539         void loadGroups(bool test);
01540 
01546         inline const char *getDefault(void)
01547                 {return getLast("default");};
01548 
01554         inline unsigned getGid(void)
01555                 {return gid;};
01556 
01562         inline unsigned getUid(void)
01563                 {return uid;};
01564 
01568         void setUid(void);
01569 
01573         void setGid(void);
01574 
01580         inline int getNodeCount(void)
01581                 {return atoi(getLast("nodes"));};
01582 
01588         inline const char *getPrefix(void)
01589                 {return altdir;};
01590 
01596         inline const char *getPhrases(void)
01597                 {return phrdir;};
01598 };
01599 
01607 class Plugins : public Keydata
01608 {
01609 public:
01613         Plugins();
01614 
01618         ~Plugins();
01619 
01625         char *getDriverName(void);
01626 
01630         void loadXML(void);
01631 
01635         void loadDebug(void);
01636 
01641         DSO *loadDriver(void);
01642 
01646         void loadExtensions(void);
01647 
01651         void loadFunctions(void);
01652 
01656         void loadMaps(void);
01657 
01661         void loadModules(void);
01662 
01666         void loadServices(void);
01667 
01671         void loadFeeds(void);
01672 
01676         void loadTGI(void);
01677 
01681         void loadManagers(void);
01682 
01686         void loadTranslators(void);
01687 
01691         void loadAuditing(void);
01692 };
01693 
01702 class aaScript : public ScriptCommand 
01703 {
01704 private:
01705         friend class Functions;
01706 
01707 #pragma pack(1)
01708         typedef struct _functions
01709         {
01710                 struct _functions *next;
01711                 functioncall_t function;
01712                 char name[1];
01713         }       functions_t;
01714 #pragma pack()
01715 
01716         functions_t *functions[KEYWORD_INDEX_SIZE];
01717 
01718 protected:
01726         unsigned long getTrapMask(const char *trapname);
01727 
01735         void addFunction(char *name, functioncall_t function);
01736 
01737 public:
01744         functioncall_t getFunction(char *name);
01745 
01749         aaScript();
01750 
01756         void addModule(Module *module);
01757 };
01758 
01768 class aaImage : public ScriptImage
01769 {
01770 protected:
01778         virtual bool isScript(char *scriptname);
01779 
01786         void scanDir(char *path);
01787 
01788 public:
01792         aaImage(aaScript *script);
01793 };
01794 
01801 class Mixer : protected Mutex
01802 {
01803 private:
01804         friend class Conference;
01805         void addGroup(void);
01806         void delGroup(void);
01807 
01808 protected:
01809         Mixer();
01810         unsigned avail, members, groups;
01811 
01812 public:
01813         unsigned getAvail(void)
01814                 {return avail;};
01815 
01816         unsigned getMembers(void)
01817                 {return members;};
01818 
01819         unsigned getGroups(void)
01820                 {return groups;};
01821 
01822         virtual bool setMixer(int groups, int members) = 0;
01823 
01824         virtual Conference *getConference(int group) = 0;
01825 };
01826 
01835 class Conference : protected Mutex
01836 {
01837 protected:
01838         Mixer *mixer;
01839         unsigned limit;
01840         unsigned members;
01841         int *membership;
01842 
01843         virtual ~Conference();
01844 
01845         Conference(Mixer *m);
01846 public:
01847         inline virtual Mixer *getMixer(void)
01848                 {return mixer;};
01849 
01850         int *getMembership(void)
01851                 {return membership;};
01852 
01853         Trunk *getTrunk(unsigned member);
01854 
01855         unsigned getMembers(void)
01856                 {return members;};
01857 
01858         unsigned getLimit(void)
01859                 {return limit;};
01860 
01861         virtual bool setConference(unsigned max) = 0;
01862 };
01863 
01871 class TrunkImage : public ScriptImage, protected URLStream, protected XMLStream
01872 {
01873 private:
01874         char *attrib[65];
01875 
01876         int Read(unsigned char *buffer, int len);
01877 
01878 protected:
01879         void Close(void)
01880                 {return URLStream::Close();};
01881 
01882         typedef struct
01883         {
01884                 scriptname_t *script;
01885                 scriptline_t *last;
01886                 unsigned line;
01887                 unsigned long addmask, submask, trapmask;
01888                 unsigned char loopid[65], looplevel[65];
01889                 unsigned trap;
01890                 void *data;     // extra state data in derived use
01891         } compile_t;
01892 
01893         compile_t *main, *current;
01894 
01900         void getCompile(const char *name = "#");
01901 
01907         void setCompile(unsigned trap);
01908 
01914         void putCompile(compile_t *cc);
01915 
01923         void addCompile(unsigned long mask, const char *cmd, const char **args);
01924 
01930         void setToken(const unsigned char **attrib);
01931 
01937         const char *getToken(void);
01938 
01944         virtual unsigned long getDefaultMask(void)
01945                 {return 3;};
01946 
01955         const char *getAttribute(const char *key, const char *value = NULL);
01956         
01957 public:
01961         TrunkImage();
01962 
01963         virtual ~TrunkImage()
01964                 {Purge();};
01965 
01972         void setProxy(const char *addr, tpport_t port)
01973                 {URLStream::setProxy(addr, port);};
01974 
01983         virtual bool Loader(trunkdata_t *data) = 0;
01984 
01988         void Purge(void);
01989 
01996         void *alloc(unsigned size) 
01997                 {return MemPager::alloc(size);};
01998 };
01999 
02009 class Trunk : public ScriptInterp
02010 {
02011 private:
02012         friend class TestDebug;
02013         friend class aaScript;
02014         friend class Translator;
02015         friend class ScriptInterface;
02016         friend class Service;
02017         friend class AudioService;
02018         friend class Fifo;
02019         friend class PortManager;
02020 
02021         unsigned member;
02022         char *cdrv[33];
02023         int cdrc;
02024         numbersymbol_t numbers[5];
02025         TrunkImage *altimage;
02026 
02027         bool scrStart(void);
02028         bool scrRequest(void);
02029         bool scrLibexec(void);
02030         bool scrHangup(void);
02031         bool scrDebug(void);
02032         bool scrImport(void);
02033         bool scrExport(void);
02034         bool scrFunction(void);
02035         bool scrAlog(void);
02036         bool scrAudit(void);
02037         bool scrPause(void);
02038         bool scrSleep(void);
02039         bool scrSync(void);
02040         bool scrTone(void);
02041         bool scrAnswer(void);
02042         bool scrCollect(void);
02043         bool scrFlash(void);
02044         bool scrSay(void);
02045         bool scrCleardigits(void);
02046         bool scrAssign(void);
02047         bool scrInsert(void);
02048         bool scrDelete(void);
02049         bool scrReplace(void);
02050         bool scrPrefix(void);
02051         bool scrChop(void);
02052         bool scrTrim(void);
02053         bool scrPlay(void);
02054         bool scrLoad(void);
02055         bool scrRecord(void);
02056         bool scrDial(void);
02057         bool scrDTMF(void);
02058         bool scrTransfer(void);
02059         bool scrHold(void);
02060         bool scrSpeak(void);
02061         bool scrMap(void);
02062         bool scrModule(void);
02063         bool scrSchedule(void);
02064         bool scrSignal(void);
02065         bool scrIdle(void);
02066 
02067         scriptname_t *getScriptImage(const char *name);
02068 
02069 protected:
02070         static ScriptSymbol globals;
02071         static char digit[16];
02072         ScriptInterface *script;
02073         TrunkGroup *group;
02074         PortManager *manager;
02075         int id;
02076         time_t start, idle;
02077 
02078         int idle_timer;
02079         int rings;
02080         int digits;
02081 
02082         Service *thread;
02083         trunkdata_t data;
02084         execdata_t tgi;
02085         digitsymbol_t dtmf;
02086         char buffer[65];
02087 
02088         struct
02089         {
02090                 bool offhook: 1;
02091                 bool dtmf: 1;
02092                 bool script: 1;
02093                 bool reset: 1;
02094                 bool timer : 1;
02095                 bool audio: 1;
02096                 bool once : 1;
02097                 bool ready : 1;
02098                 bool echo : 1;
02099                 unsigned temp : 1;
02100                 trunkmode_t trunk: 2;
02101                 dspmode_t dsp: 4;
02102         } flags;
02103 
02109         unsigned long getTrapDefault(void)
02110                 {return 0x00000007;};
02111 
02120         void setConstant(const char *id, const char *data);
02121 
02128         void repSymbol(const char *id, const char *data);
02129 
02137         scriptsymbol_t *getEntry(const char *symname, int size);
02138 
02144         void Commit(scriptsymbol_t *sym);
02145 
02155         timeout_t getTimeout(void);
02156 
02163         timeout_t getInterdigit(void);
02164 
02170         unsigned short getDigitMask(void);
02171 
02177         bool TrunkSignal(trunksignal_t);
02178 
02185         virtual void setDTMFDetect(void);
02186 
02195         virtual void setDTMFDetect(bool enable)
02196                 {flags.dtmf = enable;};
02197 
02203         virtual void stopServices(void);
02204 
02215         virtual void TrunkStep(trunkstep_t step) = 0;
02216 
02222         bool idleHangup();
02223 
02230         virtual unsigned long getIdleTime(void) = 0;
02231 
02235         bool ScriptStep(void);
02236 
02245         bool Attach(const char *scrname);
02246 
02251         void Detach(void);
02252 
02256         unsigned long getMask(void);
02257 
02264         char **getInitial(char **args);
02265 
02272         void setList(char **list);
02273 
02274         Trunk(int port);
02275 public:
02281         virtual unsigned long getCapabilities(void)
02282                 {return TRUNK_CAP_VOICE | TRUNK_CAP_DIAL;};
02283 
02289         virtual void getName(char *buffer) = 0;
02290 
02298         virtual bool postEvent(TrunkEvent *event) = 0;
02299 
02305         int getDigit(char digit);
02306 
02312         bool isReady(void);
02313 
02321         void libexec(char **argv, unsigned timeout);
02322 
02330         void libtts(const char *msg, ttsmode_t mode);
02331 
02335         inline bool getOnce(void)
02336                 {return ScriptInterp::getOnce();};
02337 
02343         inline unsigned getMemberId(void)
02344                 {return member;};
02345 
02346 };
02347 
02356 class PortManager
02357 {
02358 private:
02359         Trunk *trunk;
02360 
02361 protected:
02362         ~PortManager()
02363                 {trunk->manager = NULL;};
02364 
02370         PortManager(Trunk *trk);
02371 
02377         inline void postStep(trunkstep_t step)
02378                 {trunk->TrunkStep(step);};
02379 
02386         inline bool postEvent(TrunkEvent *event)
02387                 {return trunk->postEvent(event);};
02388 
02394         inline trunkdata_t *getData(void)
02395                 {return &trunk->data;};
02396 
02402         inline execdata_t *getExec(void)
02403                 {return &trunk->tgi;};
02404 public:
02408         virtual bool Step(void) = 0;
02409 
02415         virtual unsigned long getMask(void) = 0;
02416         
02423         virtual bool postSignal(trunksignal_t signal) = 0;
02424 
02431         virtual bool postAccept(const char *name) = 0;
02432 
02436         virtual void postDetach(void) = 0;
02437 };
02438 
02448 class Fifo : public fifostream, public Mutex
02449 {
02450 protected:
02451         char schedule[33];
02452 
02453         bool exitPid(char **args);
02454         bool waitPid(char **args);
02455         bool setSymbol(char **argv);
02456         bool putSymbol(char **argv);
02457 
02458         bool login(char **argv);
02459         bool startScript(char **argv);
02460         bool ringScript(char **argv);
02461         bool redirectScript(char **argv);
02462         bool busyLine(char **argv);
02463         bool idleLine(char **argv);
02464         bool hangupLine(char **argv);
02465         bool reqScript(char **argv);
02466         bool setSchedule(char **argv);
02467         bool postKey(char **argv);
02468         bool setMixer(char **argv);
02469         bool setLimit(char **argv);
02470         bool mapFiles(char **argv);
02471         bool submit(char **argv);
02472         bool reload(char **argv);
02473 
02474 public:
02483         bool Command(const char *cmdstring, ostream *fd = NULL);
02484 };
02485 
02499 class Audit : public Mutex
02500 {
02501 private:
02502         friend void audit(Trunk *trunk, char *detail);
02503         friend void alog(Trunk *trunk, char *detail);
02504         friend class Scheduler;
02505 
02506         static Audit *first;
02507         Audit *next;
02508 
02509 protected:
02510         static Auditdata keys;
02511 
02517         virtual void ReportAudit(Trunk *trunk, char *detail) = 0;
02518 
02524         virtual void ReportCDR(Trunk *trunk, char *detail)
02525                 {ReportAudit(trunk, detail);};
02526 
02530         virtual void ReportStats(void)
02531                 {return;};
02532 
02538         inline TrunkGroup *getFirst(void)
02539                 {return TrunkGroup::first;};
02540 
02547         inline TrunkGroup *getNext(TrunkGroup *grp)
02548                 {return grp->next;};
02549 
02553         Audit();
02554 };
02555 
02563 class Driver : public aaScript
02564 {
02565 protected:
02566         friend class TrunkGroup;
02567 
02568         TrunkGroup **groups;
02569         char *status;
02570         bool active;
02571 
02572 public:
02576         Driver();
02577 
02584         virtual int Start(void) = 0;
02585 
02589         virtual void Stop(void) = 0;
02590 
02596         void getStatus(char *buffer);
02597 
02604         virtual aaImage *getImage(void);
02605 
02612         virtual int getTrunkCount(void) = 0;
02613 
02620         virtual int getTrunkUsed(void) 
02621                 {return getTrunkCount();};
02622 
02629         TrunkGroup *getTrunkGroup(int id)
02630                 {return groups[id];}; 
02631 
02639         int getTrunkMember(TrunkGroup *grp, unsigned member);
02640         
02646         virtual Trunk *getTrunkPort(int id) = 0;
02647 
02653         virtual Conference *getConference(int id)
02654                 {return NULL;};
02655 
02661         virtual Mixer *getMixer(int id)
02662                 {return NULL;};
02663 
02669         virtual unsigned getMixers(void)
02670                 {return 0;};
02671 
02677         virtual unsigned getGroups(void)
02678                 {return 0;};
02679 };
02680 
02687 class Debug : protected Mutex
02688 {
02689 public:
02693         Debug();
02694 
02700         virtual bool DebugTest(void)
02701                 {return false;};
02702 
02706         virtual void DebugEvent(Trunk *trunk, TrunkEvent *event)
02707                 {return;};
02708 
02712         virtual void DebugState(Trunk *trunk, char *state)
02713                 {return;};
02714 
02718         virtual void DebugService(Trunk *trunk, char *msg)
02719                 {return;};
02720 
02724         virtual void DebugScript(Trunk *trunk, char *msg)
02725                 {return;};
02726 
02730         virtual void DebugStep(Trunk *trunk, scriptline_t *line)
02731                 {DebugState(trunk, "step");};
02732 
02736         virtual bool DebugFifo(char **argv)
02737                 {return true;};
02738 };
02739 
02746 class AudioService
02747 {
02748 private: 
02749         char filename[256];
02750 
02751 protected:
02752         Trunk *trunk;
02759         char *getPrompt(char *name);
02760 
02766         char *getPlayfile(void);
02767 
02771         AudioService(void);
02772 };
02773 
02781 class Service : public Semaphore, public Thread, public AudioService
02782 {
02783 protected:
02784         volatile bool stopped;
02785         trunkdata_t *data;
02786         TrunkGroup *group;
02787 
02791         void Success(void);
02792 
02796         void Failure(void);
02797 
02801         inline void dspReset(void)
02802                 {trunk->flags.reset = true;};
02803 
02807         inline void setAudio(void)
02808                 {trunk->flags.audio = true;};
02809 
02813         inline void clrAudio(void)
02814                 {trunk->flags.audio = false;};
02815 
02816 public:
02823         Service(Trunk *trunk, int pri);
02824 
02831         virtual timeout_t Stop(void);
02832 
02840         virtual bool isExiting(void)
02841                 {return true;};
02842 
02846         void endService(void)
02847                 {Terminate();};
02848 
02852         virtual ~Service()
02853                 {Terminate();}
02854 };
02855 
02863 class XMLService : public Service
02864 {
02865 private:
02866         void Run(void);
02867 
02868 public:
02869         XMLService(Trunk *trk);
02870         ~XMLService();
02871 };
02872 
02882 class Server : public Thread
02883 {
02884 private:
02885         static Server *first;
02886         Server *next;
02887         friend void startServers(void);
02888         friend void stopServers(void);
02889 
02890 protected:
02891         Server(int pri);
02892 
02896         virtual void Stop(void)
02897                 {Terminate();};
02898 };
02899 
02906 class Sync
02907 {
02908 private:
02909         friend class Scheduler;
02910 
02911         static Sync *first;
02912         Sync *next;
02913         time_t runtime;
02914 
02915 protected:
02919         Sync(void);
02920 
02925         virtual bool isScheduled(void) = 0;
02926 
02931         virtual unsigned getInterval(void)
02932                 {return 10;};
02933 
02937         virtual void Schedule(void) = 0;
02938 
02942         virtual char *getName(void) = 0;
02943 };
02944 
02953 class phTone
02954 {
02955 private:
02956         friend phTone *getphTone(const char *name);
02957         static phTone *first;
02958         static int ulaw[256];
02959         phTone *next;
02960         char name[33];
02961         unsigned char *samples;
02962         timeout_t duration;
02963         unsigned freq1, freq2;
02964 
02965 public:
02973         phTone(const char *name, timeout_t duration, unsigned f);
02974 
02983         phTone(const char *name, timeout_t duration, unsigned f1, unsigned f2);
02984 
02985         ~phTone();
02986 
02992         void Clear(void);
02993 
02999         inline unsigned char *getSamples(void)
03000                 {return samples;};
03001 
03007         inline timeout_t getDuration(void)
03008                 {return duration;};
03009 };
03010 
03017 class TGI
03018 {
03019 private:
03020         static TGI *first;
03021         TGI *next;
03022 
03023 protected:
03024         TGI();
03025 
03033         virtual bool getExtension(char *ext)
03034                 {return false;};
03035 
03036 public:
03046         virtual void Script(char *cmd, char **args)
03047                 {return;};
03048 
03057         virtual int Parse(int fd, int port, char *cmd)
03058                 {return -1;};   
03059 
03060         friend void getInterp(char *cmd, char **args);
03061         friend TGI *getInterp(char *cmd);
03062 };
03063 
03064 extern Module *tts, *asr;
03065 
03075 class Module
03076 {
03077 private:
03078         friend class Fifo;
03079         friend class AudioService;
03080         friend class TrunkGroup;
03081         friend class Network;
03082 
03083         static Module *modFirst, *sesFirst, *cmdFirst, *urlFirst, *reqFirst, *netFirst;
03084         Module *modNext, *sesNext, *cmdNext, *urlNext, *reqNext, *netNext;
03085 
03086 protected:
03087         Module();
03088 
03089         inline Module *getFirst(void)
03090                 {return modFirst;};
03091 
03097         virtual modtype_t getType(void) = 0;
03098 
03102         void addSession(void);
03103 
03107         void addCommand(void);
03108 
03112         void addPrompts(void);
03113 
03117         void addNetwork(void);
03118 
03122         void addRequest(void);
03123         
03127         inline void enableTTS(void)
03128                 {tts = this;};
03129 
03133         inline void enableASR(void)
03134                 {asr = this;};
03135 
03136 
03137 
03141         virtual char *getPrompt(const char *original)
03142                 {return NULL;};
03143 
03147         virtual void Expires(Request *request)
03148                 {return;};
03149 
03153         virtual void Running(Request *request)
03154                 {return;};
03155 
03159         virtual void Cancelled(Request *request)
03160                 {return;};
03161 
03171         virtual int Accept(char *buffer, socklen_t len, statnode_t *node)
03172                 {return 0;};
03173 
03179         virtual void Failover(statnode_t *node)
03180                 {return;};
03181 
03185         virtual void Broadcast(void)
03186                 {return;};
03187 
03188         friend void broadcast(char *msgbuf, unsigned msglen);
03189         friend void cancel(TrunkGroup *grp, const char *tag);
03190 public:
03191         inline Module *getNext(void)
03192                 {return modNext;};
03193 
03199         virtual char *getName(void) = 0;
03200 
03208         virtual char *Dispatch(Trunk *trunk)
03209                 {return NULL;};
03210 
03218         virtual unsigned Sleep(Trunk *trunk)
03219                 {return 0;};
03220 
03227         virtual void Detach(Trunk *trunk)
03228                 {return;};
03229 
03237         virtual void Attach(Trunk *trunk)
03238                 {return;};
03239 
03246         virtual TrunkImage *getXML(void)
03247                 {return NULL;};
03248 
03256         virtual AudioSample *getPhrase(Trunk *trunk, const char *phrase)
03257                 {return NULL;};
03258 
03269         virtual const char *getSpeech(Trunk *trunk, char **domain, unsigned long mask, AudioSample *sample)
03270                 {return NULL;};
03271 
03275         virtual void Reload(void)
03276                 {return;};
03277 
03281         virtual bool Command(char **argv, ostream *out)
03282                 {return false;};
03283 
03284         friend Module *getModule(modtype_t mod, const char *name = NULL);
03285         friend void detachModules(Trunk *trunk);
03286         friend void attachModules(Trunk *trunk);
03287 };
03288 
03298 class Session
03299 {
03300 private:
03301         friend class Scheduler;
03302         static Mutex mutex;
03303         static Session *first;
03304         static Session *last;
03305         Session *next, *prev;
03306         static void Clean(void);
03307 
03308 protected:
03309         Session();
03310         virtual ~Session()
03311                 {Unlink();};
03312 
03316         void Unlink(void);
03317 
03324         virtual time_t getExpires(void) = 0;
03325 };
03326 
03335 class AudioFeed : private ThreadLock
03336 {
03337 private:
03338         static AudioFeed *first;
03339         AudioFeed *next;
03340         unsigned char *buffers;
03341         volatile unsigned char *current;
03342         size_t feedsize, bufsize;
03343         bool active;
03344 
03345 protected:
03346         const char *name;
03347 
03348 public:
03349         AudioFeed(const char *name, unsigned buffers);
03350         ~AudioFeed();
03351         bool Enable(void);
03352         void Disable(void);
03353         unsigned char *getBuffer(unsigned char *prior = NULL, unsigned size = 120);
03354         void putBuffer(unsigned char *buffer, unsigned size = 120);
03355 
03356         friend AudioFeed *getAudioFeed(const char *name);
03357 };
03358 
03367 class Map : private MemPager
03368 {
03369 private:
03370         static ThreadLock lock;
03371         static Map *first, *last;
03372 
03373         typedef struct _sym
03374         {
03375                 struct _sym *next;
03376                 char *key;
03377                 char **values;
03378         }       mapsym_t;
03379 
03380         typedef struct
03381         {
03382                 mapsym_t *keys[127];
03383         } mapkey_t;
03384 
03385         mapkey_t *digits[32];
03386 
03387         Map *next, *prev;
03388         char *name;
03389 
03390         unsigned getKey(const char *key, unsigned len = 0);
03391         char **getList(const char *key, unsigned len);
03392         ~Map();
03393 
03394 public:
03395         Map(const char *path, const char *name);
03396 
03397         friend char **getMap(const char *map, const char *key, mapmode_t  mode);
03398         friend void endMaps(void);
03399 };
03400 
03409 class Protocol : public Keydata, public InetHostAddress, public ThreadLock
03410 {
03411 private:
03412         friend class Resolver;
03413         static Protocol *first;
03414         Protocol *next;
03415         Semaphore *sessions;
03416         tpport_t port;
03417 
03418         void Update(InetHostAddress addr);
03419 public:
03420         Protocol(const char *keypath, tpport_t port);
03421         ~Protocol();
03422 
03428         InetHostAddress getAddress(void);
03429 
03435         inline tpport_t getPort(void)
03436                 {return port;};
03437 
03444         inline Semaphore *getSessions(void)
03445                 {return sessions;};
03446 };
03447 
03448 statnode_t *getNodes(const char *name);
03449 timeout_t getTimeout(const char *string);
03450 bool getLogical(const char *string);
03451 
03452 extern bool running;
03453 extern Keydata application;
03454 extern KeyServer keyserver;
03455 extern KeyThreads keythreads;
03456 extern KeyMemory keymemory;
03457 extern KeyPaths keypaths;
03458 extern KeyLocal keylocal;
03459 extern KeyNetwork keynetwork;
03460 extern KeyMailbox keymailbox;
03461 extern KeyProxy keyproxy;
03462 extern KeyTones keytones;
03463 extern KeyFeed keyfeed;
03464 extern KeyHandlers keyhandlers;
03465 extern Plugins plugins;
03466 extern Driver *driver;
03467 extern Debug *debug;
03468 extern Module *asr, *tts;
03469 extern Fifo fifo;
03470 #endif
03471 

Generated at Wed Apr 25 22:24:40 2001 for Bayonne by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000