mitem_userptr(3X)
π 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 beNULLπ). it does not seterrno. not even a little bit.set_item_userptrβ always returnsE_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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright 2018-2023,2024 Thomas E. Dickey
- Copyright 1998-2010,2015 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms