1 /*
2  * Python object definition of the sequence and iterator object of extended attributes
3  *
4  * Copyright (C) 2018-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( _PYFSAPFS_EXTENDED_ATTRIBUTES_H )
23 #define _PYFSAPFS_EXTENDED_ATTRIBUTES_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #include "pyfsapfs_libfsapfs.h"
29 #include "pyfsapfs_python.h"
30 
31 #if defined( __cplusplus )
32 extern "C" {
33 #endif
34 
35 typedef struct pyfsapfs_extended_attributes pyfsapfs_extended_attributes_t;
36 
37 struct pyfsapfs_extended_attributes
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 pyfsapfs_extended_attributes_type_object;
63 
64 PyObject *pyfsapfs_extended_attributes_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 pyfsapfs_extended_attributes_init(
72      pyfsapfs_extended_attributes_t *sequence_object );
73 
74 void pyfsapfs_extended_attributes_free(
75       pyfsapfs_extended_attributes_t *sequence_object );
76 
77 Py_ssize_t pyfsapfs_extended_attributes_len(
78             pyfsapfs_extended_attributes_t *sequence_object );
79 
80 PyObject *pyfsapfs_extended_attributes_getitem(
81            pyfsapfs_extended_attributes_t *sequence_object,
82            Py_ssize_t item_index );
83 
84 PyObject *pyfsapfs_extended_attributes_iter(
85            pyfsapfs_extended_attributes_t *sequence_object );
86 
87 PyObject *pyfsapfs_extended_attributes_iternext(
88            pyfsapfs_extended_attributes_t *sequence_object );
89 
90 #if defined( __cplusplus )
91 }
92 #endif
93 
94 #endif /* !defined( _PYFSAPFS_EXTENDED_ATTRIBUTES_H ) */
95 
96