/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to views/enum.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-09-24 02:28:45 UTC
  • mfrom: (305.1.19 views)
  • Revision ID: csa@suren.me-20150924022845-p7hc8lh8v0q48g0r
Finalyze XML support and provide initial support for views (only descriptions so far)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define _PCILIB_VIEW_ENUM_C
 
2
 
 
3
#include <stdio.h>
 
4
#include <unistd.h>
 
5
#include <stdlib.h>
 
6
#include <string.h>
 
7
 
 
8
#include "version.h"
 
9
#include "model.h"
 
10
#include "enum.h"
 
11
 
 
12
static void pcilib_enum_view_free(pcilib_t *ctx, pcilib_view_context_t *view) {
 
13
}
 
14
 
 
15
static int pcilib_enum_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) {
 
16
/*        for(j=0; ((pcilib_enum_t*)(params))[j].name; j++) {
 
17
            if (*regval<=((pcilib_enum_t*)(params))[j].max && *regval>=((pcilib_enum_t*)(params))[j].min) {
 
18
                if(viewval_size<strlen(((pcilib_enum_t*)(params))[j].name)) {
 
19
                    pcilib_error("the string to contain the enum command is too tight");
 
20
                    return PCILIB_ERROR_MEMORY;
 
21
                }
 
22
                strncpy((char*)viewval,((pcilib_enum_t*)(params))[j].name, strlen(((pcilib_enum_t*)(params))[j].name));
 
23
                k=strlen(((pcilib_enum_t*)(params))[j].name);
 
24
                ((char*)viewval)[k]='\0';
 
25
                return 0;
 
26
            }
 
27
        }
 
28
    }
 
29
    return PCILIB_ERROR_INVALID_REQUEST;*/
 
30
}
 
31
 
 
32
static int pcilib_enum_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) {
 
33
/*    int j,k;
 
34
 
 
35
    if(view2reg==1) {
 
36
        for(j=0; ((pcilib_enum_t*)(params))[j].name; j++) {
 
37
            if(!(strcasecmp(((pcilib_enum_t*)(params))[j].name,(char*)viewval))) {
 
38
                *regval=((pcilib_enum_t*)(params))[j].value;
 
39
                return 0;
 
40
            }
 
41
        }*/
 
42
}
 
43
 
 
44
const pcilib_view_api_description_t pcilib_enum_view_static_api =
 
45
  { PCILIB_VERSION, sizeof(pcilib_enum_view_description_t), NULL, NULL,  pcilib_enum_view_read,  pcilib_enum_view_write };
 
46
const pcilib_view_api_description_t pcilib_enum_view_xml_api =
 
47
  { PCILIB_VERSION, sizeof(pcilib_enum_view_description_t), NULL, pcilib_enum_view_free,  pcilib_enum_view_read,  pcilib_enum_view_write };