static int pshoutobj_set_str(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { const char* str; pshout_set_shout_str set_shout; if (!PyString_Check(v)) { PyErr_SetString(PyExc_TypeError, "String argument required"); return -1; } str = PyString_AsString(v); set_shout = (pshout_set_shout_str)attr->set_shout; return set_shout(self->conn, str); }
static int pshoutobj_set_int(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { long val; pshout_set_shout_int set_shout; if (!PyInt_Check(v)) { PyErr_SetString(PyExc_TypeError, "Numerical argument required"); return -1; } val = PyLong_AsLong(v); set_shout = (pshout_set_shout_int)attr->set_shout; return set_shout(self->conn, val); }
static int pshoutobj_set_bool(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { long val; pshout_set_shout_int set_shout; if (!PyBool_Check(v)) { PyErr_SetString(PyExc_TypeError, "Boolean argument required"); return -1; } val = (v == Py_True) ? 1 : 0; set_shout = (pshout_set_shout_int)attr->set_shout; return set_shout(self->conn, val); }
static int pshoutobj_set_proto(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { const char* val; kv_strint* proto_map; pshout_set_shout_int set_shout; if (!PyString_Check(v)) { PyErr_SetString(PyExc_TypeError, "String argument required"); return SHOUTERR_INSANE; } val = PyString_AsString(v); for (proto_map = ShoutProtocolMap; proto_map->name; proto_map++) { if (!strcmp(proto_map->name, val)) { set_shout = (pshout_set_shout_int)attr->set_shout; return set_shout(self->conn, proto_map->val); } } PyErr_SetString(ShoutError, "Unsupported protocol"); return SHOUTERR_UNSUPPORTED; }