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