File: io.c

package info (click to toggle)
libbow 19981105-1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,604 kB
  • ctags: 1,612
  • sloc: ansic: 17,174; makefile: 453; perl: 391; sh: 91
file content (60 lines) | stat: -rw-r--r-- 1,757 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* Input and ouput functions */

/* Copyright (C) 1997 Andrew McCallum

   Written by:  Andrew Kachites McCallum <mccallum@cs.cmu.edu>

   This file is part of the Bag-Of-Words Library, `libbow'.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License
   as published by the Free Software Foundation, version 2.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA */

#define _BOW_IO_INLINE_EXTERN

#include <bow/libbow.h>
/* This will compile the `io' functions without "inline extern" */

int bow_file_format_version = BOW_DEFAULT_FILE_FORMAT_VERSION;

/* History of file format versions:

   Before version 4:
   In Rainbow, write bow_file_format_version to disk in a separate file.

   Before version 5:
   Changed bow_cdoc.class, bow_de.di, bow_de.count from short to int.

   */

void
bow_write_format_version_to_file (const char *filename)
{
  FILE *fp;

  fp = bow_fopen (filename, "w");
  fprintf (fp, "%d\n", bow_file_format_version);
  fclose (fp);
}

void
bow_read_format_version_from_file (const char *filename)
{
  FILE *fp;
  int got_it;

  fp = bow_fopen (filename, "r");
  got_it = fscanf (fp, "%d\n", &bow_file_format_version);
  fclose (fp);
  if (got_it != 1)
    bow_error ("Failed to read bow_file_format_version from %s", filename);
}