--- src/sbin/jscan/jfile.c 2005/03/07 02:38:28 1.1 +++ src/sbin/jscan/jfile.c 2005/03/07 05:05:04 1.2 @@ -42,14 +42,24 @@ struct jfile * jopen_stream(const char *path, enum jdirection jdir) { + FILE *fp; + struct jfile *jf; + + if ((fp = fopen(path, "r")) == NULL) + return (NULL); + if ((jf = jopen_fp(fp, jdir)) == NULL) + fclose (fp); + return(jf); +} + +struct jfile * +jopen_fp(FILE *fp, enum jdirection jdir) +{ struct jfile *jf; jf = malloc(sizeof(struct jfile)); bzero(jf, sizeof(struct jfile)); - if ((jf->jf_fp = fopen(path, "r")) == NULL) { - free(jf); - return (NULL); - } + jf->jf_fp = fp; jf->jf_direction = jdir; jf->jf_setpt = -1; if (jdir == JF_BACKWARDS) {