Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSvc / DtUtil1 / DtsDb.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /*
24  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
25  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
26  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
27  * (c) Copyright 1993, 1994 Novell, Inc.                                *
28  */
29 /*
30  *+SNOTICE
31  *
32  *      $XConsortium: DtsDb.h /main/5 1996/08/28 14:32:17 rswiston $
33  *
34  *      RESTRICTED CONFIDENTIAL INFORMATION:
35  *      
36  *      The information in this document is subject to special
37  *      restrictions in a confidential disclosure agreement bertween
38  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
39  *      document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
40  *      Sun's specific written approval.  This documment and all copies
41  *      and derivative works thereof must be returned or destroyed at
42  *      Sun's request.
43  *
44  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
45  *
46  *+ENOTICE
47  */
48 #ifndef DT_DTS_DB_H
49 #define DT_DTS_DB_H
50
51 #include <X11/Xresource.h>
52 #include <Dt/DbReader.h>
53
54 typedef int     OtBoolean;
55
56 /* typedefs for casting comparison functions if needed */
57 typedef int     (*_DtDtsDbFieldCompare)(DtDtsDbField **fld1, DtDtsDbField **fld2);
58
59 /* entry of a list of attribute/pairs */
60 typedef struct
61 {
62         XrmQuark                recordName;
63         _DtDtsDbFieldCompare    compare;
64         long                    pathId;
65         int                     seq;
66         int                     fieldCount;
67         DtDtsDbField            **fieldList;
68 } DtDtsDbRecord;
69
70 /* typedefs for casting record comparison functions if needed */
71 typedef int     (*_DtDtsDbRecordCompare)(DtDtsDbRecord **rec1, DtDtsDbRecord **rec2);
72
73 /* a "database" of a collection of entrys (i.e. OBJECT-TYPE, ACTION, FILE-TYPE 
74         This is a private Structure to the DtDtsDb component.
75 */
76 typedef struct
77 {
78         char                    *databaseName;
79         _DtDtsDbRecordCompare   compare;
80         int                     recordCount;
81         DtDtsDbRecord           **recordList;
82         unsigned long           ActionSequenceNumber;
83 } DtDtsDbDatabase;
84
85 /* for the mmaped database this the use_in_memory_db variable is used
86    to call the old API while the database is being built and is set to
87    false when the mmaped versions are being accessed.
88 */
89
90 extern  int     use_in_memory_db;
91
92 /*
93  *  adds a new database to the list of databases -- returns a pointer to the
94  *  new database.  If a database of the given name already exists it returns
95  *  a pointer to that database.
96  */
97 extern DtDtsDbDatabase          *_DtDtsDbAddDatabase( char *dbname );
98
99 /* returns the handle for the database where name is the Database name */
100 extern  DtDtsDbDatabase         *_DtDtsDbGet(char *name);
101 extern  char                    **_DtDtsDbListDb(void);
102
103 /* Record Sort function:
104  * sorts the specified database, usually obtained from _DtDtsDbGet(), in the
105  * order specified by the comparison function. If (*compare) == 0 then
106  * _DtDtsDbCompareRecordNames() is used as the (*compare) function.
107  */
108 extern  void            _DtDtsDbRecordSort(DtDtsDbDatabase *database, 
109                                         _DtDtsDbRecordCompare compare);
110 /* Field Sort function:
111  * sorts the specified Record in the order specified by the comparison function
112  * If (*compare) == 0 then _DtDtsDbCompareFieldNames() is used as the
113  * (*compare) function.
114  */
115 extern  void            _DtDtsDbFieldSort(DtDtsDbRecord *record,
116                                         _DtDtsDbFieldCompare compare);
117
118 /* Name Comparison functions:
119  * These routines can be passed in to the corresponding sort function to
120  * sort by name.
121  *
122  */
123 extern int _DtDtsDbCompareRecordNames(DtDtsDbRecord **entry1, DtDtsDbRecord **entry2);
124 extern int _DtDtsDbCompareFieldNames(DtDtsDbField **entry1, DtDtsDbField **entry2);
125
126 /* retrieves the Record that matches the specified entry from the record */
127 extern  DtDtsDbField    *_DtDtsDbGetField(DtDtsDbRecord *record,
128                                         char *value);
129
130 /* retrieves the entry of the specified entry from the specified database */
131 extern  DtDtsDbRecord   *_DtDtsDbGetRecord(DtDtsDbDatabase *database,
132                                         DtDtsDbRecord *value);
133
134 /* Get By Name functions:
135  * retrieves the entry of the specified name from the specified database
136  * ** IF ** the _DtDtsDb*Sort routine has been called with the corresponding
137  * _DtDtsDbCompare*Name comparison function. Otherwise use the standard
138  * _DtDtsDbGet* functions. 
139 */
140 extern  char *_DtDtsDbGetFieldByName(DtDtsDbRecord *record, char *name);
141 extern  DtDtsDbRecord *_DtDtsDbGetRecordByName(DtDtsDbDatabase *database, char *name);
142
143 extern  DtDtsDbRecord *_DtDtsDbAddRecord(DtDtsDbDatabase *db);
144
145 extern  DtDtsDbField *_DtDtsDbAddField(DtDtsDbRecord *rec);
146
147 extern  int     _DtDtsDbDeleteDb(DtDtsDbDatabase *db);
148 extern  int     _DtDtsDbDeleteRecord(DtDtsDbRecord *rec, DtDtsDbDatabase *db);
149 extern  int     _DtDtsDbDeleteRecords(DtDtsDbDatabase *db);
150 extern  int     _DtDtsDbDeleteField(DtDtsDbField *fld, DtDtsDbRecord *rec);
151 extern  int     _DtDtsDbDeleteFields(DtDtsDbRecord *rec);
152
153 #endif
154