/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* modem_setup.c: support for the scadm modem_setup option (access to the
* service processor modem - if present)
*/
#include <curses.h>
#include <libintl.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "librsc.h"
#include "adm.h"
extern char *ADM_Get_Var(char *Variable);
static void ADM_Send_Char(char C);
static void ADM_Modem_Listen();
static void cleanup();
static int ADM_Continue;
static int winOn = 0;
void
{
int Input;
ADM_Start();
sizeof (dp_modem_connect_r_t));
gettext("scadm: could not connect to modem"));
exit(-1);
}
/* Get the escape char BEFORE starting up the "listen" thread */
/* Create Listening Thread */
ADM_Continue = 1;
(void * (*)(void *))ADM_Modem_Listen, (void *)NULL) != 0) {
gettext("scadm: couldn't create thread"));
exit(-1);
}
gettext("scadm: cleanup() registration failed"));
ADM_Continue = 0;
exit(-1);
}
Input = 0;
winOn = 1;
initscr();
noecho();
while (exitLoop) {
if (Input == 10) {
ADM_Send_Char('\n');
ADM_Send_Char('\r');
continue;
}
switch (State) {
case ST_RESET:
if ((char)Input == rsc_escape[0]) {
} else {
ADM_Send_Char((char)Input);
}
break;
case ST_IDLE:
ADM_Send_Char((char)Input);
break;
case ST_TILDA:
if ((char)Input == '.') {
ADM_Send_Char('~');
ADM_Send_Char('.');
exitLoop = 0;
} else {
ADM_Send_Char((char)Input);
}
break;
default:
ADM_Send_Char((char)Input);
}
}
endwin();
winOn = 0;
/* Terminate Thread */
ADM_Continue = 0;
/* termination */
sizeof (dp_modem_disconnect_r_t));
gettext("scadm: could not disconnect from modem"));
ADM_Continue = 0;
exit(-1);
}
}
static void
ADM_Send_Char(char C)
{
Data[0] = C;
gettext("scadm: Unable to send modem data to SC"));
if (winOn)
endwin();
ADM_Continue = 0;
exit(-1);
}
}
static void
{
while (ADM_Continue) {
continue;
}
gettext("scadm: SC returned garbage"),
exit(-1);
}
}
}
static void
cleanup()
{
if (winOn)
endwin();
/* Terminate Thread */
ADM_Continue = 0;
sizeof (dp_modem_disconnect_r_t));
gettext("scadm: could not disconnect from modem"));
exit(-1);
}
exit(-1);
}