00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef CCXX_LIBEXEC_H_
00039 #define CCXX_LIBEXEC_H_
00040
00041 #ifndef CCXX_BAYONNE_H_
00042 #include <cc++/bayonne.h>
00043 #endif
00044
00045 #ifndef CCXX_SLOG_H_
00046 #include <cc++/slog.h>
00047 #endif
00048
00049 #ifndef CCXX_PROCESS_H_
00050 #include <cc++/process.h>
00051 #endif
00052
00053 namespace ost {
00054
00063 class __EXPORT Libexec : public Bayonne
00064 {
00065 protected:
00066 Keydata head, args;
00067 const char *tsid;
00068 const char *voice;
00069 Audio::Level level;
00070
00071 public:
00072 result_t result;
00073 char digits[64];
00074 char query[512];
00075 char position[32];
00076 unsigned exitcode, reply;
00077
00081 Libexec();
00082
00089 const char *getEnv(const char *id);
00090
00097 const char *getArg(const char *id);
00098
00107 const char *getPath(const char *filename, char *buffer, unsigned size);
00108
00115 const char *getFile(const char *filename);
00116
00122 inline void setVoice(const char *voice)
00123 {voice = voice;};
00124
00130 inline void setLevel(Audio::Level level)
00131 {level = level;};
00132
00136 void hangupSession(void);
00137
00141 void detachSession(unsigned code);
00142
00151 result_t sendCommand(const char *text, char *buffer = NULL, unsigned size = 0);
00152
00159 result_t sendResult(const char *text);
00160
00166 void sendError(const char *msg);
00167
00174 result_t xferCall(const char *dest);
00175
00182 result_t replayFile(const char *file);
00183
00191 result_t replayOffset(const char *file, const char *offset);
00192
00201 result_t recordFile(const char *file, timeout_t duration, timeout_t silence = 0);
00202
00209 result_t speak(const char *format, ...);
00210
00219 result_t playTone(const char *name, timeout_t duration = 0, unsigned level = 0);
00220 result_t playSingleTone(short f1, timeout_t duration, unsigned level = 0);
00221 result_t playDualTone(short f1, short f2, timeout_t duration, unsigned level = 0);
00222
00232 result_t recordOffset(const char *file, const char *offset, timeout_t duration, timeout_t silence = 0);
00233
00240 result_t eraseFile(const char *file);
00241
00249 result_t moveFile(const char *file1, const char *file2);
00250
00254 result_t clearInput(void);
00255
00261 bool waitInput(timeout_t timeout);
00262
00271 result_t readInput(char *buffer, unsigned size, timeout_t timeout);
00272
00279 char readKey(timeout_t timeout);
00280
00281 result_t sizeSym(const char *id, unsigned size);
00282 result_t addSym(const char *id, const char *value);
00283 result_t setSym(const char *id, const char *value);
00284 result_t getSym(const char *id, char *buf, unsigned size);
00285
00293 void postSym(const char *id, const char *value);
00294 };
00295
00296 class __EXPORT BayonneTSession : public BayonneSession
00297 {
00298 protected:
00299 friend class __EXPORT BayonneSysexec;
00300
00301 void sysPost(const char *sid, char *id, const char *value);
00302 void sysVar(const char *tsid, char *id, const char *value, int size);
00303 void sysHeader(const char *tsid);
00304 void sysArgs(const char *tsid);
00305 void sysStatus(const char *tsid);
00306 void sysRecord(const char *tsid, char *token);
00307 void sysReplay(const char *tsid, char *token);
00308 void sysFlush(const char *tsid);
00309 void sysWait(const char *tsid, char *token);
00310 void sysTone(const char *tsid, char *token);
00311 void sysSTone(const char *tsid, char *token);
00312 void sysDTone(const char *tsid, char *token);
00313 void sysPrompt(const char *tsid, const char *voice, const char *text);
00314 void sysInput(const char *tsid, char *token);
00315 void sysHangup(const char *tsid);
00316 void sysExit(const char *tsid, char *token);
00317 void sysError(const char *tsid, char *token);
00318 void sysReturn(const char *tsid, const char *text);
00319 void sysXfer(const char *tsid, const char *dest);
00320 };
00321
00328 class __EXPORT BayonneSysexec : protected Thread, protected Bayonne
00329 {
00330 private:
00331 static bool exiting;
00332 #ifndef WIN32
00333 static int iopair[2];
00334 #endif
00335 static BayonneSysexec *libexec;
00336
00337 static void readline(char *buf, unsigned max);
00338
00339 void run(void);
00340
00341 BayonneSysexec();
00342 ~BayonneSysexec();
00343
00344 public:
00345 static bool create(BayonneSession *s);
00346 static void allocate(const char *path, size_t bs = 0, int pri = 0, const char *modpath = NULL);
00347 static void cleanup(void);
00348 static void startup(void);
00349 };
00350
00351 };
00352
00353 #endif