source: trunk/python/experimental/regfi/pyregfi.h @ 295

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

reorganizing wrappers

File size: 5.4 KB
RevLine 
[196]1/*
[202]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 */
[196]24
25#ifndef         PYREGFI_H_
26# define        PYREGFI_H_
[202]27
[196]28#include "class.h"
29#include "aff4_errors.h"
30#include "regfi.h"
31
[202]32/** Forward declarations */
[196]33struct RegistryFile_t;
[202]34struct RegistryKey_t;
35struct SubkeyIterator_t;
[196]36struct ValueIterator_t;
[202]37struct TreeIterator_t;
[196]38
[203]39BIND_STRUCT(REGFI_NK)
40BIND_STRUCT(REGFI_VK)
[198]41BIND_STRUCT(REGFI_DATA)
[196]42
43/** This is the base class for data objects */
44CLASS(RawData, Object)
[198]45    const REGFI_DATA *data;
[203]46    const REGFI_VK *rec;
[196]47
[203]48    RawData METHOD(RawData, Con, REGFI_DATA *data, REGFI_VK *record);
[196]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
[202]66/** This is an iterator for traversing an entire registry hive */
67CLASS(TreeIterator, Object)
[196]68     PRIVATE REGFI_ITERATOR *iter;
[202]69     PRIVATE struct RegistryFile_t *file;
[200]70     PRIVATE bool root_traversed;
[196]71
[202]72     struct TreeIterator_t *METHOD(TreeIterator, Con, struct RegistryFile_t *file,
73                                   char **path, REGFI_ENCODING encoding);
[196]74
[202]75     void METHOD(TreeIterator, __iter__);
76     struct RegistryKey_t *METHOD(TreeIterator, iternext);
[199]77
[203]78
[202]79     int METHOD(TreeIterator, down);
80     int METHOD(TreeIterator, up);
[203]81
82     struct RegistryKey_t *METHOD(TreeIterator, current);
83     int METHOD(TreeIterator, to_root);
84
[196]85END_CLASS
86
[202]87
88/** XXX */
89CLASS(RegistryKey, Object)
90     struct RegistryFile_t *file;
[203]91     const REGFI_NK *key;
[202]92
93     struct RegistryKey_t *METHOD(RegistryKey, Con,
[203]94                                  struct RegistryFile_t *file, REGFI_NK *base_key);
[202]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, 
[203]109                           struct RegistryFile_t *file, REGFI_NK *key);
[202]110
111     void METHOD(SubkeyIterator, __iter__);
112     RegistryKey METHOD(SubkeyIterator, iternext);
113END_CLASS
114
115
116
[196]117/** This is an iterator for reading values from the registry */
118CLASS(ValueIterator, Object)
[202]119     struct RegistryFile_t *file;
120     PRIVATE const REGFI_VALUE_LIST *list;
121     PRIVATE uint32_t cur;
[199]122     
[202]123     ValueIterator METHOD(ValueIterator, Con, 
[203]124                          struct RegistryFile_t *file, REGFI_NK *key);
[196]125
[199]126     void METHOD(ValueIterator, __iter__);
[203]127     REGFI_VK *METHOD(ValueIterator, iternext);
[196]128END_CLASS
129
[202]130
131
[196]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
[202]141     XXX: can we switch to UTF-8 and have Python properly import that?
142
[196]143     DEFAULT(path) == NULL;
144     DEFAULT(encoding) = REGFI_ENCODING_ASCII;
145  */
[202]146  TreeIterator METHOD(RegistryFile, TreeIterator, char **path, REGFI_ENCODING encoding);
[196]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.