-/* PDPC code - unreviewed, verbatim.
-NOTE THAT PDPC WAS MEANT TO RUN ON A HOST OS.
-I thought the approach to "osfopen()" was close enough to what we have in mind
-for pdclib to include the code here.
-
-{
- fnm = filename;
- modus = mode;
- err = 0;
- findSpareSpot();
- if (!err)
- {
- myfile = malloc(sizeof(FILE));
- if (myfile == NULL)
- {
- err = 1;
- }
- else
- {
- fopen2();
- if (err)
- {
- free(myfile);
- }
- }
- }
- if (err)
- {
- myfile = NULL;
- }
- return (myfile);
-}
-
-static void fopen2(void)
-{
- checkMode();
- if (!err)
- {
- osfopen();
- if (!err)
- {
- __userFiles[spareSpot] = myfile;
- myfile->intFno = spareSpot;
- fopen3();
- }
- }
- return;
-}
-
-static void fopen3(void)
-{
- myfile->intBuffer = malloc(BUFSIZ + 8);
- if (myfile->intBuffer == NULL)
- {
- err = 1;
- }
- else
- {
- myfile->theirBuffer = 0;
- myfile->fbuf = myfile->intBuffer + 2;
- *myfile->fbuf++ = '\0';
- *myfile->fbuf++ = '\0';
- myfile->szfbuf = BUFSIZ;
-#ifndef __MVS__
- myfile->quickText = 0;
-#endif
- myfile->noNl = 0;
- myfile->endbuf = myfile->fbuf + myfile->szfbuf;
- *myfile->endbuf = '\n';
-#ifdef __MVS__
- myfile->upto = myfile->fbuf;
- myfile->szfbuf = myfile->lrecl;
-#else
- myfile->upto = myfile->endbuf;
-#endif
- myfile->bufStartR = -(long)myfile->szfbuf;
- myfile->errorInd = 0;
- myfile->eofInd = 0;
- myfile->ungetCh = -1;
- myfile->update = 0;
-#ifndef __MVS__
- if (!myfile->textMode)
- {
- myfile->quickBin = 1;
- }
- else
- {
- myfile->quickBin = 0;
- }
-#endif
- myfile->mode = __READ_MODE;
- switch (modeType)
- {
- case 2:
- case 3:
- case 5:
- case 6:
- case 8:
- case 9:
- case 11:
- case 12:
- myfile->bufStartR = 0;
- myfile->upto = myfile->fbuf;
- myfile->mode = __WRITE_MODE;
- break;
- }
- switch (modeType)
- {
- case 7:
- case 8:
- case 10:
- case 11:
- case 12:
- myfile->update = 1;
- break;
- }
- }
- return;
-}