The MASM Forum

Projects => Poasm => Pelle's C compiler and tools => Topic started by: Vortex on June 29, 2023, 08:56:12 PM

Title: microtar library
Post by: Vortex on June 29, 2023, 08:56:12 PM
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;
}