shishi_asn1_read_optional(3)
π 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 fromshishi_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 insidenodethat 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>. π«Ά
- GNU Shishi home page: http://www.gnu.org/software/shishi/
- General help using GNU software: http://www.gnu.org/gethelp/
π COPYRIGHT π
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 π
π¦ where this page comes from
- debian bookworm: shishi-doc 1.0.3-1 Β· GPL-3.0-or-later
- debian trixie: shishi-doc 1.0.3-5 Β· GPL-3.0-or-later
- nixos 26.05: shishi 1.0.3
- nixpkgs unstable: shishi 1.0.3
- ubuntu noble: shishi-doc 1.0.3-2.1build2 Β· GPL-3.0-or-later
- ubuntu questing: shishi-doc 1.0.3-5
- ubuntu resolute: shishi-doc 1.0.3-5build1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms