extern char *malloc(), *mktemp();
extern int f__canseek(FILE*);
extern integer
f_clos(cllist
*);
char *f__r_mode
[2] = {"r", "r"};
char *f__w_mode
[4] = {"w", "w", "r+w", "r+w"};
char *f__r_mode
[2] = {"rb", "r"};
char *f__w_mode
[4] = {"wb", "w", "r+b", "r+"};
if(stat(s
, &x
) == -1) return(0);
switch(x
.st_mode
&S_IFMT
) {
if(S_ISREG(x
.st_mode
) || S_ISDIR(x
.st_mode
))
Help
! How does stat work on
this system
?
integer
f_open(a
) olist
*a
;
if(a
->ounit
>=MXUNIT
|| a
->ounit
<0)
f__curunit
= b
= &f__units
[a
->ounit
];
b
->ublnk
= *a
->oblnk
== 'z' || *a
->oblnk
== 'Z';
&& strlen(b
->ufnm
) == a
->ofnmlen
&& !strncmp(b
->ufnm
, b
->ufnm
, (unsigned)a
->ofnmlen
))
g_char(a
->ofnm
,a
->ofnmlen
,buf
);
if (f__inode(buf
,&n
) == b
->uinode
&& n
== b
->udev
)
if ((rv
= f_clos(&x
)) != 0)
b
->ublnk
= a
->oblnk
&& (*a
->oblnk
== 'z' || *a
->oblnk
== 'Z');
{ if(b
->url
>0) b
->ufmt
=0;
else if(*a
->ofm
=='f' || *a
->ofm
== 'F') b
->ufmt
=1;
g_char(a
->ofnm
,a
->ofnmlen
,buf
);
sprintf(buf
, "fort.%ld", a
->ounit
);
switch(a
->osta
? *a
->osta
: 'u')
err(a
->oerr
,errno
,"open")
(void) strcpy(buf
,"tmp.FXXXXXX");
case 'r': /* Fortran 90 replace option */
if (tf
= fopen(buf
,f__w_mode
[0]))
(void) close(creat(buf
, 0666));
b
->ufnm
=(char *) malloc((unsigned int)(strlen(buf
)+1));
if(b
->ufnm
==NULL
) err(a
->oerr
,113,"no space");
(void) strcpy(b
->ufnm
,buf
);
{ b
->ufd
= fopen(buf
,f__r_mode
[b
->ufmt
]);
if(b
->ufd
==NULL
) err(a
->oerr
,errno
,buf
)
if(!(b
->ufd
= fopen(buf
, f__r_mode
[b
->ufmt
]))) {
if (b
->ufd
= fopen(buf
, f__w_mode
[b
->ufmt
+2]))
else if (b
->ufd
= fopen(buf
, f__w_mode
[b
->ufmt
]))
if ((n
= open(buf
,O_WRONLY
)) >= 0)
|| (b
->ufd
= fdopen(n
, f__w_mode
[b
->ufmt
])) == NULL
)
err(a
->oerr
, errno
, "open");
b
->useek
=f__canseek(b
->ufd
);
if((b
->uinode
=f__inode(buf
,&b
->udev
))==-1)
else if ((s
= a
->oacc
) && (*s
== 'a' || *s
== 'A')
&& fseek(b
->ufd
, 0L, SEEK_END
))
fk_open(seq
,fmt
,n
) ftnint n
;
fk_open(int seq
, int fmt
, ftnint n
)
(void) sprintf(nbuf
,"fort.%ld",n
);
a
.oacc
= seq
==SEQ
?"s":"d";
a
.ofm
= fmt
==FMT
?"f":"u";