| 1 |
greg |
1.1 |
#ifndef lint
|
| 2 |
greg |
1.5 |
static const char RCSid[] = "$Id: syscalls.c,v 1.4 2003/08/01 14:14:24 schorsch Exp $";
|
| 3 |
greg |
1.1 |
#endif
|
| 4 |
|
|
/*
|
| 5 |
|
|
* System calls for meta-file routines
|
| 6 |
|
|
*/
|
| 7 |
|
|
|
| 8 |
schorsch |
1.3 |
#include "rtprocess.h" /* getpid() */
|
| 9 |
|
|
#include "rterror.h"
|
| 10 |
greg |
1.1 |
#include "meta.h"
|
| 11 |
|
|
|
| 12 |
|
|
|
| 13 |
|
|
FILE *
|
| 14 |
greg |
1.5 |
efopen( /* open a file, report errors */
|
| 15 |
|
|
const char *fname,
|
| 16 |
|
|
const char *mode
|
| 17 |
|
|
)
|
| 18 |
greg |
1.1 |
{
|
| 19 |
greg |
1.5 |
FILE *fp;
|
| 20 |
greg |
1.1 |
FILE *fopen();
|
| 21 |
|
|
|
| 22 |
|
|
if ((fp = fopen(fname, mode)) == NULL) {
|
| 23 |
|
|
sprintf(errmsg, "cannot open file \"%s\", mode \"%s\"", fname, mode);
|
| 24 |
|
|
error(USER, errmsg);
|
| 25 |
|
|
}
|
| 26 |
|
|
|
| 27 |
|
|
return(fp);
|
| 28 |
|
|
}
|
| 29 |
|
|
|
| 30 |
|
|
|
| 31 |
|
|
|
| 32 |
|
|
FILE *
|
| 33 |
greg |
1.5 |
mfopen( /* open a program metafile */
|
| 34 |
|
|
const char *fname,
|
| 35 |
|
|
const char *mode
|
| 36 |
|
|
)
|
| 37 |
greg |
1.1 |
{
|
| 38 |
|
|
char *mdir, stemp[MAXFNAME];
|
| 39 |
|
|
char *getenv();
|
| 40 |
|
|
|
| 41 |
|
|
if ((mdir = getenv("MDIR")) == NULL)
|
| 42 |
|
|
mdir = MDIR;
|
| 43 |
|
|
sprintf(stemp, "%s%s", mdir, fname);
|
| 44 |
|
|
|
| 45 |
|
|
return(efopen(stemp, mode));
|
| 46 |
|
|
}
|
| 47 |
|
|
|
| 48 |
|
|
|