tt_db_server_db.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
  24. /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
  25. /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
  26. /*%% (c) Copyright 1993, 1994 Novell, Inc. */
  27. /*%% $XConsortium: tt_db_server_db.h /main/3 1995/10/20 16:43:06 rswiston $ */
  28. /*
  29. * tt_db_server_db.h - Defines the TT DB server database. This class
  30. * represents the actual data model currently being
  31. * used to store ToolTalk databse information.
  32. *
  33. * The actual database schema is the following:
  34. *
  35. * Table Fields Length Description
  36. * ----- ------ ------ -----------
  37. * File Table Contains the names of all
  38. * the that have properties
  39. * or objects in the db.
  40. *
  41. * File Key TT_DB_KEY_LENGTH Unique key that is used
  42. * to search (16 bytes) for
  43. * a file's properties and
  44. * objects in the other
  45. * tables.
  46. *
  47. * File Name Variable up to The name of the file.
  48. * MAXPATHLEN (256)
  49. *
  50. * Table Fields Length Description
  51. * ----- ------ ------ -----------
  52. * File-object Contains all of the
  53. * Map mappings of file keys to
  54. * the keys of the objects
  55. * in the file.
  56. *
  57. * Object Key TT_DB_KEY_LENGTH Unique key of an object
  58. * in a file.
  59. *
  60. * File Key TT_DB_KEY_LENGTH Unique key of a file.
  61. *
  62. * Table Fields Length Description
  63. * ----- ------ ------ -----------
  64. * Property Contains all of the
  65. * Table properties corresponding
  66. * to files and objects in
  67. * the db.
  68. *
  69. * Key TT_DB_KEY_LENGTH Unique key of an object
  70. * or a file.
  71. *
  72. * Property Name TT_DB_PROP_NAME_LENGTH The name of a file or
  73. * object property.
  74. *
  75. * Property Variable up to The value of the property.
  76. * ISMAXRECLEN.
  77. *
  78. * Table Fields Length Description
  79. * ----- ------ ------ -----------
  80. * Access Table Contains the access
  81. * privileges of all the
  82. * files and objects in
  83. * the db.
  84. *
  85. * Key TT_DB_KEY_LENGTH Unique key of an object
  86. * or a file.
  87. *
  88. * User ID XDR_LONG_SIZE The user ID of the owner
  89. * of the object or file.
  90. *
  91. * Group ID XDR_LONG_SIZE The group ID of the
  92. * object or file.
  93. *
  94. * Mode XDR_LONG_SIZE The access mode of the
  95. * object or file.
  96. *
  97. * Copyright (c) 1992 by Sun Microsystems, Inc.
  98. */
  99. #ifndef _TT_DB_SERVER_DB_H
  100. #define _TT_DB_SERVER_DB_H
  101. #include "util/tt_object.h"
  102. #include "util/tt_string.h"
  103. #include "tt_isam_file_utils.h"
  104. #include "db/tt_db_access_utils.h"
  105. #include "db/tt_db_key_utils.h"
  106. #include "db/tt_db_property_utils.h"
  107. #include "db/tt_db_results.h"
  108. class _Tt_db_server_db : public _Tt_object {
  109. public:
  110. _Tt_db_server_db ();
  111. _Tt_db_server_db (const _Tt_string&);
  112. ~_Tt_db_server_db ();
  113. // Returns the partition this DB object is connected to
  114. _Tt_string getPartition () const
  115. {
  116. _Tt_string partition = (char *)dbPartition;
  117. return partition;
  118. }
  119. // Creates a file in the TT DB and sets the access permissions of the
  120. // file.
  121. _Tt_db_results createFile (const _Tt_string &file,
  122. const _Tt_db_access_ptr &access);
  123. // Creates an object in the TT DB. If the file is not in the database,
  124. // the file will be created using the "file_access" argument to specify
  125. // its access permission. If no file is specified, this is a special
  126. // object being created just to hold a forward pointer.
  127. _Tt_db_results createObject (const _Tt_string &file,
  128. const _Tt_string &objid,
  129. const _Tt_db_access_ptr &object_access,
  130. const _Tt_db_access_ptr &file_access);
  131. _Tt_db_results removeFile (const _Tt_string &file,
  132. const _Tt_db_access_ptr &access);
  133. _Tt_db_results removeObject (const _Tt_string &objid,
  134. const _Tt_db_access_ptr &access);
  135. _Tt_db_results moveFile (const _Tt_string &file,
  136. const _Tt_string &new_file,
  137. const _Tt_db_access_ptr &access);
  138. _Tt_db_results setFileProperty (const _Tt_string &file,
  139. const _Tt_db_property_ptr &property,
  140. const _Tt_db_access_ptr &access);
  141. _Tt_db_results setFileProperties (const _Tt_string &file,
  142. const _Tt_db_property_list_ptr &properties,
  143. const _Tt_db_access_ptr &access);
  144. _Tt_db_results addFileProperty (const _Tt_string &file,
  145. const _Tt_db_property_ptr &property,
  146. bool_t unique,
  147. const _Tt_db_access_ptr &access);
  148. _Tt_db_results deleteFileProperty (const _Tt_string &file,
  149. const _Tt_db_property_ptr &property,
  150. const _Tt_db_access_ptr &access);
  151. _Tt_db_results deleteFileProperties (const _Tt_string &file,
  152. const _Tt_db_access_ptr &access);
  153. _Tt_db_results getFileProperty (const _Tt_string &file,
  154. const _Tt_string &name,
  155. const _Tt_db_access_ptr &access,
  156. _Tt_db_property_ptr &property);
  157. _Tt_db_results getFileProperties (const _Tt_string &file,
  158. const _Tt_db_access_ptr &access,
  159. _Tt_db_property_list_ptr &properties);
  160. _Tt_db_results getFileObjects (const _Tt_string &file,
  161. const _Tt_db_access_ptr &access,
  162. _Tt_string_list_ptr &objids);
  163. _Tt_db_results deleteFileObjects (const _Tt_string &file,
  164. const _Tt_db_access_ptr &access);
  165. _Tt_db_results setFileFile (const _Tt_string &file,
  166. const _Tt_string &new_file,
  167. const _Tt_db_access_ptr &access);
  168. // If the specified file is a directory, this returns all of the
  169. // file names stored in the database that are in the directory.
  170. // The file itself is also in the return list.
  171. _Tt_db_results getFileChildren (const _Tt_string &file,
  172. _Tt_string_list_ptr &children);
  173. _Tt_db_results setFileAccess (const _Tt_string &file,
  174. const _Tt_db_access_ptr &new_access,
  175. const _Tt_db_access_ptr &access);
  176. _Tt_db_results getFileAccess (const _Tt_string &file,
  177. const _Tt_db_access_ptr &access,
  178. _Tt_db_access_ptr &current_access);
  179. _Tt_db_results setObjectProperty (const _Tt_string &objid,
  180. const _Tt_db_property_ptr &property,
  181. const _Tt_db_access_ptr &access);
  182. _Tt_db_results
  183. setObjectProperties (const _Tt_string &objid,
  184. const _Tt_db_property_list_ptr &properties,
  185. const _Tt_db_access_ptr &access);
  186. _Tt_db_results addObjectProperty (const _Tt_string &objid,
  187. const _Tt_db_property_ptr &property,
  188. bool_t unique,
  189. const _Tt_db_access_ptr &access);
  190. _Tt_db_results deleteObjectProperty (const _Tt_string &objid,
  191. const _Tt_db_property_ptr &property,
  192. const _Tt_db_access_ptr &access);
  193. _Tt_db_results deleteObjectProperties (const _Tt_string &objid,
  194. const _Tt_db_access_ptr &access);
  195. _Tt_db_results getObjectProperty (const _Tt_string &objid,
  196. const _Tt_string &name,
  197. const _Tt_db_access_ptr &access,
  198. _Tt_db_property_ptr &property);
  199. _Tt_db_results
  200. getObjectProperties (const _Tt_string &objid,
  201. const _Tt_db_access_ptr &access,
  202. _Tt_db_property_list_ptr &properties);
  203. // Used to facilitate moving an object to a new file on the same
  204. // partition. The file specified must be on the partition this DB
  205. // server object is connected to. If the file is not in the database,
  206. // it will be created with the access permissions of the object.
  207. _Tt_db_results setObjectFile (const _Tt_string &objid,
  208. const _Tt_string &file,
  209. const _Tt_db_access_ptr &access);
  210. _Tt_db_results getObjectFile (const _Tt_string &objid,
  211. const _Tt_db_access_ptr &access,
  212. _Tt_string &file);
  213. _Tt_db_results setObjectAccess (const _Tt_string &objid,
  214. const _Tt_db_access_ptr &new_access,
  215. const _Tt_db_access_ptr &access);
  216. _Tt_db_results getObjectAccess (const _Tt_string &objid,
  217. const _Tt_db_access_ptr &access,
  218. _Tt_db_access_ptr &current_access);
  219. _Tt_db_results getDBResults () const
  220. {
  221. return dbResults;
  222. }
  223. const _Tt_string &getLastFileAccessed () const
  224. {
  225. return dbLastFileAccessed;
  226. }
  227. private:
  228. _Tt_isam_key_descriptor_ptr fileTableFileKey;
  229. _Tt_isam_key_descriptor_ptr fileTableFilePathKey;
  230. _Tt_isam_file_ptr fileTable;
  231. _Tt_isam_key_descriptor_ptr fileObjectMapFileKey;
  232. _Tt_isam_key_descriptor_ptr fileObjectMapObjectKey;
  233. _Tt_isam_file_ptr fileObjectMap;
  234. _Tt_isam_key_descriptor_ptr propertyTablePropertyKey;
  235. _Tt_isam_file_ptr propertyTable;
  236. _Tt_isam_key_descriptor_ptr accessTableKey;
  237. _Tt_isam_file_ptr accessTable;
  238. _Tt_string dbHostname;
  239. _Tt_string dbPartition;
  240. _Tt_db_results dbResults;
  241. _Tt_string dbLastFileAccessed;
  242. void connectToDB (const _Tt_string &partition);
  243. _Tt_db_results verifyObjectAccess (const _Tt_string&,
  244. const _Tt_db_access_ptr&,
  245. bool_t=FALSE,
  246. bool_t=FALSE);
  247. _Tt_db_results verifyUserOnlyObjectAccess (const _Tt_string&,
  248. const _Tt_db_access_ptr&);
  249. _Tt_db_results verifyAccess (const _Tt_string&,
  250. const _Tt_db_access_ptr&,
  251. bool_t=FALSE,
  252. bool_t=FALSE);
  253. _Tt_db_results getFileKey (const _Tt_string&, _Tt_string&);
  254. _Tt_string getObjectKey (const _Tt_string&);
  255. _Tt_db_results setProperty (const _Tt_string&, const _Tt_db_property_ptr&);
  256. _Tt_db_results setProperties (const _Tt_string&,
  257. const _Tt_db_property_list_ptr&);
  258. _Tt_db_results addProperty (const _Tt_string&,
  259. const _Tt_db_property_ptr&,
  260. bool_t);
  261. _Tt_db_results deleteProperty (const _Tt_string&,
  262. const _Tt_db_property_ptr&);
  263. _Tt_db_results deleteProperties (const _Tt_string&,
  264. bool_t=FALSE);
  265. _Tt_db_results getProperty (const _Tt_string&,
  266. const _Tt_string&,
  267. _Tt_db_property_ptr&);
  268. _Tt_db_results getProperties (const _Tt_string&,
  269. _Tt_db_property_list_ptr&);
  270. _Tt_db_results setAccess (const _Tt_string&, const _Tt_db_access_ptr&);
  271. _Tt_db_results getAccess (const _Tt_string&, _Tt_db_access_ptr&);
  272. _Tt_db_results getFile (const _Tt_string&, _Tt_string&);
  273. _Tt_db_results addPropertyValue (const _Tt_string&,
  274. const _Tt_string&,
  275. const _Tt_string&);
  276. };
  277. #endif /* _TT_DB_SERVER_DB_H */