enum.c 1.9 KB

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