Blender  V2.59
readfile.h
Go to the documentation of this file.
00001 /*
00002  * $Id: readfile.h 36736 2011-05-18 06:27:32Z campbellbarton $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  * blenloader readfile private function prototypes
00029  */
00030 
00035 #ifndef READFILE_H
00036 #define READFILE_H
00037 
00038 #include "zlib.h"
00039 
00040 struct OldNewMap;
00041 struct MemFile;
00042 struct bheadsort;
00043 struct ReportList;
00044 
00045 typedef struct FileData {
00046         // linked list of BHeadN's
00047         ListBase listbase;
00048         int flags;
00049         int eof;
00050         int buffersize;
00051         int seek;
00052         int (*read)(struct FileData *filedata, void *buffer, unsigned int size);
00053 
00054         // variables needed for reading from memory / stream
00055         char *buffer;
00056         // variables needed for reading from memfile (undo)
00057         struct MemFile *memfile;
00058 
00059         // variables needed for reading from file
00060         int filedes;
00061         gzFile gzfiledes;
00062 
00063         // now only in use for library appending
00064         char relabase[FILE_MAXDIR+FILE_MAXFILE];
00065         
00066         // variables needed for reading from stream
00067         char headerdone;
00068         int inbuffer;
00069         
00070         // general reading variables
00071         struct SDNA *filesdna;
00072         struct SDNA *memsdna;
00073         char *compflags;
00074         
00075         int fileversion;
00076         int id_name_offs;               /* used to retrieve ID names from (bhead+1) */
00077         int globalf, fileflags; /* for do_versions patching */
00078         
00079         struct OldNewMap *datamap;
00080         struct OldNewMap *globmap;
00081         struct OldNewMap *libmap;
00082         struct OldNewMap *imamap;
00083         
00084         struct bheadsort *bheadmap;
00085         int tot_bheadmap;
00086         
00087         ListBase mainlist;
00088         
00089                 /* ick ick, used to return
00090                  * data through streamglue.
00091                  */
00092         BlendFileData **bfd_r;
00093         struct ReportList *reports;
00094 } FileData;
00095 
00096 typedef struct BHeadN {
00097         struct BHeadN *next, *prev;
00098         struct BHead bhead;
00099 } BHeadN;
00100 
00101 
00102 #define FD_FLAGS_SWITCH_ENDIAN             (1<<0)
00103 #define FD_FLAGS_FILE_POINTSIZE_IS_4       (1<<1)
00104 #define FD_FLAGS_POINTSIZE_DIFFERS         (1<<2)
00105 #define FD_FLAGS_FILE_OK                   (1<<3)
00106 #define FD_FLAGS_NOT_MY_BUFFER                     (1<<4)
00107 #define FD_FLAGS_NOT_MY_LIBMAP                     (1<<5)
00108 
00109 #define SIZEOFBLENDERHEADER 12
00110 
00111         /***/
00112 struct Main;
00113 void blo_join_main(ListBase *mainlist);
00114 void blo_split_main(ListBase *mainlist, struct Main *main);
00115 
00116 BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath);
00117 
00118 FileData *blo_openblenderfile(const char *filepath, struct ReportList *reports);
00119 FileData *blo_openblendermemory(void *buffer, int buffersize, struct ReportList *reports);
00120 FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports);
00121 
00122 void blo_clear_proxy_pointers_from_lib(Main *oldmain);
00123 void blo_make_image_pointer_map(FileData *fd, Main *oldmain);
00124 void blo_end_image_pointer_map(FileData *fd, Main *oldmain);
00125 void blo_add_library_pointer_map(ListBase *mainlist, FileData *fd);
00126 
00127 void blo_freefiledata( FileData *fd);
00128 
00129 BHead *blo_firstbhead(FileData *fd);
00130 BHead *blo_nextbhead(FileData *fd, BHead *thisblock);
00131 BHead *blo_prevbhead(FileData *fd, BHead *thisblock);
00132 
00133 char *bhead_id_name(FileData *fd, BHead *bhead);
00134 
00135 #endif
00136