1: #include "hd.h" 2: 3: /* Open a showfile */ 4: /* Open with rwmode of "r" or "w" just like fopen */ 5: /* Smode GREPMODE opens for grep; Smode MAKEMODE opens for Make; */ 6: 7: FILE *showopen (rwmode, smode) char *rwmode; int smode; { 8: 9: extern char *envhome; 10: char buf[STRMAX + 20]; 11: FILE *tfile; 12: char *fname; 13: 14: fname = smode == GREPMODE ? GREPOUT : MAKERROR; 15: tfile = fopen (fname, rwmode); 16: if (tfile == NULL && smode == GREPMODE) { 17: if (access (fname, 0) == 0) { 18: myperror (fname); 19: return NULL; 20: } 21: strcpy (buf, envhome); 22: strcat (buf, "/"); 23: strcat (buf, fname); 24: tfile = fopen (buf, rwmode); 25: } 26: if (tfile == NULL) { 27: myperror (fname); 28: } 29: return tfile; 30: }