summaryrefslogtreecommitdiffstats
path: root/views/enum.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-09-24 04:28:45 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-09-24 04:28:45 +0200
commit08a01723af9cd52c078d5ca6c38c34d375b39fa0 (patch)
tree6eadea9c67f4bb56a9e4ee09f4982efaf61deece /views/enum.c
parent924adedb2928f5657c6668f606dbb3294b3c45da (diff)
parentae7f83a7948d8c3760f8019899a45e6ec90c2c6a (diff)
downloadpcitool-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/enum.c')
-rw-r--r--views/enum.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/views/enum.c b/views/enum.c
new file mode 100644
index 0000000..a222971
--- /dev/null
+++ b/views/enum.c
@@ -0,0 +1,47 @@
+#define _PCILIB_VIEW_ENUM_C
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "version.h"
+#include "model.h"
+#include "enum.h"
+
+static void pcilib_enum_view_free(pcilib_t *ctx, pcilib_view_context_t *view) {
+}
+
+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) {
+/* for(j=0; ((pcilib_enum_t*)(params))[j].name; j++) {
+ if (*regval<=((pcilib_enum_t*)(params))[j].max && *regval>=((pcilib_enum_t*)(params))[j].min) {
+ if(viewval_size<strlen(((pcilib_enum_t*)(params))[j].name)) {
+ pcilib_error("the string to contain the enum command is too tight");
+ return PCILIB_ERROR_MEMORY;
+ }
+ strncpy((char*)viewval,((pcilib_enum_t*)(params))[j].name, strlen(((pcilib_enum_t*)(params))[j].name));
+ k=strlen(((pcilib_enum_t*)(params))[j].name);
+ ((char*)viewval)[k]='\0';
+ return 0;
+ }
+ }
+ }
+ return PCILIB_ERROR_INVALID_REQUEST;*/
+}
+
+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) {
+/* int j,k;
+
+ if(view2reg==1) {
+ for(j=0; ((pcilib_enum_t*)(params))[j].name; j++) {
+ if(!(strcasecmp(((pcilib_enum_t*)(params))[j].name,(char*)viewval))) {
+ *regval=((pcilib_enum_t*)(params))[j].value;
+ return 0;
+ }
+ }*/
+}
+
+const pcilib_view_api_description_t pcilib_enum_view_static_api =
+ { PCILIB_VERSION, sizeof(pcilib_enum_view_description_t), NULL, NULL, pcilib_enum_view_read, pcilib_enum_view_write };
+const pcilib_view_api_description_t pcilib_enum_view_xml_api =
+ { PCILIB_VERSION, sizeof(pcilib_enum_view_description_t), NULL, pcilib_enum_view_free, pcilib_enum_view_read, pcilib_enum_view_write };