/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* write thread - read from vcc console and write to tcp client. There are one
* writer and multiple readers per console. The first client who connects to
* a console get write access.
* Writer thread writes vcc data to all tcp clients that connected to
* the console.
*/
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <thread.h>
#include <synch.h>
#include <signal.h>
#include <assert.h>
#include <poll.h>
#include <syslog.h>
#include <libintl.h>
#include "vntsd.h"
#include "chars.h"
/* handle for writing all clients */
typedef struct write_buf {
char *buf;
} write_buf_t;
/*
* check the state of write thread. exit if no more client connects to the
* console.
*/
static void
{
thr_exit(0);
}
switch (status) {
case VNTSD_STATUS_VCC_IO_ERR:
thr_exit(0);
}
break;
case VNTSD_STATUS_INTR:
thr_exit(0);
default:
break;
}
}
/*
* skip_terminal_null()
* scan terminal null character sequence (0x5e 0x40)
* return number of characters in the buf after skipping terminal null
* sequence. buf size must be at least sz+1.
*/
static int
{
int i, j;
static int term_null_seq = 0;
if (term_null_seq) {
/* skip 0x5e previously */
term_null_seq = 0;
if (buf[0] != 0x40) {
/* not terminal null sequence put 0x5e back */
for (i = sz; i > 0; i--) {
}
buf[0] = 0x5e;
sz++;
} else {
/* skip terminal null sequence */
sz--;
if (sz == 0) {
return (sz);
}
for (i = 0; i < sz; i++) {
}
}
}
for (; ; ) {
for (i = 0; i < sz; i++) {
if (buf[i] == '\0') {
return (i);
}
if (buf[i] == 0x5e) {
/* possible terminal null sequence */
if (i == sz -1) {
/* last character in buffer */
term_null_seq = 1;
sz--;
buf[i] = 0;
return (sz);
}
/* found terminal null sequence */
sz -= 2;
for (j = i; j < sz -i; j++) {
}
break;
}
buf[i] = 0;
term_null_seq = 1;
return (i);
}
}
}
if (i == sz) {
/* end of scan */
return (sz);
}
}
}
/* read data from vcc */
static int
{
/* read from vcc */
return (VNTSD_STATUS_INTR);
}
if ((*sz > 0)) {
return (VNTSD_SUCCESS);
}
return (VNTSD_STATUS_VCC_IO_ERR);
}
/*
* write to a client
* this function is passed as a parameter to vntsd_que_find.
* for each client that connected to the console, vntsd_que_find
* applies this function.
*/
static boolean_t
{
int rv;
if (rv != VNTSD_SUCCESS) {
}
return (B_FALSE);
}
/* vntsd_write_thread() */
void*
{
int sz;
int rv;
for (; ; ) {
/* read data */
if (sz <= 0) {
continue;
}
/* has data */
/* terminal null sequence */
continue;
}
/*
* output data to all clients connected
* to this console
*/
}
/*NOTREACHED*/
return (NULL);
}