1 /* $XConsortium: DtsMM.h /main/8 1996/08/28 14:27:26 rswiston $ */
4 * RESTRICTED CONFIDENTIAL INFORMATION:
7 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
15 #include <Dt/DtShmDb.h>
16 #include <X11/Intrinsic.h>
17 #include "Dt/DbReader.h"
19 #define DTDTSDB_TMPDATABASENAME "%s/.dt/.tmp_dt_db_cache.%s\0"
20 #define DTDTSDB_DATABASENAME "%s/.dt/.dt_db_cache.%s\0"
21 #define _DTDTSMMTEMPFILE "dtdbcache_"
24 * NOTE: _DTDTSMMTEMPDIR affects the location of the dtdbcache
25 * file, and therefore affects the Xsession.src, Xreset.src, and
26 * Xstartup.src scripts in dtlogin/config.
29 # define _DTDTSMMTEMPDIR "/var/tmp"
31 # define _DTDTSMMTEMPDIR "/tmp"
34 typedef int DtDtsMMSeqNo; /* the order it occures in db */
35 typedef int DtDtsMMFieldCount; /* number of fields in record */
36 typedef int DtDtsMMRecordCount; /* number of records in field */
37 typedef int DtDtsMMDataBaseCount; /* how many databases */
38 typedef int DtDtsMMFieldStart; /* index in table where field list starts */
39 typedef int DtDtsMMRecordStart; /* index in table where record list starts */
40 typedef int DtDtsMMDataBaseStart; /* index in table where database list starts */
41 typedef int DtDtsMMIndexOffset;
42 typedef int DtDtsMMNameIndex;
43 typedef int DtDtsMMPathHash;
47 DtDtsMMPathHash pathhash; /* hash of dir. we visit */
48 DtDtsMMDataBaseCount num_db; /* number of databases */
49 DtDtsMMDataBaseStart db_offset; /* index to databases */
50 DtDtsMMNameIndex name_list_offset; /* index to name list */
51 DtDtsMMNameIndex no_name_offset; /* index to nonunique names */
52 DtDtsMMNameIndex buffer_start_index; /* index to list of buffers */
53 DtDtsMMIndexOffset str_tbl_offset; /* index to table of strings */
54 DtDtsMMIndexOffset files_count; /* number of loaded files */
55 DtDtsMMIndexOffset files_offset; /* index to list of loaded files */
56 DtDtsMMIndexOffset mtimes_offset; /* index to modified times of files */
59 /* one set of attribute/pair */
62 DtShmBoson fieldName; /* name of attribute */
63 DtShmBoson fieldValue; /* value of attribute */
66 /* typedefs for casting comparison functions if needed */
67 typedef int (*_DtDtsMMFieldCompare)(DtDtsMMField *fld1, DtDtsMMField *fld2);
69 /* entry of a list of attribute/pairs */
72 DtShmBoson recordName; /* name of this entry */
73 DtShmBoson pathId; /* file entry is located in */
74 DtDtsMMSeqNo seq; /* sequence this got loaded */
75 DtDtsMMFieldCount fieldCount; /* number of fields in record */
76 DtDtsMMFieldStart fieldList; /* index to field table */
79 /* typedefs for casting record comparison functions if needed */
80 typedef int (*_DtDtsMMRecordCompare)(DtDtsMMRecord *rec1, DtDtsMMRecord *rec2);
82 /* a "database" of a collection of entrys (i.e. OBJECT-TYPE, ACTION, FILE-TYPE
83 This is a private Structure to the DtDtsMM component.
87 DtShmBoson databaseName; /* name of database */
88 DtDtsMMIndexOffset nameIndex; /* index for DataCriteria quick find */
89 DtDtsMMRecordCount recordCount; /* number of records */
90 DtDtsMMRecordStart recordList; /* index to records table */
94 /* Db Internal pointers */
95 int * _DtDtsMMGetDCNameIndex(int *size);
96 int * _DtDtsMMGetBufferIndex(int *size);
97 int * _DtDtsMMGetNoNameIndex(int *size);
98 void * _DtDtsMMGetPtr(int index);
99 DtShmInttab _DtDtsMMGetFileList(void);
100 int _DtDtsMMGetPtrSize(int index);
101 int _DtDtsMMInit(int);
102 void _DtDtsMMPrint(FILE *org_fd);
103 int _DtDtsMMCreateDb(DtDirPaths *dirs, const char *CacheFile, int override);
104 int _DtDtsMMCreateFile(DtDirPaths *dirs, const char *CacheFile);
105 char * _DtDtsMMCacheName(int);
106 int _DtDtsMMapDB(const char *CacheFile);
108 const char * _DtDtsMMBosonToString(DtShmBoson boson);
109 DtShmBoson _DtDtsMMStringToBoson(const char *string);
111 extern int use_in_memory_db;
114 /* returns the handle for the database where name is the Database name */
115 extern DtDtsMMDatabase *_DtDtsMMGet(const char *name);
116 extern char **_DtDtsMMListDb(void);
118 /* Name Comparison functions:
119 * These routines can be passed in to the corresponding sort function to
123 extern int _DtDtsMMCompareRecordNames(DtDtsMMRecord *entry1, DtDtsMMRecord *entry2);
124 extern int _DtDtsMMCompareFieldNames(DtDtsMMField *entry1, DtDtsMMField *entry2);
126 /* retrieves the Record that matches the specified entry from the record */
127 extern DtDtsMMField *_DtDtsMMGetField(DtDtsMMRecord *record,
129 extern const char *_DtDtsMMGetFieldByName(DtDtsMMRecord *rec, const char *name);
131 /* retrieves the entry of the specified entry from the specified database */
132 extern DtDtsMMRecord *_DtDtsMMGetRecord(DtDtsMMDatabase *database,
133 DtDtsMMRecord *value);
134 extern DtDtsMMRecord *_DtDtsMMGetRecordByName(DtDtsMMDatabase *database,
137 /* Get By Name functions:
138 * retrieves the entry of the specified name from the specified database
139 * ** IF ** the _DtDtsMM*Sort routine has been called with the corresponding
140 * _DtDtsMMCompare*Name comparison function. Otherwise use the standard
141 * _DtDtsMMGet* functions.
145 char * _DtDtsMMExpandValue(const char *value);
146 void _DtDtsMMSafeFree(char *value);
147 int _DtDtsMMIsMemory(const char *value);
149 extern DtShmBoson _DtDtsMMNameStringToBoson(const char *string);
152 #endif /* DT_DTS_MM_H */