1 /*
2  * Python object definition of the volume file entries sequence and iterator
3  *
4  * Copyright (C) 2010-2021, Joachim Metz <joachim.metz@gmail.com>
5  *
6  * Refer to AUTHORS for acknowledgements.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #if !defined( _PYFSNTFS_VOLUME_FILE_ENTRIES_H )
23 #define _PYFSNTFS_VOLUME_FILE_ENTRIES_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #include "pyfsntfs_file_entry.h"
29 #include "pyfsntfs_libfsntfs.h"
30 #include "pyfsntfs_python.h"
31 #include "pyfsntfs_volume.h"
32 
33 #if defined( __cplusplus )
34 extern "C" {
35 #endif
36 
37 typedef struct pyfsntfs_volume_file_entries pyfsntfs_volume_file_entries_t;
38 
39 struct pyfsntfs_volume_file_entries
40 {
41 	/* Python object initialization
42 	 */
43 	PyObject_HEAD
44 
45 	/* The volume object
46 	 */
47 	pyfsntfs_volume_t *volume_object;
48 
49 	/* The get file entry by index callback function
50 	 */
51 	PyObject* (*get_file_entry_by_index)(
52 	             pyfsntfs_volume_t *volume_object,
53 	             uint64_t file_entry_index );
54 
55 	/* The (current) file entry index
56 	 */
57 	uint64_t file_entry_index;
58 
59 	/* The number of file entries
60 	 */
61 	uint64_t number_of_file_entries;
62 };
63 
64 extern PyTypeObject pyfsntfs_volume_file_entries_type_object;
65 
66 PyObject *pyfsntfs_volume_file_entries_new(
67            pyfsntfs_volume_t *volume,
68            PyObject* (*get_file_entry_by_index)(
69                         pyfsntfs_volume_t *volume_object,
70                         uint64_t file_entry_index ),
71            uint64_t number_of_file_entries );
72 
73 int pyfsntfs_volume_file_entries_init(
74      pyfsntfs_volume_file_entries_t *pyfsntfs_volume_file_entries );
75 
76 void pyfsntfs_volume_file_entries_free(
77       pyfsntfs_volume_file_entries_t *pyfsntfs_volume_file_entries );
78 
79 Py_ssize_t pyfsntfs_volume_file_entries_len(
80             pyfsntfs_volume_file_entries_t *pyfsntfs_volume_file_entries );
81 
82 PyObject *pyfsntfs_volume_file_entries_getitem(
83            pyfsntfs_volume_file_entries_t *pyfsntfs_volume_file_entries,
84            Py_ssize_t item_index );
85 
86 PyObject *pyfsntfs_volume_file_entries_iter(
87            pyfsntfs_volume_file_entries_t *pyfsntfs_volume_file_entries );
88 
89 PyObject *pyfsntfs_volume_file_entries_iternext(
90            pyfsntfs_volume_file_entries_t *pyfsntfs_volume_file_entries );
91 
92 #if defined( __cplusplus )
93 }
94 #endif
95 
96 #endif /* !defined( _PYFSNTFS_VOLUME_FILE_ENTRIES_H ) */
97 
98