]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MINICERN/packlib/kernlib/kerngen/ccgencf/os9gs/cfget.c
Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / MINICERN / packlib / kernlib / kerngen / ccgencf / os9gs / cfget.c
CommitLineData
fe4da5cc 1/*
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1 1996/02/15 17:49:37 mclareni
6 * Kernlib
7 *
8 */
9/*> ROUTINE CFGET
10 CERN PROGLIB# Z310 CFGET .VERSION KERNOS9 1.01 940729
11 ORIG. 12/01/91, JZ
12 MOD. 29/07/94, MM (remove label retn: )
13 CALL CFGET (LUNDES, MEDIUM, NWREC, NWTAK, MBUF, ISTAT)
14 read from the file :
15 LUNDES file descriptor
16 MEDIUM = 0,1,2,3 : primary disk/tape, secondary disk/tape
17 NWREC number of words record size
18 *NWTAK* number of words to be read / actually read
19 *MBUF vector to be read into
20 *ISTAT status, =zero if success
21*/
22#include <stdio.h>
23#include <errno.h>
24#define NBYTPW 4 /* Number of bytes per word */
25
26void cfget_(lundes, medium, nwrec, nwtak, mbuf, stat)
27 char *mbuf;
28 int *lundes, *medium, *nwrec, *nwtak, *stat;
29{
30 int fildes;
31 int nbdn, nbdo;
32
33 *stat = 0;
34 if (*nwtak <= 0) return;
35
36/* read the file */
37
38 fildes = *lundes;
39 nbdo = *nwrec * NBYTPW;
40 nbdn = read (fildes, mbuf, nbdo);
41 if (nbdn == 0) goto heof;
42 if (nbdn < 0) goto herror;
43 *nwtak = (nbdn - 1) / NBYTPW + 1;
44 return;
45
46/* Handle exceptions */
47
48heof: *stat = -1;
49 return;
50
51herror: *stat = errno;
52 perror (" error in CFGET");
53 return;
54}
55/*> END <----------------------------------------------------------*/