/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <termio.h>
#include <signal.h>
#include <stdarg.h>
#include "tmstruct.h"
#include "ttymon.h"
"default",
"9600",
"9600 sane",
0,
/*
* next label is set to 4800 so we can start searching ttydefs.
* if 4800 is not in ttydefs, we will loop back to use DEFAULT
*/
"4800"
};
static void usage();
static void check_ref();
static void add_entry();
static void remove_entry();
static int copy_file();
static int verify();
extern void read_ttydefs();
extern int check_version();
extern int find_label();
/*
*
* Usage: sttydefs -a ttylabel [-n nextlabel] [-i initail-flags]
* [-f final-flags] [-b]
* sttydefs -r ttylabel
* sttydefs -l [ttylabel]
*
*/
int
{
int c; /* option letter */
int ret;
#ifdef __STDC__
const
#endif
char *argtmp;
char *nextlabel;
extern char *optarg;
extern int optind;
if (argc == 1)
usage();
/* Initialize ttydef structure */
switch (c) {
case 'a':
break;
case 'n':
break;
case 'i':
break;
case 'f':
break;
case 'b':
break;
case 'r':
usage();
break;
case 'l':
if (argc > 3)
usage();
if (ret != 2) {
exit(1);
}
exit(1);
}
printf("\n");
check_ref();
}
else {
errflg++;
break;
}
}
else { /* -lttylabel */
}
if (Ndefs == 0) {
"ttylabel <%s> not found.\n", argtmp);
exit(1);
}
Ndefs = 0;
if (Ndefs == 0) {
(void)printf("\nWarning -- nextlabel <%s> of <%s> does not reference any existing ttylabel.\n",
}
}
exit(0);
break; /*NOTREACHED*/
case '?':
errflg++;
break;
} /* end switch */
if (errflg)
usage();
} /* end while */
usage();
if (aflg) {
}
usage();
return (0);
}
/*
* verify - to check if arg is valid
* - i.e. arg cannot start with '-' and
* arg must not longer than maxarglen
* - return 0 if ok. Otherwise return -1
*/
static int
char *arg;
int maxarglen;
{
if (*arg == '-') {
return(-1);
}
return(-1);
}
return(0);
}
/*
* usage - print out a usage message
*/
static void
usage()
{
(void)fprintf(stderr, "Usage:\tsttydefs -a ttylabel [-n nextlabel] [-i initial-flags]\n\t\t [-f final-flags] [-b]\n");
exit(2);
}
/*
*/
static void
{
int errflg = 0;
extern int check_flags();
if (getuid()) {
exit(1);
}
*tp = '\0';
"%s version number is incorrect or missing.\n",TTYDEFS);
exit(1);
}
"Invalid request -- ttylabel <%s> already exists.\n",
exit(1);
}
}
else {
add_version = TRUE;
}
exit(1);
}
if (add_version) {
}
/* if optional fields are not provided, set to default */
if (!iflg)
else
errflg++;
if (!fflg)
else
errflg++;
if (errflg)
exit(1);
if (!nflg)
}
else {
}
exit(0);
}
static void
char *ttylabel;
{
if (getuid()) {
exit(1);
}
exit(1);
}
"%s version number is incorrect or missing.\n",TTYDEFS);
exit(1);
}
"Invalid request, ttylabel <%s> does not exist.\n", ttylabel);
exit(1);
}
if (line != 1)
exit(1);
}
exit(1);
}
exit(1);
}
perror("Rename failed");
exit(1);
}
exit(0);
}
/*
* open_temp - open up a temp file
*
* args: tname - temp file name
*/
static FILE *
char *tname;
{
(void)umask(0333);
exit(1);
}
perror("Cannot create tempfile");
exit(1);
}
return(fp);
}
/*
* copy_file - copy information from one file to another, return 0 on
* success, -1 on failure
*
* args: fp - source file's file pointer
* tfp - destination file's file pointer
* start - starting line number
* finish - ending line number (-1 indicates entire file)
*/
static int
register int start;
register int finish;
{
register int i; /* loop variable */
/*
* always start from the beginning because line numbers are absolute
*/
/*
* get to the starting point of interest
*/
if (start != 1) {
for (i = 1; i < start; i++)
return(-1);
}
/*
* copy as much as was requested
*/
if (finish != -1) {
return(-1);
return(-1);
}
}
else {
for (;;) {
break;
else
return(-1);
}
return(-1);
}
}
return(0);
}
/*
* check_ref - to check if nextlabel are referencing
* existing ttylabel
*/
static void
{
int i;
(void)printf("Warning -- nextlabel <%s> of <%s> does not reference any existing ttylabel.\n",
}
}
return;
}
/*
* log - print a message to stdout
*/
void
{
if (lflg) {
(void) printf("\n");
} else {
}
}