ZIP_SOURCE_SEEK_COMPUTE_OFFSET(3)

πŸ“¦
version 1.11.4 Β· 3 versions
, in arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ ZIP_SOURCE_SEEK_COMPUTE_OFFSET ✨

okay so bestie, welcome to libzip's little helper function, aka the vibe-checker for seek math πŸ’… this page lives in section 3 of the manual (library functions, iykyk) and it's about validating arguments and computing an offset. that's it. that's the whole job. and she does it flawlessly. πŸŽ€

Also she lives in libzip β€” you link against her with -lzip. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <zip.h>

zip_int64_t
zip_source_seek_compute_offset(zip_uint64_t offset, zip_uint64_t length,
    void *data, zip_uint64_t data_length, zip_error_t *error);

that's the whole signature, no cap. five arguments, one zip_int64_t coming back at you. πŸ’–


✨ DESCRIPTION ✨

okay so here's the tea β˜• β€” you use this function to compute the offset for a ZIP_SOURCE_SEEK or a ZIP_SOURCE_SEEK_WRITE command. like, that's literally her whole purpose in life and honestly? iconic. πŸ‘‘

let's break down the cast of characters:

  • data and data_length are the arguments to the source callback. so like, the raw stuff your callback got handed. 🫢
  • offset is the current offset. where you're at right now, bestie.
  • length is the length of the source data β€” OR, if you're doing ZIP_SOURCE_SEEK_WRITE, it's the amount of data written. two moods, one parameter. she contains multitudes. πŸ’œ

🌈 RETURN VALUES 🌈

  • on success? she returns the new offset. slay. ✨
  • on error? she returns -1 and sets error. 😭 not the glow-down but okay, at least she tells you what went wrong.

πŸ’€ ERRORS πŸ’€

zip_source_seek_compute_offset() fails if:

  • [ZIP_ER_INVAL] β€” one of the arguments is invalid, OR the seek would place the offset outside the data. basically: bad input, or you tried to seek somewhere that doesn't exist. the audacity. πŸ™ˆ

πŸ‘€ SEE ALSO πŸ‘€

go read that one too, bestie, they're a package deal. πŸŽ€


πŸ•°οΈ HISTORY πŸ•°οΈ

zip_source_seek_compute_offset() was added in libzip 1.0. a true original. a founding mother. πŸ‘‘


🫢 AUTHORS 🫢

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

we stan both of them fr fr. πŸ’–


heads up bestie: this page came from Debian, dated December 18. that's the source and the date, so now you know where she came from. πŸ¦‹ mwah, go compute some offsets, you've got this. πŸ’…βœ¨