/*
* 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) 1988 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
Routines to convert terminfo string parameters to termcap form.
Not all terminfo strings will be, or could be, converted.
The following parameter forms will at least be handled.
%p1%d -> %d
%p1%2.2d -> %2
%p1%3.3d -> %3
%p1%02d -> %2
%p1%03d -> %3
%p1%c -> %.
%p1%'x'%+%c -> %+x
%i -> %i
%p2 before %p1 -> %r
%p1%'x'% > %+%p1%'y'%+%; -> % > xy
*/
#include "curses.h"
/* externs from libc */
extern char *strcpy();
/* handle both Sys Vr2 and Vr3 curses */
#endif /* SYSV || USG */
extern char *strchr();
#define NULLPTR ((char *) 0)
/*
lookat looks at a string such as "%p1%d" and a pattern such as "%p*%d",
where '*' is the only wild character. Each place that the star matches,
the corresponding character in the string is placed in args. If the
pattern matches the string, 1 is returned.
*/
static int
{
if (pat == '*')
return (0);
if (pat == '\0')
return (1);
else
return (0);
}
static char *newvalue;
static void setparms();
/*
Setparms() and checkparms() are used by infotocap() to make
sure that the parameters in the terminfo entry alternate and are
only '1' or '2'. If the order has been reversed, then %r is added
in to the new value being built.
*/
static void
setparms()
{
currentparm = 1;
otherparm = 2;
reversedparms = 0;
return;
}
static int
{
arg -= '0';
return (1);
else if (arg != currentparm)
if (reversedparms)
return (1);
newvalue += 2;
} else
return (1);
else {
}
return (0);
}
/*
Infotocap looks at the string capability to see if it has any
stack manipulation operators. If possible, they are converted to
termcap form. If any operator is found that cannot be modified,
prepend a message to the beginning of the original value and
set err to 1. A pointer to the new copy of the string is returned
in either case.
*/
char
{
char *savevalue;
*err = 0;
return (value);
setparms();
while (*value)
if (*value != '%')
if (checkparms(args[0]))
goto dobyhand;
newvalue += 2;
value += 5;
if (checkparms(args[0]))
goto dobyhand;
newvalue += 2;
value += 7;
if (checkparms(args[0]))
goto dobyhand;
newvalue += 2;
value += 7;
if (checkparms(args[0]))
goto dobyhand;
newvalue += 2;
value += 8;
if (checkparms(args[0]))
goto dobyhand;
newvalue += 2;
value += 8;
if (checkparms(args[0]))
goto dobyhand;
newvalue += 2;
value += 5;
if (checkparms(args[0]))
goto dobyhand;
newvalue += 3;
value += 11;
newvalue += 2;
value += 2;
newvalue += 2;
value += 2;
goto dobyhand;
if (checkparms(args[0]))
goto dobyhand;
newvalue += 2;
value += 21;
} else
goto dobyhand;
*newvalue = '\0';
return (&_newvalue[BYHANDMSGLEN]);
*err = 1;
return (_newvalue);
}