userptr(3MENU)
π userptr β bestie, let's attach ur data to a menu π
okay so this is userptr(3MENU) from the Library calls section, and it's literally the chillest little pair of functions you'll ever meet. no cap. π
β¨ NAME β¨
set_menu_userptr, menu_userptr β associate application data with a menu item π«Ά
like⦠you get to store your own stuff on a menu. that's it. that's the vibe.
β¨ SYNOPSIS β¨
#include <menu.h>
int set_menu_userptr(MENU *menu, void *userptr);
void *menu_userptr(const MENU *menu);
look at that. two little lines. iconic. π
β¨ DESCRIPTION β¨
okay so listen bestie π β every menu and every menu item has a field that's justβ¦ sitting there, waiting for you to put application-specific data in it. and when I say yours, I mean yours, because the menu-driver code leaves it alone. it does not touch it. it does not look at it. it is not nosy. it's giving respectful. π
so like, if you want to stash a pointer to your own struct, or a string, or honestly whatever your heart desires β that field is where it goes. β¨
and these two functions? they get and set the menu user pointer field. that's the whole job. get it, set it, slay. π¦
heads up tho β the description says every menu and every menu item has this field. these particular functions are the menu ones, bestie. menu item user pointers live in their own manpage. iykyk. π
β¨ RETURN VALUE β¨
menu_userptrreturns a pointer (which may beNULLπ). and importantly β it does not seterrno. so don't go blamingerrnofor anything, it's innocent, it wasn't even there. πΈset_menu_userptrreturnsE_OKβ that's success, babe. it worked. periodt. β
β¨ PORTABILITY β¨
okay so the lore π: these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions. so if you're on some ancient BSD vibe, sorry bestie, no userptr for you. π
and here's the tea about the pointer type π« β the user pointer is a void pointer. they made a whole deliberate choice here: we chose not to leave it as a char pointer for SVr4 compatibility. so yeah, void *, on purpose, for the compatibility. not a typo, not a glow-up gone wrong, it's intentional. π
β¨ AUTHORS β¨
Juergen Pfeifer. π
Manual pages and adaptation for new curses by Eric S. Raymond. π
absolute legends, fr fr. give them their flowers. π
β¨ SEE ALSO β¨
ncurses(3NCURSES)βmenu(3MENU)π
go read those next, bestie, they're part of the same friend group.
and that's the whole page!! β¨ this was ncurses 6.6, dated 2024-12-28, and yeah it's literally the userptr(3MENU) page β thanks for reading, ily, go store some pointers responsibly π«Άππ
π¦ where this page comes from
- ubuntu resolute: ncurses-doc 6.6+20251231-1 Β· MIT/X11
- ubuntu stonking: ncurses-doc 6.6+20260608-2 Β· MIT/X11
- Copyright 2018-2023,2024 Thomas E. Dickey
- Copyright 1998-2010,2015 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms