]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MINICERN/packlib/kernlib/kerngen/ccgen/wntgs/lstati.c
This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / MINICERN / packlib / kernlib / kerngen / ccgen / wntgs / lstati.c
1 /*>    ROUTINE LSTATI
2   CERN PROGLIB# Z265    LSTATI          .VERSION KERNFOR  4.38  931108
3 C ORIG. 24/03/91, RDM + JZ
4   Fortran interface routine to lstat
5   Version for Windows NT/Windows 95 by Valery Fine 30/05/96 (fine@vxcern.cern.ch)
6 */
7 #ifdef __STDC__
8 # undef __STDC__
9 #endif
10
11 #include <stdio.h>
12 #include <sys/types.h>
13 #include <sys/stat.h>
14
15 #include "kerngen/fortranc.h"
16
17 #if defined(CERNLIB_QX_SC)
18 int  type_of_call lstati_(fname, info, lgname, slate)
19 #endif
20 #if defined(CERNLIB_QXNO_SC)
21 int  type_of_call lstati(fname, info, lgname, slate)
22 #endif
23 #if defined(CERNLIB_QXCAPT)
24 int  type_of_call LSTATI(fname, info, lgname, slate)
25 #endif
26       char *fname;
27       int  *lgname;
28       int  *info;
29       int  *slate;
30 {
31       struct _stat *buf;
32       char *ptname, *fchtak();
33       int  istat, lstat();
34
35       istat  = -1;
36       ptname = fchtak(fname,*lgname);
37       if (ptname == NULL)          goto out1;
38
39       buf = (struct _stat *) malloc(sizeof (struct _stat));
40       if (buf == NULL)             goto out2;
41
42       istat = stat(ptname, buf);
43
44       if (!istat) {
45          info[0] = (int) buf->st_dev;
46          info[1] = (int) buf->st_ino;
47          info[2] = (int) buf->st_mode;
48          info[3] = (int) buf->st_nlink;
49          info[4] = (int) buf->st_uid;
50          info[5] = (int) buf->st_gid;
51          info[6] = (int) buf->st_size;
52          info[7] = (int) buf->st_atime;
53          info[8] = (int) buf->st_mtime;
54          info[9] = (int) buf->st_ctime;
55          info[10] = 0;
56          info[11] = 0;
57          *slate++ = (buf->st_mode & S_IFMT) ^ S_IFREG; 
58          *slate++ = 0;
59          *slate++ = (buf->st_mode & S_IFMT) ^ S_IFDIR;
60        };
61
62       free(buf);
63 out2: free(ptname);
64 out1: return istat;
65
66 }
67 /*> END <----------------------------------------------------------*/