mitem_userptr(3X)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… mitem_userptr β€” library calls, but make it a group chat

okay so bestie, this is mitem_userptr(3X) from the library calls section, and honestly it's giving "small but mighty" ✨ because it's literally just two tiny functions that let you stash your own stuff on a menu item. no cap.


🌸 NAME 🌸

set_item_userptr, item_userptr β€” these two are the certified besties for associating your own application data with a menu item 🫢


✨ SYNOPSIS ✨

#include <menu.h>

int set_item_userptr(ITEM *item, void *userptr);
void *item_userptr(const ITEM *item);

like, look at them. so simple. so iconic. 😌


πŸ’– DESCRIPTION πŸ’–

so here's the tea β˜• β€” every single menu item has a field, right? and that field is yours. it's specifically for holding application-specific data, and the menu-driver code literally leaves it alone. it does not touch it. it does not look at it. it minds its own business, periodt πŸ’…

these functions get and set that field. that's the whole vibe. set_item_userptr sets it, item_userptr gets it. yin and yang. main character energy from both of them tbh πŸ¦‹


πŸŽ€ RETURN VALUE πŸŽ€

  • item_userptr β€” returns a pointer (which, lowkey, could be NULL πŸ™ˆ). it does not set errno. not even a little bit.
  • set_item_userptr β€” always returns E_OK (success). every time. no drama, no surprises, no failed vibe checks. πŸ”₯

🌈 PORTABILITY 🌈

these routines emulate the System V menu library, iykyk. they were not supported on Version 7 or BSD versions β€” so if you're on one of those, bestie, this is not the function for you 😭

also the user pointer is a void pointer. and here's the reason, which is honestly kind of a slay: we chose not to leave it as a char pointer, for SVr4 compatibility. the way that they thought ahead 🧚✨


πŸ‘‘ AUTHORS πŸ‘‘

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. absolute legends, both of them πŸ’œ


🌟 SEE ALSO 🌟

  • curses(3X)
  • menu(3X)

πŸ“ reminder bestie: the menu-driver code leaves your user pointer completely alone. it's your field, your data, your rules. go off. πŸ’…

and that's the whole page, cutie πŸŽ€ β€” brought to you by ncurses 6.5, dated 2024-12-28. mwah πŸ’–

πŸ“¦ where this page comes from