Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

htreg.h

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htreg.h
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifndef __HTREG_H__
00022 #define __HTREG_H__
00023 
00024 #include "htdata.h"
00025 #include "htstring.h"
00026 
00027 /*
00028  *      CLASS ht_registry_data
00029  */
00030 
00031 class ht_registry_data: public Object {
00032 public:
00033 /* new */
00034         virtual bool editdialog(const char *keyname);
00035         virtual   void strvalue(char *buf32bytes);
00036 };
00037 
00038 /*
00039  *      CLASS ht_registry_data_stree
00040  */
00041 
00042 class ht_registry_data_stree: public ht_registry_data {
00043 public:
00044         ht_stree *tree;
00045 
00046                         ht_registry_data_stree(ht_stree *tree=0);
00047                         ~ht_registry_data_stree();
00048 /* overwritten */
00049         virtual int  load(ht_object_stream *f);
00050         virtual OBJECT_ID object_id() const;
00051         virtual void store(ht_object_stream *f);
00052         virtual void strvalue(char *buf32bytes);
00053 };
00054 
00055 /*
00056  *      CLASS ht_registry_data_dword
00057  */
00058 
00059 class ht_registry_data_dword: public ht_registry_data {
00060 public:
00061         dword value;
00062 
00063                         ht_registry_data_dword(dword value=0);
00064 /* overwritten */
00065         virtual bool editdialog(const char *keyname);
00066         virtual int  load(ht_object_stream *f);
00067         virtual OBJECT_ID object_id() const;
00068         virtual void store(ht_object_stream *f);
00069         virtual void strvalue(char *buf32bytes);
00070 };
00071 
00072 /*
00073  *      CLASS ht_registry_data_raw
00074  */
00075 
00076 class ht_registry_data_raw: public ht_registry_data {
00077 public:
00078         void *value;
00079         UINT size;
00080 
00081                         ht_registry_data_raw(const void *value = 0, UINT size = 0);
00082                         ~ht_registry_data_raw();
00083 /* overwritten */
00084         virtual bool editdialog(const char *keyname);
00085         virtual int  load(ht_object_stream *f);
00086         virtual OBJECT_ID object_id() const;
00087         virtual void store(ht_object_stream *f);
00088         virtual void strvalue(char *buf32bytes);
00089 };
00090 
00091 /*
00092  *      CLASS ht_registry_data_string
00093  */
00094 
00095 class ht_registry_data_string: public ht_registry_data {
00096 public:
00097         char *value;
00098 
00099                         ht_registry_data_string(const char *s = 0);
00100                         ~ht_registry_data_string();
00101 /* overwritten */
00102         virtual bool editdialog(const char *keyname);
00103         virtual int  load(ht_object_stream *f);
00104         virtual OBJECT_ID object_id() const;
00105         virtual void store(ht_object_stream *f);
00106         virtual void strvalue(char *buf32bytes);
00107 };
00108 
00109 /*
00110  *      CLASS ht_registry_node
00111  */
00112 
00113 typedef ht_registry_data* (*create_empty_registry_data_func)();
00114 
00115 typedef UINT ht_registry_node_type;
00116 
00117 class ht_registry_node_type_desc: public Object {
00118 public:
00119         ht_registry_node_type type;
00120         create_empty_registry_data_func create_empty_registry_data;
00121         
00122         virtual int  load(ht_object_stream *f);
00123         virtual OBJECT_ID object_id() const;
00124         virtual void store(ht_object_stream *f);
00125 };
00126 
00127 #define RNT_INVALID             0       /* returned by some functions */
00128 // these are predefined
00129 #define RNT_SUBDIR              1
00130 #define RNT_SYMLINK             2
00131 #define RNT_DWORD               3
00132 #define RNT_STRING              4
00133 #define RNT_RAW         5
00134 
00135 #define RNT_USER        0x100
00136 // the rest may be allocated dynamically
00137 
00138 class ht_registry_node: public Object {
00139 public:
00140         ht_registry_node_type type;
00141         ht_registry_data *data;
00142 
00143                         void init(ht_registry_node_type type);
00144         virtual void done();
00145 /* overwritten */
00146         virtual int  load(ht_object_stream *f);
00147         virtual void store(ht_object_stream *f);
00148         virtual OBJECT_ID object_id() const;
00149 };
00150 
00151 /*
00152  *      CLASS ht_registry
00153  */
00154 
00155 #define MAX_SYMLINK_REC_DEPTH 20
00156 
00157 class ht_registry: public Object {
00158 protected:
00159         ht_registry_node *root;
00160         UINT rec_depth;
00161 
00162                         ht_registry_node *find_entry_i(ht_tree **dir, const char *key, bool follow_symlinks);
00163                         ht_registry_node *find_entry_get_node(ht_tree *dir, const char *nodename);
00164                         ht_registry_node *find_entry_get_subdir(ht_tree *dir, const char *nodename);
00165                         ht_registry_node *find_entry_get_data(ht_tree *dir, const char *nodename, bool follow_symlinks);
00166                         bool splitfind(const char *key, const char **name, ht_registry_node **node);
00167 public:
00168         ht_stree *node_types;
00169 
00170                         void init();
00171         virtual void done();
00172 /* new */
00173                         int create_node(const char *key, ht_registry_node_type type);
00174                         int create_subdir(const char *key);
00175                         int delete_node(const char *key);
00176                         const char *enum_next(ht_registry_data **data, ht_registry_node_type *type, const char *dir, const char *prevkey);
00177                         const char *enum_prev(ht_registry_data **data, ht_registry_node_type *type, const char *dir, const char *nextkey);
00178                         
00179                         bool find_any_entry(const char *key, ht_registry_data **data, ht_registry_node_type *type);
00180                         bool find_data_entry(const char *key, ht_registry_data **data, ht_registry_node_type *type, bool follow_symlinks);
00181                         /* node type*/
00182                         ht_registry_node_type lookup_node_type(const char *identifier);
00183                         ht_registry_node_type_desc *get_node_type_desc(ht_registry_node_type t, char **identifier);
00184                         ht_registry_node_type have_node_type(const char *identifier, create_empty_registry_data_func create_empty_registry_data);
00185                         ht_registry_node_type register_node_type(const char *identifier, create_empty_registry_data_func create_empty_registry_data);
00186                         
00187                         int set_dword(const char *key, dword d);
00188                         int set_raw(const char *key, const void *data, UINT size);
00189                         int set_node(const char *key, ht_registry_node_type type, ht_registry_data *data);
00190                         int set_string(const char *key, const char *string);
00191                         int set_symlink(const char *key, const char *dest);
00192                         bool valid_nodename(const char *nodename);
00193 /* overwritten */
00194         virtual int  load(ht_object_stream *f);
00195         virtual void store(ht_object_stream *f);
00196         virtual OBJECT_ID object_id() const;
00197 /* debug */
00198                         void debug_dump();
00199                         void debug_dump_i(FILE *f, ht_tree *t, int ident);
00200 };
00201 
00202 dword get_config_dword(char *ident);
00203 char *get_config_string(char *ident);
00204 
00205 extern ht_registry *registry;
00206 
00207 /*
00208  *      INIT
00209  */
00210 
00211 bool init_registry();
00212 
00213 /*
00214  *      DONE
00215  */
00216 
00217 void done_registry();
00218 
00219 #endif /* __HTREG_H__ */

Generated on Fri May 7 21:15:37 2004 by doxygen 1.3.5