[35] in Kerberos_V5_Development
Re: version tags
raeburn@ATHENA.MIT.EDU (raeburn@ATHENA.MIT.EDU)
Sat Jan 13 17:02:38 1990
Actually, I'd prefer short (say, 8) character arrays right in the
structures themselves, but that makes it non-trivial to compare them.
Something like:
typedef struct { char x[8]; } krb5_version_tag;
extern krb5_version_tag krb5_mumble_struct_v001;
/* contains "mumble01" */
client:
mumble_p -> tag = krb5_mumble_struct_v001;
library:
if (!krb5_version_tag_check(&mumble_p->tag, &krb5_mumble_struct_v001))
/* ... */;
This way we don't have to deal with (possibly bogus) pointers (btw,
strncmp wouldn't really buy us anything; think how the comparisons are
done in the usual implementation); also we get a textual form, which
is easier to examine when debugging, and is more difficult to
"accidentally" have set to the correct value. (Consider that we
probably want different tags for each version of each structure; how
easy is it to tell what "73" means?)
If we don't mind having to put the above extra call (which could
probably be a macro using bcmp) into many of our routines, I think
this would be best.
Also, in case it isn't obvious, the tag should always be at the start
of the structure.