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

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

    char *group_str = python_str_or_unicode_to_string(group);
    char *key_str = python_str_or_unicode_to_string(key);
    char *def_str = python_str_or_unicode_to_string(def);

    allow_python_threads();
    char *res = api_settings_string_get(group_str, key_str, def_str);
    free(group_str);
    free(key_str);
    free(def_str);
    disable_python_threads();

    if (res) {
        PyObject *pyres = Py_BuildValue("s", res);
        free(res);
        return pyres;
    } else {
        Py_RETURN_NONE;
    }
}
示例#2
0
文件: c_api.c 项目: anossov/profanity
static char*
c_api_settings_string_get(char *group, char *key, char *def)
{
    return api_settings_string_get(group, key, def);
}