/*
* Copyright (c) 1985 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <strings.h>
#include <ttyent.h>
static struct _ttyentjunk {
char zapchar;
static struct _ttyentjunk *
_ttyentjunk(void)
{
if (__ttyentjunk == 0)
return (__ttyentjunk);
}
void
setttyent(void)
{
struct _ttyentjunk *t = _ttyentjunk();
if (t == 0)
return;
else
}
void
endttyent(void)
{
struct _ttyentjunk *t = _ttyentjunk();
if (t == 0)
return;
}
}
/*
* Skip over the current field, removing quotes,
* and return a pointer to the next field.
*/
static char *
skip(char *p)
{
struct _ttyentjunk *t = _ttyentjunk();
char *cp = p;
int c;
int q = 0;
if (t == 0)
return (0);
for (; (c = *p) != '\0'; p++) {
if (c == '"') {
q ^= QUOTED; /* obscure, but nice */
continue;
}
p++;
*cp++ = *p;
if (q == QUOTED)
continue;
if (c == '#') {
t->zapchar = c;
*p = 0;
break;
}
if (c == '\t' || c == ' ' || c == '\n') {
t->zapchar = c;
*p++ = 0;
while ((c = *p) == '\t' || c == ' ' || c == '\n')
p++;
break;
}
}
*--cp = '\0';
return (p);
}
static char *
value(char *p)
{
if ((p = index(p,'=')) == 0)
return (NULL);
p++; /* get past the = sign */
return (p);
}
struct ttyent *
getttyent(void)
{
struct _ttyentjunk *t = _ttyentjunk();
char *p;
int c;
if (t == 0)
return (NULL);
return (NULL);
}
do {
if (p == NULL)
return (NULL);
while ((c = *p) == '\t' || c == ' ' || c == '\n')
p++;
} while (c == '\0' || c == '#');
t->zapchar = 0;
p = skip(p);
p = skip(p);
p = skip(p);
for (; *p; p = skip(p)) {
else
break;
}
while ((c = *++p) == ' ' || c == '\t')
;
t->tty.ty_comment = p;
if (*p == 0)
t->tty.ty_comment = 0;
if (p = index(p, '\n'))
*p = '\0';
return (&t->tty);
}