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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
/**
* $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 *****
*
* @mainpage BLI - Blender LIbrary external interface
*
* @section about About the BLI module
*
* This is the external interface of the Blender Library. If you find
* a call to a BLI function that is not prototyped here, please add a
* prototype here. The library offers mathematical operations (mainly
* vector and matrix calculus), an abstraction layer for file i/o,
* functions for calculating Perlin noise, scanfilling services for
* triangles, and a system for guarded memory
* allocation/deallocation. There is also a patch to make MS Windows
* behave more or less Posix-compliant.
*
* @section issues Known issues with BLI
*
* - blenlib is written in C.
* - The posix-compliancy may move to a separate lib that deals with
* platform dependencies. (There are other platform-dependent
* fixes as well.)
* - The file i/o has some redundant code. It should be cleaned.
* - arithb.c is a very messy matrix library. We need a better
* solution.
* - vectorops.c is close to superfluous. It may disappear in the
* near future.
*
* @section dependencies Dependencies
*
* - The blenlib uses type defines from makesdna/, and functions from
* standard libraries.
*
* $Id$
*/
#ifndef BLI_BLENLIB_H
#define BLI_BLENLIB_H
/* braindamage for the masses... needed
because fillfacebase and fillvertbase are used outside */
#include "DNA_listBase.h"
#include <stdlib.h>
extern ListBase fillfacebase;
extern ListBase fillvertbase;
/**
* @attention Defined in scanfill.c
*/
extern ListBase filledgebase;
extern int totblock;
struct chardesc;
struct direntry;
struct rctf;
struct rcti;
struct EditVert;
struct PackedFile;
struct LinkNode;
struct DynamicList;
#ifdef __cplusplus
extern "C" {
#endif
/* BLI_util.h */
char *BLI_gethome(void);
void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file);
void BLI_make_exist(char *dir);
void BLI_make_existing_file(char *name);
void BLI_split_dirfile(const char *string, char *dir, char *file);
void BLI_join_dirfile(char *string, const char *dir, const char *file);
int BLI_testextensie(const char *str, const char *ext);
void addlisttolist(ListBase *list1, ListBase *list2);
void BLI_insertlink(struct ListBase *listbase, void *vprevlink, void *vnewlink);
void * BLI_findlink(struct ListBase *listbase, int number);
void BLI_freelistN(struct ListBase *listbase);
void BLI_addtail(struct ListBase *listbase, void *vlink);
void BLI_remlink(struct ListBase *listbase, void *vlink);
void BLI_newname(char * name, int add);
int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen);
void BLI_stringenc(char *string, char *kop, char *staart, unsigned short numlen, int pic);
void BLI_addhead(struct ListBase *listbase, void *vlink);
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink);
void BLI_freelist(struct ListBase *listbase);
int BLI_countlist(struct ListBase *listbase);
void BLI_freelinkN(ListBase *listbase, void *vlink);
void BLI_splitdirstring(char *di,char *fi);
struct DynamicList *BLI_dlist_from_listbase(struct ListBase *lb);
struct ListBase *BLI_listbase_from_dlist(struct DynamicList *dlist, struct ListBase *lb);
void * BLI_dlist_find_link(struct DynamicList *dlist, unsigned int index);
unsigned int BLI_count_items(struct DynamicList *dlist);
void BLI_dlist_free_item(struct DynamicList *dlist, unsigned int index);
void BLI_dlist_rem_item(struct DynamicList *dlist, unsigned int index);
void * BLI_dlist_add_item_index(struct DynamicList *dlist, void *item, unsigned int index);
void BLI_dlist_destroy(struct DynamicList *dlist);
void BLI_dlist_init(struct DynamicList *dlist);
void BLI_dlist_reinit(struct DynamicList *dlist);
/**
* dir can be any input, like from buttons, and this function
* converts it to a regular full path.
* Also removes garbage from directory paths, like /../ or double slashes etc
*/
void BLI_cleanup_dir(const char *relabase, char *dir);
/**
* Blender's path code replacement function.
* Bases @a path strings leading with "//" by the
* directory @a basepath, and replaces instances of
* '#' with the @a framenum. Results are written
* back into @a path.
*
* @a path The path to convert
* @a basepath The directory to base relative paths with.
* @a framenum The framenumber to replace the frame code with.
* @retval Returns true if the path was relative (started with "//").
*/
int BLI_convertstringcode(char *path, const char *basepath, int framenum);
void BLI_makestringcode(const char *relfile, char *file);
/**
* Change every @a from in @a string into @a to. The
* result will be in @a string
*
* @a string The string to work on
* @a from The character to replace
* @a to The character to replace with
*/
void BLI_char_switch(char *string, char from, char to);
/**
* Makes sure @a path has platform-specific slashes.
*
* @a path The path to 'clean'
*/
void BLI_clean(char *path);
/**
* Duplicates the cstring @a str into a newly mallocN'd
* string and returns it.
*
* @param str The string to be duplicated
* @retval Returns the duplicated string
*/
char* BLI_strdup(char *str);
/**
* Duplicates the first @a len bytes of cstring @a str
* into a newly mallocN'd string and returns it. @a str
* is assumed to be at least len bytes long.
*
* @param str The string to be duplicated
* @param len The number of bytes to duplicate
* @retval Returns the duplicated string
*/
char* BLI_strdupn(char *str, int len);
/**
* Like strncpy but ensures dst is always
* '\0' terminated.
*
* @param dst Destination for copy
* @param src Source string to copy
* @param maxncpy Maximum number of characters to copy (generally
* the size of dst)
* @retval Returns dst
*/
char* BLI_strncpy(char *dst, const char *src, int maxncpy);
/*
* Replacement for snprintf
*/
int BLI_snprintf(char *buffer, size_t count, const char *format, ...);
/**
* Compare two strings
*
* @retval True if the strings are equal, false otherwise.
*/
int BLI_streq(char *a, char *b);
/**
* Compare two strings without regard to case.
*
* @retval True if the strings are equal, false otherwise.
*/
int BLI_strcaseeq(char *a, char *b);
/**
* Read a file as ASCII lines. An empty list is
* returned if the file cannot be opened or read.
*
* @attention The returned list should be free'd with
* BLI_free_file_lines.
*
* @param name The name of the file to read.
* @retval A list of strings representing the file lines.
*/
struct LinkNode *BLI_read_file_as_lines(char *name);
/**
* Free the list returned by BLI_read_file_as_lines.
*/
void BLI_free_file_lines(struct LinkNode *lines);
/**
* Checks if name is a fully qualified filename to an executable.
* If not it searches $PATH for the file. On Windows it also
* adds the correct extension (.com .exe etc) from
* $PATHEXT if necessary. Also on Windows it translates
* the name to its 8.3 version to prevent problems with
* spaces and stuff. Final result is returned in fullname.
*
* @param fullname The full path and full name of the executable
* @param name The name of the executable (usually argv[0]) to be checked
*/
void BLI_where_am_i(char *fullname, char *name);
/**
* determines the full path to the application bundle on OS X
*
* @return path to application bundle
*/
#ifdef __APPLE__
char* BLI_getbundle(void);
#endif
#ifdef WIN32
int BLI_getInstallationDir( char * str );
#endif
/* BLI_storage.h */
int BLI_filesize(int file);
double BLI_diskfree(char *dir);
char * BLI_getwdN(char * dir);
void BLI_hide_dot_files(int set);
unsigned int BLI_getdir(char *dirname, struct direntry **filelist);
/**
* @attention Do not confuse with BLI_exists
*/
int BLI_exist(char *name);
/* BLI_fileops.h */
void BLI_recurdir_fileops(char *dirname);
int BLI_link(char *file, char *to);
int BLI_backup(char *file, char *from, char *to);
int BLI_is_writable(char *filename);
/**
* @attention Do not confuse with BLI_exist
*/
int BLI_exists(char *file);
int BLI_copy_fileops(char *file, char *to);
int BLI_rename(char *from, char *to);
int BLI_gzip(char *from, char *to);
int BLI_delete(char *file, int dir, int recursive);
int BLI_move(char *file, char *to);
int BLI_touch(char *file);
char *BLI_last_slash(char *string);
/* BLI_rct.c */
/**
* Determine if a rect is empty. An empty
* rect is one with a zero (or negative)
* width or height.
*
* @return True if @a rect is empty.
*/
int BLI_rcti_is_empty(struct rcti * rect);
void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
void BLI_translate_rctf(struct rctf *rect, float x, float y);
void BLI_translate_rcti(struct rcti *rect, int x, int y);
int BLI_in_rcti(struct rcti * rect, int x, int y);
int BLI_in_rctf(struct rctf *rect, float x, float y);
int BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest);
int BLI_isect_rcti(struct rcti *src1, struct rcti *src2, struct rcti *dest);
void BLI_union_rctf(struct rctf *rcta, struct rctf *rctb);
/* scanfill.c: used in displist only... */
struct EditVert *BLI_addfillvert(float *vec);
struct EditEdge *BLI_addfilledge(struct EditVert *v1, struct EditVert *v2);
int BLI_edgefill(int mode, int mat_nr);
void BLI_end_edgefill(void);
/* noise.h: */
float BLI_hnoise(float noisesize, float x, float y, float z);
float BLI_hnoisep(float noisesize, float x, float y, float z);
float BLI_turbulence(float noisesize, float x, float y, float z, int nr);
float BLI_turbulence1(float noisesize, float x, float y, float z, int nr);
/* newnoise: generic noise & turbulence functions to replace the above BLI_hnoise/p & BLI_turbulence/1.
* This is done so different noise basis functions can be used */
float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noisebasis);
float BLI_gTurbulence(float noisesize, float x, float y, float z, int oct, int hard, int noisebasis);
/* newnoise: musgrave functions */
float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
float mg_MultiFractal(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nbas2);
float mg_HeteroTerrain(float x, float y, float z, float H, float lacunarity, float octaves, float offset, int noisebasis);
float mg_HybridMultiFractal(float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis);
float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis);
/* newnoise: voronoi */
void voronoi(float x, float y, float z, float* da, float* pa, float me, int dtype);
/* newnoise: cellNoise & cellNoiseV (for vector/point/color) */
float cellNoise(float x, float y, float z);
void cellNoiseV(float x, float y, float z, float *ca);
/* These callbacks are needed to make the lib finction properly */
/**
* Set a function taking a char* as argument to flag errors. If the
* callback is not set, the error is discarded.
* @param f The function to use as callback
* @attention used in creator.c
*/
void BLI_setErrorCallBack(void (*f)(char*));
/**
* Set a function to be able to interrupt the execution of processing
* in this module. If the function returns true, the execution will
* terminate gracefully. If the callback is not set, interruption is
* not possible.
* @param f The function to use as callback
* @attention used in creator.c
*/
void BLI_setInterruptCallBack(int (*f)(void));
char *BLI_strcasestr(const char *s, const char *find);
int BLI_strcasecmp(const char *s1, const char *s2);
int BLI_strncasecmp(const char *s1, const char *s2, int n);
void BLI_timestr(double time, char *str);
#define PRNTSUB(type,arg) printf(#arg ": %" #type " ", arg)
#ifndef PRINT
#define PRINT(t,v) {PRNTSUB(t,v); printf("\n");}
#define PRINT2(t1,v1,t2,v2) {PRNTSUB(t1,v1); PRNTSUB(t2,v2); printf("\n");}
#define PRINT3(t1,v1,t2,v2,t3,v3) {PRNTSUB(t1,v1); PRNTSUB(t2,v2); PRNTSUB(t3,v3); printf("\n");}
#define PRINT4(t1,v1,t2,v2,t3,v3,t4,v4) {PRNTSUB(t1,v1); PRNTSUB(t2,v2); PRNTSUB(t3,v3); PRNTSUB(t4,v4); printf("\n");}
#endif
/**
* @param array The array in question
* @retval The number of elements in the array.
*/
#define BLI_ARRAY_NELEMS(array) (sizeof((array))/sizeof((array)[0]))
/**
* @param strct The structure of interest
* @param member The name of a member field of @a strct
* @retval The offset in bytes of @a member within @a strct
*/
#define BLI_STRUCT_OFFSET(strct, member) ((int) &((strct*) 0)->member)
#ifdef __cplusplus
}
#endif
#endif
|