Sometimes it is not possible to provide a file descriptor for a data source; for example, if the data is extracted from a high level library. In this case, you must directly input the data to libannodex using memory buffers as follows:
- open an annodex using anx_new()
- attach read callbacks using anx_set_read_*_callback()
- call anx_reader_input() repeatedly until it returns 0 or -1
- close the annodex with anx_close()
This procedure is illustrated in src/examples/print-title-memory.c:
#include <stdio.h>
static int
{
return ANX_CONTINUE;
}
int
main (int argc, char *argv[])
{
unsigned char buf[1024];
long n = 1024;
while (n > 0) {
n = fread (buf, 1, 1024, stdin);
}
exit (0);
}
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.
long anx_read_input(ANNODEX *annodex, unsigned char *buf, long n)
Input data from a memory buffer into an annodex.