cvs: php4 /ext/exif exif.c

From: Date: Fri, 05 Apr 2002 17:59:30 +0000
Subject: cvs: php4 /ext/exif exif.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10907@lists.php.net to get a copy of this message
helly Fri Apr 5 12:59:30 2002 EDT Modified files: /php4/ext/exif exif.c Log: -correct length for ASCII -global encoding variables #will become ini settings explanation on what to set follows then Index: php4/ext/exif/exif.c diff -u php4/ext/exif/exif.c:1.84 php4/ext/exif/exif.c:1.85 --- php4/ext/exif/exif.c:1.84 Fri Apr 5 11:02:54 2002 +++ php4/ext/exif/exif.c Fri Apr 5 12:59:29 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: exif.c,v 1.84 2002/04/05 16:02:54 helly Exp $ */ +/* $Id: exif.c,v 1.85 2002/04/05 17:59:29 helly Exp $ */ /* ToDos * @@ -105,7 +105,7 @@ }; /* }}} */ -#define EXIF_VERSION "1.3 $Id: exif.c,v 1.84 2002/04/05 16:02:54 helly Exp $" +#define EXIF_VERSION "1.3 $Id: exif.c,v 1.85 2002/04/05 17:59:29 helly Exp $" PHP_MINFO_FUNCTION(exif); @@ -122,6 +122,9 @@ } /* }}} */ +static char * exif_encoding_unicode = "ISO-8859-15"; +static char * exif_encoding_jis = NULL; /* default to internal encoding */ + /* {{{ PHP_MINIT_FUNCTION(exif) Get the size of an image as 4-element array */ PHP_MINIT_FUNCTION(exif) @@ -538,7 +541,7 @@ /* {{{ exif_char_dump * Do not use! This is a debug function... */ -#ifdef EXIF_DEBUG +//#ifdef EXIF_DEBUG static unsigned char* exif_char_dump( unsigned char * addr, int len, int hex) { static unsigned char buf[1024+1]; @@ -563,7 +566,7 @@ buf[sizeof(buf)-1]=0; return buf; } -#endif +//#endif /* }}} */ /* {{{ php_jpg_get16 @@ -2003,7 +2006,7 @@ /* {{{ exif_process_string * Copy a string in Exif header to a character string and return length of allocated buffer if any. - * In contrast to exif_process_undefined this function does allways return a string buffer */ + * In contrast to exif_process_string this function does allways return a string buffer */ static int exif_process_string(char **result,char *value,size_t byte_count) { /* we cannot use strlcpy - here the problem is that we cannot use strlen to * determin length of string and we cannot use strlcpy with len=byte_count+1 @@ -2026,7 +2029,7 @@ /* {{{ exif_process_user_comment * Process UserComment in IFD. */ -static int exif_process_user_comment(char **pszInfoPtr, char **szEncoding, char *szValuePtr, int ByteCount, int motorola_intel TSRMLS_DC) +static int exif_process_user_comment(char **pszInfoPtr, char **pszEncoding, char *szValuePtr, int ByteCount, int motorola_intel TSRMLS_DC) { int a; @@ -2034,38 +2037,45 @@ size_t len;; #endif + *pszEncoding = NULL; /* Copy the comment */ if ( ByteCount>=8) { if (!memcmp(szValuePtr, "UNICODE\0", 8)) { - *szEncoding= estrdup((const char*)szValuePtr); + *pszEncoding = estrdup((const char*)szValuePtr); szValuePtr = szValuePtr+8; ByteCount -= 8; #ifdef HAVE_MBSTRING if ( motorola_intel) { - *pszInfoPtr = php_mb_convert_encoding(szValuePtr, ByteCount, "ISO-8859-15", "UCS-2BE", &len TSRMLS_CC); + *pszInfoPtr = php_mb_convert_encoding(szValuePtr, ByteCount, exif_encoding_unicode, "UCS-2BE", &len TSRMLS_CC); } else { - *pszInfoPtr = php_mb_convert_encoding(szValuePtr, ByteCount, "ISO-8859-15", "UCS-2LE", &len TSRMLS_CC); + *pszInfoPtr = php_mb_convert_encoding(szValuePtr, ByteCount, exif_encoding_unicode, "UCS-2LE", &len TSRMLS_CC); } + /*php_error(E_NOTICE,"converted(%d,%s): %s", len, *pszEncoding, *pszInfoPtr);*/ return len; #else return exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount); #endif } else if ( !memcmp(szValuePtr, "ASCII\0\0\0", 8)) { - *szEncoding= estrdup((const char*)szValuePtr); + *pszEncoding = estrdup((const char*)szValuePtr); szValuePtr = szValuePtr+8; ByteCount -= 8; } else if ( !memcmp(szValuePtr, "JIS\0\0\0\0\0", 8)) { /* JIS should be tanslated to MB or we leave it to the user - leave it to the user */ - *szEncoding= estrdup((const char*)szValuePtr); + *pszEncoding = estrdup((const char*)szValuePtr); szValuePtr = szValuePtr+8; ByteCount -= 8; +#ifdef HAVE_MBSTRING + *pszInfoPtr = php_mb_convert_encoding(szValuePtr, ByteCount, exif_encoding_jis, "JIS", &len TSRMLS_CC); + return len; +#else return exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount); +#endif } else if ( !memcmp(szValuePtr,"\0\0\0\0\0\0\0\0",8)) { /* 8 NULL means undefined and should be ASCII... */ - *szEncoding= estrdup((const char*)szValuePtr); + *pszEncoding = estrdup("UNDEFINED"); szValuePtr = szValuePtr+8; ByteCount -= 8; } @@ -2075,7 +2085,8 @@ if (ByteCount>0) for (a=ByteCount-1;a && szValuePtr[a]==' ';a--) (szValuePtr)[a] = '\0'; /* normal text without encoding */ - return exif_process_string(pszInfoPtr, szValuePtr, ByteCount); + exif_process_string(pszInfoPtr, szValuePtr, ByteCount); + return strlen(*pszInfoPtr); } /* }}} */

« previous php.cvs (#10907) next »