added ability to init lu6 with carriage control (init66_). DLW
[unix-history] / usr / src / usr.bin / f77 / libU77 / fseek_.c
CommitLineData
d030ca6c 1/*
abb67f25 2char id_fseek[] = "@(#)fseek_.c 1.2";
d030ca6c
DW
3 *
4 * position a file associated with a fortran logical unit
5 *
6 * calling sequence:
7 * ierror = fseek(lunit, ioff, ifrom)
8 * where:
9 * lunit is an open logical unit
10 * ioff is an offset in bytes relative to the position specified by ifrom
11 * ifrom - 0 means 'beginning of the file'
12 * - 1 means 'the current position'
13 * - 2 means 'the end of the file'
14 * ierror will be 0 if successful, a system error code otherwise.
15 */
16
17#include <stdio.h>
18#include "../libI77/f_errno.h"
19#include "../libI77/fiodefs.h"
20
21extern unit units[];
22
23long fseek_(lu, off, from)
24long *lu, *off, *from;
25{
abb67f25
DW
26 if (*lu < 0 || *lu >= MXUNIT)
27 return((long)(errno=F_ERUNIT));
28 if (*from < 0 || *from > 2)
d030ca6c
DW
29 return((long)(errno=F_ERARG));
30 if (!units[*lu].ufd)
31 return((long)(errno=F_ERNOPEN));
32 if (fseek(units[*lu].ufd, *off, (int)*from) < 0)
33 return((long)errno);
34 return(0L);
35}