/
githubmirror
/
libreport
Обзор
Документация
Войти
/
githubmirror
/
libreport
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/client-python/reportclient/client.c
116 строк
3 KB
Michal Fabik
Use g_autofree where possible
17 июн 2020, 13:45
17 июн 2020, 13:45
7aba6e5
Код
Авторство
О чём код?
/* Copyright (C) 2010 Abrt team. Copyright (C) 2010 RedHat inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include <glib.h> #include <Python.h> #include "common.h" /* C: void alert(const char *message); */ PyObject *p_alert(PyObject *pself, PyObject *args) { const char *message; if (!PyArg_ParseTuple(args, "s", &message)) { return NULL; } libreport_alert(message); Py_RETURN_NONE; } /* C: char *ask(const char *question, char *response, int response_len); */ PyObject *p_ask(PyObject *pself, PyObject *args) { const char *question; if (!PyArg_ParseTuple(args, "s", &question)) { return NULL; } g_autofree char *response = libreport_ask(question); if (!response) { Py_RETURN_NONE; } PyObject *r = Py_BuildValue("s", response); return r; } /* C: char *ask_password(const char *question, char *response, int response_len); */ PyObject *p_ask_password(PyObject *pself, PyObject *args) { const char *question; if (!PyArg_ParseTuple(args, "s", &question)) { return NULL; } g_autofree char *response = libreport_ask_password(question); if (!response) { Py_RETURN_NONE; } PyObject *r = Py_BuildValue("s", response); return r; } /* C: int libreport_ask_yes_no(const char *question); */ PyObject *p_ask_yes_no(PyObject *pself, PyObject *args) { const char *question; if (!PyArg_ParseTuple(args, "s", &question)) { return NULL; } int response = libreport_ask_yes_no(question); return Py_BuildValue("i", response); } /* C: int ask_yes_no_yesforever(const char *key, const char *question); */ PyObject *p_ask_yes_no_yesforever(PyObject *pself, PyObject *args) { const char *key; const char *question; if (!PyArg_ParseTuple(args, "ss", &key, &question)) { return NULL; } int response = libreport_ask_yes_no_yesforever(key, question); return Py_BuildValue("i", response); } /* C: int ask_yes_no_yesforever(const char *key, const char *question); */ PyObject *p_ask_yes_no_save_result(PyObject *pself, PyObject *args) { const char *key; const char *question; if (!PyArg_ParseTuple(args, "ss", &key, &question)) { return NULL; } int response = libreport_ask_yes_no_save_result(key, question); return Py_BuildValue("i", response); }