1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 int
 saf_describe_unit(SAF_ParMode pmode,
                   SAF_Unit *unit,               /* Unit about which to retrieve information. */
                   char **name,                  /* If non-null then upon return this will point to an allocated copy of the
                                                  * unit singular name. */
                   char **abbr,                  /* If non-null then upon return this will point to an allocated copy of the
                                                  * unit singular abbreviation. */
                   char **url,                   /* If non-null then upon return this will point to an allocated copy of the
                                                  * URL for the unit's documentation. */
                   double *scale,                /* If non-null then upon return *SCALE will be the scale factor for the unit. */
                   double *offset,               /* If non-null then upon return *OFFSET will be the offset for the unit. */
                   double *logbase,              /* If non-null then upon return *LOGBASE will be the logarithm base for the
                                                  * unit. The returned value zero indicates no logarithm is applied. */
                   double *logcoef,              /* If non-null then upon return *LOGCOEF will be the multiplier of the
                                                  * logarithmic scale. */
                   SAF_Quantity *quantity        /* If non-null then upon return this will point to the handle of the quantity
                                                  * on which this unit is based. If the UNIT has not been defined yet (such as
                                                  * calling this function immediately after saf_declare_unit()) then the
                                                  * quantity handle will be initialized to a null link. */
                   )
 {
     SAF_ENTER(saf_describe_unit, SAF_PRECONDITION_ERROR);

     SAF_REQUIRE(_saf_valid_pmode(pmode), SAF_LOW_CHK_COST, SAF_PRECONDITION_ERROR,
                 _saf_errmsg("PMODE must be valid"));
     if (!_saf_is_participating_proc(pmode)) SAF_RETURN(-1);
     SAF_REQUIRE(SS_UNIT(unit), SAF_LOW_CHK_COST, SAF_PRECONDITION_ERROR,
                 _saf_errmsg("UNIT must be a valid unit handle"));

     /* fill in return values */
     _saf_setupReturned_string(name, ss_string_ptr(SS_UNIT_P(unit,name)));
     _saf_setupReturned_string(abbr, ss_string_ptr(SS_UNIT_P(unit,abbr)));
     _saf_setupReturned_string(url, ss_string_ptr(SS_UNIT_P(unit,url)));
     if (scale)    *scale    = SS_UNIT(unit)->scale;
     if (offset)   *offset   = SS_UNIT(unit)->offset;
     if (logbase)  *logbase  = SS_UNIT(unit)->logbase;
     if (logcoef)  *logcoef  = SS_UNIT(unit)->logcoef;
     if (quantity) *quantity = SS_UNIT(unit)->quant;

     SAF_LEAVE(SAF_SUCCESS);
 }