00001 /* 00002 * Copyright (c) 2005, Condor Engineering, Inc. 00003 * All rights reserved. 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 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 3. Neither the name of the Company (Condor Engineering, Inc) nor the 00015 * names of its contributors may be used to endorse or promote products 00016 * derived from this software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00020 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00021 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00022 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00023 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00024 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00025 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00026 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00028 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 * 00030 */ 00031 00032 /* 00033 * Author: Gianluca Varenni <gianluca.varenni@gmail.com> 00034 */ 00035 00036 #ifndef __NTAR_09443049285795464587845827 00037 #define __NTAR_09443049285795464587845827 00038 00039 00045 #include <stdio.h> 00046 #include "block_headers.h" 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00102 #define NTAR_SUCCESS 0 00103 #define NTAR_FAILURE 1 00104 #define NTAR_FAILURE_INVALID_ID 2 00105 #define NTAR_FAILURE_FILENOTFOUND 3 00106 #define NTAR_FAILURE_FILEEXISTS 4 00107 #define NTAR_FAILURE_CREATEFILEFAILED 5 00108 #define NTAR_FAILURE_NOMEM 6 00109 #define NTAR_FAILURE_SECTIONNOTCLOSED 7 00110 #define NTAR_FAILURE_WRITEONREADFILE 8 00111 #define NTAR_FAILURE_IOWRITE 9 00112 #define NTAR_FAILURE_BLOCKNOTCLOSED 10 00113 #define NTAR_FAILURE_IOREAD 11 00114 #define NTAR_FAILURE_EOF 12 00115 #define NTAR_FAILURE_INVALIDFILE 13 00116 #define NTAR_FAILURE_MALFORMED_BLOCK 14 00117 #define NTAR_FAILURE_NOMOREBLOCKS 15 00118 #define NTAR_FAILURE_BLOCKDATAUNREAD 16 00119 #define NTAR_FAILURE_SMALLBUFFER 17 00120 #define NTAR_FAILURE_BLOCKDATANOTSET 18 00121 #define NTAR_FAILURE_DUPPTR 19 00122 #define NTAR_FAILURE_ASCIIDLFILE 20 00123 #define NTAR_FAILURE_BLOCKTRAILERMISMATCH 21 00124 #define NTAR_FAILURE_ACCESSDENIED 22 00125 #define NTAR_FAILURE_BADFILEDESCRIPTOR 23 00126 #define NTAR_FAILURE_INVALIDPARAMETER 24 00127 #define NTAR_FAILURE_TOOMANYOPENFILES 25 00128 #define NTAR_FAILURE_DISKFULL 26 00129 #define NTAR_FAILURE_UNKNOWNERRNO 27 00130 00138 #define NTAR_FILEMODE_WRITE 0 00139 #define NTAR_FILEMODE_READ 1 00140 #define NTAR_FILEMODE_CREATE 2 00141 #define NTAR_FILEMODE_APPEND 3 00142 00143 #define NTAR_OPEN_WRITE "w" 00144 #define NTAR_OPEN_READ "r" 00145 #define NTAR_OPEN_CREATE "c" 00146 #define NTAR_OPEN_APPEND "a" 00147 00148 00159 typedef struct _ntar_option 00160 { 00161 struct _ntar_option *next; 00162 u_int16 code; 00163 void *data; 00164 } 00165 ntar_option; 00166 00170 typedef struct _ntar_block_handle ntar_block_handle; 00171 00177 typedef struct _ntar_section_handle ntar_section_handle; 00178 00182 typedef struct _ntar_file_handle ntar_file_handle; 00183 00203 typedef int (*ntar_write_handler)(void *handle, void* buffer, size_t size); 00204 00228 typedef int (*ntar_read_handler)(void *handle, void* buffer, size_t size, size_t *read_bytes); 00229 00261 typedef int (*ntar_seek_handler)(void *handle, ntar_foff new_position, int origin, ntar_foff *pold_position); 00262 00270 typedef struct _ntar_file_handlers 00271 { 00272 ntar_read_handler read_handler; 00273 ntar_write_handler write_handler; 00274 00280 ntar_seek_handler seek_handler; 00281 00288 void *handle; 00289 } 00290 ntar_file_handlers; 00291 00300 /* NOTE: we include the plugins only here because the plugins need 00301 the definitions of all the ntar structures. If we include 00302 the header at the beginning of the file, the definition of 00303 _NTAR_H_xxxxxx will be already there, but the structures will 00304 not be declared, yet. 00305 */ 00306 #include "plugins.h" 00307 00322 int ntar_open(char* filename, char* flags, ntar_file_handle** pfile_handle); 00323 00344 int ntar_open_by_handlers(ntar_file_handlers file_handlers, char* flags, ntar_file_handle** pfile_handle); 00345 00354 int ntar_close(ntar_file_handle* file_handle); 00355 00366 int ntar_create_section(ntar_file_handle* file_handle, ntar_section_handle** psection_handle); 00367 00376 int ntar_close_section(ntar_section_handle* section_handle); 00377 00394 int ntar_add_section_option(ntar_section_handle* section_handle, ntar_option *option); 00395 00410 int ntar_create_block(ntar_section_handle* section_handle, u_int32 block_type, void *data, ntar_block_handle** pblock_handle); 00411 00419 int ntar_close_block(ntar_block_handle* block_handle); 00420 00434 int ntar_add_block_option(ntar_block_handle* block_handle, ntar_option *option); 00435 00447 int ntar_get_next_section(ntar_file_handle* file_handle, ntar_section_handle** psection_handle); 00448 00461 int ntar_get_previous_section(ntar_file_handle* file_handle, ntar_section_handle** psection_handle); 00462 00475 int ntar_get_section_options(ntar_section_handle* section_handle, ntar_option **options); 00476 00488 int ntar_get_next_block(ntar_section_handle* section_handle, ntar_block_handle** pblock_handle); 00489 00501 int ntar_get_previous_block(ntar_section_handle* section_handle, ntar_block_handle** pblock_handle); 00502 00511 int ntar_get_block_type(ntar_block_handle* block_handle, u_int32 *pblock_type); 00512 00524 int ntar_get_block_data(ntar_block_handle* block_handle, void** data); 00525 00537 int ntar_get_block_options(ntar_block_handle* block_handle, ntar_option **options); 00538 00580 int ntar_getversion(char* buffer, u_int32 *pbuffer_size); 00581 00582 #ifdef __cplusplus 00583 } 00584 #endif 00585 00586 00587 #endif /* __NTAR_09443049285795464587845827 */ 00588
NTAR documentation. Copyright (c) 2004 - 2005 Condor Engineering, Inc. All rights reserved.