File: incall.h

package info (click to toggle)
speaker 1.0.1-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 264 kB
  • ctags: 174
  • sloc: cpp: 1,521; tcl: 786; makefile: 91; sh: 22
file content (131 lines) | stat: -rw-r--r-- 3,371 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//************************************************************
// Include all files necessary for the voice modem operation
//************************************************************
// 

#include <stdio.h>
#include <string.h>
#include <fcntl.h>

#include <termios.h>

#include <unistd.h>
#include <time.h>

#ifndef _NOSTDLIB_H
#include <stdlib.h>
#endif

#include <errno.h>
#include <signal.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netdb.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <syslog.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#ifdef NAME_MAX
#define MAXFILENAME (NAME_MAX+1)
#else
#define MAXFILENAME 255;
#endif

#define PUBDTMFSIZE 1024

// Timer flag
extern int iTimedOut;
void timeout(int);

#include "config.h"
#include "cmdsequence.h"
#include "commandset.h"
#include "smodlib.h"
#include "locks.h"

// Error response should include new line (temporarily)
#define ERROR_CMD                "ERROR\015\012"

#define  THREE_RETRY for(i=0;i<3&&(ret==-1||i==0);i++)
#define  MIN(x,y) (((x)<(y))?(x):(y))

#define  PREP_ALARM int oldTime, oldTimeOut, pendingAl;

// Set a new alarm and save info about pending one if necessary
#define  SET_ALARM(x)   oldTime = alarm(MsgExchTimeOut);\
                        oldTimeOut = iTimedOut;\
                        iTimedOut = 0;\
                        if (oldTime != 0) {\
                           pendingAl = 1;\
                           oldTime -= MsgExchTimeOut;\
                        } else pendingAl = 0; 

#define  RESET_ALARM iTimedOut = alarm(0);\
                     if (pendingAl){\
                        oldTime += iTimedOut;\
                        if (oldTime > 0){\
                           iTimedOut = oldTimeOut;\
                           alarm(oldTime);\
                        } else iTimedOut = 1;\
                     } else iTimedOut = oldTimeOut;

class GlobInit
{
   private:
      void PrepareAll(); // Global init function
      void CloseAll(); // Global init function
   public:
      GlobInit(){PrepareAll();}
      ~GlobInit(){CloseAll();}
};


/*****************************************************************
** Run-time status of the modem
*****************************************************************/
class ModemStatus
{
   public:
//      int AnswerOn;
      // 1 if operating in *manual* speakerphone mode
//      int SpeakerPhoneOn;
      int AbortCommand;
//      int AllowAbortCommands;
      int StopTransmit;
      int Recording;
//      int OffHook;
//      int PortLocked;
//      int ClientConnected;
//      int ResponceRequested;
      int IgnoreDTMF;
//      int Exit;

      ModemStatus() {
//         AnswerOn = 0;
//         SpeakerPhoneOn = 0;
         AbortCommand = 0; 
//         AllowAbortCommands = 0;
         StopTransmit = 0;
         Recording = 0;
//         OffHook = 0;
//         PortLocked = 0;
//         ClientConnected = 0;
//         ResponceRequested = 0;
         IgnoreDTMF = 0;
//         Exit = 0;
      }
};

#define CHECK_ABORT if (MState.AbortCommand) return;
#define CHECK_ABORT_0 if (MState.AbortCommand) return 0;
#define ABORT_CLOSE if (MState.AbortCommand){close(sfp);return 0;}
#define CHECK_AB_FREE if (MState.AbortCommand) {RemoveLockFile(); return;}

extern ModemStatus MState;