xref: /csrg-svn/usr.bin/f77/libU77/hostnm_.c (revision 23028)
112013Sdlw /*
2*23028Skre  * Copyright (c) 1980 Regents of the University of California.
3*23028Skre  * All rights reserved.  The Berkeley software License Agreement
4*23028Skre  * specifies the terms and conditions for redistribution.
5*23028Skre  *
6*23028Skre  *	@(#)hostnm_.c	5.1	06/07/85
7*23028Skre  */
8*23028Skre 
9*23028Skre /*
1012013Sdlw  * hostnm - return this machines hostname
1112013Sdlw  *
1212013Sdlw  * synopsis:
1312013Sdlw  *	integer function hostnm (name)
1412013Sdlw  *	character(*) name
1512013Sdlw  *
1612013Sdlw  * where:
1712013Sdlw  *	name	will receive the host name
1812013Sdlw  *	The returned value will be 0 if successful, an error number otherwise.
1912013Sdlw  */
2012013Sdlw 
2112013Sdlw extern int	errno;
2212013Sdlw 
2312013Sdlw long
2412013Sdlw hostnm_ (name, len)
2512013Sdlw char	*name;
2612013Sdlw long	len;
2712013Sdlw {
2812013Sdlw 	char	buf[64];
2912013Sdlw 	register char	*bp;
3012013Sdlw 	int	blen	= sizeof buf;
3112013Sdlw 
3212013Sdlw 	if (gethostname (buf, blen) == 0)
3312013Sdlw 	{
3412013Sdlw 		b_char (buf, name, len);
3512013Sdlw 		return (0L);
3612013Sdlw 	}
3712013Sdlw 	else
3812013Sdlw 		return((long)errno);
3912013Sdlw }
40