static PyObject *pyAbandonAction(PyObject *self, PyObject *args) { void *handle; void *actionHandle; if (!PyArg_ParseTuple(args, "ll", &handle, &actionHandle)) { PyErr_SetString(RulesError, "pyAbandonAction Invalid argument"); return NULL; } unsigned int result = abandonAction(handle, actionHandle); if (result != RULES_OK) { if (result == ERR_OUT_OF_MEMORY) { PyErr_NoMemory(); } else { char *message; if (asprintf(&message, "Could not abandon action, error code: %d", result)) { PyErr_NoMemory(); } else { PyErr_SetString(RulesError, message); free(message); } } return NULL; } Py_RETURN_NONE; }
static VALUE rbAbandonAction(VALUE self, VALUE handle, VALUE actionHandle) { Check_Type(handle, T_FIXNUM); Check_Type(actionHandle, T_FIXNUM); unsigned int result = abandonAction((void *)FIX2LONG(handle), (void *)FIX2LONG(actionHandle)); if (result != RULES_OK) { if (result == ERR_OUT_OF_MEMORY) { rb_raise(rb_eNoMemError, "Out of memory"); } else { rb_raise(rb_eException, "Could not abandon action, error code: %d", result); } } return Qnil; }