summaryrefslogtreecommitdiffstats
path: root/pcilib/unit.h
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-10-08 20:04:37 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-10-08 20:04:37 +0200
commit21812f8d763fac8ee9bb3fdc593642b06f405a2b (patch)
treea55e99115e8c238e6b34159e063ac7d01ba65d54 /pcilib/unit.h
parente28e74adf3d58deb95ce84c66423f347cbe2f859 (diff)
downloadpcitool-21812f8d763fac8ee9bb3fdc593642b06f405a2b.tar.gz
pcitool-21812f8d763fac8ee9bb3fdc593642b06f405a2b.tar.bz2
pcitool-21812f8d763fac8ee9bb3fdc593642b06f405a2b.tar.xz
pcitool-21812f8d763fac8ee9bb3fdc593642b06f405a2b.zip
Base functions for views
Diffstat (limited to 'pcilib/unit.h')
-rw-r--r--pcilib/unit.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/pcilib/unit.h b/pcilib/unit.h
index 9c62ff3..e0eeefc 100644
--- a/pcilib/unit.h
+++ b/pcilib/unit.h
@@ -4,6 +4,8 @@
#include <pcilib.h>
#define PCILIB_UNIT_INVALID ((pcilib_unit_t)-1)
+#define PCILIB_UNIT_TRANSFORM_INVALID ((pcilib_unit_transform_t)-1)
+
#define PCILIB_MAX_TRANSFORMS_PER_UNIT 16 /**< Limits number of supported transforms per unit */
typedef struct pcilib_unit_context_s *pcilib_unit_context_t;
@@ -12,13 +14,13 @@ typedef struct pcilib_unit_context_s *pcilib_unit_context_t;
* unit transformation routines
*/
typedef struct {
- char *unit; /**< Name of the resulting unit */
- char *transform; /**< String, similar to view formula, explaining transform to this unit */
+ char *unit; /**< Name of the resulting unit */
+ char *transform; /**< String, similar to view formula, explaining transform to this unit */
} pcilib_unit_transform_t;
typedef struct {
- char *name; /**< Unit name */
- pcilib_unit_transform_t transforms[PCILIB_MAX_TRANSFORMS_PER_UNIT + 1]; /**< Transforms to other units */
+ char *name; /**< Unit name */
+ pcilib_unit_transform_t transforms[PCILIB_MAX_TRANSFORMS_PER_UNIT + 1]; /**< Transforms to other units */
} pcilib_unit_description_t;
#ifdef __cplusplus
@@ -26,7 +28,14 @@ extern "C" {
#endif
int pcilib_add_units(pcilib_t *ctx, size_t n, const pcilib_unit_description_t *desc);
+
pcilib_unit_t pcilib_find_unit_by_name(pcilib_t *ctx, const char *unit);
+pcilib_unit_transform_t *pcilib_find_transform_by_unit_names(pcilib_t *ctx, const char *from, const char *to);
+
+ // value is modified
+int pcilib_transform_unit(pcilib_t *ctx, pcilib_unit_transform_t *trans, pcilib_value_t *value);
+int pcilib_transform_unit_by_name(pcilib_t *ctx, const char *to, pcilib_value_t *value);
+
#ifdef __cplusplus
}