Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BLO_readfile.h « blenloader « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b54d42080b0bd89575313b08a5e28e8e89a775ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
 * $Id$
 *
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 *
 * 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
 * of the License, or (at your option) any later version. The Blender
 * Foundation also sells licenses for use in proprietary software under
 * the Blender License.  See http://www.blender.org/BL/ for information
 * about this.
 *
 * 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,
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * 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.
 *
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
 * external readfile function prototypes
 */
#ifndef BLO_READFILE_H
#define BLO_READFILE_H

#ifdef __cplusplus
extern "C" {
#endif

struct SpaceFile;
struct SpaceImaSel;
struct FileList;
struct LinkNode;
struct Main;
struct UserDef;
struct bScreen;
struct Scene;
struct MemFile;
struct direntry;

typedef struct BlendHandle	BlendHandle;

typedef enum BlenFileType {
	BLENFILETYPE_BLEND= 1, 
	BLENFILETYPE_PUB= 2, 
	BLENFILETYPE_RUNTIME= 3
} BlenFileType;

typedef enum {
	BRE_NONE, 
	
	BRE_UNABLE_TO_OPEN, 
	BRE_UNABLE_TO_READ, 

	BRE_OUT_OF_MEMORY, 
	BRE_INTERNAL_ERROR, 

	BRE_NOT_A_BLEND, 
	BRE_NOT_A_PUBFILE,
	BRE_INCOMPLETE, 
	BRE_CORRUPT, 
	
	BRE_TOO_NEW, 
	BRE_NOT_ALLOWED, 
	
	BRE_NO_SCREEN, 
	BRE_NO_SCENE, 
	
	BRE_INVALID
} BlendReadError;

typedef struct BlendFileData {
	struct Main*	main;
	struct UserDef*	user;

	int winpos;
	int fileflags;
	int displaymode;
	int globalf;

	struct bScreen*	curscreen;
	struct Scene*	curscene;
	
	BlenFileType	type;
} BlendFileData;

	/**
	 * Open a blender file from a pathname. The function
	 * returns NULL and sets the @a error_r argument if
	 * it cannot open the file.
	 * 
	 * @param file The path of the file to open.
	 * @param error_r If the return value is NULL, an error
	 * code indicating the cause of the failure.
	 * @return The data of the file.
	 */
BlendFileData*	BLO_read_from_file		(char *file, BlendReadError *error_r);

	/**
	 * Open a blender file from memory. The function
	 * returns NULL and sets the @a error_r argument if
	 * it cannot open the file.
	 * 
	 * @param mem The file data.
	 * @param memsize The length of @a mem.
	 * @param error_r If the return value is NULL, an error
	 * code indicating the cause of the failure.
	 * @return The data of the file.
	 */
BlendFileData*	BLO_read_from_memory(void *mem, int memsize, BlendReadError *error_r);

/**
 * file name is current file, only for retrieving library data */

BlendFileData *BLO_read_from_memfile(const char *filename, struct MemFile *memfile, BlendReadError *error_r);

/**
 * Convert a BlendReadError to a human readable string.
 * The string is static and does not need to be free'd.
 * 
 * @param error The error to return a string for.
 * @return A static human readable string representation
 * of @a error.
 */
 
	char*
BLO_bre_as_string(
	BlendReadError error);

/**
 * Free's a BlendFileData structure and _all_ the
 * data associated with it (the userdef data, and
 * the main libblock data).
 * 
 * @param bfd The structure to free.
 */
	void
BLO_blendfiledata_free(
	BlendFileData *bfd);

/**
 * Convert an idcode into a name.
 * 
 * @param code The code to convert.
 * @return A static string representing the name of
 * the code.
 */
	char*
BLO_idcode_to_name(
	int code);

/**
 * Convert a name into an idcode (ie. ID_SCE)
 * 
 * @param name The name to convert.
 * @return The code for the name, or 0 if invalid.
 */
	int
BLO_idcode_from_name(
	char *name);
	
/**
 * Open a blendhandle from a file path.
 * 
 * @param file The file path to open.
 * @return A handle on success, or NULL on failure.
 */
	BlendHandle*
BLO_blendhandle_from_file(
	char *file);

/**
 * Gets the names of all the datablocks in a file
 * of a certain type (ie. All the scene names in
 * a file).
 * 
 * @param bh The blendhandle to access.
 * @param ofblocktype The type of names to get.
 * @return A BLI_linklist of strings. The string links
 * should be freed with malloc.
 */
	struct LinkNode*
BLO_blendhandle_get_datablock_names(
	BlendHandle *bh, 
	int ofblocktype);

/**
 * Gets the previews of all the datablocks in a file
 * of a certain type (ie. All the scene names in
 * a file).
 * 
 * @param bh The blendhandle to access.
 * @param ofblocktype The type of names to get.
 * @return A BLI_linklist of PreviewImage. The PreviewImage links
 * should be freed with malloc.
 */
	struct LinkNode*
BLO_blendhandle_get_previews(
	BlendHandle *bh, 
	int ofblocktype);

/**
 * Gets the names of all the datablock groups in a
 * file. (ie. file contains Scene, Mesh, and Lamp
 * datablocks).
 * 
 * @param bh The blendhandle to access.
 * @return A BLI_linklist of strings. The string links
 * should be freed with malloc.
 */
	struct LinkNode*
BLO_blendhandle_get_linkable_groups(
	BlendHandle *bh);

/**
 * Close and free a blendhandle. The handle
 * becomes invalid after this call.
 *
 * @param bh The handle to close.
 */
	void
BLO_blendhandle_close(
	BlendHandle *bh);
	
	/***/

char *BLO_gethome(void);
int BLO_has_bfile_extension(char *str);
void BLO_library_append(struct SpaceFile *sfile, char *dir, int idcode);
void BLO_library_append_(BlendHandle **libfiledata, struct direntry* filelist, int totfile, char *dir, char* file, short flag, int idcode);
void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Scene *scene);

BlendFileData* blo_read_blendafterruntime(int file, int actualsize, BlendReadError *error_r);

#ifdef __cplusplus
} 
#endif

#endif