ZIP_GET_ARCHIVE_COMMENT(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_GET_ARCHIVE_COMMENT(3) ✨

okay bestie, gather round, we're reading the ZIP_GET_ARCHIVE_COMMENT(3) manual page together and honestly? it's giving helpful. it's in the Library Functions Manual, and it does exactly one thing but it does it so well.


πŸŽ€ NAME πŸŽ€

zip_get_archive_comment β€” get zip archive comment

no cap, that's the whole job. you want the comment? she has the comment. πŸ’…


πŸ“š LIBRARY πŸ“š

libzip (-lzip)

that's the library you're linking against, queen. link it or it doesn't exist. πŸ”—


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <zip.h>

const char *
zip_get_archive_comment(zip_t *archive, int *lenp, zip_flags_t flags);

look at that signature. three args. clean. iconic. the way that return type is a const char * and you are NOT allowed to touch it (more on that in a sec, i'm shaking).


πŸ’– DESCRIPTION πŸ’–

so, the zip_get_archive_comment() function returns the comment for the entire zip archive. yes, the whole archive, the main character comment, not a per-file one. πŸ—‚οΈ

the return value is in UTF-8 encoding unless ZIP_FL_ENC_RAW was specified (see below, bestie, we get there). ⚠️ and now the important part: this pointer should not be modified or free(3)'d, and it becomes invalid when archive is closed. like, do NOT free it. do NOT scribble on it. she is borrowed, not gifted. πŸ™ˆ

if lenp is not NULL, the integer to which it points will be set to the length of the comment. handy, right? ✨

if flags is set to ZIP_FL_UNCHANGED, the original unchanged comment is returned. the before picture, if you will. πŸ“Έ

additionally, the following flags are supported:

  • ZIP_FL_ENC_RAW β€” return the unmodified archive comment as it is in the ZIP archive. raw. unfiltered. no makeup. πŸͺž
  • ZIP_FL_ENC_GUESS β€” (Default.) guess the encoding of the archive comment in the ZIP archive and convert it to UTF-8, if necessary. (only CP-437 and UTF-8 are recognized, so like, those are the only two she speaks. sorry to the other encodings. 😭)
  • ZIP_FL_ENC_STRICT β€” follow the ZIP specification for file names and extend it to the archive comment, thus also expecting it in CP-437 encoding. convert it to UTF-8. she is a rule follower. πŸ‘‘
πŸ“ Note: ASCII is a subset of both CP-437 and UTF-8.

like, that note is lowkey the most important sentence here, iykyk. ASCII stays winning in both houses. 🌈


πŸ”₯ RETURN VALUES πŸ”₯

upon successful completion, a pointer to the comment is returned, or NULL if there is no comment.

that's it. that's the deal. pointer or NULL, no in-between, no grey area, she does not do ambiguity. πŸ’€


πŸ‘€ SEE ALSO πŸ‘€

libzip(3), zip_file_get_comment(3)

go read the friends too. zip_file_get_comment(3) is the per-file version in case you were wondering why the archive one was being so specific. 🫢


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

zip_get_archive_comment() was added in libzip 0.7. in libzip 0.11 the type of flags was changed from int to zip_flags_t.

glow up of the century honestly, int ➑️ zip_flags_t. we love a type-correct era. πŸ¦‹βœ¨


πŸ’œ AUTHORS πŸ’œ

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

the icons who built it. bow down. πŸ™‡β€β™€οΈ


and that's the whole page, bestie!! this was shipped as part of the Debian manual pages, dated September 22, 2020, under the name ZIP_GET_ARCHIVE_COMMENT(3). periodt. πŸ’…πŸŽ€βœ¨