Merging r41176 through r41192 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Sat, 22 Oct 2011 15:15:42 +0000 (15:15 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sat, 22 Oct 2011 15:15:42 +0000 (15:15 +0000)
86 files changed:
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/test/multitest/MultiTest.c
intern/memutil/MEM_SmartPtr.h
source/blender/blenfont/intern/blf_dir.c
source/blender/blenfont/intern/blf_lang.c
source/blender/blenkernel/BKE_bvhutils.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/bvhutils.c
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenlib/BLI_blenlib.h
source/blender/blenlib/BLI_fileops.h
source/blender/blenlib/BLI_path_util.h
source/blender/blenlib/BLI_storage.h
source/blender/blenlib/BLI_utildefines.h
source/blender/blenlib/intern/fileops.c
source/blender/blenlib/intern/path_util.c
source/blender/blenlib/intern/storage.c
source/blender/blenloader/intern/readfile.c
source/blender/collada/collada.cpp
source/blender/editors/animation/anim_ipo_utils.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/mesh_navmesh.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/render/render_shading.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_file/fsmenu.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/transform/transform.c
source/blender/imbuf/intern/IMB_anim.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_armature_api.c
source/blender/makesrna/intern/rna_fcurve_api.c
source/blender/makesrna/intern/rna_fluidsim.c
source/blender/makesrna/intern/rna_gpencil.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/modifiers/intern/MOD_edgesplit.c
source/blender/modifiers/intern/MOD_fluidsim_util.c
source/blender/nodes/composite/node_composite_util.c
source/blender/nodes/composite/nodes/node_composite_directionalblur.c
source/blender/python/BPY_extern.h
source/blender/python/generic/IDProp.c
source/blender/python/generic/py_capi_utils.c
source/blender/python/generic/py_capi_utils.h
source/blender/python/intern/bpy_app.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_rna.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/creator.c
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
source/gameengine/VideoTexture/VideoFFmpeg.cpp

index c3c0c5914442c941fd37ab9c72a2d683f57f0e3f..9ec8dd0abad905a063920d2dca5f874ecc1e3ba9 100644 (file)
@@ -1655,15 +1655,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
                return GHOST_kFailure;
        }
 
-       /* unicode input - not entirely supported yet
-        * but we are getting the right byte, Blender is not drawing it though 
-        * also some languages may need special treatment:
-                 - Japanese: romanji is used as input, and every 2 letters OSX converts the text
-                             to Hiragana/Katakana.
-                 - Korean: one add one letter at a time, and then the OSX join them in the equivalent
-                           combined letter.
-        */
        char utf8_buf[6]= {'\0'};
+       ascii = 0;
        
        switch ([event type]) {
 
@@ -1678,39 +1671,21 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
                                keyCode = convertKey([event keyCode],0,
                                                                         [event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
 
-                       /* ascii */
+                       /* handling both unicode or ascii */
                        characters = [event characters];
-                       if ([characters length]>0) { //Check for dead keys
-                               //Convert characters to iso latin 1 encoding
-                               convertedCharacters = [characters dataUsingEncoding:NSISOLatin1StringEncoding];
-                               if ([convertedCharacters length]>0)
-                                       ascii =((char*)[convertedCharacters bytes])[0];
-                               else
-                                       ascii = 0; //Character not available in iso latin 1 encoding
-                       }
-                       else
-                               ascii= 0;
-
-                       /* unicode */
                        if ([characters length]>0) {
                                convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
-                               if ([convertedCharacters length]>0) {
-                                       utf8_buf[0] = ((char*)[convertedCharacters bytes])[0];
-                                       utf8_buf[1] = ((char*)[convertedCharacters bytes])[1];
-                                       utf8_buf[2] = ((char*)[convertedCharacters bytes])[2];
-                                       utf8_buf[3] = ((char*)[convertedCharacters bytes])[3];
-                                       utf8_buf[4] = ((char*)[convertedCharacters bytes])[4];
-                                       utf8_buf[5] = ((char*)[convertedCharacters bytes])[5];
+                               
+                               for (int x = 0; x < [convertedCharacters length]; x++) {
+                                       utf8_buf[x] = ((char*)[convertedCharacters bytes])[x];
                                }
-                               else {
-                                       utf8_buf[0] = '\0';
+
+                               /* ascii is a subset of unicode */
+                               if ([convertedCharacters length] == 1) {
+                                       ascii = utf8_buf[0];
                                }
                        }
 
-                       /* XXX the above code gives us the right utf8, however if we pass it along Font Object doesn't work.
-                          let's leave utf8 disabled for OSX before we fix that */
-                       utf8_buf[0] = '\0';//to be removed once things are working
-                       
                        if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
                                break; //Cmd-Q is directly handled by Cocoa
 
@@ -1718,8 +1693,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
                                pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) );
                                //printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
                        } else {
-                               pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii, utf8_buf) );
-                               //printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
+                               pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, 0, '\0') );
+                               //printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
                        }
                        break;
        
index 24b6474732e64b488f8efe7318b3aae65178a53a..956a159a4ec0e4b5502937da624a90c42eb94501 100644 (file)
@@ -712,21 +712,23 @@ GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINP
        GHOST_SystemWin32 * system = (GHOST_SystemWin32 *)getSystem();
        GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk);
        GHOST_EventKey* event;
+
        if (key != GHOST_kKeyUnknown) {
-               char ascii = '\0';
+               char utf8_char[6] = {0} ;
 
-               unsigned short utf16[2]={0};
+               wchar_t utf16[2]={0};
                BYTE state[256];
-               GetKeyboardState((PBYTE)state);
+               GetKeyboardState((PBYTE)state);  
 
-               if(ToAsciiEx(vk, 0, state, utf16, 0, system->m_keylayout))
-                               WideCharToMultiByte(CP_ACP, 0x00000400, 
+               if(ToUnicodeEx(vk, 0, state, utf16, 2, 0, system->m_keylayout))
+                       WideCharToMultiByte(CP_UTF8, 0, 
                                                                        (wchar_t*)utf16, 1,
-                                                                       (LPSTR) &ascii, 1,
-                                                                       NULL,NULL);
+                                                                       (LPSTR) utf8_char, 5,
+                                                                       NULL,NULL); else *utf8_char = 0;
 
-               /* TODO, last arg is utf8, need to pass utf8 arg */
-               event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii, NULL);
+               if(!keyDown) utf8_char[0] = '\0';
+               
+               event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, (*utf8_char & 0x80)?'?':*utf8_char, utf8_char);
                
 #ifdef GHOST_DEBUG
                std::cout << ascii << std::endl;
index 00939e907d669dba5ebabacd39263255fe699e03..1ba28d21808704931042f0cf93d0574eda899f3e 100644 (file)
@@ -50,9 +50,8 @@
    extern int datatoc_bfont_ttf_size;
    extern char datatoc_bfont_ttf[];
 
-   // XXX, bad, but BLI uses these
-   char bprogname[160]= "";
-char U[1024]= {0};
+   /* cheat */
+   char U[1024]= {0};
 #endif
 
 #include "Util.h"
index 50d69cfd8dd421701f7710f991fce58509bf452d..ee3c4f2253680d1b550001335f71d999efdbc451 100644 (file)
  * the Standard Template Library but without the painful get()
  * semantics to access the internal c style pointer.
  *
- * It is often useful to explicitely decalre ownership of memory
+ * It is often useful to explicitly declare ownership of memory
  * allocated on the heap within class or function scope. This
  * class helps you to encapsulate this ownership within a value
  * type. When an instance of this class goes out of scope it
  * makes sure that any memory associated with it's internal pointer
  * is deleted. It can help to inform users of an aggregate class
  * that it owns instances of it's members and these instances 
- * should not be shared. This is not reliably enforcable in C++
+ * should not be shared. This is not reliably enforceable in C++
  * but this class attempts to make the 1-1 relationship clear.
  * 
  * @section Example usage
index 46be49b37e9035441a0d96a57f085f0c06f13470..3fe66118cdab18ff4ef671dea00c36efefded9e5 100644 (file)
@@ -136,7 +136,7 @@ char *blf_dir_search(const char *file)
 
        for(dir=global_font_dir.first; dir; dir= dir->next) {
                BLI_join_dirfile(full_path, sizeof(full_path), dir->path, file);
-               if (BLI_exist(full_path)) {
+               if (BLI_exists(full_path)) {
                        s= BLI_strdup(full_path);
                        break;
                }
@@ -144,7 +144,7 @@ char *blf_dir_search(const char *file)
 
        if (!s) {
                /* check the current directory, why not ? */
-               if (BLI_exist(file))
+               if (BLI_exists(file))
                        s= BLI_strdup(file);
        }
 
@@ -198,13 +198,13 @@ char *blf_dir_metrics_search(const char *filename)
                s[2]= 'm';
 
                /* first check .afm */
-               if (BLI_exist(s))
+               if (BLI_exists(s))
                        return s;
 
                /* and now check .pfm */
                s[0]= 'p';
 
-               if (BLI_exist(s))
+               if (BLI_exists(s))
                        return s;
        }
        MEM_freeN(mfile);
index d5245073e5967964ee07294440f185db20dee1ab..87fbbc7b3e52c14ab5e819b98af20b8622d0ae1f 100644 (file)
@@ -55,6 +55,7 @@
 
 #include "BLI_linklist.h"      /* linknode */
 #include "BLI_string.h"
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 
 #define DOMAIN_NAME "blender"
index 29487713ad4c4291e1a1c81df1147a20ab4e7fbd..b497698f660fa058f7b76be44c9532cd671dbab5 100644 (file)
@@ -34,7 +34,6 @@
  */
 
 #include "BLI_kdopbvh.h"
-#include "BLI_linklist.h"
 
 /*
  * This header encapsulates necessary code to buld a BVH
@@ -118,7 +117,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data);
 #define BVHTREE_FROM_VERTICES  1
 #define BVHTREE_FROM_EDGES             2
 
-typedef LinkNode* BVHCache;
+typedef struct LinkNode* BVHCache;
 
 
 /*
index c379111ccfd13d0d465bb212821d12a8964050bd..f9bd76e4ef0cc07b6f895562c77b6b079897d0c8 100644 (file)
@@ -50,6 +50,7 @@
 #include "BLI_memarena.h"
 #include "BLI_pbvh.h"
 #include "BLI_utildefines.h"
+#include "BLI_linklist.h"
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_displist.h"
index dc0580bce969ea6285afb1482f3398b8400c71e1..415d5938f955cdf97b6e9ae537f80ae063522160 100644 (file)
@@ -59,7 +59,6 @@
 #include "BLI_blenlib.h"
 #include "BLI_bpath.h"
 #include "BLI_dynstr.h"
-#include "BLI_path_util.h"
 #include "BLI_utildefines.h"
 #include "BLI_callbacks.h"
 
@@ -551,7 +550,7 @@ void BKE_write_undo(bContext *C, const char *name)
                counter= counter % U.undosteps; 
        
                BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
-               BLI_make_file_string("/", filepath, btempdir, numstr);
+               BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr);
        
                /* success= */ /* UNUSED */ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
                
@@ -721,7 +720,7 @@ void BKE_undo_save_quit(void)
        /* no undo state to save */
        if(undobase.first==undobase.last) return;
                
-       BLI_make_file_string("/", str, btempdir, "quit.blend");
+       BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
 
        file = open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
        if(file == -1) {
index 2ce6b92922d9a682844020cdea4b5d7b920b43b9..79229c49b4d9fb48b5e0bfa333436c3ebf7c91f1 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "BLI_editVert.h"
 #include "BLI_utildefines.h"
+#include "BLI_linklist.h"
 
 #include "BKE_DerivedMesh.h"
 
index 260b51bc3210b963a48ec3bf96e4996c308745e7..d30476d44f804ede20eebb1ee8d834eafa59a478 100644 (file)
@@ -40,6 +40,7 @@
 #include "BLI_math.h"
 #include "BLI_edgehash.h"
 #include "BLI_utildefines.h"
+#include "BLI_linklist.h"
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_cloth.h"
index e07093f1f78b46cb4e97dc1eddd49ebfd11177c4..c776b4d9b3557b44e06f5762692aa1132631f11c 100644 (file)
@@ -41,7 +41,6 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
-#include "BLI_listbase.h"
 #include "BLI_math.h"
 #include "BLI_editVert.h"
 #include "BLI_utildefines.h"
index 7d98119610b6655b2d827f165ad6d63ff1ca7b99..d59a9eed3639358ae2b848abc826a0d084454cf0 100644 (file)
@@ -47,7 +47,6 @@
 #include "DNA_ID.h"
 
 #include "BLI_blenlib.h"
-#include "BLI_path_util.h"
 #include "BLI_linklist.h"
 #include "BLI_math.h"
 #include "BLI_mempool.h"
index 5ce7b82a45f6fb007fa9aa681686e30035d45a7a..f728916a158b466e0d56d0dfc234d5e1acd0b396 100644 (file)
@@ -59,8 +59,6 @@
 #include "BLI_math.h"
 #include "BLI_blenlib.h"
 #include "BLI_jitter.h"
-#include "BLI_listbase.h"
-#include "BLI_noise.h"
 #include "BLI_rand.h"
 #include "BLI_utildefines.h"
 
index edddcb4a6b27bdf3f9671c65f0a794dd922dad2c..2056762e62777c420302daf15b92406e02a2bbe2 100644 (file)
@@ -54,6 +54,7 @@
 #include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 #include "BLI_listbase.h"
+#include "BLI_linklist.h"
 #include "BLI_string.h"
 
 #include "BKE_bmesh.h"
index 8669c4e0efd916ffd2208f3b899a9235fde16e24..8a83dcac765ce1f0bbffc25f878383cc440aedf7 100644 (file)
@@ -54,6 +54,7 @@
 #include "BLI_kdtree.h"
 #include "BLI_rand.h"
 #include "BLI_threads.h"
+#include "BLI_linklist.h"
 
 #include "BKE_anim.h"
 #include "BKE_animsys.h"
index 64a90e15b6033f1d0c3c43cb6cbee055e5a66a43..c642f76d400bdcb805bfbef6af8acca3221cb549 100644 (file)
 #include "BLI_rand.h"
 #include "BLI_jitter.h"
 #include "BLI_math.h"
-#include "BLI_blenlib.h"
+#include "BLI_blenlib.h" /* BLI_storage.h For _LARGEFILE64_SOURCE;  zlib needs this on some systems */
 #include "BLI_kdtree.h"
 #include "BLI_kdopbvh.h"
-#include "BLI_listbase.h"
 #include "BLI_threads.h"
-#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE;  zlib needs this on some systems */
 #include "BLI_utildefines.h"
+#include "BLI_linklist.h"
 
 #include "BKE_main.h"
 #include "BKE_animsys.h"
index bd5e5dc60493bb0318d1a417434d5e9679ab7a91..d4753f30ef2033d7fc25b151926e452530a1f062 100644 (file)
@@ -923,8 +923,8 @@ static int ptcache_path(PTCacheID *pid, char *filename)
        }
        
        /* use the temp path. this is weak but better then not using point cache at all */
-       /* btempdir is assumed to exist and ALWAYS has a trailing slash */
-       BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", btempdir, abs(getpid()));
+       /* temporary directory is assumed to exist and ALWAYS has a trailing slash */
+       BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", BLI_temporary_dir(), abs(getpid()));
        
        return BLI_add_slash(filename); /* new strlen() */
 }
@@ -2363,7 +2363,7 @@ void BKE_ptcache_remove(void)
        
        ptcache_path(NULL, path);
 
-       if (BLI_exist(path)) {
+       if (BLI_exists(path)) {
                /* The pointcache dir exists? - remove all pointcache */
 
                DIR *dir; 
index f908f40087ee393186cd1fc4f30ca420e51525c0..7250e5c714b84f46109cb171b5b703f63f842b96 100644 (file)
@@ -51,6 +51,7 @@
 #include "BLI_listbase.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
+#include "BLI_storage.h"
 #include "BLI_threads.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_sequencer.h"
 #include "BKE_fcurve.h"
 #include "BKE_scene.h"
-#include "RNA_access.h"
 #include "BKE_utildefines.h"
 
+#include "RNA_access.h"
+
 #include "RE_pipeline.h"
 
 #include <pthread.h>
index 3d3806f7c022acabd86b0f7d01dbeedaae4dee65..0d9f27e4fa96ac58a4fc2ad131431a8d92ada88e 100644 (file)
@@ -141,7 +141,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin
                ccgSubSurf_setUseAgeCounts(ccgSS, 1, 8, 8, 8);
        }
 
-       ccgSubSurf_setCalcVertexNormals(ccgSS, 1, BLI_STRUCT_OFFSET(DMGridData, no));
+       ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no));
 
        return ccgSS;
 }
index cda7a51c47fb9edf1ca25122deec55f662bdae1d..a5c0e03c09e8438dcf4407c493eb79c733fc46d0 100644 (file)
@@ -64,8 +64,6 @@ struct ListBase;
 
 #include <stdlib.h>
 
-extern char btempdir[]; /* creator.c temp dir used instead of U.tempdir, set with BLI_where_is_temp( btempdir, 1 ); */
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -86,13 +84,6 @@ extern "C" {
 
 #include "BLI_noise.h"
 
-/**
- * @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)(intptr_t) &((strct*) 0)->member)
-
 #ifdef __cplusplus
 }
 #endif
index 21d28ca31853f32e99b3404fe882db83da38c89d..354931e306a073793e03890e6561ca2cac0d2a46 100644 (file)
@@ -46,10 +46,6 @@ void  BLI_recurdir_fileops(const char *dirname);
 int BLI_link(const char *file, const char *to);
 int BLI_is_writable(const char *filename);
 
-/**
- * @attention Do not confuse with BLI_exist
- */
-int   BLI_exists(const char *file);
 int   BLI_copy_fileops(const char *file, const char *to);
 int   BLI_rename(const char *from, const char *to);
 int   BLI_gzip(const char *from, const char *to);
@@ -58,11 +54,6 @@ int   BLI_delete(const char *file, int dir, int recursive);
 int   BLI_move(const char *file, const char *to);
 int   BLI_touch(const char *file);
 
-/* only for the sane unix world: direct calls to system functions :( */
-#ifndef WIN32
-void BLI_setCmdCallBack(int (*f)(char*));
-#endif
-
 #ifdef __cplusplus
 }
 #endif
index 9ccdc37c353958c3209536f9a12dc1f9103c75b0..82794e08fa09442dcae7177b27ed5d5fe1ad6fea 100644 (file)
@@ -65,10 +65,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check);
 #define BLENDER_SYSTEM_PLUGINS         54
 #define BLENDER_SYSTEM_PYTHON          54
 
-#define BLENDER_TEMP                           80
-
-#define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS)
-
 /* for BLI_get_folder_version only */
 #define BLENDER_RESOURCE_PATH_USER             0
 #define BLENDER_RESOURCE_PATH_LOCAL            1
@@ -78,17 +74,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check);
 #define BLENDER_BOOKMARK_FILE  "bookmarks.txt"
 #define BLENDER_HISTORY_FILE   "recent-files.txt"
 
-#ifdef WIN32
-#define BLENDER_USER_FORMAT            "%s\\Blender Foundation\\Blender\\%s"
-#define BLENDER_SYSTEM_FORMAT          "%s\\Blender Foundation\\Blender\\%s"
-#elif defined(__APPLE__)
-#define BLENDER_USER_FORMAT                    "%s/Blender/%s"
-#define BLENDER_SYSTEM_FORMAT                  "%s/Blender/%s"
-#else
-#define BLENDER_USER_FORMAT                    "%s/.blender/%s"
-#define BLENDER_SYSTEM_FORMAT                  "%s/blender/%s"
-#endif
-
 #ifdef WIN32
 #define SEP '\\'
 #define ALTSEP '/'
@@ -181,29 +166,20 @@ void BLI_path_rel(char *file, const char *relfile);
         */
 void BLI_char_switch(char *string, char from, char to);
 
-/**
-        * 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, const size_t maxlen, const char *name);
-
-       /**
-        * Gets the temp directory when blender first runs.
-        * If the default path is not found, use try $TEMP
-        * 
-        * Also make sure the temp dir has a trailing slash
-        *
-        * @param fullname The full path to the temp directory
-        */
-void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp);
-
+       /* Initialize path to program executable */
+void BLI_init_program_path(const char *argv0);
+       /* Initialize path to temporary directory.
+        * NOTE: On Window userdir will be set to the temporary directory! */
+void BLI_init_temporary_dir(char *userdir);
+
+       /* Path to executable */
+const char *BLI_program_path(void);
+       /* Path to directory of executable */
+const char *BLI_program_dir(void);
+       /* Path to temporary directory (with trailing slash) */
+const char *BLI_temporary_dir(void);
+       /* Path to the system temporary directory (with trailing slash) */
+void BLI_system_temporary_dir(char *dir);
 
 #ifdef WITH_ICONV
 void BLI_string_to_utf8(char *original, char *utf_8, const char *code);
index 017f9877bafb6d05c25516dc6fdf6ea9aa42f598..13c78b711a87b9b15db58c18f8e918bf6bf0ba41 100644 (file)
  *  \ingroup bli
  */
 
-#ifdef WIN32
-/* for size_t, only needed on win32 for some reason */
+/* for size_t (needed on windows) */
 #include <stddef.h>
-#endif
 
 struct direntry;
 
-
-void   BLI_adddirstrings(void);
-void   BLI_builddir(const char *dirname, const char *relname);
-int    BLI_compare(struct direntry *entry1, struct direntry *entry2);
-
 size_t BLI_filesize(int file);
 size_t BLI_filepathsize(const char *path);
 double BLI_diskfree(const char *dir);
 char *BLI_getwdN(char *dir, const int maxncpy);
 
 unsigned int BLI_getdir(const char *dirname, struct direntry **filelist);
-/**
- * @attention Do not confuse with BLI_exists
- */
-int    BLI_exist(const char *name);
-/**
-        * 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.
-        */
 
+       /* test if file or directory exists */
+int BLI_exists(const char *name);
+       /* test if there is a directory at the specified path */
 int BLI_is_dir(const char *file);
 
-struct LinkNode *BLI_read_file_as_lines(const char *name);
+/**
+ * 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.
+ */
 
-       /**
-        * Free the list returned by BLI_read_file_as_lines.
-        */
+struct LinkNode *BLI_read_file_as_lines(const char *name);
 void BLI_free_file_lines(struct LinkNode *lines);
 
        /* Compare if one was last modified before the other */
index b2b3e7381c6eb4f26c4f3dcd6731dc7af9bac11d..c1eed40de74064dcefe7f61f2bf359d1820e68a5 100644 (file)
 #define MAX3(x,y,z)             MAX2( MAX2((x),(y)) , (z) )
 #define MAX4(x,y,z,a)           MAX2( MAX2((x),(y)) , MAX2((z),(a)) )
 
-#define INIT_MINMAX(min, max) { (min)[0]= (min)[1]= (min)[2]= 1.0e30f; (max)[0]= (max)[1]= (max)[2]= -1.0e30f; }
-
-#define INIT_MINMAX2(min, max) { (min)[0]= (min)[1]= 1.0e30f; (max)[0]= (max)[1]= -1.0e30f; }
-
-#define DO_MIN(vec, min) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0];      \
-                                                         if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1];   \
-                                                         if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; } \
-
-#define DO_MAX(vec, max) { if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0];         \
-                                                         if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1];   \
-                                                         if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \
-
-#define DO_MINMAX(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
-                                                         if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
-                                                         if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
-                                                         if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
-                                                         if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
-                                                         if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \
-
-#define DO_MINMAX2(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
-                                                         if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
-                                                         if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
-                                                         if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; }
+#define INIT_MINMAX(min, max) {                                               \
+               (min)[0]= (min)[1]= (min)[2]= 1.0e30f;                                \
+               (max)[0]= (max)[1]= (max)[2]= -1.0e30f;                               \
+       }
+#define INIT_MINMAX2(min, max) {                                              \
+               (min)[0]= (min)[1]= 1.0e30f;                                          \
+               (max)[0]= (max)[1]= -1.0e30f;                                         \
+       }
+#define DO_MIN(vec, min) {                                                    \
+               if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0];                           \
+               if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1];                           \
+               if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2];                           \
+       }
+#define DO_MAX(vec, max) {                                                    \
+               if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0];                           \
+               if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1];                           \
+               if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2];                           \
+       }
+#define DO_MINMAX(vec, min, max) {                                            \
+               if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0];                           \
+               if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1];                           \
+               if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2];                           \
+               if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0];                           \
+               if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1];                           \
+               if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2];                           \
+       }
+#define DO_MINMAX2(vec, min, max) {                                           \
+               if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0];                           \
+               if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1];                           \
+               if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0];                           \
+               if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1];                           \
+       }
 
 /* some math and copy defines */
 
 #ifndef SWAP
-#  define SWAP(type, a, b)        { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
+#  define SWAP(type, a, b)       { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
 #endif
 
-#define ABS(a)                                 ( (a)<0 ? (-(a)) : (a) )
-
-#define AVG2(x, y)             ( 0.5 * ((x) + (y)) )
+#define ABS(a)          ( (a)<0 ? (-(a)) : (a) )
 
 #define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f))
 #define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f))
-#define F3TOCHAR3(v2,v1) (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2]))
-#define F3TOCHAR4(v2,v1) { (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2])); \
-                                               (v1)[3] = 255; }
-#define F4TOCHAR4(v2,v1) { (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2])); \
-                                               (v1)[3]=FTOCHAR((v2[3])); }
-
-
-#define VECCOPY(v1,v2)          {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
-#define VECCOPY2D(v1,v2)          {*(v1)= *(v2); *(v1+1)= *(v2+1);}
-#define QUATCOPY(v1,v2)         {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
-#define LONGCOPY(a, b, c)      {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);}
-
-
-#define VECADD(v1,v2,v3)       {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
-#define VECSUB(v1,v2,v3)       {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
-#define VECSUB2D(v1,v2,v3)     {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1);}
-#define VECADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac);}
-#define VECSUBFAC(v1,v2,v3,fac) {*(v1)= *(v2) - *(v3)*(fac); *(v1+1)= *(v2+1) - *(v3+1)*(fac); *(v1+2)= *(v2+2) - *(v3+2)*(fac);}
-#define QUATADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac); *(v1+3)= *(v2+3) + *(v3+3)*(fac);}
-
-#define INPR(v1, v2)           ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
+#define F3TOCHAR3(v2, v1) {                                                   \
+               (v1)[0]= FTOCHAR((v2[0]));                                            \
+               (v1)[1]= FTOCHAR((v2[1]));                                            \
+               (v1)[2]= FTOCHAR((v2[2]));                                            \
+       }
+#define F3TOCHAR4(v2, v1) {                                                   \
+               (v1)[0]= FTOCHAR((v2[0]));                                            \
+               (v1)[1]= FTOCHAR((v2[1]));                                            \
+               (v1)[2]= FTOCHAR((v2[2]));                                            \
+               (v1)[3]= 255;                                                         \
+       }
+#define F4TOCHAR4(v2, v1) {                                                   \
+               (v1)[0]= FTOCHAR((v2[0]));                                            \
+               (v1)[1]= FTOCHAR((v2[1]));                                            \
+               (v1)[2]= FTOCHAR((v2[2]));                                            \
+               (v1)[3]= FTOCHAR((v2[3]));                                            \
+       }
+#define VECCOPY(v1, v2) {                                                     \
+               *(v1)=   *(v2);                                                       \
+               *(v1+1)= *(v2+1);                                                     \
+               *(v1+2)= *(v2+2);                                                     \
+       }
+#define VECCOPY2D(v1, v2) {                                                   \
+               *(v1)=   *(v2);                                                       \
+               *(v1+1)= *(v2+1);                                                     \
+       }
+#define QUATCOPY(v1, v2) {                                                    \
+               *(v1)=   *(v2);                                                       \
+               *(v1+1)= *(v2+1);                                                     \
+               *(v1+2)= *(v2+2);                                                     \
+               *(v1+3)= *(v2+3);                                                     \
+       }
+#define VECADD(v1,v2,v3) {                                                    \
+               *(v1)=   *(v2)   + *(v3);                                             \
+               *(v1+1)= *(v2+1) + *(v3+1);                                           \
+               *(v1+2)= *(v2+2) + *(v3+2);                                           \
+       }
+#define VECSUB(v1,v2,v3) {                                                    \
+               *(v1)=   *(v2)   - *(v3);                                             \
+               *(v1+1)= *(v2+1) - *(v3+1);                                           \
+               *(v1+2)= *(v2+2) - *(v3+2);                                           \
+       }
+#define VECSUB2D(v1,v2,v3)     {                                              \
+               *(v1)=   *(v2)   - *(v3);                                             \
+               *(v1+1)= *(v2+1) - *(v3+1);                                           \
+       }
+#define VECADDFAC(v1,v2,v3,fac) {                                             \
+               *(v1)=   *(v2)   + *(v3)*(fac);                                       \
+               *(v1+1)= *(v2+1) + *(v3+1)*(fac);                                     \
+               *(v1+2)= *(v2+2) + *(v3+2)*(fac);                                     \
+       }
+#define VECSUBFAC(v1,v2,v3,fac) {                                             \
+               *(v1)=   *(v2)   - *(v3)*(fac);                                       \
+               *(v1+1)= *(v2+1) - *(v3+1)*(fac);                                     \
+               *(v1+2)= *(v2+2) - *(v3+2)*(fac);                                     \
+       }
+#define QUATADDFAC(v1,v2,v3,fac) {                                            \
+               *(v1)=   *(v2)   + *(v3)*(fac);                                       \
+               *(v1+1)= *(v2+1) + *(v3+1)*(fac);                                     \
+               *(v1+2)= *(v2+2) + *(v3+2)*(fac);                                     \
+               *(v1+3)= *(v2+3) + *(v3+3)*(fac);                                     \
+       }
+
+#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
 
 /* some misc stuff.... */
 #define CLAMP(a, b, c)         if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
 #define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0))
 
 /* array helpers */
-#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)          (arr_dtype *)((char*)arr_start + (elem_size*(tot - 1)))
-#define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot)     ((item >= arr_start) && (item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)))
+#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)                 \
+               (arr_dtype *)((char*)arr_start + (elem_size*(tot - 1)))
+
+#define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot) (          \
+               (item >= arr_start) &&                                                \
+               (item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot))       \
+       )
 
 /* This one rotates the bytes in an int64, int (32) and short (16) */
-#define SWITCH_INT64(a) { \
-       char s_i, *p_i; \
-       p_i= (char *)&(a); \
-       s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
-       s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
-       s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
-       s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; }
-
-               #define SWITCH_INT(a) { \
-       char s_i, *p_i; \
-       p_i= (char *)&(a); \
-       s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
-       s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
-
-#define SWITCH_SHORT(a)        { \
-       char s_i, *p_i; \
-       p_i= (char *)&(a); \
-       s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; }
+#define SWITCH_INT64(a) {                                                     \
+               char s_i, *p_i;                                                       \
+               p_i= (char *)&(a);                                                    \
+               s_i= p_i[0]; p_i[0]= p_i[7]; p_i[7]= s_i;                             \
+               s_i= p_i[1]; p_i[1]= p_i[6]; p_i[6]= s_i;                             \
+               s_i= p_i[2]; p_i[2]= p_i[5]; p_i[5]= s_i;                             \
+               s_i= p_i[3]; p_i[3]= p_i[4]; p_i[4]= s_i;                             \
+       }
+
+#define SWITCH_INT(a) {                                                       \
+               char s_i, *p_i;                                                       \
+               p_i= (char *)&(a);                                                    \
+               s_i= p_i[0]; p_i[0]= p_i[3]; p_i[3]= s_i;                             \
+               s_i= p_i[1]; p_i[1]= p_i[2]; p_i[2]= s_i;                             \
+       }
+
+#define SWITCH_SHORT(a) {                                                     \
+               char s_i, *p_i;                                                       \
+               p_i= (char *)&(a);                                                    \
+               s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i;                                \
+       }
 
 
 /* Warning-free macros for storing ints in pointers. Use these _only_
 #  else
 #    define _dummy_abort() (void)0
 #  endif
-#  if defined(__GNUC__) || defined(_MSC_VER) /* just want to check if __func__ is available */
-#    define BLI_assert(a) \
-do { \
-       if (!(a)) { \
-               fprintf(stderr, \
-                       "BLI_assert failed: %s, %s(), %d at \'%s\'\n", \
-                       __FILE__, __func__, __LINE__, STRINGIFY(a)); \
-               _dummy_abort(); \
-       } \
+#  if defined(__GNUC__) || defined(_MSC_VER) /* check __func__ is available */
+#    define BLI_assert(a)                                                     \
+do {                                                                          \
+       if (!(a)) {                                                               \
+               fprintf(stderr,                                                       \
+                       "BLI_assert failed: %s, %s(), %d at \'%s\'\n",                    \
+                       __FILE__, __func__, __LINE__, STRINGIFY(a));                      \
+               _dummy_abort();                                                       \
+       }                                                                         \
 } while (0)
 #  else
 #    define BLI_assert(a) \
-do { \
-       if (0 == (a)) { \
-               fprintf(stderr, \
-                       "BLI_assert failed: %s, %d at \'%s\'\n", \
-                       __FILE__, __LINE__, STRINGIFY(a)); \
-               _dummy_abort(); \
-       } \
+do {                                                                          \
+       if (0 == (a)) {                                                           \
+               fprintf(stderr,                                                       \
+                       "BLI_assert failed: %s, %d at \'%s\'\n",                          \
+                       __FILE__, __LINE__, STRINGIFY(a));                                \
+               _dummy_abort();                                                       \
+       }                                                                         \
 } while (0)
 #  endif
 #else
index e848ad8d0d38ccba5af0b2b8ee5d60fed13c2660..3a2efbd6feb819023e8f3c111afa4b8d7c1a3eb7 100644 (file)
@@ -195,10 +195,6 @@ int BLI_touch(const char *file)
        return 0;
 }
 
-int BLI_exists(const char *file) {
-       return BLI_exist(file);
-}
-
 #ifdef WIN32
 
 static char str[MAXPATHLEN+12];
index b338bfcbc50bd4b097fc9feef71f30f214e68118..91e813a03508044bd5ed0f0b3954bcfa0b6dee22 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "DNA_userdef_types.h"
+#include "DNA_listBase.h"
 
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 
 #endif /* WIN32 */
 
+/* standard paths */
+#ifdef WIN32
+#define BLENDER_USER_FORMAT            "%s\\Blender Foundation\\Blender\\%s"
+#define BLENDER_SYSTEM_FORMAT          "%s\\Blender Foundation\\Blender\\%s"
+#elif defined(__APPLE__)
+#define BLENDER_USER_FORMAT                    "%s/Blender/%s"
+#define BLENDER_SYSTEM_FORMAT                  "%s/Blender/%s"
+#else
+#define BLENDER_USER_FORMAT                    "%s/.blender/%s"
+#define BLENDER_SYSTEM_FORMAT                  "%s/blender/%s"
+#endif
+
 /* local */
 #define UNIQUE_NAME_MAX 128
 
-extern char bprogname[];
-extern char bprogdir[];
+static char bprogname[FILE_MAX];       /* path to program executable */
+static char bprogdir[FILE_MAX];                /* path in which executable is located */
+static char btempdir[FILE_MAX];                /* temporary directory */
 
 static int add_win32_extension(char *name);
 static char *blender_version_decimal(const int ver);
@@ -1634,7 +1647,7 @@ static int add_win32_extension(char *name)
        int retval = 0;
        int type;
 
-       type = BLI_exist(name);
+       type = BLI_exists(name);
        if ((type == 0) || S_ISDIR(type)) {
 #ifdef _WIN32
                char filename[FILE_MAXDIR+FILE_MAXFILE];
@@ -1654,7 +1667,7 @@ static int add_win32_extension(char *name)
                                        strcat(filename, extensions);
                                }
 
-                               type = BLI_exist(filename);
+                               type = BLI_exists(filename);
                                if (type && (! S_ISDIR(type))) {
                                        retval = 1;
                                        strcpy(name, filename);
@@ -1670,8 +1683,19 @@ static int add_win32_extension(char *name)
        return (retval);
 }
 
-/* filename must be FILE_MAX length minimum */
-void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
+/*
+* 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
+* (must be FILE_MAX minimum)
+* @param name The name of the executable (usually argv[0]) to be checked
+*/
+static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name)
 {
        char filename[FILE_MAXDIR+FILE_MAXFILE];
        const char *path = NULL, *temp;
@@ -1751,12 +1775,37 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
        }
 }
 
-void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp)
+void BLI_init_program_path(const char *argv0)
+{
+       bli_where_am_i(bprogname, sizeof(bprogname), argv0);
+       BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
+}
+
+const char *BLI_program_path(void)
+{
+       return bprogname;
+}
+
+const char *BLI_program_dir(void)
+{
+       return bprogdir;
+}
+
+/**
+* Gets the temp directory when blender first runs.
+* If the default path is not found, use try $TEMP
+* 
+* Also make sure the temp dir has a trailing slash
+*
+* @param fullname The full path to the temp directory
+* @param userdir Directory specified in user preferences 
+*/
+void BLI_where_is_temp(char *fullname, const size_t maxlen, char *userdir)
 {
        fullname[0] = '\0';
        
-       if (usertemp && BLI_is_dir(U.tempdir)) {
-               BLI_strncpy(fullname, U.tempdir, maxlen);
+       if (userdir && BLI_is_dir(userdir)) {
+               BLI_strncpy(fullname, userdir, maxlen);
        }
        
        
@@ -1790,13 +1839,28 @@ void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp)
                /* add a trailing slash if needed */
                BLI_add_slash(fullname);
 #ifdef WIN32
-               if(U.tempdir != fullname) {
-                       BLI_strncpy(U.tempdir, fullname, maxlen); /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
+               if(userdir != fullname) {
+                       BLI_strncpy(userdir, fullname, maxlen); /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
                }
 #endif
        }
 }
 
+void BLI_init_temporary_dir(char *userdir)
+{
+       BLI_where_is_temp(btempdir, FILE_MAX, userdir);
+}
+
+const char *BLI_temporary_dir(void)
+{
+       return btempdir;
+}
+
+void BLI_system_temporary_dir(char *dir)
+{
+       BLI_where_is_temp(dir, FILE_MAX, NULL);
+}
+
 #ifdef WITH_ICONV
 
 void BLI_string_to_utf8(char *original, char *utf_8, const char *code)
index 7638e95b4ec2d6b8e4f6070ec109d9e674affd6d..8b383f5fd1127a57058f58779f6c14afb1f15752 100644 (file)
@@ -438,7 +438,7 @@ size_t BLI_filepathsize(const char *path)
 }
 
 
-int BLI_exist(const char *name)
+int BLI_exists(const char *name)
 {
 #if defined(WIN32) && !defined(__MINGW32__)
        struct _stat64i32 st;
@@ -471,7 +471,7 @@ int BLI_exist(const char *name)
 /* would be better in fileops.c except that it needs stat.h so add here */
 int BLI_is_dir(const char *file)
 {
-       return S_ISDIR(BLI_exist(file));
+       return S_ISDIR(BLI_exists(file));
 }
 
 LinkNode *BLI_read_file_as_lines(const char *name)
index 4d6bbebca318dae21338f8192c69f7edc0d4d5db..de8ff01d6802ed6677b9c5a727cd43a3711467b1 100644 (file)
@@ -8802,7 +8802,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                
                for (wo = main->world.first; wo; wo= wo->id.next) {
                        /* Migrate to Bullet for games, except for the NaN versions */
-                       /* People can still explicitely choose for Sumo (after 2.42 is out) */
+                       /* People can still explicitly choose for Sumo (after 2.42 is out) */
                        if(main->versionfile > 225)
                                wo->physicsEngine = WOPHY_BULLET;
                        if(WO_AODIST == wo->aomode)
index 8059b1cf3ffa126084d48dff83ad7413fc2f58d8..b411d61fe376d298ec170c70d3e38ea881ff4502 100644 (file)
@@ -60,7 +60,7 @@ extern "C"
                export_settings.filepath = (char *)filepath;
 
                /* annoying, collada crashes if file cant be created! [#27162] */
-               if(!BLI_exist(filepath)) {
+               if(!BLI_exists(filepath)) {
                        BLI_make_existing_file(filepath); /* makes the dir if its not there */
                        if(BLI_touch(filepath) == 0) {
                                return 0;
index 383e0bac796d0817b9328265fa0440ec3e1e34d8..d18a3c320f77c19bac14b6b94b88423e4877e718 100644 (file)
@@ -118,7 +118,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
                                PropertyRNA *nameprop= RNA_struct_name_property(ptr.type);
                                if (nameprop) {
                                        /* this gets a string which will need to be freed */
-                                       structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0);
+                                       structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL);
                                        free_structname= 1;
                                }
                                else
index a12d297bbb1a3f59a593ea8a7c580bdec66aa256..b7b572e72170af4e560f71a525f8031e659ab8f3 100644 (file)
@@ -1593,17 +1593,18 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
        if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
                PropertyType type;
                char *buf= NULL;
+               int buf_len;
 
                type= RNA_property_type(but->rnaprop);
 
                if(type == PROP_STRING) {
                        /* RNA string */
-                       buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen);
+                       buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
                }
                else if(type == PROP_POINTER) {
                        /* RNA pointer */
                        PointerRNA ptr= RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
-                       buf= RNA_struct_name_get_alloc(&ptr, str, maxlen);
+                       buf= RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
                }
 
                if(!buf) {
@@ -1611,7 +1612,7 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
                }
                else if(buf && buf != str) {
                        /* string was too long, we have to truncate */
-                       BLI_strncpy(str, buf, maxlen);
+                       memcpy(str, buf, MIN2(maxlen, buf_len+1));
                        MEM_freeN(buf);
                }
        }
index 46094a14179c2eb20e034d22abeb2b57c2ca38ff..6d0e7a7565e49373eecb7abdae72cb5216f443b2 100644 (file)
@@ -2210,15 +2210,11 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
                
                /* always set */
                but->modifier_key = 0;
-               if(event->shift)
-                       but->modifier_key |= KM_SHIFT;
-               if(event->alt)
-                       but->modifier_key |= KM_ALT;
-               if(event->ctrl)
-                       but->modifier_key |= KM_CTRL;
-               if(event->oskey)
-                       but->modifier_key |= KM_OSKEY;
-               
+               if(event->shift) but->modifier_key |= KM_SHIFT;
+               if(event->alt)   but->modifier_key |= KM_ALT;
+               if(event->ctrl)  but->modifier_key |= KM_CTRL;
+               if(event->oskey) but->modifier_key |= KM_OSKEY;
+
                ui_check_but(but);
                ED_region_tag_redraw(data->region);
                        
@@ -3684,7 +3680,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                        if(sel!= -1) {
                                /* ok, we move a point */
                                /* deselect all if this one is deselect. except if we hold shift */
-                               if(event->shift==0) {
+                               if(event->shift == FALSE) {
                                        for(a=0; a<cuma->totpoint; a++)
                                                cmp[a].flag &= ~SELECT;
                                        cmp[sel].flag |= SELECT;
@@ -3723,7 +3719,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
 
                                if(!data->dragchange) {
                                        /* deselect all, select one */
-                                       if(event->shift==0) {
+                                       if(event->shift == FALSE) {
                                                for(a=0; a<cuma->totpoint; a++)
                                                        cmp[a].flag &= ~SELECT;
                                                cmp[data->dragsel].flag |= SELECT;
@@ -4584,7 +4580,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                        ui_but_drop     (C, event, but, data);
                }
                /* handle keyframing */
-               else if(event->type == IKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
+               else if(event->type == IKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
                        if(event->alt)
                                ui_but_anim_delete_keyframe(C);
                        else
@@ -4595,7 +4591,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                        return WM_UI_HANDLER_BREAK;
                }
                /* handle drivers */
-               else if(event->type == DKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
+               else if(event->type == DKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
                        if(event->alt)
                                ui_but_anim_remove_driver(C);
                        else
@@ -4606,7 +4602,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                        return WM_UI_HANDLER_BREAK;
                }
                /* handle keyingsets */
-               else if(event->type == KKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
+               else if(event->type == KKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
                        if(event->alt)
                                ui_but_anim_remove_keyingset(C);
                        else
@@ -6079,9 +6075,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
                                case ZKEY:
                                {
                                        if(     (event->val == KM_PRESS) &&
-                                               (event->shift == FALSE) &&
-                                               (event->ctrl == FALSE) &&
-                                               (event->oskey == FALSE)
+                                           (event->shift == FALSE) &&
+                                           (event->ctrl ==  FALSE) &&
+                                           (event->oskey == FALSE)
                                        ) {
                                                for(but= block->buttons.first; but; but= but->next) {
 
index 2f423a361b83bf4e1c62afcf6d9b89b852344554..be6c89eb37dbaeec14de1866d8fafbfe781ffafb 100644 (file)
@@ -1221,7 +1221,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
                        iconid= ui_id_icon_get((bContext*)C, id, 1);
                }
                else {
-                       name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
+                       name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
                        iconid = 0;
                }
 
index 890a2b4ee7f29366e55634c13beec9b70f230acb..546f4f0b6398741d75f79d388fe27e5a4e49e4d3 100644 (file)
@@ -1042,7 +1042,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
                                inside= 1;
                
                if(inside && event->val==KM_PRESS) {
-                       if(event->type == AKEY && !ELEM4(1, event->ctrl, event->oskey, event->shift, event->alt)) {
+                       if(event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) {
                                
                                if(pa->flag & PNL_CLOSEDY) {
                                        if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my))
index 565d22646a26e805c7a1b4e57f7e12bd777751e3..651c6ef43109a6be45c61fdd06a0a3f6477a63e4 100644 (file)
@@ -2085,7 +2085,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
        if(icon == ICON_NONE || icon == ICON_DOT)
                icon= 0;
 
-       namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0);
+       namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0, NULL);
        name= (namebuf)? namebuf: "";
 
        /* hardcoded types */
@@ -2270,7 +2270,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
 
                                if(found) {
                                        /* create button */
-                                       name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
+                                       name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL);
                                        icon= list_item_icon_get(C, &itemptr, rnaicon, 0);
                                        uiItemL(row, (name)? name: "", icon);
 
index 3776d57f953753d6ea83c966a6aeb6d5ccaa6003..8b140e40cb15bae16cc4369816430636b5c11c21 100644 (file)
@@ -1167,7 +1167,7 @@ void init_userdef_do_versions(void)
        }
        if(U.mixbufsize==0) U.mixbufsize= 2048;
        if (strcmp(U.tempdir, "/") == 0) {
-               BLI_where_is_temp(U.tempdir, sizeof(U.tempdir), FALSE);
+               BLI_system_temporary_dir(U.tempdir);
        }
        if (U.autokey_mode == 0) {
                /* 'add/replace' but not on */
index b8ace26991ed13d7c8ef8e0b89f4aa4da5f3968c..84943ecc7772d330ba99f24dccf290c362f322c9 100644 (file)
@@ -53,6 +53,7 @@
 #include "BLI_listbase.h"
 #include "BLI_utildefines.h"
 #include "BLI_math_vector.h"
+#include "BLI_linklist.h"
 
 #include "ED_object.h"
 #include "ED_mesh.h"
index 740fd5137dead728c7c8c6eac6fa1c08e4f0c4b2..c0b81efe18cd2c55eca5e79a9d592b55f661ec56 100644 (file)
@@ -3700,7 +3700,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event)
        RNA_collection_add(op->ptr, "stroke", &itemptr);
 
        RNA_float_set_array(&itemptr, "mouse", mouse);
-       RNA_boolean_set(&itemptr, "pen_flip", event->shift != 0); // XXX hardcoded
+       RNA_boolean_set(&itemptr, "pen_flip", event->shift != FALSE); // XXX hardcoded
 
        /* apply */
        brush_edit_apply(C, op, &itemptr);
index 918adcac1386fba553f783edf61d3213da05c179..188bab9dced5ed051aa6f362901c5a3406af544e 100644 (file)
@@ -50,7 +50,6 @@
 #include "DNA_object_fluidsim.h"       
 
 #include "BLI_blenlib.h"
-#include "BLI_fileops.h"
 #include "BLI_threads.h"
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
@@ -833,7 +832,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss)
 
                curFrame++;
 
-               if((exists = BLI_exist(targetFile)))
+               if((exists = BLI_exists(targetFile)))
                {
                        BLI_delete(targetFile, 0, 0);
                        BLI_delete(targetFileVel, 0, 0);
index faf0baa1aca1b56c67ec56d2122bcf1c2ebb0c15..582a8596dd18b355ca933e019a6e778660f710a8 100644 (file)
@@ -47,7 +47,6 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_editVert.h"
-#include "BLI_listbase.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_animsys.h"
index 4a2860335fe93e73aba688da8d26fb9e3bca49f1..309c5cfc2189bc95cbd7e64ed4fa033016622fb9 100644 (file)
@@ -925,7 +925,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
 
                if(ptr->data) {
                        icon= RNA_struct_ui_icon(ptr->type);
-                       name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf));
+                       name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
 
                        if(name) {
                                if(!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene)
index 75b3eb950a5926ce6c9d5dcedbc70bed649ed88b..3cf4de992e5eb241837a7ea85115869bbca74687 100644 (file)
@@ -169,7 +169,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
        if(!prop)
                return OPERATOR_CANCELLED;
 
-       str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0);
+       str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL);
 
        /* useful yet irritating feature, Shift+Click to open the file
         * Alt+Click to browse a folder in the OS's browser */
index 559873bd601767ae4f0ce36854d510ef4957a6e6..7a379b93ee66afa402ecb19c0fde679c9ec4dc2f 100644 (file)
@@ -749,7 +749,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
 
                file_sfile_to_operator(op, sfile, filepath);
 
-               if (BLI_exist(sfile->params->dir))
+               if (BLI_exists(sfile->params->dir))
                        fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, 0, 1);
 
                BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
index 149d84b86cd5e6720a7e0b3e1ce0ae573da1362a..790e2f573ee4063ffbfb40a9a7b089d3f53a21aa 100644 (file)
@@ -64,7 +64,6 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_linklist.h"
-#include "BLI_path_util.h"
 #include "BLI_storage_types.h"
 #include "BLI_dynstr.h"
 #include "BLI_utildefines.h"
index bd9a38ab27e4743d180c21648152689aa46dbbfc..a843129c4d9b1f4f87d642d269526c183dcb362c 100644 (file)
@@ -278,7 +278,7 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename)
                                if (line[len-1] == '\n') {
                                        line[len-1] = '\0';
                                }
-                               if (BLI_exist(line)) {
+                               if (BLI_exists(line)) {
                                        fsmenu_insert_entry(fsmenu, category, line, 0, 1);
                                }
                        }
index 85942901c001464e46ed5a5769ace3fc4bdece3e..5ca9a6f12fb5a6ff6f11559ebf8c08c23adc2178 100644 (file)
@@ -68,7 +68,6 @@
 
 
 #include "BLI_math.h"
-#include "BLI_blenlib.h"
 #include "BLI_storage_types.h"
 
 #include "RE_pipeline.h"
index 1d1abf80fe45cbbc8c4d4002322f73a92fb900ae..30a7abd3c0b6d4431a0f190ae81b6e2a02972775 100644 (file)
@@ -1021,7 +1021,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
                                        /* tsenext= TREESTORE(temnext); */ /* UNUSED */
                                        
                                        nextptr= &temnext->rnaptr;
-                                       name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf));
+                                       name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL);
                                        
                                        if(name) {
                                                /* if possible, use name as a key in the path */
index dda103b971b1400daee537d611d140166ea81b2b..925c4571a66144f0c4188ce8bca28a02f72c397f 100644 (file)
@@ -972,7 +972,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                }
                else if(type == TSE_RNA_STRUCT) {
                        /* struct */
-                       te->name= RNA_struct_name_get_alloc(ptr, NULL, 0);
+                       te->name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
 
                        if(te->name)
                                te->flag |= TE_FREE_NAME;
index 4590880114762c5f03d684e570bf7eddd7ea46f8..9468603be7fb347a44d0fb436872f8e2dc466e70 100644 (file)
@@ -40,7 +40,6 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
-#include "BLI_path_util.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_context.h"
index 6ad7acdfecb44fd9627d0626c5f538220f912085..afa67d5b66eceefc3e33f7d7c09c107a2685b1a5 100644 (file)
@@ -1581,10 +1581,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
                {
                        if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS)
                        {
-                               if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) ||
-                                       (ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
-                                       (ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) ||
-                                       (kmi->type == OSKEY && event->oskey)) {
+                               if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) &&   event->ctrl)  ||
+                                   (ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
+                                   (ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) &&     event->alt)   ||
+                                   ((kmi->type == OSKEY) &&                         event->oskey) )
+                               {
                                        t->modifiers |= MOD_SNAP_INVERT;
                                }
                                break;
index 43168b97b88a0fa70010dfa41ab829f3b43ac080..05ba4b0d05fb0ab80fbe1a6bf1e1818ca3d280fe 100644 (file)
@@ -67,9 +67,6 @@
 #  include <dirent.h>
 #endif
 
-#include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail
-                                                       BLI_countlist BLI_stringdec */
-
 #include "imbuf.h"
 
 #include "AVI_avi.h"
index 9342c661021ae3cbd1dcba8f50570c54f7bff0b0..19d95dee88743cb7e639c5b1260ef9370528f29f 100644 (file)
@@ -649,7 +649,7 @@ PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifi
 FunctionRNA *RNA_struct_find_function(PointerRNA *ptr, const char *identifier);
 const struct ListBase *RNA_struct_type_functions(StructRNA *srna);
 
-char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen);
+char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len);
 
 /* Properties
  *
@@ -756,7 +756,7 @@ void RNA_property_float_get_default_array(PointerRNA *ptr, PropertyRNA *prop, fl
 float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index);
 
 void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value);
-char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen);
+char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len);
 void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value);
 int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop);
 void RNA_property_string_get_default(PointerRNA *ptr, PropertyRNA *prop, char *value);
@@ -824,20 +824,6 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path,
 char *RNA_path_from_ID_to_struct(PointerRNA *ptr);
 char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop);
 
-#if 0
-/* Dependency
- *
- * Experimental code that will generate callbacks for each dependency
- * between ID types. This may end up being useful for UI
- * and evaluation code that needs to know such dependencies for correct
- * redraws and re-evaluations. */
-
-typedef void (*PropDependencyCallback)(void *udata, PointerRNA *from, PointerRNA *to);
-void RNA_test_dependencies_cb(void *udata, PointerRNA *from, PointerRNA *to);
-
-void RNA_generate_dependencies(PointerRNA *mainptr, void *udata, PropDependencyCallback cb);
-#endif
-
 /* Quick name based property access
  *
  * These are just an easier way to access property values without having to
index 149497c85fb260a2e5503cb8bb200962a1ab3bd5..c1c22afcf75ffc2778ed7cadf4282065e13ca371 100644 (file)
@@ -748,12 +748,12 @@ void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
        srna->blender_type= blender_type;
 }
 
-char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen)
+char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
 {
        PropertyRNA *nameprop;
 
        if(ptr->data && (nameprop = RNA_struct_name_property(ptr->type)))
-               return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen);
+               return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen, r_len);
 
        return NULL;
 }
@@ -2276,7 +2276,8 @@ void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
                strcpy(value, sprop->defaultvalue);
 }
 
-char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen)
+char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop,
+                                    char *fixedbuf, int fixedlen, int *r_len)
 {
        char *buf;
        int length;
@@ -2301,6 +2302,10 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi
        BLI_assert(buf[length] == '\0');
 #endif
 
+       if (r_len) {
+               *r_len= length;
+       }
+
        return buf;
 }
 
@@ -2836,15 +2841,17 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co
                PropertyRNA *nameprop;
                char name[256], *nameptr;
                int found= 0;
+               int keylen= strlen(key);
+               int namelen;
 
                RNA_property_collection_begin(ptr, prop, &iter);
                for(; iter.valid; RNA_property_collection_next(&iter)) {
                        if(iter.ptr.data && iter.ptr.type->nameproperty) {
                                nameprop= iter.ptr.type->nameproperty;
 
-                               nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
+                               nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen);
 
-                               if(strcmp(nameptr, key) == 0) {
+                               if((keylen == namelen) && (strcmp(nameptr, key) == 0)) {
                                        *r_ptr= iter.ptr;
                                        found= 1;
                                }
@@ -4254,7 +4261,7 @@ char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, in
        PropertyRNA *prop= RNA_struct_find_property(ptr, name);
 
        if(prop) {
-               return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen);
+               return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen, NULL); /* TODO, pass length */
        }
        else {
                printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
@@ -5442,7 +5449,7 @@ int RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, i
                }
                case PROP_STRING:
                {
-                       char *value= RNA_property_string_get_alloc(fromptr, prop, NULL, 0);
+                       char *value= RNA_property_string_get_alloc(fromptr, prop, NULL, 0, NULL);
                        RNA_property_string_set(ptr, prop, value);
                        MEM_freeN(value);
                        return 1;
index b65122835f1dd9077dc27db2499f4aa71a224592..fa079486b95ec74900775400fc961c5e13f43cb7 100644 (file)
@@ -40,7 +40,6 @@
 
 #include <stddef.h>
 
-#include "BLI_blenlib.h"
 #include "BKE_armature.h"
 
 void rna_EditBone_align_roll(EditBone *ebo, float no[3])
index a1b84f5bcfe856b53366ba74c4c1dc58f81bcbee..50698757ecbb22a8cb93db7bbcafb57cbb7feb83 100644 (file)
@@ -42,8 +42,6 @@
 
 #include <stddef.h>
 
-#include "BLI_blenlib.h"
-
 #include "BKE_animsys.h"
 #include "BKE_fcurve.h"
 
index c114c44ad7750e071c3e8a06fee40051682be64c..13e9c88bfe316e46ce3cf81daa48ab2d14fb0b48 100644 (file)
@@ -96,7 +96,7 @@ static int fluidsim_find_lastframe(FluidsimSettings *fss)
        do {
                BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
                BLI_path_frame(targetFile, curFrame++, 0);
-       } while(BLI_exist(targetFile));
+       } while(BLI_exists(targetFile));
 
        return curFrame - 1;
 }
index 371c387e871a415025cfca32dd88fc1a8d7237ec..eacd814c9266241f9cd7834b741cd3e196b825b6 100644 (file)
@@ -40,8 +40,6 @@
 
 #ifdef RNA_RUNTIME
 
-#include "BLI_path_util.h"
-
 static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
 {
        bGPDlayer *gpl= (bGPDlayer *)ptr->data;
index 597f8730e721cd476b5b9b54fca4d576dc374c72..4ac29d8a8815a70e5df799254fd8353c79e6bcab 100644 (file)
@@ -98,8 +98,6 @@ static EnumPropertyItem empty_vortex_shape_items[] = {
 #include "BKE_pointcache.h"
 #include "BKE_depsgraph.h"
 
-#include "BLI_blenlib.h"
-
 #include "ED_object.h"
 
 static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
index a1d156a2b2ac146f5579963c5241e01818839fa0..4b27e025fa3d2766fe0c9315ffa68daab94ed5f8 100644 (file)
@@ -120,7 +120,6 @@ EnumPropertyItem part_hair_ren_as_items[] = {
 #ifdef RNA_RUNTIME
 
 #include "BLI_math.h"
-#include "BLI_listbase.h"
 
 #include "BKE_context.h"
 #include "BKE_cloth.h"
index a68d4e93c0054df55d39dc2df23ab1b55c1c14b5..044414d4ee452a79aff220121043cb7ed593ec23 100644 (file)
@@ -175,7 +175,6 @@ EnumPropertyItem image_color_mode_items[] ={
 
 #include "BLI_threads.h"
 #include "BLI_editVert.h"
-#include "BLI_blenlib.h"
 
 #include "BKE_context.h"
 #include "BKE_global.h"
index c34fecf407a9d89d8a674e5cce020a47597c4692..0c98a22bd88b28df75855d6aec3e79fe347cf42f 100644 (file)
@@ -295,8 +295,7 @@ static void rna_userdef_addon_remove(bAddon *bext)
 
 static void rna_userdef_temp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
 {
-       extern char btempdir[];
-       BLI_where_is_temp(btempdir, FILE_MAX, 1);
+       BLI_init_temporary_dir(U.tempdir);
 }
 
 static void rna_userdef_text_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
index db49174226526306421d93c7c951695419c202c2..e9a341896e6673597b4fc78bd5f4fc13c4eaa3fb 100644 (file)
@@ -47,6 +47,7 @@
 #include "BLI_edgehash.h"
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
+#include "BLI_linklist.h"
 
 
 #include "BKE_cdderivedmesh.h"
index 277f0852f901985c31d8acd8ca3825360a075464..a2f62d55d6926c413f463a8bf426e39328d974cf 100644 (file)
@@ -105,7 +105,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
 
                /*  elubie: changed this to default to the same dir as the render output
                to prevent saving to C:\ on Windows */
-               BLI_strncpy(fss->surfdataPath, btempdir, FILE_MAX);
+               BLI_strncpy(fss->surfdataPath, BLI_temporary_dir(), FILE_MAX);
 
                // first init of bounding box
                // no bounding box needed
index 78f97c5289e41a9cc763199adf5470b892ff57b9..2047a9089f4d6b63ba18f90fc25642dc1923bea3 100644 (file)
@@ -1320,7 +1320,7 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy)
        
        if ((xy < 1) || (xy > 3)) xy = 3;
        
-       // XXX The YVV macro defined below explicitely expects sources of at least 3x3 pixels,
+       // XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
        //     so just skiping blur along faulty direction if src's def is below that limit!
        if (src->x < 3) xy &= ~(int) 1;
        if (src->y < 3) xy &= ~(int) 2;
@@ -1346,7 +1346,7 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy)
        // it seems to work, not entirely sure if it is actually totally correct,
        // Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark),
        // found one other implementation by Cristoph Lampert,
-       // but neither seem to be quite the same, result seems to be ok sofar anyway.
+       // but neither seem to be quite the same, result seems to be ok so far anyway.
        // Extra scale factor here to not have to do it in filter,
        // though maybe this had something to with the precision errors
        sc = cf[0]/((1.0 + cf[1] - cf[2] + cf[3])*(1.0 - cf[1] - cf[2] - cf[3])*(1.0 + cf[2] + (cf[1] - cf[3])*cf[3]));
index 1a5e3150f53f393cbc9fd5c98cedebe738ca46b8..34815fcb24c0ac5e73bf56b9df1fbc6d7d8cd7dd 100644 (file)
@@ -86,8 +86,9 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
                                        getpix(tmp, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, col);
 
                                        /* mix img and transformed tmp */
-                                       for(j= 0; j < 4; ++j)
-                                               img->rect[p + j]= AVG2(img->rect[p + j], col[j]);
+                                       for(j= 0; j < 4; ++j) {
+                                               img->rect[p + j]= 0.5f * (img->rect[p + j] + col[j]);
+                                       }
                                }
                        }
 
index cd5c8e53ef74807d21e4a0a8d37c9c13cad573c0..ae82dac7f145a9da6a8383c54848aef7845ec627 100644 (file)
@@ -36,8 +36,6 @@
 #ifndef BPY_EXTERN_H
 #define BPY_EXTERN_H
 
-extern char bprogname[];       /* holds a copy of argv[0], from creator.c */
-
 struct Text; /* defined in DNA_text_types.h */
 struct ID; /* DNA_ID.h */
 struct Object; /* DNA_object_types.h */
index 1524812086bb171c812ae28264aa6f9741671769..541008ebaa53b4bebf0612b02fe4702c19608064 100644 (file)
@@ -67,9 +67,9 @@ PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
        switch ( prop->type ) {
                case IDP_STRING:
 #ifdef USE_STRING_COERCE
-                       return PyC_UnicodeFromByte(IDP_Array(prop));
+            return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len);
 #else
-                       return PyUnicode_FromString(IDP_Array(prop));
+            return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len);
 #endif
                case IDP_INT:
                        return PyLong_FromLong( (long)prop->data.val );
@@ -485,9 +485,9 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
        switch (prop->type) {
                case IDP_STRING:
 #ifdef USE_STRING_COERCE
-                       return PyC_UnicodeFromByte(IDP_Array(prop));
+            return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len);
 #else
-                       return PyUnicode_FromString(IDP_Array(prop));
+            return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len);
 #endif
                        break;
                case IDP_FLOAT:
index 575495e186e3d7d8a2d7ea2379057b016a934acb..587ac69071e46963d0bfcb034a944c7616df5241 100644 (file)
@@ -386,9 +386,9 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
        }
 }
 
-PyObject *PyC_UnicodeFromByte(const char *str)
+PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size)
 {
-       PyObject *result= PyUnicode_FromString(str);
+    PyObject *result= PyUnicode_FromStringAndSize(str, size);
        if (result) {
                /* 99% of the time this is enough but we better support non unicode
                 * chars since blender doesnt limit this */
@@ -397,11 +397,16 @@ PyObject *PyC_UnicodeFromByte(const char *str)
        else {
                PyErr_Clear();
                /* this means paths will always be accessible once converted, on all OS's */
-               result= PyUnicode_DecodeFSDefault(str);
+               result= PyUnicode_DecodeFSDefaultAndSize(str, size);
                return result;
        }
 }
 
+PyObject *PyC_UnicodeFromByte(const char *str)
+{
+       return PyC_UnicodeFromByteAndSize(str, strlen(str));
+}
+
 /*****************************************************************************
 * Description: This function creates a new Python dictionary object.
 * note: dict is owned by sys.modules["__main__"] module, reference is borrowed
index f38ce209be2284abe98a47af5649a1efac8d4729..ccd001aabd4b21664b735929bb8313d785c28bfc 100644 (file)
@@ -40,8 +40,9 @@ void                  PyC_FileAndNum_Safe(const char **filename, int *lineno); /* checks python
 int                            PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObject *type, const short is_double, const char *error_prefix);
 
 /* follow http://www.python.org/dev/peps/pep-0383/ */
-PyObject *             PyC_UnicodeFromByte(const char *str);
-const char *   PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
+PyObject *      PyC_UnicodeFromByte(const char *str);
+PyObject *      PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size);
+const char *    PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
 
 /* name namespace function for bpy & bge */
 PyObject *             PyC_DefaultNameSpace(const char *filename);
index bd7be8dd9c5fcbedbdd727fd039330b43ae0e863..c3d60bc353d16f0f0e52205c983dbab527b207aa 100644 (file)
@@ -93,8 +93,6 @@ static PyStructSequence_Desc app_info_desc= {
 
 static PyObject *make_app_info(void)
 {
-       extern char bprogname[]; /* argv[0] from creator.c */
-
        PyObject *app_info;
        int pos= 0;
 
@@ -118,7 +116,7 @@ static PyObject *make_app_info(void)
        SetStrItem("");
 #endif
        SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
-       SetStrItem(bprogname);
+       SetStrItem(BLI_program_path());
        SetObjItem(PyBool_FromLong(G.background));
 
        /* build info */
@@ -200,8 +198,7 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void
 
 static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closure))
 {
-       extern char btempdir[];
-       return PyC_UnicodeFromByte(btempdir);
+       return PyC_UnicodeFromByte(BLI_temporary_dir());
 }
 
 static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure))
index ddbd557375c86f28b6d3019779da9535796855d7..7a39cfc93c8b25bcfb54aafced0a449f761733ab 100644 (file)
@@ -193,9 +193,9 @@ void BPY_python_start(int argc, const char **argv)
        PyThreadState *py_tstate= NULL;
 
        /* not essential but nice to set our name */
-       static wchar_t bprogname_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
-       BLI_strncpy_wchar_from_utf8(bprogname_wchar, bprogname, sizeof(bprogname_wchar) / sizeof(wchar_t));
-       Py_SetProgramName(bprogname_wchar);
+       static wchar_t program_path_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
+       BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t));
+       Py_SetProgramName(program_path_wchar);
 
        /* must run before python initializes */
        PyImport_ExtendInittab(bpy_internal_modules);
@@ -203,9 +203,9 @@ void BPY_python_start(int argc, const char **argv)
        /* allow to use our own included python */
        PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL));
 
-       /* Python 3.2 now looks for '2.58/python/include/python3.2d/pyconfig.h' to parse
-        * from the 'sysconfig' module which is used by 'site', so for now disable site.
-        * alternatively we could copy the file. */
+       /* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to
+        * parse from the 'sysconfig' module which is used by 'site',
+        * so for now disable site. alternatively we could copy the file. */
        Py_NoSiteFlag= 1;
 
        Py_Initialize();
@@ -215,8 +215,11 @@ void BPY_python_start(int argc, const char **argv)
        {
                int i;
                PyObject *py_argv= PyList_New(argc);
-               for (i=0; i<argc; i++)
-                       PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i])); /* should fix bug #20021 - utf path name problems, by replacing PyUnicode_FromString */
+               for (i=0; i<argc; i++) {
+                       /* should fix bug #20021 - utf path name problems, by replacing
+                        * PyUnicode_FromString, with this one */
+                       PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i]));
+               }
 
                PySys_SetObject("argv", py_argv);
                Py_DECREF(py_argv);
index a6306909699c4ead984e67311f783a103f40c364..70e7ba051f0bd51f468c2759c85e1bb045ff4d50 100644 (file)
@@ -810,7 +810,7 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self)
        }
 
        /* print name if available */
-       name= RNA_struct_name_get_alloc(&self->ptr, NULL, FALSE);
+       name= RNA_struct_name_get_alloc(&self->ptr, NULL, 0, NULL);
        if (name) {
                ret= PyUnicode_FromFormat("<bpy_struct, %.200s(\"%.200s\")>",
                                          RNA_struct_identifier(self->ptr.type),
@@ -901,7 +901,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
        /* if a pointer, try to print name of pointer target too */
        if (RNA_property_type(self->prop) == PROP_POINTER) {
                ptr= RNA_property_pointer_get(&self->ptr, self->prop);
-               name= RNA_struct_name_get_alloc(&ptr, NULL, FALSE);
+               name= RNA_struct_name_get_alloc(&ptr, NULL, 0, NULL);
 
                if (name) {
                        ret= PyUnicode_FromFormat("<bpy_%.200s, %.200s.%.200s(\"%.200s\")>",
@@ -1257,14 +1257,22 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
                                ret= PyUnicode_FromString(enum_item->identifier);
                        }
                        else {
-                               const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, FALSE);
+                               const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
 
                                /* prefer not fail silently incase of api errors, maybe disable it later */
-                               printf("RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'\n", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
+                               printf("RNA Warning: Current value \"%d\" "
+                                          "matches no enum in '%s', '%s', '%s'\n",
+                                          val, RNA_struct_identifier(ptr->type),
+                                          ptr_name, RNA_property_identifier(prop));
 
 #if 0                  // gives python decoding errors while generating docs :(
                                char error_str[256];
-                               BLI_snprintf(error_str, sizeof(error_str), "RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
+                               BLI_snprintf(error_str, sizeof(error_str),
+                                                        "RNA Warning: Current value \"%d\" "
+                                                        "matches no enum in '%s', '%s', '%s'",
+                                                        val, RNA_struct_identifier(ptr->type),
+                                                        ptr_name, RNA_property_identifier(prop));
+
                                PyErr_Warn(PyExc_RuntimeWarning, error_str);
 #endif
 
@@ -1311,19 +1319,20 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
        {
                int subtype= RNA_property_subtype(prop);
                const char *buf;
+               int buf_len;
                char buf_fixed[32];
 
-               buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed));
+               buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed), &buf_len);
 #ifdef USE_STRING_COERCE
                /* only file paths get special treatment, they may contain non utf-8 chars */
                if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
-                       ret= PyC_UnicodeFromByte(buf);
+                       ret= PyC_UnicodeFromByteAndSize(buf, buf_len);
                }
                else {
-                       ret= PyUnicode_FromString(buf);
+                       ret= PyUnicode_FromStringAndSize(buf, buf_len);
                }
 #else // USE_STRING_COERCE
-               ret= PyUnicode_FromString(buf);
+               ret= PyUnicode_FromStringAndSize(buf, buf_len);
 #endif // USE_STRING_COERCE
                if (buf_fixed != buf) {
                        MEM_freeN((void *)buf);
@@ -3127,14 +3136,15 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
                 * Collect RNA attributes
                 */
                char name[256], *nameptr;
+               int namelen;
 
                iterprop= RNA_struct_iterator_property(ptr->type);
 
                RNA_PROP_BEGIN(ptr, itemptr, iterprop) {
-                       nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
+                       nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
 
                        if (nameptr) {
-                               pystring= PyUnicode_FromString(nameptr);
+                               pystring= PyUnicode_FromStringAndSize(nameptr, namelen);
                                PyList_Append(list, pystring);
                                Py_DECREF(pystring);
 
@@ -3716,13 +3726,14 @@ static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self)
        PyObject *ret= PyList_New(0);
        PyObject *item;
        char name[256], *nameptr;
+       int namelen;
 
        RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
-               nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
+               nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
 
                if (nameptr) {
                        /* add to python list */
-                       item= PyUnicode_FromString(nameptr);
+                       item= PyUnicode_FromStringAndSize(nameptr, namelen);
                        PyList_Append(ret, item);
                        Py_DECREF(item);
                        /* done */
@@ -3751,15 +3762,16 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
        PyObject *ret= PyList_New(0);
        PyObject *item;
        char name[256], *nameptr;
+       int namelen;
        int i= 0;
 
        RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
                if (itemptr.data) {
                        /* add to python list */
                        item= PyTuple_New(2);
-                       nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
+                       nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
                        if (nameptr) {
-                               PyTuple_SET_ITEM(item, 0, PyUnicode_FromString(nameptr));
+                               PyTuple_SET_ITEM(item, 0, PyUnicode_FromStringAndSize(nameptr, namelen));
                                if (name != nameptr)
                                        MEM_freeN(nameptr);
                        }
index 3db738160259ecdaba9028655a43f947f612c0e7..104a298acf120896189abd7497bb63e0b985204d 100644 (file)
@@ -478,7 +478,7 @@ static void scene_unique_exr_name(Scene *scene, char *str, int sample)
        else
                BLI_snprintf(name, sizeof(name), "%s_%s%d.exr", fi, scene->id.name+2, sample);
 
-       BLI_make_file_string("/", str, btempdir, name);
+       BLI_make_file_string("/", str, BLI_temporary_dir(), name);
 }
 
 static void render_unique_exr_name(Render *re, char *str, int sample)
@@ -3146,11 +3146,11 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
                                if(scene->r.mode & (R_NO_OVERWRITE | R_TOUCH))
                                        BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE);
 
-                               if(scene->r.mode & R_NO_OVERWRITE && BLI_exist(name)) {
+                               if(scene->r.mode & R_NO_OVERWRITE && BLI_exists(name)) {
                                        printf("skipping existing frame \"%s\"\n", name);
                                        continue;
                                }
-                               if(scene->r.mode & R_TOUCH && !BLI_exist(name)) {
+                               if(scene->r.mode & R_TOUCH && !BLI_exists(name)) {
                                        BLI_make_existing_file(name); /* makes the dir if its not there */
                                        BLI_touch(name);
                                }
@@ -3175,7 +3175,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
                        if(G.afbreek==1) {
                                /* remove touched file */
                                if(BKE_imtype_is_movie(scene->r.imtype) == 0) {
-                                       if (scene->r.mode & R_TOUCH && BLI_exist(name) && BLI_filepathsize(name) == 0) {
+                                       if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_filepathsize(name) == 0) {
                                                BLI_delete(name, 0, 0);
                                        }
                                }
index 052b9faa8b606a48607439dfd28ab0f6e2983285..b9390eb43e58fac50245b1c83cfeac47173cc22f 100644 (file)
@@ -98,6 +98,11 @@ enum {
 #define KM_ALT2                64
 #define KM_OSKEY2      128
 
+/* KM_MOD_ flags for wmKeyMapItem and wmEvent.alt/shift/oskey/ctrl  */
+/* note that KM_ANY and FALSE are used with these defines too */
+#define KM_MOD_FIRST  1
+#define KM_MOD_SECOND 2
+
 /* type: defined in wm_event_types.c */
 #define KM_TEXTINPUT   -2
 
index e73440e5eb0b9a1e6255fce53fdbbedfd764b3a9..c798b284c7bd9cc6833d312c194af516d8952a31 100644 (file)
@@ -2611,39 +2611,43 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                        GHOST_TEventKeyData *kd= customdata;
                        event.type= convert_key(kd->key);
                        event.ascii= kd->ascii;
-                       strcpy(event.utf8_buf, kd->utf8_buf);
+                       memcpy(event.utf8_buf, kd->utf8_buf,sizeof(event.utf8_buf));/* might be not null terminated*/
                        event.val= (type==GHOST_kEventKeyDown)?KM_PRESS:KM_RELEASE;
                        
                        /* exclude arrow keys, esc, etc from text input */
-                       if(type==GHOST_kEventKeyUp || (event.ascii<32 && event.ascii>0))
-                               event.ascii= '\0';
-                       
-                       /* modifiers */
-                       if (event.type==LEFTSHIFTKEY || event.type==RIGHTSHIFTKEY) {
-                               event.shift= evt->shift= (event.val==KM_PRESS);
-                               if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->oskey))
-                                  event.shift= evt->shift = 3;         // define?
-                       } 
-                       else if (event.type==LEFTCTRLKEY || event.type==RIGHTCTRLKEY) {
-                               event.ctrl= evt->ctrl= (event.val==KM_PRESS);
-                               if(event.val==KM_PRESS && (evt->shift || evt->alt || evt->oskey))
-                                  event.ctrl= evt->ctrl = 3;           // define?
-                       } 
-                       else if (event.type==LEFTALTKEY || event.type==RIGHTALTKEY) {
-                               event.alt= evt->alt= (event.val==KM_PRESS);
-                               if(event.val==KM_PRESS && (evt->ctrl || evt->shift || evt->oskey))
-                                  event.alt= evt->alt = 3;             // define?
-                       } 
-                       else if (event.type==OSKEY) {
-                               event.oskey= evt->oskey= (event.val==KM_PRESS);
-                               if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->shift))
-                                  event.oskey= evt->oskey = 3;         // define?
+                       if(type==GHOST_kEventKeyUp) {
+                               if (event.ascii<32 && event.ascii > 0) {
+                                       event.ascii= '\0';
+                               }
+
+                               /* ghost should do this already for key up */
+                               if (event.utf8_buf[0]) {
+                                       printf("%s: ghost on you're platform is misbehaving, utf8 events on key up!\n", __func__);
+                               }
+                               event.utf8_buf[0]= '\0';
                        }
-                       else {
+
+                       /* modifiers */
+                       /* assigning both first and second is strange - campbell */
+                       switch(event.type) {
+                       case LEFTSHIFTKEY: case RIGHTSHIFTKEY:
+                               event.shift= evt->shift= (event.val==KM_PRESS) ? ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE;
+                               break;
+                       case LEFTCTRLKEY: case RIGHTCTRLKEY:
+                               event.ctrl= evt->ctrl= (event.val==KM_PRESS) ? ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE;
+                               break;
+                       case LEFTALTKEY: case RIGHTALTKEY:
+                               event.alt= evt->alt= (event.val==KM_PRESS) ? ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE;
+                               break;
+                       case OSKEY:
+                               event.oskey= evt->oskey= (event.val==KM_PRESS) ? ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE;
+                               break;
+                       default:
                                if(event.val==KM_PRESS && event.keymodifier==0)
                                        evt->keymodifier= event.type; /* only set in eventstate, for next event */
                                else if(event.val==KM_RELEASE && event.keymodifier==event.type)
                                        event.keymodifier= evt->keymodifier= 0;
+                               break;
                        }
 
                        /* this case happens on some systems that on holding a key pressed,
@@ -2729,4 +2733,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                }
 
        }
+
+       /* Handy when debugging checking events */
+       /* WM_event_print(&event); */
+
 }
index 9b2d7026a46e983510d963cc352ef666d4b0eaff..4cd31b8d8943f90ba7f93accf93a4784a74bf460 100644 (file)
@@ -289,8 +289,9 @@ static void wm_init_userdef(bContext *C)
                if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |=  G_SCRIPT_AUTOEXEC;
                else                                                                                      G.f &= ~G_SCRIPT_AUTOEXEC;
        }
+
        /* update tempdir from user preferences */
-       BLI_where_is_temp(btempdir, FILE_MAX, 1);
+       BLI_init_temporary_dir(U.tempdir);
 }
 
 
@@ -856,14 +857,14 @@ void wm_autosave_location(char *filepath)
         * BLI_make_file_string will create string that has it most likely on C:\
         * through get_default_root().
         * If there is no C:\tmp autosave fails. */
-       if (!BLI_exists(btempdir)) {
+       if (!BLI_exists(BLI_temporary_dir())) {
                savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL);
                BLI_make_file_string("/", filepath, savedir, pidstr);
                return;
        }
 #endif
 
-       BLI_make_file_string("/", filepath, btempdir, pidstr);
+       BLI_make_file_string("/", filepath, BLI_temporary_dir(), pidstr);
 }
 
 void WM_autosave_init(wmWindowManager *wm)
@@ -921,7 +922,7 @@ void wm_autosave_delete(void)
 
        if(BLI_exists(filename)) {
                char str[FILE_MAXDIR+FILE_MAXFILE];
-               BLI_make_file_string("/", str, btempdir, "quit.blend");
+               BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
 
                /* if global undo; remove tempsave, otherwise rename */
                if(U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, 0, 0);
index 854fa688ea4d9b108da23f340f4764abe3a6071d..99bd83ef8c1f1335658756306ce6350f828b6646 100644 (file)
@@ -310,31 +310,15 @@ static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modif
        kmi->type= type;
        kmi->val= val;
        kmi->keymodifier= keymodifier;
-       
+
        if(modifier == KM_ANY) {
                kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY;
        }
        else {
-               
-               kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= 0;
-               
-               /* defines? */
-               if(modifier & KM_SHIFT)
-                       kmi->shift= 1;
-               else if(modifier & KM_SHIFT2)
-                       kmi->shift= 2;
-               if(modifier & KM_CTRL)
-                       kmi->ctrl= 1;
-               else if(modifier & KM_CTRL2)
-                       kmi->ctrl= 2;
-               if(modifier & KM_ALT)
-                       kmi->alt= 1;
-               else if(modifier & KM_ALT2)
-                       kmi->alt= 2;
-               if(modifier & KM_OSKEY)
-                       kmi->oskey= 1;
-               else if(modifier & KM_OSKEY2)
-                       kmi->oskey= 2;  
+               kmi->shift= (modifier & KM_SHIFT) ? KM_MOD_FIRST : ((modifier & KM_SHIFT2) ? KM_MOD_SECOND : FALSE);
+               kmi->ctrl=  (modifier & KM_CTRL)  ? KM_MOD_FIRST : ((modifier & KM_CTRL2)  ? KM_MOD_SECOND : FALSE);
+               kmi->alt=   (modifier & KM_ALT)   ? KM_MOD_FIRST : ((modifier & KM_ALT2)   ? KM_MOD_SECOND : FALSE);
+               kmi->oskey= (modifier & KM_OSKEY) ? KM_MOD_FIRST : ((modifier & KM_OSKEY2) ? KM_MOD_SECOND : FALSE);
        }
 }
 
index 9d8ed546b98205e22b4df7ba2d12e7f368b87f86..f8a63fb796db182ed5ff2028ee65203f463a8298 100644 (file)
@@ -1807,7 +1807,7 @@ static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
        WM_event_add_notifier(C, NC_WINDOW, NULL);
 
        /* load file */
-       BLI_make_file_string("/", filename, btempdir, "quit.blend");
+       BLI_make_file_string("/", filename, BLI_temporary_dir(), "quit.blend");
        WM_read_file(C, filename, op->reports);
 
        G.fileflags &= ~G_FILE_RECOVER;
index eb3a9c96770a9dccc2f68c292f9a8fc4e7110011..b12e51c44b509df2de57a7f874560a52b711867c 100644 (file)
@@ -129,7 +129,6 @@ struct RenderResult *RE_GetResult(struct Render *re){return (struct RenderResult
 struct Render *RE_GetRender(const char *name){return (struct Render *) NULL;}
 
 /* blenkernel */
-char btempdir[] = "";
 void RE_FreeRenderResult(struct RenderResult *res){}
 struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty){return (struct RenderResult *) NULL;}
 void RE_GetResultImage(struct Render *re, struct RenderResult *rr){}
index 2ac4aee87a868c5c8771692e39266e10cf06c272..40dfdfa8d36e39f2c181bdf7900575f0b3f90820 100644 (file)
@@ -62,6 +62,7 @@
 
 #include "DNA_ID.h"
 #include "DNA_scene_types.h"
+#include "DNA_userdef_types.h"
 
 #include "BLI_blenlib.h"
 
@@ -145,10 +146,6 @@ static int print_version(int argc, const char **argv, void *data);
 
 extern int pluginapi_force_ref(void);  /* from blenpluginapi:pluginapi.c */
 
-char bprogname[FILE_MAX];
-char bprogdir[FILE_MAX];
-char btempdir[FILE_MAX];
-
 #define BLEND_VERSION_STRING_FMT "Blender %d.%02d (sub %d)\n", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION
 
 /* Initialize callbacks for the modules that need them */
@@ -1166,11 +1163,8 @@ int main(int argc, const char **argv)
        fpsetmask(0);
 #endif
 
-       // copy path to executable in bprogname. playanim and creting runtimes
-       // need this.
-
-       BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]);
-       BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
+       // initialize path to executable
+       BLI_init_program_path(argv[0]);
 
        BLI_threadapi_init();
 
@@ -1225,7 +1219,8 @@ int main(int argc, const char **argv)
                WM_init(C, argc, argv);
 
                /* this is properly initialized with user defs, but this is default */
-               BLI_where_is_temp(btempdir, FILE_MAX, 1); /* call after loading the startup.blend so we can read U.tempdir */
+               /* call after loading the startup.blend so we can read U.tempdir */
+               BLI_init_temporary_dir(U.tempdir);
 
 #ifdef WITH_SDL
        BLI_setenv("SDL_VIDEODRIVER", "dummy");
@@ -1236,7 +1231,8 @@ int main(int argc, const char **argv)
 
                WM_init(C, argc, argv);
 
-               BLI_where_is_temp(btempdir, FILE_MAX, 0); /* call after loading the startup.blend so we can read U.tempdir */
+               /* don't use user preferences temp dir */
+               BLI_init_temporary_dir(NULL);
        }
 #ifdef WITH_PYTHON
        /**
index 78ea2aac8ced01f63802c0c5221c6ce94d8e844e..f5439ba4f6430db9a6f2a7f6c15659340894da69 100644 (file)
@@ -76,9 +76,6 @@ extern "C"
        
        int GHOST_HACK_getFirstFile(char buf[]);
        
-extern char bprogname[];       /* holds a copy of argv[0], from creator.c */
-extern char btempdir[];                /* use this to store a valid temp directory */
-
 // For BLF
 #include "BLF_api.h"
 #include "BLF_translation.h"
@@ -116,9 +113,6 @@ extern char datatoc_bfont_ttf[];
 const int kMinWindowWidth = 100;
 const int kMinWindowHeight = 100;
 
-char bprogname[FILE_MAX];
-char bprogdir[FILE_MAX];
-
 static void mem_error_cb(const char *errorStr)
 {
        fprintf(stderr, "%s", errorStr);
@@ -380,8 +374,8 @@ int main(int argc, char** argv)
        signal (SIGFPE, SIG_IGN);
 #endif /* __alpha__ */
 #endif /* __linux__ */
-       BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]);
-       BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
+       BLI_init_program_path(argv[0]);
+       BLI_init_temporary_dir(NULL);
 #ifdef __APPLE__
        // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh)
        /*
@@ -786,7 +780,7 @@ int main(int argc, char** argv)
                                        }
                                        else
                                        {
-                                               bfd = load_game_data(bprogname, filename[0]? filename: NULL);
+                                               bfd = load_game_data(BLI_program_path(), filename[0]? filename: NULL);
                                        }
                                        
                                        //::printf("game data loaded from %s\n", filename);
index 6e5513991f9df51e1d7cbacb26b6707d475a9d02..3febff92e18d2ebfe4434e2f0fd12743b2b871f7 100644 (file)
@@ -98,7 +98,7 @@ void  KX_BulletPhysicsController::SetObject (SG_IObject* object)
        if (m_bSensor)
        {
                // use a different callback function for sensor object, 
-               // bullet will not synchronize, we must do it explicitely
+               // bullet will not synchronize, we must do it explicitly
                SG_Callbacks& callbacks = gameobj->GetSGNode()->GetCallBackFunctions();
                callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc;
        } 
index 2bc11ef5f5b7283b2ad25495499171192393536a..76bdd36a70f53115753168e0498d7622fbe0c5ed 100644 (file)
@@ -767,7 +767,7 @@ void        CcdPhysicsController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *
        if (m_cci.m_physicsEnv != physicsEnv) 
        {
                // since the environment is changing, we must also move the controler to the
-               // new environement. Note that we don't handle sensor explicitely: this
+               // new environment. Note that we don't handle sensor explicitly: this
                // function can be called on sensor but only when they are not registered
                if (m_cci.m_physicsEnv->removeCcdPhysicsController(this))
                {
index 60da4523dd5de9b9825945235a2d38da2131079b..e0a12a64b12bed23134839ac5e016ffd8b40fb37 100644 (file)
@@ -63,7 +63,7 @@ struct PHY_RayCastResult
 /**
  * This class replaces the ignoreController parameter of rayTest function. 
  * It allows more sophisticated filtering on the physics controller before computing the ray intersection to save CPU. 
- * It is only used to its full extend by the Ccd physics environement (Bullet).
+ * It is only used to its full extend by the Ccd physics environment (Bullet).
  */
 class PHY_IRayCastFilterCallback
 {
index 8a76b0c004d2f4a28a687653b4df690994d1fd30..ae8132514cf4ccfb8d13abe8011c37d386cc09c1 100644 (file)
@@ -607,7 +607,7 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
        // The driver name is constructed automatically from the device type:
        // v4l   : /dev/video<camIdx>
        // dv1394: /dev/dv1394/<camIdx>
-       // If you have different driver name, you can specify the driver name explicitely 
+       // If you have different driver name, you can specify the driver name explicitly
        // instead of device type. Examples of valid filename:
        //    /dev/v4l/video0:pal
        //    /dev/ieee1394/1:ntsc