npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

microtar.c

v0.1.0

Published

A lightweight tar library written in ANSI C; rxi (2016).

Readme

microtar

A lightweight tar library written in ANSI C, by rxi.

Installation

Run:

$ npm i microtar.c

And then include microtar.h as follows:

#include "node_modules/microtar.c/src/microtar.h"

You may also want to include microtar.c as follows:

#ifndef __MICROTAR_C__
#define __MICROTAR_C__
#include "node_modules/microtar.c/src/microtar.c"
#endif

This will include both the function declaration and their definitions into a single file.

Basic Usage

The library consists of microtar.c and microtar.h. These two files can be included in an existing project and compiled along with it.

Reading

mtar_t tar;
mtar_header_t h;
char *p;

/* Open archive for reading */
mtar_open(&tar, "test.tar", "r");

/* Print all file names and sizes */
while ( (mtar_read_header(&tar, &h)) != MTAR_ENULLRECORD ) {
  printf("%s (%d bytes)\n", h.name, h.size);
  mtar_next(&tar);
}

/* Load and print contents of file "test.txt" */
mtar_find(&tar, "test.txt", &h);
p = calloc(1, h.size + 1);
mtar_read_data(&tar, p, h.size);
printf("%s", p);
free(p);

/* Close archive */
mtar_close(&tar);

Writing

mtar_t tar;
const char *str1 = "Hello world";
const char *str2 = "Goodbye world";

/* Open archive for writing */
mtar_open(&tar, "test.tar", "w");

/* Write strings to files `test1.txt` and `test2.txt` */
mtar_write_file_header(&tar, "test1.txt", strlen(str1));
mtar_write_data(&tar, str1, strlen(str1));
mtar_write_file_header(&tar, "test2.txt", strlen(str2));
mtar_write_data(&tar, str2, strlen(str2));

/* Finalize -- this needs to be the last thing done before closing */
mtar_finalize(&tar);

/* Close archive */
mtar_close(&tar);

Error handling

All functions which return an int will return MTAR_ESUCCESS if the operation is successful. If an error occurs an error value less-than-zero will be returned; this value can be passed to the function mtar_strerror() to get its corresponding error string.

Wrapping a stream

If you want to read or write from something other than a file, the mtar_t struct can be manually initialized with your own callback functions and a stream pointer.

All callback functions are passed a pointer to the mtar_t struct as their first argument. They should return MTAR_ESUCCESS if the operation succeeds without an error, or an integer below zero if an error occurs.

After the stream field has been set, all required callbacks have been set and all unused fields have been zeroset the mtar_t struct can be safely used with the microtar functions. mtar_open should not be called if the mtar_t struct was initialized manually.

Reading

The following callbacks should be set for reading an archive from a stream:

Name | Arguments | Description --------|------------------------------------------|--------------------------- read | mtar_t *tar, void *data, unsigned size | Read data from the stream seek | mtar_t *tar, unsigned pos | Set the position indicator close | mtar_t *tar | Close the stream

Writing

The following callbacks should be set for writing an archive to a stream:

Name | Arguments | Description --------|------------------------------------------------|--------------------- write | mtar_t *tar, const void *data, unsigned size | Write data to the stream

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.

ORG