5 * Revision 1.1.1.1 1996/02/15 17:49:37 mclareni
10 CERN PROGLIB# Z310 CFOPEI .VERSION KERNOS9 1.01 940801
12 CALL CFOPEN (LUNDES, MEDIUM, NWREC, MODE, NBUF, TEXT, ISTAT)
14 *LUNDES file descriptor
15 MEDIUM = 0,1,2,3 : primary disk/tape, secondary disk/tape
16 NWREC record length in number of words
17 MODE string selecting IO mode
18 = 'r ', 'w ', 'a ', 'r+ ', ...
19 NBUF number of buffers to be allocated, (not used)
21 *ISTAT status, =zero if success
23 #include "kerngen/cf#open.h"
26 #include "kerngen/cf#xaft.h"
27 #include "kerngen/fortchar.h"
28 #include "kerngen/wordsizc.h"
31 void cfopei_(lundes,medium,nwrec,mode,nbuf,ftext,stat,lgtx)
33 int *lundes, *medium, *nwrec, *nbuf, *stat, *lgtx;
36 char *pttext, *fchtak();
49 * mode[0] = 0 r 1 w 2 a
53 if ((*medium == 1) || (*medium == 3))
65 flags = FAM_READ | FAM_WRITE;
67 } else if (mode[0] == 1) {
72 flags = FAM_READ | FAM_WRITE;
74 } else if (mode[0] == 2) return;
87 flags = FAM_READ | FAM_WRITE;
89 } else if (mode[0] == 1) {
94 flags = FAM_WRITE | FAM_READ;
96 } else if (mode[0] == 2) {
99 flags = FAM_WRITE | FAM_APPEND;
101 flags = FAM_WRITE | FAM_READ | FAM_APPEND;
109 pttext = fchtak(ftext,*lgtx);
110 if (pttext == 0) return;
112 if (perm == 0) perm = FAP_READ | FAP_WRITE | FAP_PREAD;
114 if ( (mode[0] == 1) &
115 ((*medium == 0) || (*medium == 2))
117 if ( (fildes = create (pttext, flags, perm)) < 0 )
118 fildes = creat (pttext, flags);
121 fildes = open (pttext, flags);
123 (fildes < 0) ) fildes = create (pttext, flags, perm);
126 if (fildes < 0) goto errm;
133 perror (" error in CFOPEN");
138 /*> END <----------------------------------------------------------*/