xref: /csrg-svn/usr.bin/f77/libU77/lstat_.c (revision 23037)
112028Sdlw /*
2*23037Skre  * Copyright (c) 1980 Regents of the University of California.
3*23037Skre  * All rights reserved.  The Berkeley software License Agreement
4*23037Skre  * specifies the terms and conditions for redistribution.
512028Sdlw  *
6*23037Skre  *	@(#)lstat_.c	5.1	06/07/85
7*23037Skre  */
8*23037Skre 
9*23037Skre /*
1012028Sdlw  * get file status
1112028Sdlw  *
1212028Sdlw  * calling sequence:
1312028Sdlw  *	integer lstat, statb(12)
1412028Sdlw  *	external lstat
1512028Sdlw  *	ierr = lstat (name, statb)
1612028Sdlw  * where:
1712028Sdlw  *	'statb' will receive the stat structure for file 'name'.
1812028Sdlw  */
1912028Sdlw 
2012148Sdlw #include <sys/param.h>
2112148Sdlw #ifndef	MAXPATHLEN
2212148Sdlw #define MAXPATHLEN	128
2312148Sdlw #endif
2412028Sdlw #include <sys/stat.h>
2512028Sdlw #include "../libI77/f_errno.h"
2612028Sdlw 
2712028Sdlw long lstat_(name, stbuf, namlen)
2812028Sdlw char *name; long *stbuf, namlen;
2912028Sdlw {
3012148Sdlw 	char buf[MAXPATHLEN];
3112028Sdlw 	struct stat statb;
3212028Sdlw 
3312028Sdlw 	if (namlen >= sizeof buf)
3412028Sdlw 		return((long)(errno=F_ERARG));
3512028Sdlw 	g_char(name, namlen, buf);
3612028Sdlw 	if (lstat(buf, &statb) == 0)
3712028Sdlw 	{
3812028Sdlw 		*stbuf++ = statb.st_dev;
3912028Sdlw 		*stbuf++ = statb.st_ino;
4012028Sdlw 		*stbuf++ = statb.st_mode;
4112028Sdlw 		*stbuf++ = statb.st_nlink;
4212028Sdlw 		*stbuf++ = statb.st_uid;
4312028Sdlw 		*stbuf++ = statb.st_gid;
4412028Sdlw 		*stbuf++ = statb.st_rdev;
4512028Sdlw 		*stbuf++ = statb.st_size;
4612028Sdlw 		*stbuf++ = statb.st_atime;
4712028Sdlw 		*stbuf++ = statb.st_mtime;
4812028Sdlw 		*stbuf++ = statb.st_ctime;
4912028Sdlw 		*stbuf++ = statb.st_blksize;
5012028Sdlw 		return(0L);
5112028Sdlw 	}
5212028Sdlw 	return ((long)errno);
5312028Sdlw }
54