1 /* 2 * Python object definition of the sequence and iterator object of file entries 3 * 4 * Copyright (C) 2020-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( _PYFSXFS_FILE_ENTRIES_H ) 23 #define _PYFSXFS_FILE_ENTRIES_H 24 25 #include <common.h> 26 #include <types.h> 27 28 #include "pyfsxfs_libfsxfs.h" 29 #include "pyfsxfs_python.h" 30 31 #if defined( __cplusplus ) 32 extern "C" { 33 #endif 34 35 typedef struct pyfsxfs_file_entries pyfsxfs_file_entries_t; 36 37 struct pyfsxfs_file_entries 38 { 39 /* Python object initialization 40 */ 41 PyObject_HEAD 42 43 /* The parent object 44 */ 45 PyObject *parent_object; 46 47 /* The get item by index callback function 48 */ 49 PyObject* (*get_item_by_index)( 50 PyObject *parent_object, 51 int index ); 52 53 /* The current index 54 */ 55 int current_index; 56 57 /* The number of items 58 */ 59 int number_of_items; 60 }; 61 62 extern PyTypeObject pyfsxfs_file_entries_type_object; 63 64 PyObject *pyfsxfs_file_entries_new( 65 PyObject *parent_object, 66 PyObject* (*get_item_by_index)( 67 PyObject *parent_object, 68 int index ), 69 int number_of_items ); 70 71 int pyfsxfs_file_entries_init( 72 pyfsxfs_file_entries_t *sequence_object ); 73 74 void pyfsxfs_file_entries_free( 75 pyfsxfs_file_entries_t *sequence_object ); 76 77 Py_ssize_t pyfsxfs_file_entries_len( 78 pyfsxfs_file_entries_t *sequence_object ); 79 80 PyObject *pyfsxfs_file_entries_getitem( 81 pyfsxfs_file_entries_t *sequence_object, 82 Py_ssize_t item_index ); 83 84 PyObject *pyfsxfs_file_entries_iter( 85 pyfsxfs_file_entries_t *sequence_object ); 86 87 PyObject *pyfsxfs_file_entries_iternext( 88 pyfsxfs_file_entries_t *sequence_object ); 89 90 #if defined( __cplusplus ) 91 } 92 #endif 93 94 #endif /* !defined( _PYFSXFS_FILE_ENTRIES_H ) */ 95 96