annotate README.md @ 14:2d7c810a1ac2 default tip

*: misc. cleanup
author Paper <paper@paper.us.eu.org>
date Fri, 03 May 2024 22:40:28 -0400
parents 0cc2555db371
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
1 # libedl
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
2 libedl is a library for parsing Vegas Pro EDL files and translating them into usable C structures.
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
3
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
4 ## Build
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
5 ```console
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
6 $ autoreconf -i
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
7 $ mkdir build
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
8 $ cd build
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
9 $ ../configure
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
10 $ make
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
11 $ sudo make install
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
12 ```
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
13
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
14 ## Example
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
15 ```c
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
16 #include <stdio.h>
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
17 #include <stdlib.h>
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
18
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
19 #include <edl.h>
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
20
12
0cc2555db371 *: make our string functions not stupid
Paper <paper@paper.us.eu.org>
parents: 8
diff changeset
21 int file_get_contents(const char* f, char** contents, long* size) {
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
22 /* open the file */
12
0cc2555db371 *: make our string functions not stupid
Paper <paper@paper.us.eu.org>
parents: 8
diff changeset
23 FILE* file = fopen(f, "rb");
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
24 if (!file)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
25 return 1;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
26
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
27 /* get filesize */
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
28 fseek(file, 0L, SEEK_END);
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
29 *size = ftell(file);
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
30 fseek(file, 0L, SEEK_SET);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
32 /* grab the contents */
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
33 *contents = malloc(*size + 1);
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
34 if (!*contents)
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
35 return 1;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
36
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
37 /* hope and pray that `char` is 8-bit */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
38 fread(*contents, *size, 1, file);
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
39
12
0cc2555db371 *: make our string functions not stupid
Paper <paper@paper.us.eu.org>
parents: 8
diff changeset
40 (*contents)[*size] = '\0';
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
41
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
42 fclose(file);
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
43 }
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
44
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
45 int main(int argc, char** argv) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
46 char* data = NULL;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
47 long size = 0;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
48 EDL edl = {0};
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
49
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
50 if (argc != 2)
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
51 return 1;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
52
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
53 if (file_get_contents(argv[1], &data, &size))
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
54 return 1;
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
55
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
56 /* if you know the amount of lines beforehand,
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
57 * you can preallocate the memory for libedl to use */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
58 EDL_reallocate(&edl, 1024);
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
59
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
60 /* pass the file data to libedl
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
61 *
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
62 * it is also perfectly valid to use mmap() or
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
63 * variations of it (ex MapViewOfFile()) here... */
12
0cc2555db371 *: make our string functions not stupid
Paper <paper@paper.us.eu.org>
parents: 8
diff changeset
64 EDL_parse(&edl, data, size + 1);
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
65
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
66 /* dump the data to a valid EDL string */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
67 char* edl_str = EDL_dump(&edl);
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
68 printf("%s\n", edl_str);
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
69 free(edl_str);
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
70
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
71 /* free our used memory; libedl allocates on the heap */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 5
diff changeset
72 EDL_free(&edl);
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
73 free(data);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
74
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
75 return 0;
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
76 }
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
77 ```