projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4_3 release
[unix-history]
/
usr
/
src
/
lib
/
libc
/
gen
/
getttyent.c
diff --git
a/usr/src/lib/libc/gen/getttyent.c
b/usr/src/lib/libc/gen/getttyent.c
index
f25b1f1
..
164c6b3
100644
(file)
--- a/
usr/src/lib/libc/gen/getttyent.c
+++ b/
usr/src/lib/libc/gen/getttyent.c
@@
-1,19
+1,19
@@
/*
/*
- * Copyright (c) 198
3
Regents of the University of California.
+ * Copyright (c) 198
5
Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#if
ndef lint
-static char sccsid[] = "@(#)getttyent.c 5.
1 (Berkeley) %G%
";
-#endif not lint
+#if
defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getttyent.c 5.
4 (Berkeley) 5/19/86
";
+#endif
LIBC_SCCS and
not lint
#include <stdio.h>
#include <strings.h>
#include <ttyent.h>
static char TTYFILE[] = "/etc/ttys";
#include <stdio.h>
#include <strings.h>
#include <ttyent.h>
static char TTYFILE[] = "/etc/ttys";
-static char
EMPTY[] = ""
;
+static char
zapchar
;
static FILE *tf = NULL;
#define LINE 256
static char line[LINE];
static FILE *tf = NULL;
#define LINE 256
static char line[LINE];
@@
-35,16
+35,17
@@
endttyent()
}
}
}
}
-#define QUOTED 1
+#define QUOTED 1
/*
/*
- * Skip over the current field
and
- * return a pointer to the next field.
+ * Skip over the current field
, removing quotes,
+ *
and
return a pointer to the next field.
*/
static char *
skip(p)
register char *p;
{
*/
static char *
skip(p)
register char *p;
{
+ register char *t = p;
register int c;
register int q = 0;
register int c;
register int q = 0;
@@
-53,19
+54,25
@@
skip(p)
q ^= QUOTED; /* obscure, but nice */
continue;
}
q ^= QUOTED; /* obscure, but nice */
continue;
}
+ if (q == QUOTED && *p == '\\' && *(p+1) == '"')
+ p++;
+ *t++ = *p;
if (q == QUOTED)
continue;
if (c == '#') {
if (q == QUOTED)
continue;
if (c == '#') {
- *p = '\0';
+ zapchar = c;
+ *p = 0;
break;
}
if (c == '\t' || c == ' ' || c == '\n') {
break;
}
if (c == '\t' || c == ' ' || c == '\n') {
- *p++ = '\0';
+ zapchar = c;
+ *p++ = 0;
while ((c = *p) == '\t' || c == ' ' || c == '\n')
p++;
break;
}
}
while ((c = *p) == '\t' || c == ' ' || c == '\n')
p++;
break;
}
}
+ *--t = '\0';
return (p);
}
return (p);
}
@@
-79,20
+86,6
@@
value(p)
return(p);
}
return(p);
}
-/* get rid of quotes. */
-
-static
-qremove(p)
- register char *p;
-{
- register char *t;
-
- for (t = p; *p; p++)
- if (*p != '"')
- *t++ = *p;
- *t = '\0';
-}
-
struct ttyent *
getttyent()
{
struct ttyent *
getttyent()
{
@@
-110,6
+103,7
@@
getttyent()
while ((c = *p) == '\t' || c == ' ' || c == '\n')
p++;
} while (c == '\0' || c == '#');
while ((c = *p) == '\t' || c == ' ' || c == '\n')
p++;
} while (c == '\0' || c == '#');
+ zapchar = 0;
tty.ty_name = p;
p = skip(p);
tty.ty_getty = p;
tty.ty_name = p;
p = skip(p);
tty.ty_getty = p;
@@
-117,25
+111,27
@@
getttyent()
tty.ty_type = p;
p = skip(p);
tty.ty_status = 0;
tty.ty_type = p;
p = skip(p);
tty.ty_status = 0;
- tty.ty_window =
EMPTY
;
+ tty.ty_window =
NULL
;
for (; *p; p = skip(p)) {
for (; *p; p = skip(p)) {
- if (strncmp(p, "on", 2) == 0)
+#define space(x) ((c = p[x]) == ' ' || c == '\t' || c == '\n')
+ if (strncmp(p, "on", 2) == 0 && space(2))
tty.ty_status |= TTY_ON;
tty.ty_status |= TTY_ON;
- else if (strncmp(p, "off", 3) == 0)
+ else if (strncmp(p, "off", 3) == 0
&& space(3)
)
tty.ty_status &= ~TTY_ON;
tty.ty_status &= ~TTY_ON;
- else if (strncmp(p, "secure", 6) == 0)
+ else if (strncmp(p, "secure", 6) == 0
&& space(6)
)
tty.ty_status |= TTY_SECURE;
tty.ty_status |= TTY_SECURE;
- else if (strncmp(p, "window", 6) == 0) {
- if ((tty.ty_window = value(p)) == NULL)
- tty.ty_window = EMPTY;
- } else
+ else if (strncmp(p, "window=", 7) == 0)
+ tty.ty_window = value(p);
+ else
break;
}
break;
}
+ if (zapchar == '#' || *p == '#')
+ while ((c = *++p) == ' ' || c == '\t')
+ ;
tty.ty_comment = p;
tty.ty_comment = p;
+ if (*p == 0)
+ tty.ty_comment = 0;
if (p = index(p, '\n'))
*p = '\0';
if (p = index(p, '\n'))
*p = '\0';
- qremove(tty.ty_getty);
- qremove(tty.ty_window);
- qremove(tty.ty_comment);
return(&tty);
}
return(&tty);
}