DtsDb.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 libraries 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. #include <X11/Xresource.h>
  51. #include <Dt/DbReader.h>
  52. typedef int OtBoolean;
  53. /* typedefs for casting comparison functions if needed */
  54. typedef int (*_DtDtsDbFieldCompare)(DtDtsDbField **fld1, DtDtsDbField **fld2);
  55. /* entry of a list of attribute/pairs */
  56. typedef struct
  57. {
  58. XrmQuark recordName;
  59. _DtDtsDbFieldCompare compare;
  60. long pathId;
  61. int seq;
  62. int fieldCount;
  63. DtDtsDbField **fieldList;
  64. } DtDtsDbRecord;
  65. /* typedefs for casting record comparison functions if needed */
  66. typedef int (*_DtDtsDbRecordCompare)(DtDtsDbRecord **rec1, DtDtsDbRecord **rec2);
  67. /* a "database" of a collection of entrys (i.e. OBJECT-TYPE, ACTION, FILE-TYPE
  68. This is a private Structure to the DtDtsDb component.
  69. */
  70. typedef struct
  71. {
  72. char *databaseName;
  73. _DtDtsDbRecordCompare compare;
  74. int recordCount;
  75. DtDtsDbRecord **recordList;
  76. unsigned long ActionSequenceNumber;
  77. } DtDtsDbDatabase;
  78. /* for the mmaped database this the use_in_memory_db variable is used
  79. to call the old API while the database is being built and is set to
  80. false when the mmaped versions are being accessed.
  81. */
  82. extern int use_in_memory_db;
  83. /*
  84. * adds a new database to the list of databases -- returns a pointer to the
  85. * new database. If a database of the given name already exists it returns
  86. * a pointer to that database.
  87. */
  88. extern DtDtsDbDatabase *_DtDtsDbAddDatabase( char *dbname );
  89. /* returns the handle for the database where name is the Database name */
  90. extern DtDtsDbDatabase *_DtDtsDbGet(char *name);
  91. extern char **_DtDtsDbListDb(void);
  92. /* Record Sort function:
  93. * sorts the specified database, usually obtained from _DtDtsDbGet(), in the
  94. * order specified by the comparison function. If (*compare) == 0 then
  95. * _DtDtsDbCompareRecordNames() is used as the (*compare) function.
  96. */
  97. extern void _DtDtsDbRecordSort(DtDtsDbDatabase *database,
  98. _DtDtsDbRecordCompare compare);
  99. /* Field Sort function:
  100. * sorts the specified Record in the order specified by the comparison function
  101. * If (*compare) == 0 then _DtDtsDbCompareFieldNames() is used as the
  102. * (*compare) function.
  103. */
  104. extern void _DtDtsDbFieldSort(DtDtsDbRecord *record,
  105. _DtDtsDbFieldCompare compare);
  106. /* Name Comparison functions:
  107. * These routines can be passed in to the corresponding sort function to
  108. * sort by name.
  109. *
  110. */
  111. extern int _DtDtsDbCompareRecordNames(DtDtsDbRecord **entry1, DtDtsDbRecord **entry2);
  112. extern int _DtDtsDbCompareFieldNames(DtDtsDbField **entry1, DtDtsDbField **entry2);
  113. /* retrieves the Record that matches the specified entry from the record */
  114. extern DtDtsDbField *_DtDtsDbGetField(DtDtsDbRecord *record,
  115. char *value);
  116. /* retrieves the entry of the specified entry from the specified database */
  117. extern DtDtsDbRecord *_DtDtsDbGetRecord(DtDtsDbDatabase *database,
  118. DtDtsDbRecord *value);
  119. /* Get By Name functions:
  120. * retrieves the entry of the specified name from the specified database
  121. * ** IF ** the _DtDtsDb*Sort routine has been called with the corresponding
  122. * _DtDtsDbCompare*Name comparison function. Otherwise use the standard
  123. * _DtDtsDbGet* functions.
  124. */
  125. extern char *_DtDtsDbGetFieldByName(DtDtsDbRecord *record, char *name);
  126. extern DtDtsDbRecord *_DtDtsDbGetRecordByName(DtDtsDbDatabase *database, char *name);
  127. extern DtDtsDbRecord *_DtDtsDbAddRecord(DtDtsDbDatabase *db);
  128. extern DtDtsDbField *_DtDtsDbAddField(DtDtsDbRecord *rec);
  129. extern int _DtDtsDbDeleteDb(DtDtsDbDatabase *db);
  130. extern int _DtDtsDbDeleteRecord(DtDtsDbRecord *rec, DtDtsDbDatabase *db);
  131. extern int _DtDtsDbDeleteRecords(DtDtsDbDatabase *db);
  132. extern int _DtDtsDbDeleteField(DtDtsDbField *fld, DtDtsDbRecord *rec);
  133. extern int _DtDtsDbDeleteFields(DtDtsDbRecord *rec);
  134. #endif