xref: /csrg-svn/usr.bin/f77/libU77/lstat_.c (revision 12028)
1*12028Sdlw /*
2*12028Sdlw char id_stat[] = "@(#)lstat_.c	1.1";
3*12028Sdlw  *
4*12028Sdlw  * get file status
5*12028Sdlw  *
6*12028Sdlw  * calling sequence:
7*12028Sdlw  *	integer lstat, statb(12)
8*12028Sdlw  *	external lstat
9*12028Sdlw  *	ierr = lstat (name, statb)
10*12028Sdlw  * where:
11*12028Sdlw  *	'statb' will receive the stat structure for file 'name'.
12*12028Sdlw  */
13*12028Sdlw 
14*12028Sdlw #include <sys/types.h>
15*12028Sdlw #include <sys/stat.h>
16*12028Sdlw #include "../libI77/f_errno.h"
17*12028Sdlw 
18*12028Sdlw long lstat_(name, stbuf, namlen)
19*12028Sdlw char *name; long *stbuf, namlen;
20*12028Sdlw {
21*12028Sdlw 	char buf[256];
22*12028Sdlw 	struct stat statb;
23*12028Sdlw 
24*12028Sdlw 	if (namlen >= sizeof buf)
25*12028Sdlw 		return((long)(errno=F_ERARG));
26*12028Sdlw 	g_char(name, namlen, buf);
27*12028Sdlw 	if (lstat(buf, &statb) == 0)
28*12028Sdlw 	{
29*12028Sdlw 		*stbuf++ = statb.st_dev;
30*12028Sdlw 		*stbuf++ = statb.st_ino;
31*12028Sdlw 		*stbuf++ = statb.st_mode;
32*12028Sdlw 		*stbuf++ = statb.st_nlink;
33*12028Sdlw 		*stbuf++ = statb.st_uid;
34*12028Sdlw 		*stbuf++ = statb.st_gid;
35*12028Sdlw 		*stbuf++ = statb.st_rdev;
36*12028Sdlw 		*stbuf++ = statb.st_size;
37*12028Sdlw 		*stbuf++ = statb.st_atime;
38*12028Sdlw 		*stbuf++ = statb.st_mtime;
39*12028Sdlw 		*stbuf++ = statb.st_ctime;
40*12028Sdlw 		*stbuf++ = statb.st_blksize;
41*12028Sdlw 		return(0L);
42*12028Sdlw 	}
43*12028Sdlw 	return ((long)errno);
44*12028Sdlw }
45