1 /* $Id: $ */
2 
3 /* Copyright (C) 1997 Sverre Hvammen Johansen,
4  * Department of Informatics, University of Oslo.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #include "cim.h"
21 #include "simfile.h"
22 
23 /******************************************************************************
24                                          BOOLEAN PROCEDURE CLOSE             */
25 
26 char
__riclose(p)27 __riclose (p)
28      __bs1FILE *p;
29 {
30   if (p->open)
31     {
32       if (((__bs1FILE *) p)->re_wind == __REWIND
33 	  && fseek (((__bs1FILE *) p)->file, 0L, 0) == __EOF)
34 	__rerror ("Close: Not possible to rewind");
35       fclose (((__bs1FILE *) p)->file);
36 #if HAVE_UNLINK
37       if (((__bs1FILE *) p)->purge == __PURGE)
38 	(void) unlink (p->filename.obj->string);
39 #endif
40       ((__bs2FILE *) p)->IMAGE.obj = __NULL;
41       ((__bs2FILE *) p)->IMAGE.length = 0;
42       ((__bs2FILE *) p)->IMAGE.pos = 0;
43       ((__bs2FILE *) p)->IMAGE.start = 0;
44       p->open = __FALSE;
45       return ((((__bs4FILE *) p)->endfile = __TRUE));
46     }
47   else
48     return (__FALSE);
49 }
50