Changed prototype for chr_map_input - added const.
[idzebra-moved-to-github.git] / include / mfile.h
1 /*
2  * Copyright (C) 1994-1995, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: mfile.h,v $
7  * Revision 1.7  1997-09-05 15:30:01  adam
8  * Changed prototype for chr_map_input - added const.
9  * Added support for C++, headers uses extern "C" for public definitions.
10  *
11  * Revision 1.6  1996/10/29 13:46:10  adam
12  * Removed obsolete headers alexpath, alexutil. Created zebrautl.h as
13  * a replacement.
14  *
15  * Revision 1.5  1995/12/05 11:15:03  quinn
16  * Fixed FILENAME_MAX for some Sun systems, hopefully.
17  *
18  * Revision 1.4  1995/11/30  08:33:30  adam
19  * Started work on commit facility.
20  *
21  * Revision 1.3  1995/09/04  12:33:35  adam
22  * Various cleanup. YAZ util used instead.
23  *
24  * Revision 1.2  1994/09/14  13:10:36  quinn
25  * Small changes
26  *
27  * Revision 1.1  1994/08/23  14:41:46  quinn
28  * First functional version of mfile.
29  *
30  */
31
32 #ifndef MFILE_H
33 #define MFILE_H
34
35 #include <stdio.h>
36
37 #ifndef FILENAME_MAX
38 #include <sys/param.h>
39 #define FILENAME_MAX MAXPATHLEN
40 #endif
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #define MF_MIN_BLOCKS_CREAT 1          /* minimum free blocks in new dir */
47 #define MF_DEFAULT_AREA "register"      /* Use if no mf_init */
48 #define MF_MAX_PARTS 28                 /* max # of part-files per metafile */
49
50 #define mf_blocksize(mf) ((mf)->blocksize)
51
52 typedef struct mf_dir
53 {
54     char name[FILENAME_MAX+1];
55     int max_bytes;      /* allocated bytes in this dir. */
56     int avail_bytes;    /* bytes left */
57     struct mf_dir *next;
58 } mf_dir;
59
60 typedef struct part_file
61 {
62     int number;
63     int top;
64     int blocks;
65     int bytes;
66     mf_dir *dir;
67     char *path;
68     int fd;
69 } part_file;
70
71 struct MFile_area_struct;
72 typedef struct MFile_area_struct *MFile_area;
73
74 typedef struct meta_file
75 {
76     char name[FILENAME_MAX+1];
77     part_file files[MF_MAX_PARTS];
78     int no_files;
79     int cur_file;
80     int open;                          /* is this file open? */
81     int blocksize;
82     int min_bytes_creat;  /* minimum bytes required to enter directory */
83     MFile_area ma;
84     int wr;
85
86     struct meta_file *next;
87 } *MFile, meta_file;
88
89 typedef struct MFile_area_struct
90 {
91     char name[FILENAME_MAX+1];
92     mf_dir *dirs;
93     struct meta_file *mfiles;
94     struct MFile_area_struct *next;  /* global list of active areas */
95 } MFile_area_struct;
96
97 /*
98  * Open an area, cotaining metafiles in directories.
99  */
100 MFile_area mf_init(const char *name); 
101
102 /*
103  * Release an area.
104  */
105 int mf_dispose(MFile_area ma);
106
107 /*
108  * Open a metafile.
109  */
110 MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag);
111
112 /*
113  * Close a metafile.
114  */
115 int mf_close(MFile mf);
116
117 /*
118  * Read one block from a metafile. Interface mirrors bfile.
119  */
120 int mf_read(MFile mf, int no, int offset, int num, void *buf);
121
122 /*
123  * Same.
124  */
125 int mf_write(MFile mf, int no, int offset, int num, const void *buf);
126
127 /*
128  * Destroy a metafile, unlinking component files. File must be open.
129  */
130 int mf_unlink(MFile mf);
131
132 /*
133  * Unlink the file by name, rather than MFile-handle.
134  */
135 int mf_unlink_name(MFile_area, const char *name);
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #endif