Back to index

radiance  4R0+20100331
syscalls.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: syscalls.c,v 1.4 2003/08/01 14:14:24 schorsch Exp $";
00003 #endif
00004 /*
00005  *  System calls for meta-file routines
00006  */
00007 
00008 #include "rtprocess.h" /* getpid() */
00009 #include "rterror.h"
00010 #include  "meta.h"
00011 
00012 
00013 FILE *
00014 efopen(fname, mode)         /* open a file, report errors */
00015 
00016 char  *fname, *mode;
00017 
00018 {
00019  register FILE  *fp;
00020  FILE  *fopen();
00021 
00022  if ((fp = fopen(fname, mode)) == NULL)  {
00023     sprintf(errmsg, "cannot open file \"%s\", mode \"%s\"", fname, mode);
00024     error(USER, errmsg);
00025     }
00026 
00027  return(fp);
00028  }
00029 
00030 
00031 
00032 FILE *
00033 mfopen(fname, mode)         /* open a program metafile */
00034 
00035 char  *fname;
00036 char  *mode;
00037 
00038 {
00039     char  *mdir, stemp[MAXFNAME];
00040     char  *getenv();
00041 
00042     if ((mdir = getenv("MDIR")) == NULL)
00043        mdir = MDIR;
00044     sprintf(stemp, "%s%s", mdir, fname);
00045 
00046     return(efopen(stemp, mode));
00047 }
00048 
00049