Blender V2.61 - r43446
Defines | Enumerations | Functions | Variables

thumbs.c File Reference

#include <stdio.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_md5.h"
#include "BKE_utildefines.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "IMB_thumbs.h"
#include "IMB_metadata.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

Go to the source code of this file.

Defines

#define URI_MAX   FILE_MAX*3 + 8
#define ACCEPTABLE(a)   ((a)>=32 && (a)<128 && (acceptable[(a)-32] & use_mask))

Enumerations

enum  UnsafeCharacterSet {
  UNSAFE_ALL = 0x1, UNSAFE_ALLOW_PLUS = 0x2, UNSAFE_PATH = 0x8, UNSAFE_HOST = 0x10,
  UNSAFE_SLASHES = 0x20
}

Functions

static int get_thumb_dir (char *dir, ThumbSize size)
static void escape_uri_string (const char *string, char *escaped_string, int len, UnsafeCharacterSet mask)
static void to_hex_char (char *hexbytes, const unsigned char *bytes, int len)
static int uri_from_filename (const char *path, char *uri)
static void thumbname_from_uri (const char *uri, char *thumb, const int thumb_len)
static int thumbpath_from_uri (const char *uri, char *path, const int path_len, ThumbSize size)
void IMB_thumb_makedirs (void)
ImBufIMB_thumb_create (const char *path, ThumbSize size, ThumbSource source, ImBuf *img)
ImBufIMB_thumb_read (const char *path, ThumbSize size)
void IMB_thumb_delete (const char *path, ThumbSize size)
ImBufIMB_thumb_manage (const char *path, ThumbSize size, ThumbSource source)

Variables

static const unsigned char acceptable [96]
static const char hex [17] = "0123456789abcdef"

Detailed Description

Definition in file thumbs.c.


Define Documentation

#define ACCEPTABLE (   a)    ((a)>=32 && (a)<128 && (acceptable[(a)-32] & use_mask))

Referenced by escape_uri_string().

#define URI_MAX   FILE_MAX*3 + 8

Definition at line 68 of file thumbs.c.

Referenced by IMB_thumb_create(), and uri_from_filename().


Enumeration Type Documentation

----- begin of adapted code from glib --- The following code is adapted from function g_escape_uri_string from the gnome glib Source: http://svn.gnome.org/viewcvs/glib/trunk/glib/gconvert.c?view=markup released under the Gnu General Public License.

Enumerator:
UNSAFE_ALL 
UNSAFE_ALLOW_PLUS 
UNSAFE_PATH 
UNSAFE_HOST 
UNSAFE_SLASHES 

Definition at line 101 of file thumbs.c.


Function Documentation

static void escape_uri_string ( const char *  string,
char *  escaped_string,
int  len,
UnsafeCharacterSet  mask 
) [static]

Definition at line 129 of file thumbs.c.

References ACCEPTABLE, hex, and p.

Referenced by uri_from_filename().

static int get_thumb_dir ( char *  dir,
ThumbSize  size 
) [static]

Definition at line 70 of file thumbs.c.

References BLI_strncpy(), FILE_MAX, THB_FAIL, THB_LARGE, and THB_NORMAL.

Referenced by IMB_thumb_create(), IMB_thumb_makedirs(), and thumbpath_from_uri().

ImBuf* IMB_thumb_create ( const char *  path,
ThumbSize  size,
ThumbSource  source,
ImBuf img 
)
void IMB_thumb_delete ( const char *  path,
ThumbSize  size 
)
void IMB_thumb_makedirs ( void  )

Definition at line 235 of file thumbs.c.

References BLI_dir_create_recursive(), FILE_MAX, get_thumb_dir(), THB_FAIL, and THB_NORMAL.

Referenced by ED_file_init().

ImBuf* IMB_thumb_manage ( const char *  path,
ThumbSize  size,
ThumbSource  source 
)
ImBuf* IMB_thumb_read ( const char *  path,
ThumbSize  size 
)
static void thumbname_from_uri ( const char *  uri,
char *  thumb,
const int  thumb_len 
) [static]

Definition at line 209 of file thumbs.c.

References BLI_snprintf(), md5_buffer(), strlen(), and to_hex_char().

Referenced by IMB_thumb_create(), and thumbpath_from_uri().

static int thumbpath_from_uri ( const char *  uri,
char *  path,
const int  path_len,
ThumbSize  size 
) [static]
static void to_hex_char ( char *  hexbytes,
const unsigned char *  bytes,
int  len 
) [static]

Definition at line 155 of file thumbs.c.

References hex, len(), and p.

Referenced by thumbname_from_uri().

static int uri_from_filename ( const char *  path,
char *  uri 
) [static]

----- end of adapted code from glib ---

Definition at line 170 of file thumbs.c.

References BLI_char_switch(), BLI_strncpy(), escape_uri_string(), FILE_MAX, NULL, strlen(), UNSAFE_PATH, and URI_MAX.

Referenced by IMB_thumb_create(), IMB_thumb_delete(), IMB_thumb_manage(), and IMB_thumb_read().


Variable Documentation

const unsigned char acceptable[96] [static]
Initial value:
 {
    
    
    0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C,
    
    0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x38,0x20,0x20,0x2C,0x20,0x20,
    
    0x38,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
    
    0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x20,0x3F,
    
    0x20,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
    
    0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x3F,0x20
}

Definition at line 109 of file thumbs.c.

Referenced by NPP_WriteReady().

const char hex[17] = "0123456789abcdef" [static]

Definition at line 125 of file thumbs.c.

Referenced by escape_uri_string(), Exception::setXptDesc(), and to_hex_char().