Blender V2.61 - r43446

readfile.h

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