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