#include <drStd.h>
#include <DrApi/DrApi.h>
#include <tee_internal_api.h>

#include <tees_log.h>
#include <protocol.h>

extern PersObjectCmd *g_po_cmd_buffer;
extern ProtocolCmd *g_cmd_buffer;

// should get all information from current command buffer
bool GetCancellationFlag(void) {
  uint8_t res = 0;

  TEE_MemFill(g_po_cmd_buffer, 0x00, sizeof(PersObjectCmd));
  g_po_cmd_buffer->cmd_id = PROTOCOL_COMMAND_GETCANCELFLAG;

  g_po_cmd_buffer->data_len = 1;
  g_po_cmd_buffer->teec_oper = g_cmd_buffer->teec_oper;

  /* Process request by client */
  if (DRAPI_OK != drApiNotify()) {
    goto exit;
  }
  /* Go on working */
  if (DRAPI_OK != drApiIpcSigWait()) {
    goto exit;
  }

  if (TEE_SUCCESS == g_cmd_buffer->cmd_ret) {
    TEE_MemMove(&res, g_po_cmd_buffer->data, 1);
  }
exit:
  return res;
}
