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