ole.h

Go to the documentation of this file.
00001 
00002 #ifndef LIBOLE
00003 #define LIBOLE
00004 
00005 #define LIBOLE_VERSION "200512112226"
00006 
00007 #define OLE_OK 0
00008 #define OLEER_NO_INPUT_FILE 100
00009 #define OLEER_BAD_INPUT_FILE 101
00010 #define OLEER_NOT_OLE_FILE 102
00011 #define OLEER_INSANE_OLE_FILE 103
00012 
00013 #define OLEER_DECODE_NULL_OBJECT                                        10
00014 #define OLEER_DECODE_NULL_FILENAME                              11
00015 #define OLEER_DECODE_NULL_PATH                                  12
00016 
00017 #define OLEER_LOADFAT_BAD_BOUNDARY                              20
00018 
00019 #define OLEER_MINIFAT_READ_FAIL                                 30
00020 #define OLEER_PROPERTIES_READ_FAIL                              31
00021 #define OLEER_MINISTREAM_READ_FAIL                              32
00022 #define OLEER_MINISTREAM_STREAM_READ_FAIL    33
00023 #define OLEER_NORMALSTREAM_STREAM_READ_FAIL  34
00024 
00025 #define OLEER_GET_BLOCK_SEEK                                            41
00026 #define OLEER_GET_BLOCK_READ                                            42
00027 
00028 #define OLEER_MEMORY_OVERFLOW                                           50
00029 
00030 #define OLE_VERBOSE_NORMAL 1
00031 #define OLE_VERBOSE_FATREAD 2
00032 #define OLE_VERBOSE_DIRREAD 4
00033 #define OLE_VERBOSE_STREAMREAD 8
00034 #define OLE_VERBOSE_STREAMDECODE 16
00035 
00036 #define OLE_VNORMAL(x) ((x) && OLE_VERBOSE_NORMAL == OLE_VERBOSE_NORMAL )
00037 
00038 #define OLE_DEBUG_NORMAL 1
00039 #define OLE_DEBUG_PEDANTIC 2
00040 
00041 #define OLE_DNORMAL(x) ((x) && OLE_DEBUG_NORMAL == OLE_DEBUG_NORMAL)
00042 #define OLE_DPEDANTIC(x) ((x) && OLE_DEBUG_PEDANTIC == OLE_DEBUG_PEDANTIC)
00043 
00044 
00045 #define OLE_HEADER_FAT_SECTOR_COUNT_LIMIT 109
00046 struct OLE_header {
00047                 unsigned int minor_version;
00048                 unsigned int dll_version;
00049                 unsigned int byte_order;
00050                 unsigned int sector_shift;
00051                 unsigned int sector_size;
00052                 unsigned int mini_sector_shift;
00053                 unsigned int mini_sector_size;
00054                 unsigned int fat_sector_count;
00055                 unsigned int directory_stream_start_sector;
00056                 unsigned int mini_cutoff_size;
00057                 unsigned int mini_fat_start;
00058                 unsigned int mini_fat_sector_count;
00059                 unsigned int dif_start_sector;
00060                 unsigned int dif_sector_count;
00061                 unsigned int FAT[OLE_HEADER_FAT_SECTOR_COUNT_LIMIT];
00062 };
00063 
00064 #define OLE_DIRECTORY_ELEMENT_NAME_SIZE 64
00065 #define OLE_DIRECTORY_CLASS_SIZE 16
00066 #define OLE_DIRECTORY_TIMESTAMPS_SIZE 16
00067 struct OLE_directory_entry {
00068         char element_name[OLE_DIRECTORY_ELEMENT_NAME_SIZE];
00069         int element_name_byte_count;
00070 
00071         char element_type;
00072         char element_colour;
00073 
00074         unsigned int left_child;
00075         unsigned int right_child;
00076         unsigned int root;
00077 
00078         unsigned char class[OLE_DIRECTORY_CLASS_SIZE];
00079         unsigned int userflags;
00080         unsigned char timestamps[OLE_DIRECTORY_TIMESTAMPS_SIZE];
00081         unsigned int start_sector;
00082         unsigned int stream_size;
00083 };
00084 
00085 
00086         
00087 #define OLE_HEADER_BLOCK_SIZE 512
00088 struct OLE_object {
00089 
00090         int error;
00091         size_t file_size;
00092         int last_sector;
00093         size_t last_chain_size;
00094 
00095         FILE *f;
00096         unsigned char *FAT;
00097         unsigned char *FAT_limit; 
00098         unsigned char *miniFAT;
00099         unsigned char *miniFAT_limit; 
00100         unsigned char header_block[OLE_HEADER_BLOCK_SIZE];
00101         unsigned char *ministream;
00102         unsigned char *properties;
00103 
00104         struct OLE_header header;
00105         
00106   /* End user configurable parameters:*/
00107         int debug;
00108         int verbose;
00109         int quiet;
00110         int save_unknown_streams;
00111         
00112         int save_streams;
00113         int save_mini_streams;
00114         int save_normal_streams;
00115 
00116         int decode_streams;
00117         int decode_mini_streams;
00118         int decode_normal_streams;
00119 
00120         int (*filename_report_fn)(char *);
00121 
00122 };
00123 
00124 
00125 
00126 /* Prototypes*/
00127 
00128 int OLE_version( void );
00129 
00130 int OLE_init( struct OLE_object *ole );
00131 int OLE_set_verbose( struct OLE_object *ole, int level );
00132 int OLE_set_debug( struct OLE_object *ole, int level );
00133 int OLE_set_quiet( struct OLE_object *ole, int level );
00134 int OLE_set_save_unknown_streams( struct OLE_object  *ole, int level );
00135 
00136 int OLE_get_block( struct OLE_object *ole, int block_index, unsigned char *block_buffer );
00137 int OLE_get_miniblock( struct OLE_object *ole, int block_index, unsigned char *block_buffer );
00138 int OLE_dbstosbs( char *raw_string, size_t char_count, char *clean_string, int clean_string_len );
00139 int OLE_print_string( char *string, size_t char_count);
00140 int OLE_print_sector( struct OLE_object *ole, char *sector, unsigned int bytes);
00141 int OLE_get_header( struct OLE_object *ole );
00142 int OLE_convert_header( struct OLE_object *ole );
00143 int OLE_print_header( struct OLE_object *ole );
00144 int OLE_convert_directory(struct OLE_object *ole, unsigned char *buf, struct OLE_directory_entry *dir );
00145 int OLE_print_directory( struct OLE_object *ole, struct OLE_directory_entry *dir );
00146 int OLE_load_FAT( struct OLE_object *ole );
00147 int OLE_follow_chain( struct OLE_object *ole, int FAT_sector_start );
00148 int OLE_follow_minichain( struct OLE_object *ole, int miniFAT_sector_start );
00149 unsigned char *OLE_load_minichain( struct OLE_object *ole, int miniFAT_sector_start );
00150 unsigned char *OLE_load_chain( struct OLE_object *ole, int FAT_sector_start );
00151 int OLE_open_file( struct OLE_object *ole, char *fullpath );
00152 int OLE_decode_file( struct OLE_object *ole, char *fname, char *decode_path );
00153 int OLE_decode_file_done( struct OLE_object *ole );
00154 
00155 int OLE_dir_init(struct OLE_directory_entry *dir );
00156 int OLE_sectorpos( struct OLE_object *ole, int SID );
00157 int OLE_is_file_OLE( struct OLE_object *ole );
00158 int OLE_open_directory( struct OLE_object *ole, char *directory );
00159 int OLE_store_stream( struct OLE_object *ole, char *stream_name, char *directory, char *stream, size_t stream_size );
00160 int OLE_terminate_and_return( struct OLE_object *ole, int result );
00161 int OLE_decode_stream( struct OLE_object *ole,  struct OLE_directory_entry *adir, char *decode_path );
00162 
00163 
00164 /* Our callbacks.*/
00165 int OLE_set_filename_report_fn( struct OLE_object *ole, int (*ptr_to_fn)(char *) );
00166 
00167 #endif

Generated on Sun Mar 4 15:03:49 2007 for Scilab [trunk] by  doxygen 1.5.1