2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: DtsMM.h /main/8 1996/08/28 14:27:26 rswiston $ */
26 * RESTRICTED CONFIDENTIAL INFORMATION:
29 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
37 #include <Dt/DtShmDb.h>
38 #include <X11/Intrinsic.h>
39 #include "Dt/DbReader.h"
41 #define DTDTSDB_TMPDATABASENAME "%s/.dt/.tmp_dt_db_cache.%s\0"
42 #define DTDTSDB_DATABASENAME "%s/.dt/.dt_db_cache.%s\0"
43 #define _DTDTSMMTEMPFILE "dtdbcache_"
46 * NOTE: _DTDTSMMTEMPDIR affects the location of the dtdbcache
47 * file, and therefore affects the Xsession.src, Xreset.src, and
48 * Xstartup.src scripts in dtlogin/config.
51 # define _DTDTSMMTEMPDIR "/var/tmp"
53 # define _DTDTSMMTEMPDIR "/tmp"
56 typedef int DtDtsMMSeqNo; /* the order it occures in db */
57 typedef int DtDtsMMFieldCount; /* number of fields in record */
58 typedef int DtDtsMMRecordCount; /* number of records in field */
59 typedef int DtDtsMMDataBaseCount; /* how many databases */
60 typedef int DtDtsMMFieldStart; /* index in table where field list starts */
61 typedef int DtDtsMMRecordStart; /* index in table where record list starts */
62 typedef int DtDtsMMDataBaseStart; /* index in table where database list starts */
63 typedef int DtDtsMMIndexOffset;
64 typedef int DtDtsMMNameIndex;
65 typedef int DtDtsMMPathHash;
69 DtDtsMMPathHash pathhash; /* hash of dir. we visit */
70 DtDtsMMDataBaseCount num_db; /* number of databases */
71 DtDtsMMDataBaseStart db_offset; /* index to databases */
72 DtDtsMMNameIndex name_list_offset; /* index to name list */
73 DtDtsMMNameIndex no_name_offset; /* index to nonunique names */
74 DtDtsMMNameIndex buffer_start_index; /* index to list of buffers */
75 DtDtsMMIndexOffset str_tbl_offset; /* index to table of strings */
76 DtDtsMMIndexOffset files_count; /* number of loaded files */
77 DtDtsMMIndexOffset files_offset; /* index to list of loaded files */
78 DtDtsMMIndexOffset mtimes_offset; /* index to modified times of files */
81 /* one set of attribute/pair */
84 DtShmBoson fieldName; /* name of attribute */
85 DtShmBoson fieldValue; /* value of attribute */
88 /* typedefs for casting comparison functions if needed */
89 typedef int (*_DtDtsMMFieldCompare)(DtDtsMMField *fld1, DtDtsMMField *fld2);
91 /* entry of a list of attribute/pairs */
94 DtShmBoson recordName; /* name of this entry */
95 DtShmBoson pathId; /* file entry is located in */
96 DtDtsMMSeqNo seq; /* sequence this got loaded */
97 DtDtsMMFieldCount fieldCount; /* number of fields in record */
98 DtDtsMMFieldStart fieldList; /* index to field table */
101 /* typedefs for casting record comparison functions if needed */
102 typedef int (*_DtDtsMMRecordCompare)(DtDtsMMRecord *rec1, DtDtsMMRecord *rec2);
104 /* a "database" of a collection of entrys (i.e. OBJECT-TYPE, ACTION, FILE-TYPE
105 This is a private Structure to the DtDtsMM component.
109 DtShmBoson databaseName; /* name of database */
110 DtDtsMMIndexOffset nameIndex; /* index for DataCriteria quick find */
111 DtDtsMMRecordCount recordCount; /* number of records */
112 DtDtsMMRecordStart recordList; /* index to records table */
116 /* Db Internal pointers */
117 int * _DtDtsMMGetDCNameIndex(int *size);
118 int * _DtDtsMMGetBufferIndex(int *size);
119 int * _DtDtsMMGetNoNameIndex(int *size);
120 void * _DtDtsMMGetPtr(int index);
121 DtShmInttab _DtDtsMMGetFileList(void);
122 int _DtDtsMMGetPtrSize(int index);
123 int _DtDtsMMInit(int);
124 void _DtDtsMMPrint(FILE *org_fd);
125 int _DtDtsMMCreateDb(DtDirPaths *dirs, const char *CacheFile, int override);
126 int _DtDtsMMCreateFile(DtDirPaths *dirs, const char *CacheFile);
127 char * _DtDtsMMCacheName(int);
128 int _DtDtsMMapDB(const char *CacheFile);
130 const char * _DtDtsMMBosonToString(DtShmBoson boson);
131 DtShmBoson _DtDtsMMStringToBoson(const char *string);
133 extern int use_in_memory_db;
136 /* returns the handle for the database where name is the Database name */
137 extern DtDtsMMDatabase *_DtDtsMMGet(const char *name);
138 extern char **_DtDtsMMListDb(void);
140 /* Name Comparison functions:
141 * These routines can be passed in to the corresponding sort function to
145 extern int _DtDtsMMCompareRecordNames(DtDtsMMRecord *entry1, DtDtsMMRecord *entry2);
146 extern int _DtDtsMMCompareFieldNames(DtDtsMMField *entry1, DtDtsMMField *entry2);
148 /* retrieves the Record that matches the specified entry from the record */
149 extern DtDtsMMField *_DtDtsMMGetField(DtDtsMMRecord *record,
151 extern const char *_DtDtsMMGetFieldByName(DtDtsMMRecord *rec, const char *name);
153 /* retrieves the entry of the specified entry from the specified database */
154 extern DtDtsMMRecord *_DtDtsMMGetRecord(DtDtsMMDatabase *database,
155 DtDtsMMRecord *value);
156 extern DtDtsMMRecord *_DtDtsMMGetRecordByName(DtDtsMMDatabase *database,
159 /* Get By Name functions:
160 * retrieves the entry of the specified name from the specified database
161 * ** IF ** the _DtDtsMM*Sort routine has been called with the corresponding
162 * _DtDtsMMCompare*Name comparison function. Otherwise use the standard
163 * _DtDtsMMGet* functions.
167 char * _DtDtsMMExpandValue(const char *value);
168 void _DtDtsMMSafeFree(char *value);
169 int _DtDtsMMIsMemory(const char *value);
171 extern DtShmBoson _DtDtsMMNameStringToBoson(const char *string);
174 #endif /* DT_DTS_MM_H */