-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdatabase.h
134 lines (102 loc) · 3.37 KB
/
database.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
** $Filename: data\database.h
** $Release: 1
** $Revision: 0
** $Date: 09-03-94
**
** database interface for "Der Clou!"
**
** (c) 1994 ...and avoid panic by, Kaweh Kazemi
** All Rights Reserved.
**
*/
/****************************************************************************
Portions copyright (c) 2005 Vasco Alexandre da Silva Costa
Please read the license terms contained in the LICENSE and
publiclicensecontract.doc files which should be contained with this
distribution.
****************************************************************************/
#ifndef MODULE_DATABASE
#define MODULE_DATABASE
/* includes */
#include "theclou.h"
#include "data/relation.h"
#include "list/list.h"
#include "disk/disk.h"
#include "text/text.h"
#include "data/objstd/tcdata.h"
#define GET_OUT ((U8)-1)
/* public defines */
#define DB_LOAD_MODE_STD 1
#define DB_LOAD_MODE_NO_NAME 0
#define OLF_NORMAL (0)
#define OLF_INCLUDE_NAME (1)
#define OLF_INSERT_STAR (1 << 1)
#define OLF_PRIVATE_LIST (1 << 2)
#define OLF_ADD_PREV_STRING (1 << 3)
#define OLF_ADD_SUCC_STRING (1 << 4)
#define OLF_ALIGNED (1 << 5)
#define OL_NAME(n) ((char *)NODE_NAME((NODE *)n))
#define OL_NR(n) (((struct ObjectNode *)n)->nr)
#define OL_TYPE(n) (((struct ObjectNode *)n)->type)
#define OL_DATA(n) (((struct ObjectNode *)n)->data)
#define OBJ_HASH_SIZE 31
/* public structures */
struct dbObject {
NODE link;
U32 nr;
U32 type;
U32 realNr;
};
struct dbObjectHeader {
U32 nr;
U32 type;
U32 size;
};
struct ObjectNode {
NODE Link;
U32 nr;
U32 type;
void *data;
};
/* public global data */
extern LIST *ObjectList;
extern LIST *ObjectListPrivate;
extern U32 ObjectListWidth;
extern char *(*ObjectListPrevString) (U32, U32, void *);
extern char *(*ObjectListSuccString) (U32, U32, void *);
extern LIST *objHash[OBJ_HASH_SIZE];
/* public prototypes - OBJECTS */
U8 dbLoadAllObjects(char *fileName, U16 diskId);
U8 dbSaveAllObjects(char *fileName, U32 offset, U32 size, U16 diskId);
void dbDeleteAllObjects(U32 offset, U32 size);
U32 dbGetObjectCountOfDB(U32 offset, U32 size);
void dbSetLoadObjectsMode(U8 mode);
/* public prototypes - OBJECT */
void *dbNewObject(U32 nr, U32 type, U32 size, char *name, U32 realNr);
void dbDeleteObject(U32 nr);
void *dbGetObject(U32 nr);
U32 dbGetObjectNr(void *key);
char *dbGetObjectName(U32 nr, char *objName);
void *dbIsObject(U32 nr, U32 type);
/* public prototypes - OBJECTNODE */
struct ObjectNode *dbAddObjectNode(LIST * objectList, U32 nr, U32 flags);
void dbRemObjectNode(LIST * objectList, U32 nr);
struct ObjectNode *dbHasObjectNode(LIST * objectList, U32 nr);
void SetObjectListAttr(U32 flags, U32 type);
void BuildObjectList(void *key);
void ExpandObjectList(LIST * objectList, char *expandItem);
S16 dbStdCompareObjects(struct ObjectNode *obj1, struct ObjectNode *obj2);
S32 dbSortObjectList(LIST ** objectList,
S16(*processNode) (struct ObjectNode *,
struct ObjectNode *));
void dbSortPartOfList(LIST * objectList, struct ObjectNode *start,
struct ObjectNode *end,
S16(*processNode) (struct ObjectNode *,
struct ObjectNode *));
struct ObjectNode *dbAddObjectNode(LIST * objectList, U32 nr, U32 flags);
void dbRemObjectNode(LIST * objectList, U32 nr);
/* public prototypes */
void dbInit(void);
void dbDone(void);
#endif