-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.h
35 lines (35 loc) · 999 Bytes
/
db.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
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdint.h>
#define ptrdist(a,b) (((char *)a)-((char *)b))
#define ptrmov(a,b) ((typeof(a)) (((char *)(a))+b))
#define nextstruct(p) ((typeof(p)) (((char *)(p))+sizeof(*p)+1+strlen(((char *)(p))+sizeof(*p) )))
#define structsize(p) {typeof(p) _r=p; while (_r->name[0]) _r=nextstruct(_r); size=ptrdist(_r,p)+3*sizeof(*p)+1; }
typedef struct {
char name[1];
} mimeinfo;
typedef struct {
/*#define ATR(x,y) x y , min##y , max##y;
#define ATR2(x,y)
#include "atrs.h"*/
int mtime;
int firstfile,filesize,firstdir,dirsize;
char name[1];
} dirinfo;
typedef struct {
short int mime;
char name[1];
} fileinfo;
typedef struct {
char *path;
mimeinfo *mimes,*mimep;
dirinfo *dirs,*dirp,*ldir;
fileinfo *files,*filep,*lfile;
} dbase;
dbase *makedb(char *path);
dbase *readdb(char *path);
dbase * dbdup(dbase *d);
dbase *createdb();
void copydir(dbase *old,dbase *ne,char *path,int rec);
void writedb(dbase * db,char *path);