More minor IPI work.
[dragonfly/vkernel-mp.git] / usr.sbin / i4b / isdnmonitor / monprivate.h
blob7c5d8cf07150fecdac6d3562c8f46eb31a90fb4e
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.10 1999/12/13 21:25:26 hm Exp $
32 * $FreeBSD: src/usr.sbin/i4b/isdnmonitor/monprivate.h,v 1.1.2.1 2001/08/01 17:45:06 obrien Exp $
33 * $DragonFly: src/usr.sbin/i4b/isdnmonitor/monprivate.h,v 1.4 2004/02/10 03:59:42 rob Exp $
35 * last edit-date: [Mon Dec 13 21:52:25 1999]
37 *---------------------------------------------------------------------------*/
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <ctype.h>
43 #include <errno.h>
44 #include <signal.h>
46 #ifndef WIN32
47 #include <unistd.h>
48 #include <syslog.h>
49 #include <regex.h>
50 #include <curses.h>
51 #include <fcntl.h>
53 #include <sys/param.h>
54 #include <sys/stat.h>
55 #include <sys/time.h>
56 #include <sys/types.h>
57 #include <sys/ioctl.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__) || \
65 defined (__DragonFly__)
67 #include <i4b_machine/i4b_ioctl.h>
69 #else
71 #define FOREIGN 1 /* we are running on a "foreign" OS */
73 #define I4B_TIME_FORMAT "%d.%m.%Y %H:%M:%S"
74 #define VERSION 0
75 #define REL 0
76 #define STEP 0
78 #endif
80 /*---------------------------------------------------------------------------*
81 * some general definitions
82 *---------------------------------------------------------------------------*/
83 #define GOOD 0 /* general "good" or "ok" return*/
84 #define ERROR (-1) /* general error return */
85 #define WARNING (-2) /* warning return */
86 #define INVALID (-1) /* an invalid integer */
88 /*---------------------------------------------------------------------------*
89 * state definitions
90 *---------------------------------------------------------------------------*/
91 #define ST_INIT 0 /* initial data */
92 #define ST_ICTRL 1 /* initial controller list */
93 #define ST_IDEV 2 /* initial entry devicename list */
94 #define ST_ANYEV 3 /* any event */
95 #define ST_RIGHT 4 /* one record in a list of monitor rights */
96 #define ST_CONNS 5 /* monitor connections */
98 /*---------------------------------------------------------------------------*
99 * curses fullscreen display definitions
100 *---------------------------------------------------------------------------*/
101 /* window dimensions */
102 #define UPPER_B 2 /* upper window start */
104 /* horizontal positions for upper window */
105 #define H_CNTL 0 /* controller */
106 #define H_TEI 2 /* TEI */
107 #define H_CHAN (H_TEI+4) /* channel */
108 #define H_TELN (H_CHAN+2) /* telephone number */
109 #define H_IFN (H_TELN+23) /* interfacename */
110 #define H_IO (H_IFN+7) /* incoming or outgoing */
111 #define H_OUT (H_IO+4) /* # of bytes out */
112 #define H_OUTBPS (H_OUT+11) /* bytes per second out */
113 #define H_IN (H_OUTBPS+5) /* # of bytes in */
114 #define H_INBPS (H_IN+11) /* bytes per second in */
115 #define H_UNITS (H_INBPS+6) /* # of charging units */
117 /* fullscreen mode menu window */
118 #define WMENU_LEN 35 /* width of menu window */
119 #define WMENU_TITLE "Command" /* title string */
120 #define WMENU_POSLN 10 /* menu position, line */
121 #define WMENU_POSCO 5 /* menu position, col */
122 #define WMITEMS 4 /* no of menu items */
123 #define WMENU_HGT (WMITEMS + 4) /* menu window height */
125 #define WREFRESH 0
126 #define WHANGUP 1
127 #define WREREAD 2
128 #define WQUIT 3
130 #define WMTIMEOUT 5 /* timeout in seconds */
132 /*---------------------------------------------------------------------------*
133 * misc
134 *---------------------------------------------------------------------------*/
135 #define CHPOS(uctlr, uchan) (((uctlr)*2) + (uchan))
137 /*---------------------------------------------------------------------------*
138 * remote state
139 *---------------------------------------------------------------------------*/
141 #define MAX_CTRL 4
143 typedef struct remstate {
144 int ch1state;
145 int ch2state;
146 } remstate_t;
148 /*---------------------------------------------------------------------------*
149 * global variables
150 *---------------------------------------------------------------------------*/
151 #ifdef MAIN
153 remstate_t remstate[MAX_CTRL];
155 int nctrl = 0; /* # of controllers available */
156 int curses_ready = 0; /* curses initialized */
157 int do_bell = 0;
158 int nentries = 0;
159 int fullscreen = 0;
160 int debug_noscreen = 0;
162 #ifndef WIN32
163 WINDOW *upper_w; /* curses upper window pointer */
164 WINDOW *mid_w; /* curses mid window pointer */
165 WINDOW *lower_w; /* curses lower window pointer */
166 #endif
168 char devbuf[256];
170 char *sockpath = NULL;
171 char *hostname = NULL;
172 int portno;
174 #else /* !MAIN */
176 remstate_t remstate[MAX_CTRL];
178 int nctrl;
179 int curses_ready;
180 int do_bell;
181 int nentries;
182 int fullscreen;
183 int debug_noscreen;
185 WINDOW *upper_w;
186 WINDOW *mid_w;
187 WINDOW *lower_w;
189 char devbuf[256];
191 char *sockpath;
192 char *hostname;
193 int portno;
195 #endif
197 extern void do_exit ( int exitval );
198 extern void do_menu ( void );
199 extern void init_screen ( void );
200 extern void display_charge ( int pos, int charge );
201 extern void display_ccharge ( int pos, int units );
202 extern void display_connect(int pos, int dir, char *name, char *remtel, char *dev);
203 extern void display_acct ( int pos, int obyte, int obps, int ibyte, int ibps );
204 extern void display_disconnect ( int pos );
205 extern void display_updown ( int pos, int updown, char *device );
206 extern void display_l12stat ( int controller, int layer, int state );
207 extern void display_tei ( int controller, int tei );
209 extern void reread(void);
210 extern void hangup(int ctrl, int chan);