#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <tee_client_api.h>

TEEC_UUID uuid = {
    .timeLow = 0x83f96314,
    .timeMid = 0x3a8d,
    .timeHiAndVersion = 0x4a65,
    .clockSeqAndNode = {0xbe, 0x07, 0xc4, 0x8b, 0x2d, 0x24, 0xf6, 0x86},
};

int main(void)
{
    TEEC_Context context;
    TEEC_Session session;
    TEEC_Operation operation;
    uint32_t returnOrigin;


    TEEC_Result res = TEEC_InitializeContext(NULL, &context);

    if (res != TEEC_SUCCESS) {
        fprintf(stderr,"InitializeContext failed: %s\n", get_error_name(res));
        return 1;
    }

    res = TEEC_OpenSession(&context, &session, &uuid, 0, NULL, NULL,
                           &returnOrigin);
    if (res != TEEC_SUCCESS) {
        fprintf(stderr,"TEEC_OpenSession returned %s from %x\n", get_error_name(res),
                returnOrigin);
        TEEC_FinalizeContext(&context);
        return 1;
    }

    operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);

    res = TEEC_InvokeCommand(&session, 0x0, &operation, &returnOrigin);
    if (res != TEEC_SUCCESS) {
        fprintf(stderr,"TEEC_InvokeCommand returned %s from %x\n", get_error_name(res),
                returnOrigin);
    }

    TEEC_CloseSession(&session);
    TEEC_FinalizeContext(&context);
    (res == TEEC_SUCCESS)? printf("Test passed\n"): printf("Test failed\n");

    return (res != TEEC_SUCCESS);
}
