DC_DEVICE_SET_CANCEL(3)

πŸ“¦ version 0.9.0, in nixos 26.05, nixpkgs unstable

πŸ’… dc_device_set_cancel β€” the little callback that asks "bestie, should we bail?" ✨

okay so real talk, this is a page from DC_DEVICE_SET_CANCEL(3) in the Library Functions Manual, and it lives in the library "libdivecomputer" β€” yes that's the LIBRARY situation, we'll get there 🫢


🌸 SYNOPSIS 🌸

like, here's the whole vibe in code form, no cap:

#include <libdivecomputer/device.h>

typedef int
(*dc_cancel_callback_t)(void *userdata);

dc_status_t
dc_device_set_cancel(dc_device_t *device, dc_cancel_callback_t callback,
    void *userdata);

πŸ¦‹ DESCRIPTION πŸ¦‹

So what you're doing here is handing over a function β€” like, your function β€” and the underlying device is gonna periodically call it to check if it should cancel its processing. That's the whole deal. It's literally a vibe check for your dive operation 😭

The callback returns zero if the operation should not be cancelled, and one if it should be cancelled. Binary. Iconic. Periodt. πŸ‘‘

Now, the callback usually checks a value that gets set during a signal handling callback. For example β€” and this is the cute part β€” you can invoke signal(3) to point at a function that sets a volatile sig_atomic_t value, and then your callback handler checks that value. chef's kiss, fr fr πŸ’–


⭐ RETURN VALUES ⭐

  • Returns DC_STATUS_UNSUPPORTED if the device is NULL πŸ™ˆ (like, bestie, you gotta give it an actual device)
  • DC_STATUS_SUCCESS otherwise πŸ’š

πŸŽ€ SEE ALSO πŸŽ€


πŸ‘‘ AUTHORS πŸ‘‘

The library "libdivecomputer" library was written by Jef Driesen, jef@libdivecomputer.org. These manpages were written by Kristaps Dzonsons, kristaps@bsd.lv. absolute legends, both of them, we stan 🌈


okay that's the whole page, mwah πŸ’‹ this lil writeup came from the Debian edition, dated January 5, 2017, and it's the DC_DEVICE_SET_CANCEL(3) manpage β€” go forth and cancel your processing responsibly, bestie πŸ§šπŸ’œ

πŸ“¦ where this page comes from