shishi_asn1_read_optional(3)

πŸ“¦
version 1.0.3 Β· 3 versions
, in debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute

πŸ’– shishi_asn1_read_optional πŸ’–

okay bestie, gather round, because today we're reading a field from an ASN.1 node and being chill about it possibly not existing. this is shishi_asn1_read_optional(3), one of the shishi man pages, and honestly? she's serving convenience and I'm obsessed. πŸ¦‹


✨ SYNOPSIS ✨

#include <shishi.h>

int shishi_asn1_read_optional(Shishi * handle, Shishi_asn1 node, const
char * field, char ** data, size_t * datalen);

like look at her. five arguments. no notes. πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • Shishi * handle β€” your shishi handle, aka the one you got from shishi_init(). if you didn't call that first, girl what are you doing 😭
  • Shishi_asn1 node β€” the ASN.1 variable you wanna read a field out of.
  • const char * field β€” the name of the field inside node that you're trying to read.
  • char ** data β€” the output buffer. it's newly allocated, and it's gonna hold your ASN.1 field data. 🫢
  • size_t * datalen β€” the actual size of that output buffer. keep her around, she matters.

🌸 DESCRIPTION 🌸

so the whole vibe here is: you extract data stored in an ASN.1 field, and it lands in a newly allocated buffer. that's it. that's the job. ✨

but here's the part that makes her iconic: if the field doesn't exist β€” like, i.e. SHISHI_ASN1_NO_ELEMENT doesn't exist energy β€” this function just sets datalen to 0 and succeeds anyway. no drama. no tears. πŸ’…

and that is exactly why you'd use her. she's the go-to for reading ASN.1 fields that are marked OPTIONAL in the grammar, so you don't have to write a whole special error-handling subplot in your code. she handles the "maybe it's not there" situation so you don't have to. main character energy fr fr. πŸ‘‘


⭐ RETURN VALUE ⭐

  • SHISHI_OK β€” slayed. it worked. βœ…
  • SHISHI_ASN1_NO_VALUE β€” the field exists but has no value. it's giving empty. πŸ’€
  • SHISHI_ASN1_ERROR β€” something went wrong otherwise. 😭

πŸ› REPORTING BUGS πŸ›

found a bug? don't be shy, tell the shishi people at <bug-shishi@gnu.org>. 🫢


Copyright Β© 2002-2022 Simon Josefsson.

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.

(translation: take her, share her, just keep the receipts bestie πŸ§ΎπŸ’–)


πŸ¦‹ SEE ALSO πŸ¦‹

the full documentation for shishi lives in a Texinfo manual, and if the info and shishi programs are properly installed at your site, this command:

info shishi

should give you access to the complete manual. go read her, she's long but she's worth it. πŸ“šβœ¨


and that's a wrap, bestie!! 🌈 this was shishi_asn1_read_optional(3), from shishi version 1.0.3, and yeah she's been sitting in the manual since forever, doing her little optional-field thing. no cap. πŸ’œπŸŽ€

mwah πŸ’