xref: /csrg-svn/usr.bin/f77/libU77/hostnm_.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
423028Skre  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623028Skre  */
723028Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)hostnm_.c	5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic 
1223028Skre /*
1312013Sdlw  * hostnm - return this machines hostname
1412013Sdlw  *
1512013Sdlw  * synopsis:
1612013Sdlw  *	integer function hostnm (name)
1712013Sdlw  *	character(*) name
1812013Sdlw  *
1912013Sdlw  * where:
2012013Sdlw  *	name	will receive the host name
2112013Sdlw  *	The returned value will be 0 if successful, an error number otherwise.
2212013Sdlw  */
2312013Sdlw 
2412013Sdlw extern int	errno;
2512013Sdlw 
2612013Sdlw long
hostnm_(name,len)2712013Sdlw hostnm_ (name, len)
2812013Sdlw char	*name;
2912013Sdlw long	len;
3012013Sdlw {
3112013Sdlw 	char	buf[64];
3212013Sdlw 	register char	*bp;
3312013Sdlw 	int	blen	= sizeof buf;
3412013Sdlw 
3512013Sdlw 	if (gethostname (buf, blen) == 0)
3612013Sdlw 	{
3712013Sdlw 		b_char (buf, name, len);
3812013Sdlw 		return (0L);
3912013Sdlw 	}
4012013Sdlw 	else
4112013Sdlw 		return((long)errno);
4212013Sdlw }
43