add .gbp.conf for gbp service
[tools/isomd5sum.git] / pyisomd5sum.c
1 /*
2  * Copyright (C) 2001-2007 Red Hat, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 #include <Python.h>
20 #include <stdio.h>
21
22 #include "libcheckisomd5.h"
23 #include "libimplantisomd5.h"
24
25 static PyObject * doCheckIsoMD5Sum(PyObject * s, PyObject * args);
26 static PyObject * doImplantIsoMD5Sum(PyObject * s, PyObject * args);
27
28 static PyMethodDef isomd5sumMethods[] = {
29     { "checkisomd5sum", (PyCFunction) doCheckIsoMD5Sum, METH_VARARGS, NULL },
30     { "implantisomd5sum", (PyCFunction) doImplantIsoMD5Sum, METH_VARARGS, NULL },
31     { NULL }
32 } ;
33
34
35 static PyObject * doCheckIsoMD5Sum(PyObject * s, PyObject * args) {
36     char *isofile;
37     int rc;
38
39     if (!PyArg_ParseTuple(args, "s", &isofile))
40         return NULL;
41  
42     rc = mediaCheckFile(isofile, NULL, NULL);
43
44     return Py_BuildValue("i", rc);
45 }
46
47 static PyObject * doImplantIsoMD5Sum(PyObject * s, PyObject * args) {
48     char *isofile, *errstr;
49     int forceit, supported;
50     int rc;
51
52     if (!PyArg_ParseTuple(args, "sii", &isofile, &supported, &forceit))
53         return NULL;
54
55     rc = implantISOFile(isofile, supported, forceit, 1, &errstr);
56
57     return Py_BuildValue("i", rc);
58 }
59
60
61 void initpyisomd5sum(void) {
62     PyObject * m, * d;
63
64     m = Py_InitModule("pyisomd5sum", isomd5sumMethods);
65     d = PyModule_GetDict(m);
66 }