40
40
* already registered unit. The function will copy the context of unit description, but name,
41
41
* transform, and other strings in the structure are considered to have static duration
42
42
* and will not be copied. On error no new units are initalized.
43
* @param[in,out] ctx - pcilib context
44
* @param[in] n - number of units to initialize. It is OK to pass 0 if protocols variable is NULL terminated (last member of protocols array have all members set to 0)
45
* @param[in] desc - unit descriptions
46
* @return - error or 0 on success
43
* @param[in,out] ctx - pcilib context
44
* @param[in] n - number of units to initialize. It is OK to pass 0 if protocols variable is NULL terminated (last member of protocols array have all members set to 0)
45
* @param[in] desc - unit descriptions
46
* @return - error or 0 on success
48
48
int pcilib_add_units(pcilib_t *ctx, size_t n, const pcilib_unit_description_t *desc);
51
51
* Destroys data associated with units. This is an internal function and will
52
52
* be called during clean-up.
53
* @param[in,out] ctx - pcilib context
54
* @param[in] start - specifies first unit to clean (used to clean only part of the units to keep the defined state if pcilib_add_units has failed)
53
* @param[in,out] ctx - pcilib context
54
* @param[in] start - specifies first unit to clean (used to clean only part of the units to keep the defined state if pcilib_add_units has failed)
56
56
void pcilib_clean_units(pcilib_t *ctx, pcilib_unit_t start);
59
* Find unit id using supplied name.
60
* @param[in] ctx - pcilib context
61
* @param[in] unit - the requested unit name
62
* @return - unit id or PCILIB_UNIT_INVALID if error not found or error has occured
58
64
pcilib_unit_t pcilib_find_unit_by_name(pcilib_t *ctx, const char *unit);
67
* Find the required transform between two specified units.
68
* @param[in] ctx - pcilib context
69
* @param[in] from - the source unit
70
* @param[in] to - destination unit
71
* @return - the pointer to unit transform or NULL in case of error. If no transform required (i.e. \a from = \a to),
72
the function will return #pcilib_unit_transform_t structure with \a transform field set to NULL.
59
74
pcilib_unit_transform_t *pcilib_find_transform_by_unit_names(pcilib_t *ctx, const char *from, const char *to);
62
77
* Converts value to the requested units. It is error to convert values with unspecified units.
63
78
* This is internal function, use pcilib_value_convert_value_unit instead.
64
* @param[in,out] ctx - pcilib context
65
* @param[in] trans - the requested unit transform
79
* @param[in,out] ctx - pcilib context
80
* @param[in] trans - the requested unit transform
66
81
* @param[in,out] value - the value to be converted (changed on success)
67
* @return - error or 0 on success
82
* @return - error or 0 on success
69
84
int pcilib_transform_unit(pcilib_t *ctx, const pcilib_unit_transform_t *trans, pcilib_value_t *value);
72
87
* Converts value to the requested units. It is error to convert values with unspecified units.
73
88
* This is internal function, use pcilib_value_convert_value_unit instead.
74
* @param[in,out] ctx - pcilib context
75
* @param[in] name - specifies the requested unit of the value
89
* @param[in,out] ctx - pcilib context
90
* @param[in] to - specifies the requested unit of the value
76
91
* @param[in,out] value - the value to be converted (changed on success)
77
* @return - error or 0 on success
92
* @return - error or 0 on success
79
94
int pcilib_transform_unit_by_name(pcilib_t *ctx, const char *to, pcilib_value_t *value);