Change __signed to signed.
[dragonfly.git] / crypto / kerberosIV / lib / krb / getst.c
1 /* 
2   Copyright (C) 1989 by the Massachusetts Institute of Technology
3
4    Export of this software from the United States of America is assumed
5    to require a specific license from the United States Government.
6    It is the responsibility of any person or organization contemplating
7    export to obtain such a license before exporting.
8
9 WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
10 distribute this software and its documentation for any purpose and
11 without fee is hereby granted, provided that the above copyright
12 notice appear in all copies and that both that copyright notice and
13 this permission notice appear in supporting documentation, and that
14 the name of M.I.T. not be used in advertising or publicity pertaining
15 to distribution of the software without specific, written prior
16 permission.  M.I.T. makes no representations about the suitability of
17 this software for any purpose.  It is provided "as is" without express
18 or implied warranty.
19
20   */
21
22 #include "krb_locl.h"
23
24 RCSID("$Id: getst.c,v 1.6 1997/03/23 03:53:11 joda Exp $");
25
26 /*
27  * getst() takes a file descriptor, a string and a count.  It reads
28  * from the file until either it has read "count" characters, or until
29  * it reads a null byte.  When finished, what has been read exists in
30  * the given string "s".  If "count" characters were actually read, the
31  * last is changed to a null, so the returned string is always null-
32  * terminated.  getst() returns the number of characters read, including
33  * the null terminator.
34  */
35
36 int
37 getst(int fd, char *s, int n)
38 {
39     int count = n;
40     while (read(fd, s, 1) > 0 && --count)
41         if (*s++ == '\0')
42             return (n - count);
43     *s = '\0';
44     return (n - count);
45 }