diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-09-24 04:28:45 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-09-24 04:28:45 +0200 |
commit | 08a01723af9cd52c078d5ca6c38c34d375b39fa0 (patch) | |
tree | 6eadea9c67f4bb56a9e4ee09f4982efaf61deece /views/transform.c | |
parent | 924adedb2928f5657c6668f606dbb3294b3c45da (diff) | |
parent | ae7f83a7948d8c3760f8019899a45e6ec90c2c6a (diff) | |
download | pcitool-08a01723af9cd52c078d5ca6c38c34d375b39fa0.tar.gz pcitool-08a01723af9cd52c078d5ca6c38c34d375b39fa0.tar.bz2 pcitool-08a01723af9cd52c078d5ca6c38c34d375b39fa0.tar.xz pcitool-08a01723af9cd52c078d5ca6c38c34d375b39fa0.zip |
Finalyze XML support and provide initial support for views (only descriptions so far)
Diffstat (limited to 'views/transform.c')
-rw-r--r-- | views/transform.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/views/transform.c b/views/transform.c new file mode 100644 index 0000000..54ae2c1 --- /dev/null +++ b/views/transform.c @@ -0,0 +1,71 @@ +#define _PCILIB_VIEW_TRANSFORM_C + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> + +#include "version.h" +#include "model.h" +#include "transform.h" + + +static int pcilib_transform_view_read(pcilib_t *ctx, pcilib_view_context_t *view, const pcilib_register_value_t *regval, pcilib_data_type_t viewval_type, size_t viewval_size, void *viewval) { +/* int j=0; + pcilib_register_value_t value=0; + char* formula=NULL; + + if(view2reg==0) { + if(!(strcasecmp(unit,((pcilib_view_t*)viewval)->base_unit.name))) { + formula=malloc(sizeof(char)*strlen(((pcilib_formula_t*)params)->read_formula)); + if(!(formula)) { + pcilib_error("can't allocate memory for the formula"); + return PCILIB_ERROR_MEMORY; + } + strncpy(formula,((pcilib_formula_t*)params)->read_formula,strlen(((pcilib_formula_t*)params)->read_formula)); + pcilib_view_apply_formula(ctx,formula,regval); + return 0; + } + + for(j=0; ((pcilib_view_t*)viewval)->base_unit.transforms[j].name; j++) { + if(!(strcasecmp(((pcilib_view_t*)viewval)->base_unit.transforms[j].name,unit))) { + // when we have found the correct view of type formula, we apply the formula, that get the good value for return + formula=malloc(sizeof(char)*strlen(((pcilib_formula_t*)params)->read_formula)); + if(!(formula)) { + pcilib_error("can't allocate memory for the formula"); + return PCILIB_ERROR_MEMORY; + } + strncpy(formula,((pcilib_formula_t*)params)->read_formula,strlen(((pcilib_formula_t*)params)->read_formula)); + pcilib_view_apply_formula(ctx,formula, regval); + // pcilib_view_apply_unit(((pcilib_view_t*)viewval)->base_unit.transforms[j],unit,regval); + return 0; + } + }*/ +} + +static int pcilib_transform_view_write(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t *regval, pcilib_data_type_t viewval_type, size_t viewval_size, const void *viewval) { +/* if(!(strcasecmp(unit, ((pcilib_view_t*)viewval)->base_unit.name))) { + formula=malloc(sizeof(char)*strlen(((pcilib_formula_t*)params)->write_formula)); + strncpy(formula,((pcilib_formula_t*)params)->write_formula,strlen(((pcilib_formula_t*)params)->write_formula)); + pcilib_view_apply_formula(ctx,formula,regval); + return 0; + } + + for(j=0; ((pcilib_view_t*)viewval)->base_unit.transforms[j].name; j++) { + if(!(strcasecmp(((pcilib_view_t*)viewval)->base_unit.transforms[j].name,unit))) { + // when we have found the correct view of type formula, we apply the formula, that get the good value for return + formula=malloc(sizeof(char)*strlen(((pcilib_formula_t*)params)->write_formula)); + strncpy(formula,((pcilib_formula_t*)params)->write_formula,strlen((( pcilib_formula_t*)params)->write_formula)); + //pcilib_view_apply_unit(((pcilib_view_t*)viewval)->base_unit.transforms[j],unit,regval); + pcilib_view_apply_formula(ctx,formula,regval); + // we maybe need some error checking there , like temp_value >min and <max + return 0; + } + } + free(formula); + return PCILIB_ERROR_INVALID_REQUEST;*/ +} + + +const pcilib_view_api_description_t pcilib_transform_view_api = + { PCILIB_VERSION, sizeof(pcilib_transform_view_description_t), NULL, NULL, pcilib_transform_view_read, pcilib_transform_view_write }; |