source: buchla-68k/orig/GP/STDOPEN.C@ 9519422

Last change on this file since 9519422 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 2.7 KB
Line 
1/*
2 =============================================================================
3 stdopen.c -- standard C file openers
4 Version 1 -- 1988-11-07 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define OPEN_AB /* define to compile stdopna(), stdopnb() */
9
10#include "stdio.h" /* standard I/O definitions */
11#include "stddefs.h" /* standard C utility definitions */
12
13extern char *pgmname; /* program name string pointer */
14
15extern short (*errterm)(); /* program error termination exit function */
16
17extern FILE *(*opnfail)(); /* file open error function */
18
19/*
20 =============================================================================
21 stdopen() -- standard C file opener -- system standard files
22 =============================================================================
23*/
24
25FILE *
26stdopen(name, mode)
27char *name, *mode;
28{
29 FILE *fp;
30
31 if ((FILE *)NULL EQ (fp = fopen(name, mode))) {
32
33 if (opnfail)
34 if ((FILE *)NULL NE (fp = (*opnfail)(name, mode)))
35 return(fp);
36
37 fprintf(stderr, "%s: ERROR - Unable to open \"%s\" in mode \"%s\".\n",
38 name, mode);
39
40 if (errterm)
41 (*errterm)();
42
43 fprintf(stderr, "%s: Program terminated due to I/O error.\n");
44 exit(1);
45 }
46
47 return(fp);
48}
49
50/*
51
52*/
53
54#ifdef OPEN_AB
55
56/*
57 =============================================================================
58 stdopna() -- standard C file opener -- ASCII files
59 =============================================================================
60*/
61
62FILE *
63stdopna(name, mode)
64char *name, *mode;
65{
66 FILE *fp;
67
68 if ((FILE *)NULL EQ (fp = fopena(name, mode))) {
69
70 if (opnfail)
71 if ((FILE *)NULL NE (fp = (*opnfail)(name, mode)))
72 return(fp);
73
74 fprintf(stderr, "%s: ERROR - Unable to open \"%s\" in mode \"%s\".\n",
75 name, mode);
76
77 if (errterm)
78 (*errterm)();
79
80 fprintf(stderr, "%s: Program terminated due to I/O error.\n");
81 exit(1);
82 }
83
84 return(fp);
85}
86
87#endif
88
89/*
90
91*/
92
93#ifdef OPEN_AB
94
95/*
96 =============================================================================
97 stdopnb() -- standard C file opener -- binary files
98 =============================================================================
99*/
100
101FILE *
102stdopnb(name, mode)
103char *name, *mode;
104{
105 FILE *fp;
106
107 if ((FILE *)NULL EQ (fp = fopenb(name, mode))) {
108
109 if (opnfail)
110 if ((FILE *)NULL NE (fp = (*opnfail)(name, mode)))
111 return(fp);
112
113 fprintf(stderr, "%s: ERROR - Unable to open \"%s\" in mode \"%s\".\n",
114 name, mode);
115
116 if (errterm)
117 (*errterm)();
118
119 fprintf(stderr, "%s: Program terminated due to I/O error.\n");
120 exit(1);
121 }
122
123 return(fp);
124}
125
126#endif
Note: See TracBrowser for help on using the repository browser.