Protoize
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@992 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -46,58 +46,58 @@ static char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95";
|
||||
* the length of *s1 is returned.
|
||||
*/
|
||||
|
||||
int isprefix(char *s1, char *s2)
|
||||
int
|
||||
isprefix(char *s1, char *s2)
|
||||
{
|
||||
char *os1;
|
||||
register char c1, c2;
|
||||
char *os1;
|
||||
register char c1, c2;
|
||||
|
||||
if (*s1 == '\0')
|
||||
return(-1);
|
||||
os1 = s1;
|
||||
c1 = *s1;
|
||||
c2 = *s2;
|
||||
while (LOWER(c1) == LOWER(c2)) {
|
||||
if (c1 == '\0')
|
||||
break;
|
||||
c1 = *++s1;
|
||||
c2 = *++s2;
|
||||
}
|
||||
return(*s1 ? 0 : (*s2 ? (s1 - os1) : (os1 - s1)));
|
||||
if (*s1 == '\0')
|
||||
return(-1);
|
||||
os1 = s1;
|
||||
c1 = *s1;
|
||||
c2 = *s2;
|
||||
while (LOWER(c1) == LOWER(c2)) {
|
||||
if (c1 == '\0')
|
||||
break;
|
||||
c1 = *++s1;
|
||||
c2 = *++s2;
|
||||
}
|
||||
return(*s1 ? 0 : (*s2 ? (s1 - os1) : (os1 - s1)));
|
||||
}
|
||||
|
||||
static char *ambiguous; /* special return value for command routines */
|
||||
|
||||
char **
|
||||
genget(name, table, stlen)
|
||||
char *name; /* name to match */
|
||||
char **table; /* name entry in table */
|
||||
int stlen;
|
||||
char **
|
||||
genget(char *name, char **table, int stlen)
|
||||
/* name to match */
|
||||
/* name entry in table */
|
||||
|
||||
{
|
||||
register char **c, **found;
|
||||
register int n;
|
||||
register char **c, **found;
|
||||
register int n;
|
||||
|
||||
if (name == 0)
|
||||
return 0;
|
||||
if (name == 0)
|
||||
return 0;
|
||||
|
||||
found = 0;
|
||||
for (c = table; *c != 0; c = (char **)((char *)c + stlen)) {
|
||||
if ((n = isprefix(name, *c)) == 0)
|
||||
continue;
|
||||
if (n < 0) /* exact match */
|
||||
return(c);
|
||||
if (found)
|
||||
return(&ambiguous);
|
||||
found = c;
|
||||
}
|
||||
return(found);
|
||||
found = 0;
|
||||
for (c = table; *c != 0; c = (char **)((char *)c + stlen)) {
|
||||
if ((n = isprefix(name, *c)) == 0)
|
||||
continue;
|
||||
if (n < 0) /* exact match */
|
||||
return(c);
|
||||
if (found)
|
||||
return(&ambiguous);
|
||||
found = c;
|
||||
}
|
||||
return(found);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function call version of Ambiguous()
|
||||
*/
|
||||
int
|
||||
Ambiguous(s)
|
||||
char *s;
|
||||
int
|
||||
Ambiguous(char *s)
|
||||
{
|
||||
return((char **)s == &ambiguous);
|
||||
return((char **)s == &ambiguous);
|
||||
}
|
||||
|
Reference in New Issue
Block a user