Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4973 right-hear 1
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
2
#include 
3
#include 
4
#include 
5
#include 
6
#include 
7
#include 
8
#include 
9
 
10
int fclose(FILE *f)
11
{
12
  int r;
13
 
14
  r = EOF;
15
  if (!f)
16
    return r;
17
  if (f->_flag & (_IOREAD|_IOWRT|_IORW)
18
      && !(f->_flag&_IOSTRG))
19
  {
20
    r = fflush(f);
21
    if (close(fileno(f)) < 0)
22
      r = EOF;
23
    if (f->_flag&_IOMYBUF)
24
      free(f->_base);
25
  }
26
  if (f->_flag & _IORMONCL && f->_name_to_remove)
27
  {
28
    remove(f->_name_to_remove);
29
    free(f->_name_to_remove);
30
    f->_name_to_remove = 0;
31
  }
32
  f->_cnt = 0;
33
  f->_base = 0;
34
  f->_ptr = 0;
35
  f->_bufsiz = 0;
36
  f->_flag = 0;
37
  f->_file = -1;
38
  return r;
39
}