DC_DEVICE_SET_CANCEL(3)
π 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_UNSUPPORTEDif the device isNULLπ (like, bestie, you gotta give it an actual device) DC_STATUS_SUCCESSotherwise π
π SEE ALSO π
dc_device_open(3)β go read that one too, iykyk
π 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
- nixos 26.05: libdivecomputer 0.9.0
- nixpkgs unstable: libdivecomputer 0.9.0
- Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms