Mercurial > libedl
view README.md @ 8:0c98b46eaf73 v2.0
*: update API to 2.0, big changes
all APIs now use pointers to an EDL object. it is up to the
user to make sure that the pointer is valid.
additionally, many things have been separated into new files
to make it easier to digest
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 03 Mar 2024 17:56:58 -0500 |
parents | a6ab6d9c0dac |
children | 0cc2555db371 |
line wrap: on
line source
# libedl libedl is a library for parsing Vegas Pro EDL files and translating them into usable C structures. ## Build ```console $ autoreconf -i $ mkdir build $ cd build $ ../configure $ make $ sudo make install ``` ## Example ```c #include <stdio.h> #include <stdlib.h> #include <edl.h> int file_get_contents(const char* file, char** contents, long* size) { /* open the file */ FILE* file = fopen(file, "rb"); if (!file) return 1; /* get filesize */ fseek(file, 0L, SEEK_END); *size = ftell(file); fseek(file, 0L, SEEK_SET); /* grab the contents */ *contents = malloc(*size + 1); if (!*contents) return 1; /* hope and pray that `char` is 8-bit */ fread(*contents, *size, 1, file); data[*size] = '\0'; fclose(file); } int main(int argc, char** argv) { char* data = NULL; long size = 0; EDL edl = {0}; if (argc != 2) return 1; if (file_get_contents(argv[1], &data, &size)) return 1; /* if you know the amount of lines beforehand, * you can preallocate the memory for libedl to use */ EDL_reallocate(&edl, 1024); /* pass the file data to libedl * * it is also perfectly valid to use mmap() or * variations of it (ex MapViewOfFile()) here... */ EDL_parse(&edl, data, fsize + 1); /* dump the data to a valid EDL string */ char* edl_str = EDL_dump(&edl); printf("%s\n", edl_str); free(edl_str); /* free our used memory; libedl allocates on the heap */ EDL_free(&edl); free(data); return 0; } ```