-
Notifications
You must be signed in to change notification settings - Fork 1
/
fileio.h
78 lines (67 loc) · 2.94 KB
/
fileio.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef SOMPAK_FILEIO_H
#define SOMPAK_FILEIO_H
/************************************************************************
* *
* Program packages 'lvq_pak' and 'som_pak' : *
* *
* fileio.h *
* - header file for fileio.c. *
* *
* Version 3.2 *
* Date: 21 Aug 1995 *
* *
* NOTE: This program package is copyrighted in the sense that it *
* may be used for scientific purposes. The package as a whole, or *
* parts thereof, cannot be included or used in any commercial *
* application without written permission granted by its producents. *
* No programs contained in this package may be copied for commercial *
* distribution. *
* *
* All comments concerning this program package may be sent to the *
* e-mail address 'lvq@cochlea.hut.fi'. *
* *
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "errors.h"
#include "config.h"
/* these should be moved to config.h or something similar */
/* default commands for compressing and uncompressing files */
#ifndef DEF_COMPRESS_COM
#define DEF_COMPRESS_COM "gzip -9 -c >%s"
#endif /* DEF_COMPRESS_COM */
#ifndef DEF_UNCOMPRESS_COM
#define DEF_UNCOMPRESS_COM "gzip -d -c %s"
#endif /* DEF_UNCOMPRESS_COM */
#ifndef NO_PIPED_COMMANDS
extern char *compress_command, *uncompress_command;
#endif /* NO_PIPED_COMMANDS */
struct file_info {
char *name;
FILE *fp;
struct {
unsigned int compressed : 1; /* is the file compressed */
unsigned int pipe : 1; /* the file is a pipe */
unsigned int eof : 1; /* has end of line been reached */
} flags;
int error; /* error code or 0 if OK */
long lineno; /* line number we are on */
};
#define fi2fp(fi) ((fi != NULL) ? (fi)->fp : NULL)
#ifndef STR_LNG
#define STR_LNG 2000
#endif
#ifndef ABS_STR_LNG
#define ABS_STR_LNG 50000
#endif
/* prototypes */
struct file_info *open_file(char *name, char *fmode);
int close_file(struct file_info *fi);
char *getline_file(struct file_info *fi);
int rewind_file(struct file_info *fi);
#if defined(__GLIBC__)
/* for getting the program name */
char *setprogname(char *argv0);
#define getprogname() setprogname(NULL);
#endif
#endif /* SOMPAK_FILEIO_H */