mitem_userptr(3X)

πŸ’– mitem_userptr(3X) πŸ’–

okay bestie, so this one's a library call from the ncurses girlies β€” it's called mitem_userptr(3X) and it's literally the "here's my stuff, hold it for me" page for menu items. no cap.


✨ NAME ✨

set_item_userptr, item_userptr β€” associate application data with a menu item πŸŽ€


🌸 SYNOPSIS 🌸

#include <menu.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so every single menu item has a field, right? and that field exists purely so you can stash your own application-specific data in it. and the way the menu-driver code handles it? it leaves it alone. completely. it does not touch it, it does not look at it, it minds its own business. periodt. πŸ’…

these two functions are your get-and-set duo for that field. that's it, that's the whole vibe.


πŸ’œ RETURN VALUE πŸ’œ

  • item_userptr hands you back a pointer. and yes, that pointer can be NULL β€” no drama, that's allowed. also: it does not set errno.
  • set_item_userptr always returns E_OK, which means success. every time. iconic behaviour honestly. ✨

🌈 PORTABILITY 🌈

these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions. so if you're kicking it on ancient BSD, sorry bestie, no userptr for you. 😭

and the user pointer is a void pointer. we deliberately did not leave it as a char pointer, because of SVr4 compatibility. that's the reason, that's the lore, iykyk.


πŸ‘‘ AUTHORS πŸ‘‘

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. absolute legends, we love them, no notes. 🫢


πŸŽ€ SEE ALSO πŸŽ€

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

ngl the void * thing is doing main character energy β€” it just wants to be compatible with SVr4, let it live. πŸ’€

and that's a wrap, babe! this page came to you courtesy of ncurses 6.6, dated 2024-12-28. go forth and stash your pointers. πŸ’–πŸŒΈβœ¨

πŸ“¦ where this page comes from