5
5
* Written by Fabian Knittel <fknittel@gmx.de>
7
* $Id: filedb3.h,v 1.11 2002/01/02 03:46:38 guppy Exp $
7
* $Id: filedb3.h,v 1.16 2004/01/09 05:56:38 wcc Exp $
10
* Copyright (C) 1999, 2000, 2001, 2002 Eggheads Development Team
10
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Eggheads Development Team
12
12
* This program is free software; you can redistribute it and/or
13
13
* modify it under the terms of the GNU General Public License
27
27
#ifndef _EGG_MOD_FILESYS_FILEDB3_H
28
28
#define _EGG_MOD_FILESYS_FILEDB3_H
30
#include <time.h> /* for time_t */
31
* FIXME: These really should be in the .c files that include this header
38
#ifdef TIME_WITH_SYS_TIME
39
# include <sys/time.h>
42
# ifdef HAVE_SYS_TIME_H
43
# include <sys/time.h>
32
49
/* Top of each DB */
34
char version; /* DB version */
35
time_t timestamp; /* Last updated */
51
char version; /* DB version */
52
time_t timestamp; /* Last updated */
38
55
/* Header of each entry */
40
time_t uploaded; /* Upload time */
41
unsigned int size; /* File size */
42
unsigned short int stat; /* Misc information */
43
unsigned short int gots; /* Number of gets */
44
unsigned short int filename_len; /* Length of filename buf */
45
unsigned short int desc_len; /* Length of description buf */
46
unsigned short int sharelink_len; /* Length of sharelink buf */
47
unsigned short int chan_len; /* Length of channel name buf */
48
unsigned short int uploader_len; /* Length of uploader buf */
49
unsigned short int flags_req_len; /* Length of flags buf */
50
unsigned short int buffer_len; /* Length of additional buffer */
57
time_t uploaded; /* Upload time */
58
unsigned int size; /* File size */
59
unsigned short int stat; /* Misc information */
60
unsigned short int gots; /* Number of gets */
61
unsigned short int filename_len; /* Length of filename buf */
62
unsigned short int desc_len; /* Length of description buf */
63
unsigned short int sharelink_len; /* Length of sharelink buf */
64
unsigned short int chan_len; /* Length of channel name buf */
65
unsigned short int uploader_len; /* Length of uploader buf */
66
unsigned short int flags_req_len; /* Length of flags buf */
67
unsigned short int buffer_len; /* Length of additional buffer */
53
70
/* Structure used to pass data between lower level
54
71
* and higher level functions.
57
time_t uploaded; /* Upload time */
58
unsigned int size; /* File size */
59
unsigned short int stat; /* Misc information */
60
unsigned short int gots; /* Number of gets */
61
unsigned short int _type; /* Type of entry (private) */
74
time_t uploaded; /* Upload time */
75
unsigned int size; /* File size */
76
unsigned short int stat; /* Misc information */
77
unsigned short int gots; /* Number of gets */
78
unsigned short int _type; /* Type of entry (private) */
63
80
/* NOTE: These three are only valid during one db open/close. Entry
64
81
* movements often invalidate them too, so make sure you know
65
82
* what you're doing before using/relying on them.
67
long pos; /* Last position in the filedb */
68
unsigned short int dyn_len; /* Length of dynamic data in DB */
69
unsigned short int buf_len; /* Length of additional buffer */
84
long pos; /* Last position in the filedb */
85
unsigned short int dyn_len; /* Length of dynamic data in DB */
86
unsigned short int buf_len; /* Length of additional buffer */
71
char *filename; /* Filename */
72
char *desc; /* Description */
73
char *sharelink; /* Share link. Points to remote
74
file on linked bot. */
75
char *chan; /* Channel name */
76
char *uploader; /* Uploader */
77
char *flags_req; /* Required flags */
88
char *filename; /* Filename */
89
char *desc; /* Description */
90
char *sharelink; /* Share link. Points to remote
91
* file on linked bot. */
92
char *chan; /* Channel name */
93
char *uploader; /* Uploader */
94
char *flags_req; /* Required flags */
85
#define my_free(ptr) \
102
#define my_free(ptr) \
91
108
/* Copy entry to target -- Uses dynamic memory allocation, which
92
109
* means you'll eventually have to free the memory again. 'target'
93
110
* will be overwritten.
95
#define malloc_strcpy(target, entry) \
98
(target) = nrealloc((target), strlen(entry) + 1); \
99
strcpy((target), (entry)); \
112
#define malloc_strcpy(target, entry) \
115
(target) = nrealloc((target), strlen(entry) + 1); \
116
strcpy((target), (entry)); \
104
121
/* Macro to calculate the total length of dynamic data. */
105
#define filedb_tot_dynspace(fdh) ((fdh).filename_len + (fdh).desc_len + \
106
(fdh).chan_len + (fdh).uploader_len + (fdh).flags_req_len + \
122
#define filedb_tot_dynspace(fdh) ((fdh).filename_len + (fdh).desc_len + \
123
(fdh).chan_len + (fdh).uploader_len + (fdh).flags_req_len + \
109
#define filedb_zero_dynspace(fdh) { \
110
(fdh).filename_len = 0; \
111
(fdh).desc_len = 0; \
112
(fdh).chan_len = 0; \
113
(fdh).uploader_len = 0; \
114
(fdh).flags_req_len = 0; \
115
(fdh).sharelink_len = 0; \
126
#define filedb_zero_dynspace(fdh) { \
127
(fdh).filename_len = 0; \
128
(fdh).desc_len = 0; \
129
(fdh).chan_len = 0; \
130
(fdh).uploader_len = 0; \
131
(fdh).flags_req_len = 0; \
132
(fdh).sharelink_len = 0; \
118
135
/* Memory debugging makros */
131
#define FILEDB_VERSION1 0x0001
132
#define FILEDB_VERSION2 0x0002 /* DB version used for 1.3, 1.4 */
133
#define FILEDB_VERSION3 0x0003
134
#define FILEDB_NEWEST_VER FILEDB_VERSION3 /* Newest DB version */
136
#define POS_NEW 0 /* Position which indicates that the
137
entry wants to be repositioned. */
139
#define FILE_UNUSED 0x0001 /* Deleted entry. */
140
#define FILE_DIR 0x0002 /* It's actually a directory. */
141
#define FILE_SHARE 0x0004 /* Can be shared on the botnet. */
142
#define FILE_HIDDEN 0x0008 /* Hidden file. */
143
#define FILE_ISLINK 0x0010 /* The file is a link to another bot. */
145
#define FILEDB_ESTDYN 50 /* Estimated dynamic length of an entry */
148
#define FILEDB_VERSION1 0x0001
149
#define FILEDB_VERSION2 0x0002 /* DB version used for 1.3, 1.4 */
150
#define FILEDB_VERSION3 0x0003
151
#define FILEDB_NEWEST_VER FILEDB_VERSION3 /* Newest DB version */
153
#define POS_NEW 0 /* Position which indicates that the
154
* entry wants to be repositioned. */
156
#define FILE_UNUSED 0x0001 /* Deleted entry. */
157
#define FILE_DIR 0x0002 /* It's actually a directory. */
158
#define FILE_SHARE 0x0004 /* Can be shared on the botnet. */
159
#define FILE_HIDDEN 0x0008 /* Hidden file. */
160
#define FILE_ISLINK 0x0010 /* The file is a link to another bot. */
162
#define FILEDB_ESTDYN 50 /* Estimated dynamic length of an entry */
148
GET_HEADER, /* Only save minimal data */
149
GET_FILENAME, /* Additionally save filename */
150
GET_FULL, /* Save all data */
152
UPDATE_HEADER, /* Only update header */
153
UPDATE_SIZE, /* Update header, enforce new buf sizes */
154
UPDATE_ALL, /* Update additional data too */
156
TYPE_NEW, /* New entry */
157
TYPE_EXIST /* Existing entry */
165
GET_HEADER, /* Only save minimal data */
166
GET_FILENAME, /* Additionally save filename */
167
GET_FULL, /* Save all data */
169
UPDATE_HEADER, /* Only update header */
170
UPDATE_SIZE, /* Update header, enforce new buf sizes */
171
UPDATE_ALL, /* Update additional data too */
173
TYPE_NEW, /* New entry */
174
TYPE_EXIST /* Existing entry */