This procedure is illustrated in src/examples/print-title-memory.c:
/* Copyright (C) 2003 Commonwealth Scientific and Industrial Research Organisation (CSIRO) Australia Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of CSIRO Australia nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> #include <annodex/annodex.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; unsigned char buf[1024]; long n = 1024; anx = anx_new (ANX_READ); anx_set_read_head_callback (anx, read_head, NULL); while (n > 0) { /* Fill a memory buffer */ n = fread (buf, 1, 1024, stdin); /* Input that memory buffer into the annodex */ n = anx_read_input (anx, buf, n); } anx_close (anx); exit (0); }
00001 /* 00002 Copyright (C) 2003 Commonwealth Scientific and Industrial Research 00003 Organisation (CSIRO) Australia 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions 00007 are met: 00008 00009 - Redistributions of source code must retain the above copyright 00010 notice, this list of conditions and the following disclaimer. 00011 00012 - Redistributions in binary form must reproduce the above copyright 00013 notice, this list of conditions and the following disclaimer in the 00014 documentation and/or other materials provided with the distribution. 00015 00016 - Neither the name of CSIRO Australia nor the names of its 00017 contributors may be used to endorse or promote products derived from 00018 this software without specific prior written permission. 00019 00020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00023 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR 00024 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00026 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 */ 00032 00033 #include <stdio.h> 00034 #include <annodex/annodex.h> 00035 00036 static int 00037 read_head (ANNODEX * anx, const AnxHead * head, void * user_data) 00038 { 00039 puts (head->title); 00040 return ANX_CONTINUE; 00041 } 00042 00043 int 00044 main (int argc, char *argv[]) 00045 { 00046 ANNODEX * anx = NULL; 00047 unsigned char buf[1024]; 00048 long n = 1024; 00049 00050 anx = anx_new (ANX_READ); 00051 00052 anx_set_read_head_callback (anx, read_head, NULL); 00053 00054 while (n > 0) { 00055 /* Fill a memory buffer */ 00056 n = fread (buf, 1, 1024, stdin); 00057 00058 /* Input that memory buffer into the annodex */ 00059 n = anx_read_input (anx, buf, n); 00060 } 00061 00062 anx_close (anx); 00063 00064 exit (0); 00065 }