[Swan-dev] strip_prefix + enum_show + bitnamesof

Andrew Cagney andrew.cagney at gmail.com
Thu Jul 21 20:58:25 UTC 2016


On 21 July 2016 at 16:11, D. Hugh Redelmeier <hugh at mimosa.com> wrote:
> | From: Andrew Cagney <andrew.cagney at gmail.com>
>
> | then I can display a truncated value vis:
> |
> |    strip_prefix("ESN_", enum_enum_show(ikev2_trans_type_esn_names,
> | IKEv2_ESN_DISABLED))
> |    -> "DISABLED"
>
> It seems that strip_prefix is used about 45 times.  That's often
> enough to be catered to.
>
> Idea: introduce
>
> 1) a "prefix" field into struct enum names
>
> 2) add new functions "enum_showb_short" and "enum_name_short" that
>    suppress the prefix found in struct enum names
>    Don't bother with a version of enum_show: let's not make
>    another function with confusing storage for the result

Yes.

> 3) we could add a shortbitnames function.  That would take an extra
>    argument, prefix-to-be-suppressed.  (There is no descriptor struct
>    to contain the prefix.  I guess we could add one.)

why not pass in the enum_name?  Well in truth, if the above was added
I'd likely just wrap it with an enum variant that passes in the stuff
from the enum struct.

> Is that reasonable?
> _______________________________________________
> Swan-dev mailing list
> Swan-dev at lists.libreswan.org
> https://lists.libreswan.org/mailman/listinfo/swan-dev


More information about the Swan-dev mailing list