ZIP_REGISTER_CANCEL_CALLBACK_WITH_STATE(3)

πŸ“¦
version 1.11.4 Β· 2 versions
  • 1.11.4 Β· arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.10.1 Β· centos-stream 10
, in arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

zip_register_cancel_callback_with_state β€” bestie, this is the one that lets you cancel stuff while zip_close is doing its thing πŸ’…


πŸ“š LIBRARY

libzip β€” link it with -lzip πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <zip.h>

typedef int (*zip_cancel_callback)(zip_t *, void *);

void
zip_register_cancel_callback_with_state(zip_t *archive,
    zip_cancel_callback callback, void (*ud_free)(void *), void *ud);

πŸ’– DESCRIPTION πŸ’–

okay so, real talk: this function is your little emergency brake πŸ›‘. You use it to cancel writing of a zip archive while zip_close(3) is mid-grind.

The zip_register_cancel_callback_with_state() function registers a callback function, callback, for the zip archive archive. And the ud_free function? That one gets called during cleanup, for deleting the userdata you supplied in ud. So like… it handles the ✨aftercare✨. No leaks, no mess, iconic behavior honestly 🫢

Now the callback function itself gets called during zip_close(3) in regular intervals β€” specifically after every zip archive entry that's completely written to disk, and while writing data for entries β€” and it gets handed the zip archive archive and the user-provided user-data ud as arguments. The way that it works is: when the callback function returns a non-zero value, writing is cancelled and zip_close(3) returns an error. Periodt. πŸ’€

⚠️ Heads up bestie: the callback function should be fast, since it will be called often. Like, it's giving "quick vibe check," not "write me a whole novel." Don't be doing heavy stuff in there, fr fr 😭

πŸ‘€ SEE ALSO πŸ‘€


🌈 HISTORY 🌈

zip_register_cancel_callback_with_state() was added in libzip 1.6.0 β€” so it's a relatively fresh baddie, not an ancient relic πŸ’œ


πŸ‘‘ AUTHORS πŸ‘‘

The masterminds behind this whole thing:

  • Dieter Baron <dillo@nih.at>
  • Thomas Klausner <wiz@gatalith.at>

and that's the whole page, bestie πŸ’– this one came from the Debian crew, dated June, and it's the ZIP_REGISTER_CANCEL_CALLBACK_WITH_STATE(3) page β€” go forth and cancel responsibly πŸŽ€βœ¨