libannodex  0.7.3
Reading from files and file descriptors

If the Annodex media you wish to access is directly available as a local file or via a file descriptor (such as a network socket), it can be directly opened as follows:

This procedure is illustrated in src/examples/print-title-file.c:

#include <stdio.h>
static int
read_head (ANNODEX * anx, const AnxHead * head, void * user_data)
{
puts (head->title);
return ANX_CONTINUE;
}
int
main (int argc, char *argv[])
{
ANNODEX * anx = NULL;
char * filename;
long n;
if (argc != 2) {
fprintf (stderr, "Usage: %s file.anx\n", argv[0]);
exit (1);
}
filename = argv[1];
anx = anx_open (filename, ANX_READ);
anx_set_read_head_callback (anx, read_head, NULL);
while ((n = anx_read (anx, 1024)) > 0);
anx_close (anx);
exit (0);
}
annodex.h
_AnxHead
Definition: anx_types.h:87
anx_set_read_head_callback
int anx_set_read_head_callback(ANNODEX *annodex, AnxReadHead read_head, void *user_data)
Set the function to call when the head element is read.
ANNODEX
void ANNODEX
An ANNODEX handle.
Definition: anx_types.h:55
_AnxHead::title
const char * title
title element of header
Definition: anx_types.h:92
anx_open
ANNODEX * anx_open(char *filename, int mode)
Open a file containing Annodex media.
anx_read
long anx_read(ANNODEX *annodex, long n)
Read from an annodex opened with anx_open() or anx_open_stdio().
anx_close
ANNODEX * anx_close(ANNODEX *annodex)
Close an annodex.