scan_ldapescape(3)

πŸ’– scan_ldapescape β€” bestie's guide to the LDIF escape decoder πŸ’–

okay so hi!! you're here because you wanna know about scan_ldapescape, the little function from the Library Functions Manual that lives in libowfat and parses LDIF escaped strings. she's not famous but she's iconic in her own quiet way, fr fr. πŸ¦‹


✨ NAME ✨

scan_ldapescape β€” parse LDIF escaped string πŸ’…


🌸 SYNTAX 🌸

#include <libowfat/textcode.h>

size_t scan_ldapescape(const char *src,char *dest,size_t* destlen);

πŸŽ€ DESCRIPTION πŸŽ€

so like, what does she do. scan_ldapescape parses LDIF escaped text from src into dest. that's the whole vibe. and then β€” and this is important bestie β€” parsing stops at the 0 terminator or at invalid input characters. so she knows when to quit, unlike your ex. 😭

this function will turn backslash escaped characters into their binary equivalent, i.e. a to new-line and 5c to backslash. lowkey magic honestly ✨

then scan_cescape will write the number of bytes in dest into *destlen, and return the number of bytes decoded from src. (yes girl, the manpage really says scan_cescape there β€” we're just reporting the facts, no editing, periodt.)

also, super flexible queen behavior:

  • dest can be NULL.
  • destlen can be NULL.
  • dest can be src. (in-place glow-up!! πŸ‘‘)

and the reassurance you needed: the decoded data needs at most as much space as the encoded data used. so no surprise explosions, she's chill. 🫢


⭐ RETURN VALUE ⭐

scan_ldapescape returns the number of bytes successfully parsed from src. that's it, that's the number. 🎯


🌈 EXAMPLES 🌈

here's the moment you've been waiting for:

scan_ldapescape("test5C\");",buf,&i) -> return 7, i=5, buf="test\" (C notation).

she ate that. πŸ’€βœ¨ return 7, i=5, buf becomes "test\" in C notation.


πŸ‘‘ SEE ALSO πŸ‘‘


ngl bestie, if you take nothing else from this page, take this: check your destlen, respect the 0 terminator, and never trust an escape sequence you didn't decode yourself. πŸ’–

and that's the whole page!! this lil cutie comes to you from the Library Functions Manual β€” scan_ldapescape(3), mwah, go forth and parse responsibly. πŸ’…πŸŒΈπŸ¦‹