1 |
greg |
1.1 |
#ifndef lint |
2 |
schorsch |
1.2 |
static const char RCSid[] = "$Id: syscalls.c,v 1.1 2003/02/22 02:07:26 greg Exp $"; |
3 |
greg |
1.1 |
#endif |
4 |
|
|
/* |
5 |
|
|
* System calls for meta-file routines |
6 |
|
|
*/ |
7 |
|
|
|
8 |
schorsch |
1.2 |
#ifdef _WIN32 |
9 |
|
|
#include <process.h> /* getpid() */ |
10 |
|
|
#endif |
11 |
greg |
1.1 |
|
12 |
|
|
#include "meta.h" |
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
FILE * |
19 |
|
|
efopen(fname, mode) /* open a file, report errors */ |
20 |
|
|
|
21 |
|
|
char *fname, *mode; |
22 |
|
|
|
23 |
|
|
{ |
24 |
|
|
register FILE *fp; |
25 |
|
|
FILE *fopen(); |
26 |
|
|
|
27 |
|
|
if ((fp = fopen(fname, mode)) == NULL) { |
28 |
|
|
sprintf(errmsg, "cannot open file \"%s\", mode \"%s\"", fname, mode); |
29 |
|
|
error(USER, errmsg); |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
return(fp); |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
FILE * |
38 |
|
|
mfopen(fname, mode) /* open a program metafile */ |
39 |
|
|
|
40 |
|
|
char *fname; |
41 |
|
|
char *mode; |
42 |
|
|
|
43 |
|
|
{ |
44 |
|
|
char *mdir, stemp[MAXFNAME]; |
45 |
schorsch |
1.2 |
#if UNIX || MAC || _WIN32 |
46 |
greg |
1.1 |
char *getenv(); |
47 |
|
|
|
48 |
|
|
if ((mdir = getenv("MDIR")) == NULL) |
49 |
|
|
#endif |
50 |
|
|
mdir = MDIR; |
51 |
|
|
sprintf(stemp, "%s%s", mdir, fname); |
52 |
|
|
|
53 |
|
|
return(efopen(stemp, mode)); |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
#ifdef CPM |
59 |
|
|
getpid() /* for CP/M, get user number */ |
60 |
|
|
|
61 |
|
|
{ |
62 |
|
|
|
63 |
|
|
return(getusr()); |
64 |
|
|
} |
65 |
|
|
#endif |
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
#ifdef MAC |
70 |
|
|
getpid() /* dummy value for MacIntosh */ |
71 |
|
|
|
72 |
|
|
{ |
73 |
|
|
|
74 |
|
|
return(0); |
75 |
|
|
} |
76 |
|
|
#endif |