f_downstream_api.c 1.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#include "nrm.h"
#include <stdlib.h>
#include <stdint.h>

int f_nrm_ctxt_create_(uintptr_t *ctxt)
{
    *ctxt = nrm_ctxt_create();
    return 0;
}

int f_nrm_ctxt_delete_(uintptr_t *ctxt)
{
    return nrm_ctxt_delete(*((struct nrm_context **)ctxt));
}

int f_nrm_init_(uintptr_t *ctxt, char* uuid_in, int* size)
{
    char* uuid = calloc(*size+1, sizeof(char));
    int i, err;
    for (i = 0; i < *size; i++)
    {
      uuid[i] = uuid_in[i];
      if (uuid_in[i] == ' ')
      {
        uuid[i] = 0;
        i = *size;
      }
    }
    uuid[*size] = 0;
    err = nrm_init(*((struct nrm_context **)ctxt), uuid);
    free(uuid);
    return err;
}

int f_nrm_fini_(uintptr_t *ctxt)
{
    return nrm_fini(*((struct nrm_context **)ctxt));
}

int f_nrm_send_progress_(uintptr_t *ctxt, unsigned long *progress)
{
    return nrm_send_progress(*((struct nrm_context **)ctxt), *progress);
}

int f_nrm_send_phase_context_(uintptr_t *ctxt, unsigned int *cpu, unsigned int *aggregation, unsigned long long int *computeTime, unsigned long long int *totalTime)
{
    return nrm_send_phase_context(*((struct nrm_context **)ctxt), *cpu, *aggregation, *computeTime, *totalTime);
}