示例#1
0
static PyObject*
python_api_settings_boolean_get(PyObject *self, PyObject *args)
{
    PyObject *group = NULL;
    PyObject *key = NULL;
    PyObject *defobj = NULL;

    if (!PyArg_ParseTuple(args, "OOO!", &group, &key, &PyBool_Type, &defobj)) {
        Py_RETURN_NONE;
    }

    char *group_str = python_str_or_unicode_to_string(group);
    char *key_str = python_str_or_unicode_to_string(key);
    int def = PyObject_IsTrue(defobj);

    allow_python_threads();
    int res = api_settings_boolean_get(group_str, key_str, def);
    free(group_str);
    free(key_str);
    disable_python_threads();

    if (res) {
        return Py_BuildValue("O", Py_True);
    } else {
        return Py_BuildValue("O", Py_False);
    }
}
示例#2
0
文件: c_api.c 项目: anossov/profanity
static int
c_api_settings_boolean_get(char *group, char *key, int def)
{
    return api_settings_boolean_get(group, key, def);
}