| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-01-07 19:13:47 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2008-01-07 19:13:47 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): none yet. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-01-07 19:13:47 +00:00
										 |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-02-17 18:59:41 +00:00
										 |  |  | #ifndef __BLO_READFILE_H__
 | 
					
						
							|  |  |  | #define __BLO_READFILE_H__
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-17 23:34:07 +00:00
										 |  |  | /** \file BLO_readfile.h
 | 
					
						
							| 
									
										
										
										
											2011-02-27 20:35:41 +00:00
										 |  |  |  *  \ingroup blenloader | 
					
						
							| 
									
										
										
										
											2011-02-17 23:34:07 +00:00
										 |  |  |  *  \brief external readfile function prototypes. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-19 00:50:21 +00:00
										 |  |  | struct bScreen; | 
					
						
							|  |  |  | struct direntry; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | struct LinkNode; | 
					
						
							|  |  |  | struct Main; | 
					
						
							| 
									
										
										
										
											2004-09-05 13:43:51 +00:00
										 |  |  | struct MemFile; | 
					
						
							| 
									
										
										
										
											2008-12-19 00:50:21 +00:00
										 |  |  | struct ReportList; | 
					
						
							|  |  |  | struct Scene; | 
					
						
							|  |  |  | struct SpaceFile; | 
					
						
							|  |  |  | struct UserDef; | 
					
						
							| 
									
										
										
										
											2009-09-12 19:54:39 +00:00
										 |  |  | struct bContext; | 
					
						
							| 
									
										
										
										
											2011-05-18 19:42:30 +00:00
										 |  |  | struct BHead; | 
					
						
							|  |  |  | struct FileData; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | typedef struct BlendHandle BlendHandle; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef enum BlenFileType { | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | 	BLENFILETYPE_BLEND = 1, | 
					
						
							|  |  |  | 	BLENFILETYPE_PUB = 2, | 
					
						
							|  |  |  | 	BLENFILETYPE_RUNTIME = 3 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | } BlenFileType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct BlendFileData { | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | 	struct Main *main; | 
					
						
							|  |  |  | 	struct UserDef *user; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	int winpos; | 
					
						
							|  |  |  | 	int fileflags; | 
					
						
							|  |  |  | 	int displaymode; | 
					
						
							| 
									
										
										
										
											2003-07-21 19:41:07 +00:00
										 |  |  | 	int globalf; | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | 	char filename[1024];    /* 1024 = FILE_MAX */ | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | 	struct bScreen *curscreen; | 
					
						
							|  |  |  | 	struct Scene *curscene; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | 	BlenFileType type; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | } BlendFileData; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Open a blender file from a pathname. The function | 
					
						
							|  |  |  |  * returns NULL and sets a report in the list if | 
					
						
							|  |  |  |  * it cannot open the file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param filepath The path of the file to open. | 
					
						
							|  |  |  |  * \param reports If the return value is NULL, errors | 
					
						
							|  |  |  |  * indicating the cause of the failure. | 
					
						
							|  |  |  |  * \return The data of the file. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | BlendFileData *BLO_read_from_file(const char *filepath, struct ReportList *reports); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Open a blender file from memory. The function | 
					
						
							|  |  |  |  * returns NULL and sets a report in the list if | 
					
						
							|  |  |  |  * it cannot open the file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param mem The file data. | 
					
						
							|  |  |  |  * \param memsize The length of \a mem. | 
					
						
							|  |  |  |  * \param reports If the return value is NULL, errors | 
					
						
							|  |  |  |  * indicating the cause of the failure. | 
					
						
							|  |  |  |  * \return The data of the file. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | BlendFileData *BLO_read_from_memory(void *mem, int memsize, struct ReportList *reports); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-05 14:12:07 +00:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2008-12-19 16:36:15 +00:00
										 |  |  |  * oldmain is old main, from which we will keep libraries, images, .. | 
					
						
							| 
									
										
										
										
											2006-01-05 14:12:07 +00:00
										 |  |  |  * file name is current file, only for retrieving library data */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-19 16:36:15 +00:00
										 |  |  | BlendFileData *BLO_read_from_memfile(struct Main *oldmain, const char *filename, struct MemFile *memfile, struct ReportList *reports); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Free's a BlendFileData structure and _all_ the | 
					
						
							|  |  |  |  * data associated with it (the userdef data, and | 
					
						
							|  |  |  |  * the main libblock data). | 
					
						
							|  |  |  |  *  | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param bfd The structure to free. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | void | 
					
						
							|  |  |  | BLO_blendfiledata_free(BlendFileData *bfd); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Open a blendhandle from a file path. | 
					
						
							|  |  |  |  *  | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param file The file path to open. | 
					
						
							|  |  |  |  * \param reports Report errors in opening the file (can be NULL). | 
					
						
							|  |  |  |  * \return A handle on success, or NULL on failure. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | BlendHandle * | 
					
						
							|  |  |  | BLO_blendhandle_from_file(char *file, | 
					
						
							|  |  |  |                           struct ReportList *reports); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-28 02:07:55 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Open a blendhandle from memory. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param mem The data to load from. | 
					
						
							|  |  |  |  * \param memsize The size of the data. | 
					
						
							|  |  |  |  * \return A handle on success, or NULL on failure. | 
					
						
							| 
									
										
										
										
											2010-08-28 02:07:55 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | BlendHandle * | 
					
						
							|  |  |  | BLO_blendhandle_from_memory(void *mem, | 
					
						
							|  |  |  |                             int memsize); | 
					
						
							| 
									
										
										
										
											2010-08-28 02:07:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Gets the names of all the datablocks in a file | 
					
						
							|  |  |  |  * of a certain type (ie. All the scene names in | 
					
						
							|  |  |  |  * a file). | 
					
						
							|  |  |  |  *  | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param bh The blendhandle to access. | 
					
						
							|  |  |  |  * \param ofblocktype The type of names to get. | 
					
						
							|  |  |  |  * \param tot_names The length of the returned list. | 
					
						
							|  |  |  |  * \return A BLI_linklist of strings. The string links | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * should be freed with malloc. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | struct LinkNode * | 
					
						
							|  |  |  | BLO_blendhandle_get_datablock_names(BlendHandle *bh, | 
					
						
							|  |  |  |                                     int ofblocktype, | 
					
						
							|  |  |  |                                     int *tot_names); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-02 17:25:03 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Gets the previews of all the datablocks in a file | 
					
						
							|  |  |  |  * of a certain type (ie. All the scene names in | 
					
						
							|  |  |  |  * a file). | 
					
						
							|  |  |  |  *  | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param bh The blendhandle to access. | 
					
						
							|  |  |  |  * \param ofblocktype The type of names to get. | 
					
						
							|  |  |  |  * \param tot_prev The length of the returned list. | 
					
						
							|  |  |  |  * \return A BLI_linklist of PreviewImage. The PreviewImage links | 
					
						
							| 
									
										
										
										
											2007-09-02 17:25:03 +00:00
										 |  |  |  * should be freed with malloc. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | struct LinkNode * | 
					
						
							|  |  |  | BLO_blendhandle_get_previews(BlendHandle *bh, | 
					
						
							|  |  |  |                              int ofblocktype, | 
					
						
							|  |  |  |                              int *tot_prev); | 
					
						
							| 
									
										
										
										
											2007-09-02 17:25:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Gets the names of all the datablock groups in a | 
					
						
							|  |  |  |  * file. (ie. file contains Scene, Mesh, and Lamp | 
					
						
							|  |  |  |  * datablocks). | 
					
						
							|  |  |  |  *  | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param bh The blendhandle to access. | 
					
						
							|  |  |  |  * \return A BLI_linklist of strings. The string links | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * should be freed with malloc. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | struct LinkNode * | 
					
						
							|  |  |  | BLO_blendhandle_get_linkable_groups(BlendHandle *bh); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Close and free a blendhandle. The handle | 
					
						
							|  |  |  |  * becomes invalid after this call. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param bh The handle to close. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | void | 
					
						
							|  |  |  | BLO_blendhandle_close(BlendHandle *bh); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | /***/ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-12 19:54:39 +00:00
										 |  |  | #define GROUP_MAX 32
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-15 05:01:47 +00:00
										 |  |  | int BLO_has_bfile_extension(const char *str); | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-12 19:54:39 +00:00
										 |  |  | /* return ok when a blenderfile, in dir is the filename,
 | 
					
						
							|  |  |  |  * in group the type of libdata | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2010-03-20 16:56:52 +00:00
										 |  |  | int BLO_is_a_library(const char *path, char *dir, char *group); | 
					
						
							| 
									
										
										
										
											2009-09-12 19:54:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-05 05:26:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Initialize the BlendHandle for appending or linking library data. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param mainvar The current main database eg G.main or CTX_data_main(C). | 
					
						
							|  |  |  |  * \param bh A blender file handle as returned by BLO_blendhandle_from_file or BLO_blendhandle_from_memory. | 
					
						
							|  |  |  |  * \param filepath Used for relative linking, copied to the lib->name | 
					
						
							|  |  |  |  * \return the library Main, to be passed to BLO_library_append_named_part as mainl. | 
					
						
							| 
									
										
										
										
											2011-08-05 05:26:19 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | struct Main *BLO_library_append_begin(struct Main *mainvar, BlendHandle **bh, const char *filepath); | 
					
						
							| 
									
										
										
										
											2011-03-13 01:15:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-26 20:45:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-13 01:15:14 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Link/Append a named datablock from an external blend file. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param mainl The main database to link from (not the active one). | 
					
						
							|  |  |  |  * \param bh The blender file handle. | 
					
						
							|  |  |  |  * \param idname The name of the datablock (without the 2 char ID prefix) | 
					
						
							|  |  |  |  * \param idcode The kind of datablock to link. | 
					
						
							|  |  |  |  * \return the appended ID when found. | 
					
						
							| 
									
										
										
										
											2011-05-26 20:45:19 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | struct ID *BLO_library_append_named_part(struct Main *mainl, BlendHandle **bh, const char *idname, const int idcode); | 
					
						
							| 
									
										
										
										
											2011-05-26 20:45:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Link/Append a named datablock from an external blend file. | 
					
						
							|  |  |  |  * optionally instance the object in the scene when the flags are set. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-03-18 07:38:51 +00:00
										 |  |  |  * \param C The context, when NULL instancing object in the scene isn't done. | 
					
						
							| 
									
										
										
										
											2012-03-02 16:05:54 +00:00
										 |  |  |  * \param mainl The main database to link from (not the active one). | 
					
						
							|  |  |  |  * \param bh The blender file handle. | 
					
						
							|  |  |  |  * \param idname The name of the datablock (without the 2 char ID prefix) | 
					
						
							|  |  |  |  * \param idcode The kind of datablock to link. | 
					
						
							|  |  |  |  * \param flag Options for linking, used for instancing. | 
					
						
							|  |  |  |  * \return the appended ID when found. | 
					
						
							| 
									
										
										
										
											2011-03-13 01:15:14 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | struct ID *BLO_library_append_named_part_ex(const struct bContext *C, struct Main *mainl, BlendHandle **bh, const char *idname, const int idcode, const short flag); | 
					
						
							| 
									
										
										
										
											2011-05-26 20:45:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle **bh, int idcode, short flag); | 
					
						
							| 
									
										
										
										
											2009-09-12 19:54:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-18 19:42:30 +00:00
										 |  |  | void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-12 20:39:39 +00:00
										 |  |  | BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, struct ReportList *reports); | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2002-10-30 02:07:20 +00:00
										 |  |  | 
 |