source: trunk/python2/regfi/pyregfi.h @ 202

Last change on this file since 202 was 202, checked in by tim, 14 years ago

began implementing independent python subkey and value iterators

File size: 5.4 KB
Line 
1/*
2 * Top-level definitions for pyregfi to be processed by Michael Cohen's
3 * automated Python bindings generator.
4 *
5 * Copyright (C) 2010 Michael I. Cohen
6 * Copyright (C) 2010 Timothy D. Morgan
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 3 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * $Id: $
22 *
23 */
24
25#ifndef         PYREGFI_H_
26# define        PYREGFI_H_
27
28#include "class.h"
29#include "aff4_errors.h"
30#include "regfi.h"
31
32/** Forward declarations */
33struct RegistryFile_t;
34struct RegistryKey_t;
35struct SubkeyIterator_t;
36struct ValueIterator_t;
37struct TreeIterator_t;
38
39BIND_STRUCT(REGFI_NK_REC)
40BIND_STRUCT(REGFI_VK_REC)
41BIND_STRUCT(REGFI_DATA)
42
43/** This is the base class for data objects */
44CLASS(RawData, Object)
45    const REGFI_DATA *data;
46    const REGFI_VK_REC *rec;
47
48    RawData METHOD(RawData, Con, REGFI_DATA *data, REGFI_VK_REC *record);
49
50    /** Return the raw buffer as a string. By default we only return
51        this much data - specify a required length to return more.
52
53        DEFAULT(len) = 4096;
54    */
55    int METHOD(RawData, get_value, OUT char *buffer, int len);
56END_CLASS
57
58CLASS(DataString, RawData)
59     BORROWED char *METHOD(DataString, get_value);
60END_CLASS
61
62CLASS(DWORDData, RawData)
63     uint64_t METHOD(DWORDData, get_value);
64END_CLASS
65
66/** This is an iterator for traversing an entire registry hive */
67CLASS(TreeIterator, Object)
68     PRIVATE REGFI_ITERATOR *iter;
69     PRIVATE struct RegistryFile_t *file;
70     PRIVATE bool root_traversed;
71
72     struct TreeIterator_t *METHOD(TreeIterator, Con, struct RegistryFile_t *file,
73                                   char **path, REGFI_ENCODING encoding);
74
75/*     struct ValueIterator_t *METHOD(TreeIterator, list_values);*/
76
77     void METHOD(TreeIterator, __iter__);
78     struct RegistryKey_t *METHOD(TreeIterator, iternext);
79
80     int METHOD(TreeIterator, down);
81     int METHOD(TreeIterator, up);
82END_CLASS
83
84
85/** XXX */
86CLASS(RegistryKey, Object)
87     struct RegistryFile_t *file;
88     const REGFI_NK_REC *key;      /* XXX: temporary */
89
90     struct RegistryKey_t *METHOD(RegistryKey, Con,
91                                  struct RegistryFile_t *file, REGFI_NK_REC *base_key);
92
93     struct SubkeyIterator_t *METHOD(RegistryKey, subkeys);
94     struct ValueIterator_t *METHOD(RegistryKey, values);
95
96END_CLASS
97
98
99/** This is an iterator for reading keys from the registry */
100CLASS(SubkeyIterator, Object)
101     struct RegistryFile_t *file;
102     PRIVATE const REGFI_SUBKEY_LIST *list;
103     PRIVATE uint32_t cur;
104     
105     SubkeyIterator METHOD(SubkeyIterator, Con, 
106                           struct RegistryFile_t *file, REGFI_NK_REC *key);
107
108     void METHOD(SubkeyIterator, __iter__);
109     RegistryKey METHOD(SubkeyIterator, iternext);
110END_CLASS
111
112
113
114/** This is an iterator for reading values from the registry */
115CLASS(ValueIterator, Object)
116     struct RegistryFile_t *file;
117     PRIVATE const REGFI_VALUE_LIST *list;
118     PRIVATE uint32_t cur;
119     
120     ValueIterator METHOD(ValueIterator, Con, 
121                          struct RegistryFile_t *file, REGFI_NK_REC *key);
122
123     void METHOD(ValueIterator, __iter__);
124     REGFI_VK_REC *METHOD(ValueIterator, iternext);
125END_CLASS
126
127
128
129CLASS(RegistryFile, Object)
130  REGFI_FILE *reg;
131  int fd;
132
133  RegistryFile METHOD(RegistryFile, Con, char *filename);
134
135  /* Get an iterator for a specific path in the register if path is
136     specified.
137
138     XXX: can we switch to UTF-8 and have Python properly import that?
139
140     DEFAULT(path) == NULL;
141     DEFAULT(encoding) = REGFI_ENCODING_ASCII;
142  */
143  TreeIterator METHOD(RegistryFile, TreeIterator, char **path, REGFI_ENCODING encoding);
144
145  /** Set the verbosity level of messages generated by the library for the
146 *  current thread.
147 *
148 * @param mask   An integer representing the types of messages desired.
149 *               Acceptable values are created through bitwise ORs of
150 *               REGFI_LOG_* values.  For instance, if only errors and
151 *               informational messages were desired (but not warnings),
152 *               then one would specify: REGFI_LOG_ERROR|REGFI_LOG_INFO
153 *               By default the message mask is: REGFI_LOG_ERROR|REGFI_LOG_WARN.
154 *
155 * @return       true on success and false on failure.  Failure occurs if
156 *               underlying pthread functions fail.  errno is set in this case.
157 *
158 * Message masks are set in a thread-specific way.  If one were to set a message
159 * mask in one thread and then spawn a new thread, then the new thread will have
160 * it's message mask reset to the default.  This function may be called at any
161 * time and will take effect immediately for the current thread.
162 *
163 * @note When a non-zero message mask is set, messages will
164 *       accumulate in memory without limit if they are not fetched using
165 *       @ref regfi_get_log_str and subsequently freed by the caller.  It is
166 *       recommended that messsages be fetched after each regfi API call in
167 *       order to provide the most context.
168 *
169 * @ingroup regfiBase
170 */
171  int METHOD(RegistryFile, set_log_mask, uint16_t mask);
172
173 
174END_CLASS
175
176
177void pyregfi_init();
178
179#endif      /* !PYREGFI_H_ */
Note: See TracBrowser for help on using the repository browser.