2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17 * All rights reserved.
18 * blenloader readfile private function prototypes
25 #ifndef __READFILE_H__
26 #define __READFILE_H__
28 #include "DNA_sdna_types.h"
29 #include "DNA_space_types.h"
30 #include "DNA_windowmanager_types.h" /* for ReportType */
43 typedef struct IDNameLib_Map IDNameLib_Map;
46 FD_FLAGS_SWITCH_ENDIAN = 1 << 0,
47 FD_FLAGS_FILE_POINTSIZE_IS_4 = 1 << 1,
48 FD_FLAGS_POINTSIZE_DIFFERS = 1 << 2,
49 FD_FLAGS_FILE_OK = 1 << 3,
50 FD_FLAGS_NOT_MY_BUFFER = 1 << 4,
51 /* XXX Unused in practice (checked once but never set). */
52 FD_FLAGS_NOT_MY_LIBMAP = 1 << 5,
55 /* Disallow since it's 32bit on ms-windows. */
57 # pragma GCC poison off_t
60 #if defined(_MSC_VER) || defined(__APPLE__) || defined(__HAIKU__) || defined(__NetBSD__)
61 typedef int64_t off64_t;
64 typedef int(FileDataReadFn)(struct FileData *filedata,
67 bool *r_is_memchunk_identical);
68 typedef off64_t(FileDataSeekFn)(struct FileData *filedata, off64_t offset, int whence);
70 typedef struct FileData {
71 /** Linked list of BHeadN's. */
73 enum eFileDataFlag flags;
81 /** Regular file reading. */
84 /** Variables needed for reading from memory / stream. */
86 /** Variables needed for reading from memfile (undo). */
87 struct MemFile *memfile;
88 /** Whether we are undoing (< 0) or redoing (> 0), used to choose which 'unchanged' flag to use
89 * to detect unchanged data from memfile. */
92 /** Variables needed for reading from file. */
94 /** Gzip stream for memory decompression. */
97 /** Now only in use for library appending. */
98 char relabase[FILE_MAX];
100 /** General reading variables. */
101 struct SDNA *filesdna;
102 const struct SDNA *memsdna;
103 /** Array of #eSDNA_StructCompare. */
104 const char *compflags;
107 /** Used to retrieve ID names from (bhead+1). */
109 /** For do_versions patching. */
110 int globalf, fileflags;
112 /** Optionally skip some data-blocks when they're not needed. */
113 eBLOReadSkip skip_flags;
115 struct OldNewMap *datamap;
116 struct OldNewMap *globmap;
117 struct OldNewMap *libmap;
118 struct OldNewMap *imamap;
119 struct OldNewMap *movieclipmap;
120 struct OldNewMap *scenemap;
121 struct OldNewMap *soundmap;
122 struct OldNewMap *volumemap;
123 struct OldNewMap *packedmap;
125 struct BHeadSort *bheadmap;
128 /** See: #USE_GHASH_BHEAD. */
129 struct GHash *bhead_idname_hash;
132 /** Used for undo. */
133 ListBase *old_mainlist;
134 struct IDNameLib_Map *old_idmap;
136 struct ReportList *reports;
139 #define SIZEOFBLENDERHEADER 12
143 void blo_join_main(ListBase *mainlist);
144 void blo_split_main(ListBase *mainlist, struct Main *main);
146 BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath);
148 FileData *blo_filedata_from_file(const char *filepath, struct ReportList *reports);
149 FileData *blo_filedata_from_memory(const void *buffer, int buffersize, struct ReportList *reports);
150 FileData *blo_filedata_from_memfile(struct MemFile *memfile,
151 const struct BlendFileReadParams *params,
152 struct ReportList *reports);
154 void blo_clear_proxy_pointers_from_lib(struct Main *oldmain);
155 void blo_make_image_pointer_map(FileData *fd, struct Main *oldmain);
156 void blo_end_image_pointer_map(FileData *fd, struct Main *oldmain);
157 void blo_make_scene_pointer_map(FileData *fd, struct Main *oldmain);
158 void blo_end_scene_pointer_map(FileData *fd, struct Main *oldmain);
159 void blo_make_movieclip_pointer_map(FileData *fd, struct Main *oldmain);
160 void blo_end_movieclip_pointer_map(FileData *fd, struct Main *oldmain);
161 void blo_make_sound_pointer_map(FileData *fd, struct Main *oldmain);
162 void blo_end_sound_pointer_map(FileData *fd, struct Main *oldmain);
163 void blo_make_volume_pointer_map(FileData *fd, struct Main *oldmain);
164 void blo_end_volume_pointer_map(FileData *fd, struct Main *oldmain);
165 void blo_make_packed_pointer_map(FileData *fd, struct Main *oldmain);
166 void blo_end_packed_pointer_map(FileData *fd, struct Main *oldmain);
167 void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd);
168 void blo_make_old_idmap_from_main(FileData *fd, struct Main *bmain);
170 void blo_filedata_free(FileData *fd);
172 BHead *blo_bhead_first(FileData *fd);
173 BHead *blo_bhead_next(FileData *fd, BHead *thisblock);
174 BHead *blo_bhead_prev(FileData *fd, BHead *thisblock);
176 const char *blo_bhead_id_name(const FileData *fd, const BHead *bhead);
178 /* do versions stuff */
180 void blo_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...)
181 ATTR_PRINTF_FORMAT(3, 4);
183 void blo_do_versions_dna(struct SDNA *sdna, const int versionfile, const int subversionfile);
185 void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm,
189 void *blo_do_versions_newlibadr(struct FileData *fd, const void *lib, const void *adr);
190 void *blo_do_versions_newlibadr_us(struct FileData *fd, const void *lib, const void *adr);
192 struct PartEff *blo_do_version_give_parteff_245(struct Object *ob);
193 void blo_do_version_old_trackto_to_constraints(struct Object *ob);
194 void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase *regions);
195 void blo_do_versions_key_uidgen(struct Key *key);
197 void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *bmain);
198 void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *bmain);
199 void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *bmain);
200 void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *bmain);
201 void blo_do_versions_280(struct FileData *fd, struct Library *lib, struct Main *bmain);
202 void blo_do_versions_290(struct FileData *fd, struct Library *lib, struct Main *bmain);
203 void blo_do_versions_cycles(struct FileData *fd, struct Library *lib, struct Main *bmain);
205 void do_versions_after_linking_250(struct Main *bmain);
206 void do_versions_after_linking_260(struct Main *bmain);
207 void do_versions_after_linking_270(struct Main *bmain);
208 void do_versions_after_linking_280(struct Main *bmain, ReportList *reports);
209 void do_versions_after_linking_cycles(struct Main *bmain);