|
|
1.1 root 1: /*
2: * $Source: /mit/kerberos/src/lib/krb/RCS/getst.c,v $
3: * $Author: jtkohl $
4: *
5: * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
6: *
7: * For copying and distribution information, please see the file
8: * <mit-copyright.h>.
9: */
10:
11: #ifndef lint
12: static char rcsid_getst_c[] =
13: "$Header: getst.c,v 4.5 88/11/15 16:31:39 jtkohl Exp $";
14: #endif /* lint */
15:
16: #include <mit-copyright.h>
17:
18: /*
19: * getst() takes a file descriptor, a string and a count. It reads
20: * from the file until either it has read "count" characters, or until
21: * it reads a null byte. When finished, what has been read exists in
22: * the given string "s". If "count" characters were actually read, the
23: * last is changed to a null, so the returned string is always null-
24: * terminated. getst() returns the number of characters read, including
25: * the null terminator.
26: */
27:
28: getst(fd, s, n)
29: int fd;
30: register char *s;
31: {
32: register count = n;
33: while (read(fd, s, 1) > 0 && --count)
34: if (*s++ == '\0')
35: return (n - count);
36: *s = '\0';
37: return (n - count);
38: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.