{"id":13750667,"url":"https://github.com/jbreeden/mruby-zlib","last_synced_at":"2025-05-09T16:31:30.718Z","repository":{"id":71330778,"uuid":"51262304","full_name":"jbreeden/mruby-zlib","owner":"jbreeden","description":"ZLib bindings for MRuby","archived":false,"fork":false,"pushed_at":"2018-10-28T23:22:27.000Z","size":88,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-03T08:02:35.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbreeden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-07T19:34:10.000Z","updated_at":"2018-07-20T00:42:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e86720d-1943-45fe-b269-edc990e03bcb","html_url":"https://github.com/jbreeden/mruby-zlib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbreeden%2Fmruby-zlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbreeden%2Fmruby-zlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbreeden%2Fmruby-zlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbreeden%2Fmruby-zlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbreeden","download_url":"https://codeload.github.com/jbreeden/mruby-zlib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224869032,"owners_count":17383306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T08:00:43.897Z","updated_at":"2024-11-16T02:31:29.051Z","avatar_url":"https://github.com/jbreeden.png","language":"C","readme":"\nmruby-zlib\n----------\n\nBindings to ZLib for MRuby.\n\nUsage\n-----\n\n\n### `compress` \u0026 `uncompress`\n\n`compress` \u0026 `uncompress` provide a simple API for bulk compression. `compress`\nproduces a deflate stream wrapped in a zlib header, and `uncompress` reverses\nthat action.\n\nExample:\n\n```Ruby\nsrc = 'test' * 10\n# =\u003e \"testtesttesttesttesttesttesttesttesttest\"\n\nsrc.length\n# =\u003e 40\n\ncompressed = ZLib.compress(src)\n# =\u003e \"x\\234+I-.)!\\002\\003\\000f\\261\\021\\201\"\n\ncompressed.length\n# =\u003e 15\n\nZLib.uncompress(src.length, compressed)\n# =\u003e \"testtesttesttesttesttesttesttesttesttest\"\n```\n\n- `ZLib.compress(src)`\n  + Compresses `src` with default settings \u0026 returns the compressed result.\n  + Returns a deflate stream wrapped in a zlib header/footer\n\n- `ZLib.uncompress(max_size, src)`\n  + Uncompresses the src string (i.e. reverses `ZLib.compress`)\n  + Raises a `ZLib::ZDataError` if src is not in the zlib format\n  + Raises a `ZLib::ZBufferError` if `max_size` is not \u003e= the size of the uncompressed data\n  + Raises a `ZLib::ZDataError` if the input string is incomplete\n\n### `inflate` \u0026 `deflate`\n\nThese functions provide a streaming interface for zlib \u0026 gzip compression.\n\nExample:\n\n```Ruby\nsrc = \"example\" * 100\n\nstream = ZLib::ZStream.new\nZLib.deflateInit(stream)\nstream.next_in = src\ncompressed = ZLib.deflate(stream, ZLib::Z_FINISH)\n# =\u003e \"x\\234K\\255H\\314-\\310IM\\035\\245F\\251\\241F\\001\\000)h$@\"\n\ncompressed.length\n# =\u003e 22\n\nstream = ZLib::ZStream.new\nZLib.inflateInit(stream)\nstream.next_in = compressed\nZLib.inflate(stream, ZLib::Z_FINISH)\n# =\u003e \"exampleexampleexampleexampleexampleexampleexampleexampleexampleexample...\n```\n\n- `ZLib::deflateInit(stream, level = ZLib::Z_DEFAULT_COMPRESSION)`\n  + Initalizes a stream to deflate at the given `level`\n  + `level` defaults to 6 (ZLib::Z_DEFAULT_COMPRESSION)\n  + Raises a `ZLib::ZStreamError` if called on a previously initialized stream\n\n- `ZLib.deflate(stream, flush)`\n  + Deflates all of `stream.next_in`, possibly returning a chunk of the compressed output\n  + Will process the remaining input and return all output if `flush` is `ZLib::Z_FINISH`\n  + Raises a ZBufferError if `Z_FINISH` is used twice\n  + Raises a `ZLib::ZStreamError` if used on a stream that has been finished already\n\n- `ZLib::inflateInit(stream)`\n  + Initalizes a stream to inflate data\n  + Raises a `ZLib::ZStreamError` if called on a previously initialized stream\n\n- `ZLib.inflate(stream, flush)`\n  + Inflates `str`, possibly returning a chunk of the uncompressed output\n  + Returns the empty string if the stream has already been finished (TODO: should probably raise)\n  + Will process the remaining input and return all output if `flush` is `ZLib::Z_FINISH`\n\n- `ZLib.inflateEnd(stream)` \u0026\u0026 `ZLib.deflateEnd(stream)`\n  + Are used to cleanup native resources of the stream\n  + Called automatically by the MRuby GC when the stream is freed\n  + Raise a `ZLib::ZStreamError` if the stream already ended, or is of the wrong type\n\n### `GZFile` APIs\n\nThese functions provide IO for GZip files similar to C's stdlib `fopen`, `fread`, `fwrite`, etc.\n\n- `ZLib.gzopen(filename, mode)`\n  + Returns a `ZLib::GZFile` based on the given `filename` \u0026 `mode` string\n  + Open semantics are like C's `fopen` (\"w\" create a file if it doesn't exist, etc.)\n  + Returns `nil` if trying to read a file that doesn't exist\n\n- `ZLib.gzwrite(file, str)`\n  + Compresses `str`, then writes it to `file` (a `ZLib::GZFile`)\n\n- `ZLib::gzread(file, size)`\n  + Reads up to `size` uncompressed bytes from the compressed GZFile `file`\n\n- `ZLib.gzflush(file, flush)`\n  + Flushes the given file according to the `flush` argument\n  + `flush` should be one of `ZLib::Z_NO_FLUSH`, `ZLib::Z_PARTIAL_FLUSH`,\n    `ZLib::Z_SYNC_FLUSH`, `ZLib::Z_FULL_FLUSH`, or `ZLib::Z_FINISH`\n  + Should be called on `GZFile`s when finished, to ensure the gz file has the proper footer\n\n- `ZLib.gzclose(file)`\n  + Closes the given GZFile `file`\n  + Is called automatically when the file is GC'ed, but you may still call it sooner\n  + After a file is closed, any attempt to use it will raise a `ZLib::ZIOError`\n\n_The following functions marked [SKIPPED] are implemented already, but lacking automated tests._\n\n- `ZLib.gzsetparams(file, level, strategy)`\n  + [SKIPPED] Dynamically update the compression level or strategy\n\n- `ZLib.gztell(file)`\n  + [SKIPPED] Tells the currect seek position\n\n- `ZLib.gzrewind(file)`\n  + [SKIPPED] Seek to the begining of the file\n\n- `ZLib.gzseek(file, offset, whence)`\n  + [SKIPPED] Set the location for the next read/write\n\n- `ZLib.gzputs(file, string)`\n  + [SKIPPED] Writes the `string` param (which must not contain null characters) to the file\n\n- `ZLib.gzputc(file, char)` (char should be an int as in `'a'.ord`)\n  + [SKIPPED] Writes a character\n\n- `ZLib.gzungetc(char, file)` (char should be an int as in `'a'.ord`)\n  + [SKIPPED] Ungets a character\n\n- `ZLib.gzbuffer(file, size)`\n  + [SKIPPED] Set the internal buffer size used by this library's functions\n\n- `ZLib.gzclearerr(file)`\n  + [SKIPPED] Clears the error and end-of-file flags for file\n\n- `ZLib.gzdirect(file)`\n  + [SKIPPED] Returns true if file is being copied directly while reading, or false if file is a gzip stream being decompressed\n\n- `ZLib.gzdopen(fd, mode)`\n  + [SKIPPED] gzdopen associates a gzFile * with the file descriptor fd.\n\n- `ZLib.gzeof(file)`\n  + [SKIPPED] Returns true if the file is at eof, or else false\n\n- `ZLib.gzerror(file)`\n  + [SKIPPED] Returns the error message for the last error which occurred on the given compressed file\n\n- `ZLib.gzgetc`\n  + [SKIPPED] Reads one byte from the compressed file.\n  + [SKIPPED] Returns the byte (as an int) or -1 in case of end of file or error.\n\n- `ZLib.gzoffset`\n  + [SKIPPED] Returns the current offset in the file being read or written\n  + [SKIPPED] When reading, the offset does not include as yet unused buffered input\n  + [SKIPPED] This information can be used for a progress indicator\n\n- `ZLib.gzgets(file)`\n  + [SKIPPED] Reads until a newline or eof\n\n\nSUCCESS [0 failed, 19 skipped, 51 total]\n","funding_links":[],"categories":["System"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbreeden%2Fmruby-zlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbreeden%2Fmruby-zlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbreeden%2Fmruby-zlib/lists"}