summaryrefslogtreecommitdiffstats
path: root/fdisk.h
blob: 5f41581bc56af78a4f701556a12f50f3f2dbedb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * (C) 2022 Soleta Consulting S.L. <info@soleta.eu>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Author: Jose M. Guisado <jguisado@soleta.eu>
 */


#ifndef UTIL_LINUX_PYLIBFDISK_H
#define UTIL_LINUX_PYLIBFDISK_H

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <structmember.h>

#include <libfdisk/libfdisk.h>

#define CONSTRUCT_ERR	"Error during object construction"
#define ARG_ERR		"Invalid number or type of arguments"

typedef struct {
	PyObject_HEAD
	struct fdisk_context		*cxt;
	struct fdisk_table		*tb;
} ContextObject;

typedef struct {
	PyObject_HEAD
	struct fdisk_label		*lb;
} LabelObject;

typedef struct {
	PyObject_HEAD
	struct fdisk_partition		*pa;
} PartitionObject;

typedef struct {
	PyObject_HEAD
	struct fdisk_parttype		*type;
} PartTypeObject;

extern PyTypeObject ContextType;
extern PyTypeObject PartitionType;
extern PyTypeObject PartTypeType;

extern void Context_AddModuleObject(PyObject *mod);
extern void Label_AddModuleObject(PyObject *mod);
extern void Partition_AddModuleObject(PyObject *mod);
extern void PartType_AddModuleObject(PyObject *mod);

extern PyObject *PyObjectResultStr(const char *s);
extern PyObject *PyObjectResultLabel(struct fdisk_label *lb);
extern PyObject *PyObjectResultPartition(struct fdisk_partition *pa);
extern PyObject *PyObjectResultPartType(struct fdisk_parttype *t);

extern void *set_PyErr_from_rc(int err);

#endif