Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / usr.sbin / isdn / isdnmonitor / monprivate.h
blob4c595455fce8a987e7e865b2d41a769a095336b6
1 /*
2 * Copyright (c) 1999 Hellmuth Michaelis. All rights reserved.
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.
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.
25 *---------------------------------------------------------------------------
27 * i4b remote monitor - private header
28 * -----------------------------------
30 * $Id: monprivate.h,v 1.2 2002/09/20 15:15:49 mycroft Exp $
32 * $FreeBSD$
34 * last edit-date: [Sat Jan 6 13:01:04 2001]
36 *---------------------------------------------------------------------------*/
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <ctype.h>
42 #include <errno.h>
43 #include <signal.h>
45 #ifndef WIN32
46 #include <unistd.h>
47 #include <syslog.h>
48 #include <regex.h>
49 #include <curses.h>
50 #include <fcntl.h>
52 #include <sys/param.h>
53 #include <sys/stat.h>
54 #include <sys/time.h>
55 #include <sys/types.h>
56 #include <sys/ioctl.h>
57 #include <sys/poll.h>
58 #endif
60 /*---------------------------------------------------------------------------*
61 * definitions in i4b_ioctl.h, do something for other systems
62 *---------------------------------------------------------------------------*/
63 #if defined (__FreeBSD__) || defined(__NetBSD__) || \
64 defined (__OpenBSD__) || defined(__bsdi__)
66 #include <netisdn/i4b_ioctl.h>
68 #else
70 #define FOREIGN 1 /* we are running on a "foreign" OS */
72 #define I4B_TIME_FORMAT "%d.%m.%Y %H:%M:%S"
73 #define VERSION 0
74 #define REL 0
75 #define STEP 0
77 #endif
79 /*---------------------------------------------------------------------------*
80 * some general definitions
81 *---------------------------------------------------------------------------*/
82 #define GOOD 0 /* general "good" or "ok" return*/
83 #define ERROR (-1) /* general error return */
84 #define WARNING (-2) /* warning return */
85 #define INVALID (-1) /* an invalid integer */
87 /*---------------------------------------------------------------------------*
88 * state definitions
89 *---------------------------------------------------------------------------*/
90 #define ST_INIT 0 /* initial data */
91 #define ST_ICTRL 1 /* initial controller list */
92 #define ST_IDEV 2 /* initial entry devicename list */
93 #define ST_ANYEV 3 /* any event */
94 #define ST_RIGHT 4 /* one record in a list of monitor rights */
95 #define ST_CONNS 5 /* monitor connections */
97 /*---------------------------------------------------------------------------*
98 * curses fullscreen display definitions
99 *---------------------------------------------------------------------------*/
100 /* window dimensions */
101 #define UPPER_B 2 /* upper window start */
103 /* horizontal positions for upper window */
104 #define H_CNTL 0 /* controller */
105 #define H_TEI 2 /* TEI */
106 #define H_CHAN (H_TEI+4) /* channel */
107 #define H_TELN (H_CHAN+2) /* telephone number */
108 #define H_IFN (H_TELN+23) /* interfacename */
109 #define H_IO (H_IFN+7) /* incoming or outgoing */
110 #define H_OUT (H_IO+4) /* # of bytes out */
111 #define H_OUTBPS (H_OUT+11) /* bytes per second out */
112 #define H_IN (H_OUTBPS+5) /* # of bytes in */
113 #define H_INBPS (H_IN+11) /* bytes per second in */
114 #define H_UNITS (H_INBPS+6) /* # of charging units */
116 /* fullscreen mode menu window */
117 #define WMENU_LEN 35 /* width of menu window */
118 #define WMENU_TITLE "Command" /* title string */
119 #define WMENU_POSLN 10 /* menu position, line */
120 #define WMENU_POSCO 5 /* menu position, col */
121 #define WMITEMS 4 /* no of menu items */
122 #define WMENU_HGT (WMITEMS + 4) /* menu window height */
124 #define WREFRESH 0
125 #define WHANGUP 1
126 #define WREREAD 2
127 #define WQUIT 3
129 #define WMTIMEOUT 5 /* timeout in seconds */
131 /*---------------------------------------------------------------------------*
132 * misc
133 *---------------------------------------------------------------------------*/
134 #define CHPOS(uctlr, uchan) (((uctlr)*2) + (uchan))
136 /*---------------------------------------------------------------------------*
137 * remote state
138 *---------------------------------------------------------------------------*/
140 #define MAX_CTRL 4
142 typedef struct remstate {
143 int ch1state;
144 int ch2state;
145 } remstate_t;
147 /*---------------------------------------------------------------------------*
148 * global variables
149 *---------------------------------------------------------------------------*/
150 #ifdef MAIN
152 remstate_t remstate[MAX_CTRL];
154 int nctrl = 0; /* # of controllers available */
155 int curses_ready = 0; /* curses initialized */
156 int do_bell = 0;
157 int nentries = 0;
158 int fullscreen = 0;
159 int debug_noscreen = 0;
161 #ifndef WIN32
162 WINDOW *upper_w; /* curses upper window pointer */
163 WINDOW *mid_w; /* curses mid window pointer */
164 WINDOW *lower_w; /* curses lower window pointer */
165 #endif
167 char devbuf[256];
169 char *sockpath = NULL;
170 char *hostname = NULL;
171 int portno;
173 #else /* !MAIN */
175 remstate_t remstate[MAX_CTRL];
177 int nctrl;
178 int curses_ready;
179 int do_bell;
180 int nentries;
181 int fullscreen;
182 int debug_noscreen;
184 WINDOW *upper_w;
185 WINDOW *mid_w;
186 WINDOW *lower_w;
188 char devbuf[256];
190 char *sockpath;
191 char *hostname;
192 int portno;
194 #endif
196 extern void do_exit ( int exitval );
197 extern void do_menu ( void );
198 extern void init_screen ( void );
199 extern void display_charge ( int pos, int charge );
200 extern void display_ccharge ( int pos, int units );
201 extern void display_connect(int pos, int dir, char *name, char *remtel, char *dev);
202 extern void display_acct ( int pos, int obyte, int obps, int ibyte, int ibps );
203 extern void display_disconnect ( int pos );
204 extern void display_updown ( int pos, int updown, char *device );
205 extern void display_l12stat ( int controller, int layer, int state );
206 extern void display_tei ( int controller, int tei );
208 extern void reread(void);
209 extern void hangup(int ctrl, int chan);