News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

microtar library

Started by Vortex, June 29, 2023, 12:59:09 PM

Previous topic - Next topic

Vortex

Hello,

Project adapted to Pelles C Version 12 :

QuoteA lightweight tar library written in ANSI C

https://github.com/rxi/microtar

Example code from the GitHub repository :

#include <stdio.h>
#include "microtar.h"

int main(void)
{
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);
return 0;
}
Code it... That's all...

cosh

Thank you for providing such a great library.
:)
This library is so good and simple. I like it.

Vortex

Hi cosh,

Thanks for your feedback. The real provider is the author of the original code, rxi

All what I did are some minor modiicafions to compile the code with Pelles C.
Code it... That's all...

John Z

Hi Vortex,

Another nice contribution!  Thanks.  I don't use the tar format for anything but nice to have options for Pelles C libraries.  Sometimes minor mods are the hardest  :)

John Z