ntar_int.h

Go to the documentation of this file.
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_INT_H_2233343443h4h4437y3y4
00037 #define __NTAR_INT_H_2233343443h4h4437y3y4
00038 
00039 #include "ntar.h"
00040 
00041 #include "ntar_debug.h"
00042 
00043 #include <errno.h>
00044 #include <stdio.h>
00045 #include <string.h>
00046 #include <malloc.h>
00047 #ifdef WIN32
00048 #include <io.h>
00049 #endif
00050 
00051 #include <fcntl.h>
00052 
00053 
00054 #ifndef WIN32
00055 #define stricmp strcasecmp
00056 #endif
00057 
00058 struct _ntar_file_handle;       /* Forward structure declaration to make the compiler happy. */
00059 struct _ntar_section_handle;    /* Forward structure declaration to make the compiler happy. */
00060 struct _ntar_plugin_data;       /* Forward structure declaration to make the compiler happy. */
00061 
00066 typedef struct _ntar_read_iterator
00067 {
00068 #define NTAR_POS_NOT_DEFINED    ((ntar_foff)(-1))    
00069 #define NTAR_BEGINNING_OF_FILE  ((ntar_foff)0)          
00070     ntar_foff  prev_pos;                   
00071     ntar_foff  curr_pos;                   
00072     ntar_foff  next_pos;                   
00073 }
00074     ntar_read_iterator;
00075 
00079 struct _ntar_block_handle
00080 {
00083     ntar_file_handlers file_handlers;
00084 
00091     int byte_order;             
00092 
00095     ntar_foff block_start; 
00096     
00099     struct _ntar_section_handle *section_handle;    
00100     
00103     void *plugin_state;        
00104     
00105     ntar_option *options;    
00106     
00109     struct _ntar_plugin_data *plugin_data;  
00110     
00114     block_header bh;                
00115 
00119     int are_block_data_read;
00120 
00123     char* options_buffer;
00124 
00127     size_t  options_buffer_length;
00128 
00131     size_t  data_buffer_length;
00132 
00135     char* data_buffer;
00136 
00137     void *block_data;
00138     void *raw_data_buffer;
00139     size_t raw_data_buffer_length;
00140     size_t raw_data_buffer_start_options;
00141 };
00142 
00148 struct _ntar_section_handle
00149 {
00152     ntar_file_handlers file_handlers;
00153     
00156     ntar_foff block_start; 
00157     
00161     block_header bh;
00162 
00166     section_header_block shb;
00167 
00171     ntar_option *options;
00172 
00175     struct _ntar_file_handle *file_handle;  
00176 
00183     int byte_order;             
00184     
00187     ntar_block_handle cache_block;   
00188 
00191     int block_opened;
00192 
00196     int header_written;   
00197     
00201     u_int32 shb_header_length;      
00202     
00205     ntar_read_iterator read_iterator;
00206 
00209     char* options_buffer;
00210 
00213     size_t  options_buffer_length;
00214     
00215     char* raw_options_buffer;
00216 
00217     size_t raw_options_buffer_length;
00218 
00219     int reached_end_of_section;
00220 
00221 };
00222 
00226 struct _ntar_file_handle
00227 {
00234     int file_mode;
00235 
00236     int using_internal_handlers;
00237 
00240     ntar_file_handlers file_handlers;
00241 
00244     ntar_section_handle cache_section;   
00245     
00248     int section_opened;
00249 
00252     ntar_read_iterator read_iterator;
00253 
00254     block_header last_bh;
00255 };
00256 
00257 
00274 int reallocate_memory(void **buffer, size_t *buffer_size, size_t new_size);
00275 
00290 int ntar_convert_errno(int local_errno);
00291 
00292 
00293 int ntar_native_file_write(void *handle, void* buffer, size_t size);
00294 int ntar_native_file_read(void *handle, void* buffer, size_t size, size_t *read_bytes);
00295 int ntar_native_file_seek(void *handle, ntar_foff new_position, int origin, ntar_foff *old_position);
00296 int ntar_native_file_close(ntar_file_handlers file_handlers);
00297 int ntar_native_file_open(char *filename, char *flags, ntar_file_handlers *file_handlers);
00298 
00299 
00300 
00304 #endif /*__NTAR_INT_H_2233343443h4h4437y3y4*/

NTAR documentation. Copyright (c) 2004 - 2005 Condor Engineering, Inc. All rights reserved.