af_note(3)

πŸ’– af_note(3) β€” bestie edition πŸ’–

okay so this is a page from the Attribute Filesystem (AtFS) manual, and today's main character is af_note β€” the lil function duo that lets you read and modify the note attribute. yes, the note attribute. the vibe sticker of the ASO world. let's get into it 🫢


✨ NAME ✨

af_note β€” read and modify note attribute

like. the whole personality is right there in the name. read it. modify it. slay. πŸ’…


🌸 SYNOPSIS 🌸

#include <atfs.h>

in     af_snote (Af_key *aso, char *buf)

char  *af_rnote (Af_key *aso)

so you pull in <atfs.h> first, obvi, and then you've got two besties to work with: af_snote and af_rnote. one writes, one reads. a duo. an iconic pair. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so af_snote β€” it sets the given text (in buf) as change note of the specified ASO. that's the whole thing. you hand it text, it becomes the note.

heads up bestie: Text must be null terminated. no null terminator, no party. 🚫

and like, this is the important part β€” af_snote requires a lock (see af_lock(3)) set on the specified ASO. so if you roll up without locking first, that's not giving main character energy, that's giving chaos. lock it first. then write. periodt. πŸ”’

now af_rnote β€” she's the reader. she returns a pointer to the note attribute of the specified ASO. cute, right? BUT. and this is the part where you have to pay attention, bestie:

  • the note text is returned in memory allocated by malloc(3)
  • so when you're done, you use free(3) to make that space available for further allocation

like, it's yours, you own it, but you also have to clean up after yourself. the note isn't gonna free itself. 😭 that's literally your job now. free your girl. 🫢


πŸŽ€ SEE ALSO πŸŽ€

yes you need both. af_lock(3) for the locking situation before you af_snote, and free(3) for after you af_rnote. the full circle. the character arc. 🌈


πŸ’€ DIAGNOSTICS πŸ’€

so when things go wrong β€” and sometimes they do, it's not your fault β€” upon error, -1 or a nil pointer (depending on the return type) is returned, and af_errno is set to the corresponding error number.

okay so like. af_snote gives you back an in-flavoured thing and errors out with -1. af_rnote gives you back a char * and errors out with a nil pointer. either way, check af_errno and she'll tell you what actually happened. no guessing. no cap. πŸ”₯

not me almost forgetting to check af_errno... bestie PLEASE check af_errno πŸ™ˆ

πŸ’– and that's the whole page, bestie!! this gorgeous little slice of documentation came to you courtesy of AtFS-1.71, dated Fri Jun 25 14:33:14 1993 β€” yeah, the original is old enough to have its own vibe era, and we're keeping her legacy alive. go lock your ASO, write your note, read it back, and free it. in that order. mwah. βœ¨πŸ’…πŸ¦‹

πŸ“¦ where this page comes from