Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

cfopei.c File Reference

#include "kerngen/pilot.h"
#include "kerngen/fortranc.h"
#include <stdio.h>
#include <stdlib.h>
#include "kerngen/cf_open.h"
#include <errno.h>
#include "kerngen/cf_xaft.h"
#include "kerngen/fortchar.h"
#include "kerngen/wordsizc.h"

Go to the source code of this file.

Functions

void type_of_call cfopei_ (int *lundes, int *medium, int *nwrec, int *mode, int *nbuf, char *ftext, int *stat, int *lgtx)

Variables

int cfopen_perm = 0


Function Documentation

void type_of_call cfopei_ int *  lundes,
int *  medium,
int *  nwrec,
int *  mode,
int *  nbuf,
char *  ftext,
int *  stat,
int *  lgtx
 

Definition at line 58 of file cfopei.c.

References cfopen_perm, done(), fchtak(), and type_of_call.

00079 {
00080       char *pttext, *fchtak();
00081       int  flags;
00082       int  fildes;
00083       int  perm;
00084 
00085       *lundes = 0;
00086       *stat   = -1;
00087 
00088       perm = cfopen_perm;
00089       cfopen_perm = 0;
00090 
00091 /*        construct flags :
00092             mode[0] =    0 r    1 w    2 a
00093             mode[1] =    1 +
00094 */
00095 /*        flags for disk     */
00096 
00097       if (*medium == 1)            goto fltp;
00098       if (*medium == 3)            goto fltp;
00099 
00100       if (mode[0] == 0)
00101         {if (mode[1] == 0)
00102           flags = O_RDONLY;
00103         else
00104           flags = O_RDWR;}
00105 
00106       else if (mode[0] == 1)
00107         {if (mode[1] == 0)
00108           flags = O_WRONLY | O_CREAT | O_TRUNC;
00109         else
00110           flags = O_RDWR | O_CREAT | O_TRUNC;}
00111 
00112       else if (mode[0] == 2)
00113         {if (mode[1] == 0)
00114           flags = O_WRONLY | O_CREAT | O_APPEND;
00115         else
00116           flags = O_RDWR | O_CREAT | O_APPEND;}
00117       goto act;
00118 
00119 /*        flags for tape     */
00120 
00121 fltp: if (mode[0] == 0)
00122         {if (mode[1] == 0)
00123           flags = O_RDONLY;
00124         else
00125           flags = O_RDWR;}
00126 
00127       else if (mode[0] == 1)
00128         {if (mode[1] == 0)
00129           flags = O_WRONLY;
00130         else
00131           flags = O_RDWR;}
00132 
00133       else if (mode[0] == 2)       return;
00134 
00135 /*        open the file      */
00136 
00137 act:  pttext = fchtak(ftext,*lgtx);
00138       if (pttext == 0)             return;
00139 
00140       if (perm == 0)   perm = 0644;
00141 
00142 #if defined(CERNLIB_QMDOS) || defined(CERNLIB_WINNT)
00143       fildes = open (pttext, flags | O_BINARY, perm);
00144 #else
00145       fildes = open (pttext, flags, perm);
00146 #endif
00147       if (fildes < 0)              goto errm;
00148       *lundes = fildes;
00149       *stat   = 0;
00150       goto done;
00151 
00152 #if defined(CERNLIB_PROJSHIFT)
00153 errm: *stat = (serrno ? serrno : (rfio_errno ? rfio_errno : errno));
00154 #else
00155 errm: *stat = errno;
00156 #endif
00157       perror (" error in CFOPEN");
00158 
00159 done: free(pttext);
00160       return;
00161 }


Variable Documentation

int cfopen_perm = 0
 

Definition at line 56 of file cfopei.c.

Referenced by cfopei_().


Generated on Mon Feb 15 11:07:55 2010 for loon by  doxygen 1.3.9.1