static uint8_t prv_server_delete(uint16_t id, lwm2m_object_t * objectP) { server_instance_t * serverInstance; objectP->instanceList = lwm2m_list_remove(objectP->instanceList, id, (lwm2m_list_t **)&serverInstance); if (NULL == serverInstance) return COAP_404_NOT_FOUND; lwm2m_free(serverInstance); return COAP_202_DELETED; }
static uint8_t prv_delete(uint16_t id, lwm2m_object_t * objectP) { prv_instance_t * targetP; objectP->instanceList = lwm2m_list_remove(objectP->instanceList, id, (lwm2m_list_t **)&targetP); if (NULL == targetP) return COAP_404_NOT_FOUND; lwm2m_free(targetP); return COAP_202_DELETED; }
static uint8_t prv_delete(uint16_t id, lwm2m_object_t * objectP) { acc_ctrl_oi_t* targetP; objectP->instanceList = lwm2m_list_remove(objectP->instanceList, id, (lwm2m_list_t**)&targetP); if (NULL == targetP) return COAP_404_NOT_FOUND; LWM2M_LIST_FREE(targetP->accCtrlValList); lwm2m_free(targetP); return COAP_202_DELETED; }
static uint8_t prv_delete(uint16_t id, lwm2m_object_t * objectP) { // Remove instance in C list lwm2m_list_t * deletedInstance; objectP->instanceList = lwm2m_list_remove(objectP->instanceList, id, (lwm2m_list_t **) &deletedInstance); if (NULL == deletedInstance) return COAP_404_NOT_FOUND ; free(deletedInstance); // Get user data. luaobject_userdata * userdata = (luaobject_userdata*) objectP->userData; lua_State * L = userdata->L; // Push instance on the stack int res = prv_get_instance(L, userdata, id); // stack: ..., instance if (!res) return COAP_500_INTERNAL_SERVER_ERROR ; // Get the delete function lua_getfield(L, -1, "delete"); // stack: ..., instance, deleteFunc if (!lua_isfunction(L, -1)) { lua_pop(L, 1); // clean the stack return COAP_500_INTERNAL_SERVER_ERROR ; } // Push instance and resource id on the stack and call the writeFunc lua_pushvalue(L, -2); // stack: ..., instance, deleteFunc, instance lua_call(L, 1, 1); // stack: ..., instance, return_code // Get return code int ret = lua_tointeger(L, -1); // Clean the stack lua_pop(L, 2); return ret; }