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

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

misc fixes

stripped _REC from some data type names

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)
40BIND_STRUCT(REGFI_VK)
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;
47
48    RawData METHOD(RawData, Con, REGFI_DATA *data, REGFI_VK *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     void METHOD(TreeIterator, __iter__);
76     struct RegistryKey_t *METHOD(TreeIterator, iternext);
77
78
79     int METHOD(TreeIterator, down);
80     int METHOD(TreeIterator, up);
81
82     struct RegistryKey_t *METHOD(TreeIterator, current);
83     int METHOD(TreeIterator, to_root);
84
85END_CLASS
86
87
88/** XXX */
89CLASS(RegistryKey, Object)
90     struct RegistryFile_t *file;
91     const REGFI_NK *key;
92
93     struct RegistryKey_t *METHOD(RegistryKey, Con,
94                                  struct RegistryFile_t *file, REGFI_NK *base_key);
95
96     struct SubkeyIterator_t *METHOD(RegistryKey, subkeys);
97     struct ValueIterator_t *METHOD(RegistryKey, values);
98
99END_CLASS
100
101
102/** This is an iterator for reading keys from the registry */
103CLASS(SubkeyIterator, Object)
104     struct RegistryFile_t *file;
105     PRIVATE const REGFI_SUBKEY_LIST *list;
106     PRIVATE uint32_t cur;
107     
108     SubkeyIterator METHOD(SubkeyIterator, Con, 
109                           struct RegistryFile_t *file, REGFI_NK *key);
110
111     void METHOD(SubkeyIterator, __iter__);
112     RegistryKey METHOD(SubkeyIterator, iternext);
113END_CLASS
114
115
116
117/** This is an iterator for reading values from the registry */
118CLASS(ValueIterator, Object)
119     struct RegistryFile_t *file;
120     PRIVATE const REGFI_VALUE_LIST *list;
121     PRIVATE uint32_t cur;
122     
123     ValueIterator METHOD(ValueIterator, Con, 
124                          struct RegistryFile_t *file, REGFI_NK *key);
125
126     void METHOD(ValueIterator, __iter__);
127     REGFI_VK *METHOD(ValueIterator, iternext);
128END_CLASS
129
130
131
132CLASS(RegistryFile, Object)
133  REGFI_FILE *reg;
134  int fd;
135
136  RegistryFile METHOD(RegistryFile, Con, char *filename);
137
138  /* Get an iterator for a specific path in the register if path is
139     specified.
140
141     XXX: can we switch to UTF-8 and have Python properly import that?
142
143     DEFAULT(path) == NULL;
144     DEFAULT(encoding) = REGFI_ENCODING_ASCII;
145  */
146  TreeIterator METHOD(RegistryFile, TreeIterator, char **path, REGFI_ENCODING encoding);
147
148  /** Set the verbosity level of messages generated by the library for the
149 *  current thread.
150 *
151 * @param mask   An integer representing the types of messages desired.
152 *               Acceptable values are created through bitwise ORs of
153 *               REGFI_LOG_* values.  For instance, if only errors and
154 *               informational messages were desired (but not warnings),
155 *               then one would specify: REGFI_LOG_ERROR|REGFI_LOG_INFO
156 *               By default the message mask is: REGFI_LOG_ERROR|REGFI_LOG_WARN.
157 *
158 * @return       true on success and false on failure.  Failure occurs if
159 *               underlying pthread functions fail.  errno is set in this case.
160 *
161 * Message masks are set in a thread-specific way.  If one were to set a message
162 * mask in one thread and then spawn a new thread, then the new thread will have
163 * it's message mask reset to the default.  This function may be called at any
164 * time and will take effect immediately for the current thread.
165 *
166 * @note When a non-zero message mask is set, messages will
167 *       accumulate in memory without limit if they are not fetched using
168 *       @ref regfi_get_log_str and subsequently freed by the caller.  It is
169 *       recommended that messsages be fetched after each regfi API call in
170 *       order to provide the most context.
171 *
172 * @ingroup regfiBase
173 */
174  int METHOD(RegistryFile, set_log_mask, uint16_t mask);
175
176 
177END_CLASS
178
179
180void pyregfi_init();
181
182#endif      /* !PYREGFI_H_ */
Note: See TracBrowser for help on using the repository browser.