FreeBSD/usr.sbin/uhsoctl/uhsoctl.c
/* Read a \n-terminated line from file */
Read a \n-terminated line from file
Read a \ n - terminated line from file
static int
readline(int fd, char *buf, size_t bufsz)
{
	int n = 0, pos = 0;
	char *p = buf;
	for (;;) {
		n = read(fd, p, 1);
		if (n <= 0)
			break;
		pos++;
		if (pos >= (bufsz - 1))
			break;
		if (*p++ == '\n')
			break;
	}
	*p = '\0';
	return (n <= 0 ? n : pos);
}
static int readline ( int fd , char * buf , size_t bufsz ) { int n = 0 , pos = 0 ; char * p = buf ; for ( ; ; ) { n = read ( fd , p , 1 ) ; if ( n <= 0 ) break ; pos ++ ; if ( pos >= ( bufsz - 1 ) ) break ; if ( * p ++ == ' \n ' ) break ; } * p = ' \0 ' ; return ( n <= 0 ? n : pos ) ; }
Read a \n-terminated line from file
Read a \ n - terminated line from file