CVS update: php3/functions
| From: | thies | Date: | Wed, 06 Jan 1999 13:28:46 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3330@lists.php.net to get a copy of this message | ||
Date: Wednesday January 6, 1999 @ 8:28
Author: thies
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv16272/functions
Modified Files:
basic_functions.c iptc.c php3_iptc.h
Log Message:
Index: php3/functions/basic_functions.c
diff -c php3/functions/basic_functions.c:1.249 php3/functions/basic_functions.c:1.250
*** php3/functions/basic_functions.c:1.249 Mon Jan 4 09:25:18 1999
--- php3/functions/basic_functions.c Wed Jan 6 08:28:45 1999
***************
*** 28,34 ****
+----------------------------------------------------------------------+
*/
! /* $Id: basic_functions.c,v 1.249 1999/01/04 14:25:18 jah Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 28,34 ----
+----------------------------------------------------------------------+
*/
! /* $Id: basic_functions.c,v 1.250 1999/01/06 13:28:45 thies Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 155,160 ****
--- 155,161 ----
{"md5", php3_md5, NULL},
{"iptcparse", php3_iptcparse, NULL},
+ {"iptcembed", php3_iptcembed, NULL},
{"parse_url", php3_parse_url, NULL},
{"parse_str", php3_parsestr, NULL},
Index: php3/functions/iptc.c
diff -c php3/functions/iptc.c:1.10 php3/functions/iptc.c:1.11
*** php3/functions/iptc.c:1.10 Mon Jan 4 09:25:21 1999
--- php3/functions/iptc.c Wed Jan 6 08:28:45 1999
***************
*** 27,52 ****
+----------------------------------------------------------------------+
*/
! /* $Id: iptc.c,v 1.10 1999/01/04 14:25:21 jah Exp $ */
/*
* Functions to parse & compse IPTC data.
* PhotoShop >= 3.0 can read and write textual data to JPEG files.
* ... more to come .....
*/
/*
* TODO:
* - add IPTC translation table
- * - implement a call to embed iptc into a JPEG file
*/
#include "php.h"
#include "internal_functions.h"
#include "php3_iptc.h"
! /* {{{ proto array iptcparse(string jpeg_image)
! ??? */
void php3_iptcparse(INTERNAL_FUNCTION_PARAMETERS)
{
unsigned int length, inx, len, inheader, tagsfound;
--- 27,279 ----
+----------------------------------------------------------------------+
*/
! /* $Id: iptc.c,v 1.11 1999/01/06 13:28:45 thies Exp $ */
/*
* Functions to parse & compse IPTC data.
* PhotoShop >= 3.0 can read and write textual data to JPEG files.
* ... more to come .....
+ *
+ * i know, parts of this is now duplicated in image.c
+ * but in this case i think it's okay!
*/
/*
* TODO:
* - add IPTC translation table
*/
#include "php.h"
#include "internal_functions.h"
#include "php3_iptc.h"
! #include <sys/stat.h>
!
!
! /* some defines for the different JPEG block types */
! #define M_SOF0 0xC0 /* Start Of Frame N */
! #define M_SOF1 0xC1 /* N indicates which compression process */
! #define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */
! #define M_SOF3 0xC3
! #define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */
! #define M_SOF6 0xC6
! #define M_SOF7 0xC7
! #define M_SOF9 0xC9
! #define M_SOF10 0xCA
! #define M_SOF11 0xCB
! #define M_SOF13 0xCD
! #define M_SOF14 0xCE
! #define M_SOF15 0xCF
! #define M_SOI 0xD8
! #define M_EOI 0xD9 /* End Of Image (end of datastream) */
! #define M_SOS 0xDA /* Start Of Scan (begins compressed data) */
! #define M_APP0 0xe0
! #define M_APP1 0xe1
! #define M_APP2 0xe2
! #define M_APP3 0xe3
! #define M_APP4 0xe4
! #define M_APP5 0xe5
! #define M_APP6 0xe6
! #define M_APP7 0xe7
! #define M_APP8 0xe8
! #define M_APP9 0xe9
! #define M_APP10 0xea
! #define M_APP11 0xeb
! #define M_APP12 0xec
! #define M_APP13 0xed
! #define M_APP14 0xee
! #define M_APP15 0xef
!
! static int php3_iptc_put1(FILE *fp,int spool,unsigned char c,unsigned char **spoolbuf)
! {
! if (spool > 0)
! PUTC(c);
!
! if (spoolbuf) *(*spoolbuf)++ = c;
!
! return c;
! }
!
! static int php3_iptc_get1(FILE *fp,int spool,unsigned char **spoolbuf)
! {
! int c;
!
! c = getc(fp);
!
! if (c == EOF) return EOF;
!
! if (spool > 0) PUTC(c);
!
! if (spoolbuf) *(*spoolbuf)++ = c;
!
! return c;
! }
!
! static int php3_iptc_read_remaining(FILE *fp,int spool,unsigned char **spoolbuf)
! {
! int c;
!
! while ((c = php3_iptc_get1(fp,spool,spoolbuf)) != EOF) continue;
!
! return M_EOI;
! }
!
! static int php3_iptc_skip_variable(FILE *fp,int spool,unsigned char **spoolbuf)
! {
! unsigned int length;
! int c1,c2;
!
! if ((c1 = php3_iptc_get1(fp,spool,spoolbuf)) == EOF) return M_EOI;
!
! if ((c2 = php3_iptc_get1(fp,spool,spoolbuf)) == EOF) return M_EOI;
!
! length = (((unsigned char) c1) << 8) + ((unsigned char) c2);
!
! length -= 2;
!
! while (length--)
! if (php3_iptc_get1(fp,spool,spoolbuf) == EOF) return M_EOI;
!
! return 0;
! }
!
! static int php3_iptc_nextmarker(FILE *fp,int spool,unsigned char **spoolbuf)
! {
! int c;
!
! /* skip unimportant stuff */
!
! c = php3_iptc_get1(fp,spool,spoolbuf);
!
! if (c == EOF) return M_EOI;
!
! while (c != 0xff) {
! if ((c = php3_iptc_get1(fp,spool,spoolbuf)) == EOF)
! return M_EOI; /* we hit EOF */
! }
!
! /* get marker byte, swallowing possible padding */
! do {
! if ((c = php3_iptc_get1(fp,spool,spoolbuf)) == EOF)
! return M_EOI; /* we hit EOF */
! } while (c == 0xff);
!
! return (unsigned int) c;
! }
!
! static char psheader[] = "\xFF\xED\0\0Photoshop 3.0\08BIM\x04\x04\0\0\0\0";
!
! /* {{{ proto array iptcembed(string iptcdata, string jpeg_file_name [ , int spool ])
! Embed binary IPTC-Data into jpeg-image. Either output it direct (spool = 1|2) or return result
to caller
! (spool = 0|1) or both. */
! void php3_iptcembed(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *iptcdata, *jpeg_file, *spool_flag;
! FILE *fp;
! unsigned int marker;
! unsigned int spool = 0, done = 0, inx, len, nlen;
! unsigned char *spoolbuf,*poi=0;
! struct stat sb;
!
! switch(ARG_COUNT(ht)){
! case 3:
! if (getParameters(ht, 3, &iptcdata, &jpeg_file, &spool_flag) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_string(iptcdata);
! convert_to_string(jpeg_file);
! convert_to_long(spool_flag);
! spool = spool_flag->value.lval;
! break;
!
! case 2:
! if (getParameters(ht, 2, &iptcdata, &jpeg_file) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_string(iptcdata);
! convert_to_string(jpeg_file);
! break;
!
! default:
! WRONG_PARAM_COUNT;
! break;
! }
!
! if (_php3_check_open_basedir(jpeg_file->value.str.val))
! RETURN_FALSE;
!
! if ((fp = fopen(jpeg_file->value.str.val,"rb")) == 0) {
! php3_error(E_WARNING, "Unable to open %s", jpeg_file->value.str.val);
! RETURN_FALSE;
! }
!
! len = iptcdata->value.str.len;
!
! if (spool < 2) {
! fstat(fileno(fp),&sb);
!
! nlen = len + 30 + sb.st_size;
!
! poi = spoolbuf = emalloc(nlen);
!
! if (! spoolbuf) {
! fclose(fp);
! RETURN_FALSE;
! }
! }
!
! if (php3_iptc_get1(fp,spool,poi?&poi:0) != 0xFF) {
! fclose(fp);
! RETURN_FALSE;
! }
!
! if (php3_iptc_get1(fp,spool,poi?&poi:0) != 0xD8) {
! fclose(fp);
! RETURN_FALSE;
! }
!
! while (!done) {
! marker = php3_iptc_nextmarker(fp,spool,poi?&poi:0);
! switch (marker) {
! case M_EOI:
! done = 1;
! break;
!
! case M_APP0:
! php3_iptc_skip_variable(fp,spool,poi?&poi:0);
!
! psheader[ 2 ] = (len+28)>>8;
! psheader[ 3 ] = (len+28)&0xff;
!
! for (inx = 0; inx < 28; inx++)
! php3_iptc_put1(fp,spool,psheader[inx],poi?&poi:0);
!
! php3_iptc_put1(fp,spool,len>>8,poi?&poi:0);
! php3_iptc_put1(fp,spool,len&0xff,poi?&poi:0);
!
! for (inx = 0; inx < len; inx++)
! php3_iptc_put1(fp,spool,iptcdata->value.str.val[inx],poi?&poi:0);
!
! php3_iptc_read_remaining(fp,spool,poi?&poi:0);
! break;
!
! default:
! php3_iptc_skip_variable(fp,spool,poi?&poi:0);
! break;
! }
! }
!
! fclose(fp);
!
! if (spool < 2) {
! RETVAL_STRINGL(spoolbuf,nlen,0);
! } else {
! RETURN_TRUE;
! }
! }
!
! /* {{{ proto array iptcparse(string iptcdata)
! parse biary IPTC-Data into assoc. array */
void php3_iptcparse(INTERNAL_FUNCTION_PARAMETERS)
{
unsigned int length, inx, len, inheader, tagsfound;
***************
*** 59,65 ****
WRONG_PARAM_COUNT;
}
convert_to_string(str);
-
inx = 0;
length = str->value.str.len;
--- 286,291 ----
Index: php3/functions/php3_iptc.h
diff -c php3/functions/php3_iptc.h:1.2 php3/functions/php3_iptc.h:1.3
*** php3/functions/php3_iptc.h:1.2 Fri Jan 1 12:59:15 1999
--- php3/functions/php3_iptc.h Wed Jan 6 08:28:45 1999
***************
*** 28,38 ****
*/
! /* $Id: php3_iptc.h,v 1.2 1999/01/01 17:59:15 zeev Exp $ */
#ifndef _PHPIPTC_H
#define _PHPIPTC_H
extern void php3_iptcparse(INTERNAL_FUNCTION_PARAMETERS);
#endif /* _PHPIPTC_H */
--- 28,39 ----
*/
! /* $Id: php3_iptc.h,v 1.3 1999/01/06 13:28:45 thies Exp $ */
#ifndef _PHPIPTC_H
#define _PHPIPTC_H
extern void php3_iptcparse(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_iptcembed(INTERNAL_FUNCTION_PARAMETERS);
#endif /* _PHPIPTC_H */
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net