Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.sbin / i4b / isdnphone / defs.h
1 /*
2  * Copyright (c) 1999 Hellmuth Michaelis. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  *---------------------------------------------------------------------------
26  *
27  *      isdnphone - header file
28  *      =======================
29  *
30  *      $Id: defs.h,v 1.6 1999/12/13 21:25:26 hm Exp $ 
31  *
32  * $FreeBSD: src/usr.sbin/i4b/isdnphone/defs.h,v 1.2.2.1 2001/08/01 17:45:06 obrien Exp $
33  *
34  *      last edit-date: [Mon Dec 13 21:52:46 1999]
35  *
36  *----------------------------------------------------------------------------*/
37
38 #include <ncurses.h>
39 #include <stdio.h>
40 #include <stdarg.h>
41 #include <signal.h>
42 #include <errno.h>
43 #include <string.h>
44 #include <stdlib.h>
45 #include <unistd.h>
46 #include <fcntl.h>
47 #include <ctype.h>
48
49 #include <sys/stat.h>
50 #include <sys/wait.h>
51 #include <sys/ioctl.h>
52 #include <sys/soundcard.h>
53 #include <sys/types.h>
54 #include <sys/time.h>
55 #include <sys/param.h>
56
57 #include <machine/i4b_ioctl.h>
58 #include <machine/i4b_tel_ioctl.h>
59
60 /* device file prefixes */
61
62 #define I4BTELDEVICE    "/dev/i4btel"
63 #define I4BTELDDEVICE   "/dev/i4bteld"
64 #define AUDIODEVICE     "/dev/audio"
65
66 #define GOOD    0
67 #define ERROR   (-1)
68 #define WARNING (-2)
69
70 /* main window dimensions */
71
72 #define MW_ROW          5
73 #define MW_COL          8
74
75 #define MW_WIDTH        60
76 #define MW_HEIGHT       8
77
78 #define DB_ROW          15
79 #define DB_COL          1
80 #define DB_WID          79
81 #define DB_HGT          9
82
83 #define MW_STATEY       2
84 #define MW_STATEX       1
85 #define MW_STX          10
86
87 #define MW_NUMY         4
88 #define MW_NUMX         1
89 #define MW_NUX          10
90
91 #define MW_MSGY         6
92 #define MW_MSGX         1
93 #define MW_MSX          10
94
95 /* fullscreen mode menu window */
96
97 #define WMITEMS         4               /* no of items */
98 #define WMENU_LEN       18              /* window width */
99 #define WMENU_HGT       (WMITEMS+4)     /* window height */
100 #define WMENU_TITLE     "Command"
101 #define WMENU_POSLN     8               /* window position: lines */
102 #define WMENU_POSCO     20              /* window position: columns */
103
104 #define CR              0x0d
105 #define LF              0x0a
106 #define TAB             0x09
107 #define CNTRL_D         0x04
108 #define CNTRL_L         0x0c
109
110 #define ST_IDLE         0
111 #define ST_DIALING      1
112 #define ST_ACTIVE       2
113 #define ST_MAX          2
114
115 #define AUDIORATE       8000
116
117 #ifdef MAIN
118
119 WINDOW *main_w;                 /* curses main window pointer */
120 WINDOW *dbg_w;
121
122 int curses_ready = 0;           /* flag, curses display is initialized */
123 int state = ST_IDLE;
124
125 char *states[] = {
126         "IDLE",
127         "DIALING",
128         "ACTIVE"
129 };
130
131 int dialerfd = -1;
132 int audiofd = -1;
133 int telfd = -1;
134 int curx;
135 char numberbuffer[TELNO_MAX];
136
137 int play_fmt = AFMT_MU_LAW;
138 int rec_fmt = AFMT_MU_LAW;
139
140 int opt_unit = 0;
141 int opt_d = 0;
142 #else
143
144 extern WINDOW *main_w;
145 extern WINDOW *dbg_w;
146
147 extern int curses_ready;
148 extern int state;
149
150 extern char *states[];
151
152 extern int dialerfd;
153 extern int audiofd;
154 extern int telfd;
155 extern int curx;
156 extern char numberbuffer[];
157
158 extern int play_fmt;
159 extern int rec_fmt;
160
161 int opt_unit;
162 int opt_d;
163
164 #endif
165
166 extern void audio_hdlr ( void );
167 extern void tel_hdlr ( void );
168 extern void init_mainw ( void );
169 extern int init_audio ( char * );
170 extern void do_menu ( void );
171 extern int main ( int argc, char **argv );
172 extern void do_quit ( int exitval );
173 extern void fatal ( char *fmt, ... );
174 extern void message ( char *fmt, ... );
175 extern void do_dial ( char *number );
176 extern void do_hangup ( void );
177
178 extern void audiowrite ( int, unsigned char * );
179 extern void telwrite ( int, unsigned char * );
180
181 extern void newstate ( int newstate );
182
183 int init_dial(char *device);
184 void dial_hdlr(void);
185 int init_tel(char *device);
186
187 extern void debug ( char *fmt, ... );
188
189 /* EOF */