xref: /csrg-svn/usr.bin/f77/libU77/lstat_.c (revision 12148)
112028Sdlw /*
2*12148Sdlw char id_stat[] = "@(#)lstat_.c	1.2";
312028Sdlw  *
412028Sdlw  * get file status
512028Sdlw  *
612028Sdlw  * calling sequence:
712028Sdlw  *	integer lstat, statb(12)
812028Sdlw  *	external lstat
912028Sdlw  *	ierr = lstat (name, statb)
1012028Sdlw  * where:
1112028Sdlw  *	'statb' will receive the stat structure for file 'name'.
1212028Sdlw  */
1312028Sdlw 
14*12148Sdlw #include <sys/param.h>
15*12148Sdlw #ifndef	MAXPATHLEN
16*12148Sdlw #define MAXPATHLEN	128
17*12148Sdlw #endif
1812028Sdlw #include <sys/stat.h>
1912028Sdlw #include "../libI77/f_errno.h"
2012028Sdlw 
2112028Sdlw long lstat_(name, stbuf, namlen)
2212028Sdlw char *name; long *stbuf, namlen;
2312028Sdlw {
24*12148Sdlw 	char buf[MAXPATHLEN];
2512028Sdlw 	struct stat statb;
2612028Sdlw 
2712028Sdlw 	if (namlen >= sizeof buf)
2812028Sdlw 		return((long)(errno=F_ERARG));
2912028Sdlw 	g_char(name, namlen, buf);
3012028Sdlw 	if (lstat(buf, &statb) == 0)
3112028Sdlw 	{
3212028Sdlw 		*stbuf++ = statb.st_dev;
3312028Sdlw 		*stbuf++ = statb.st_ino;
3412028Sdlw 		*stbuf++ = statb.st_mode;
3512028Sdlw 		*stbuf++ = statb.st_nlink;
3612028Sdlw 		*stbuf++ = statb.st_uid;
3712028Sdlw 		*stbuf++ = statb.st_gid;
3812028Sdlw 		*stbuf++ = statb.st_rdev;
3912028Sdlw 		*stbuf++ = statb.st_size;
4012028Sdlw 		*stbuf++ = statb.st_atime;
4112028Sdlw 		*stbuf++ = statb.st_mtime;
4212028Sdlw 		*stbuf++ = statb.st_ctime;
4312028Sdlw 		*stbuf++ = statb.st_blksize;
4412028Sdlw 		return(0L);
4512028Sdlw 	}
4612028Sdlw 	return ((long)errno);
4712028Sdlw }
48