Blame src/python-problem/problem/pyabrtmodule.c

Packit 8ea169
/*
Packit 8ea169
    Copyright (C) 2010  Abrt team.
Packit 8ea169
    Copyright (C) 2010  RedHat inc.
Packit 8ea169
Packit 8ea169
    This program is free software; you can redistribute it and/or modify
Packit 8ea169
    it under the terms of the GNU General Public License as published by
Packit 8ea169
    the Free Software Foundation; either version 2 of the License, or
Packit 8ea169
    (at your option) any later version.
Packit 8ea169
Packit 8ea169
    This program is distributed in the hope that it will be useful,
Packit 8ea169
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8ea169
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8ea169
    GNU General Public License for more details.
Packit 8ea169
Packit 8ea169
    You should have received a copy of the GNU General Public License along
Packit 8ea169
    with this program; if not, write to the Free Software Foundation, Inc.,
Packit 8ea169
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 8ea169
*/
Packit 8ea169
#include <Python.h>
Packit 8ea169
Packit 8ea169
#include "common.h"
Packit 8ea169
Packit 8ea169
#if PY_MAJOR_VERSION >= 3
Packit 8ea169
  #define MOD_ERROR_VAL NULL
Packit 8ea169
  #define MOD_SUCCESS_VAL(val) val
Packit 8ea169
  #define MOD_INIT PyMODINIT_FUNC PyInit__py3abrt(void)
Packit 8ea169
  #define MOD_DEF(ob, name, doc, methods) \
Packit 8ea169
            static struct PyModuleDef moduledef = { \
Packit 8ea169
                          PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \
Packit 8ea169
          ob = PyModule_Create(&moduledef);
Packit 8ea169
#else
Packit 8ea169
  #define MOD_ERROR_VAL
Packit 8ea169
  #define MOD_SUCCESS_VAL(val)
Packit 8ea169
  #define MOD_INIT void init_pyabrt(void)
Packit 8ea169
  #define MOD_DEF(ob, name, doc, methods) \
Packit 8ea169
            ob = Py_InitModule3(name, methods, doc);
Packit 8ea169
#endif
Packit 8ea169
Packit 8ea169
static char module_doc[] = "ABRT utilities";
Packit 8ea169
Packit 8ea169
static PyMethodDef module_methods[] = {
Packit 8ea169
    /* method_name, func, flags, doc_string */
Packit 8ea169
    /* for include/client.h */
Packit 8ea169
    { "notify_new_path"           , p_notify_new_path         , METH_VARARGS },
Packit 8ea169
    { "load_conf_file"            , p_load_conf_file          , METH_VARARGS },
Packit 8ea169
    { "load_plugin_conf_file"     , p_load_plugin_conf_file   , METH_VARARGS },
Packit 8ea169
    { NULL }
Packit 8ea169
};
Packit 8ea169
Packit 8ea169
MOD_INIT
Packit 8ea169
{
Packit 8ea169
    PyObject *m;
Packit 8ea169
    MOD_DEF(m, "_pyabrt", module_doc, module_methods);
Packit 8ea169
    if (m == NULL)
Packit 8ea169
        return MOD_ERROR_VAL;
Packit 8ea169
    return MOD_SUCCESS_VAL(m);
Packit 8ea169
}